Skip to content

Short-circuit address parsing on hot path during block processing #1395

Open
pragmaxim wants to merge 2 commits intoresync-mempool-using-batch-apifrom
micro-optimizations-for-block-processing
Open

Short-circuit address parsing on hot path during block processing #1395
pragmaxim wants to merge 2 commits intoresync-mempool-using-batch-apifrom
micro-optimizations-for-block-processing

Conversation

@pragmaxim
Copy link
Copy Markdown
Contributor

Summary Of Changes

  • Speed up padded address parsing in addressFromPaddedHex by decoding the last 20 bytes directly when the input is a 32-byte padded topic or calldata slot, and fall back to big.Int only for odd formats.
  • Add unit tests that cover padded, unpadded, and invalid inputs for addressFromPaddedHex.

addressFromPaddedHex: What Was Wrong And How It Was Fixed

  • Problem: The original implementation always parsed the full hex string into a big.Int. For topics and calldata, addresses are 32-byte padded, so most of that work was wasted and done on every transfer/log.
  • Fix: Strip optional 0x, fast-path decode the last 40 hex characters (20 bytes) via hex.DecodeString and BytesToAddress, and fall back to the original big.Int parse only when the fast path does not apply or fails.

@pragmaxim pragmaxim force-pushed the micro-optimizations-for-block-processing branch from 4e88372 to c5f8539 Compare January 21, 2026 07:47
@pragmaxim pragmaxim changed the base branch from using-backend-env-vars-for-builds-and-integration-tests to evm-chains-with-both-http-and-ws-json-rpc-clients January 21, 2026 07:47
@pragmaxim pragmaxim force-pushed the micro-optimizations-for-block-processing branch from aec6adf to 331c523 Compare January 25, 2026 09:47
@pragmaxim pragmaxim changed the base branch from evm-chains-with-both-http-and-ws-json-rpc-clients to resync-mempool-using-batch-api January 25, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant