Skip to content

refactor: extract precompile gas from CALL overhead and emit synthetic frame#83

Open
mattevans wants to merge 14 commits intomasterfrom
release/mem-expansion-and-precompiles
Open

refactor: extract precompile gas from CALL overhead and emit synthetic frame#83
mattevans wants to merge 14 commits intomasterfrom
release/mem-expansion-and-precompiles

Conversation

@mattevans
Copy link
Member

@mattevans mattevans commented Feb 16, 2026

Precompile calls (CALL/STATICCALL to addresses 0x010x11, 0x100) were previously invisible in structlog_agg. Their gas was silently absorbed into the parent frame's CALL opcode stats. This change makes them visible by emitting synthetic call frames, the same way we already do for EOA calls.

refactor: extract precompile gas from CALL overhead and emit synthetic frame
@mattevans mattevans self-assigned this Feb 16, 2026
@mattevans mattevans requested a review from Savid as a code owner February 16, 2026 02:47
…ties

feat(structlog): expose IsPrecompile helper for external use
feat(execution): extend StructLog with MemorySize, CallTransfersValue, ExtCodeCopySize
test(structlog): add comprehensive tests for cold access and memory expansion
Introduce memory and cold-access counters to enable gas cost
breakdown into memory expansion and state-access categories.

- Extend CallFrameRow and OpcodeStats with memory-words sums
 (before/after) and squared sums plus cold-access counts.
- Update aggregator to accumulate the new fields per opcode
 and roll them up to frame summaries.
- Add memWordsBefore, memWordsAfter, coldAccessCount params
 to ProcessStructlog and wire them in transaction processing.
- Extend ClickHouse columns and batch insert logic to persist
 the new metrics.
- Remove local precompile list and delegate to structlog pkg.
…stant

test(memory_test): add comprehensive unit tests for resolveLastInFrame
style(memory): remove outdated comment about RETURN/REVERT stack layout
test: add boundary precision tests for cold access classification
test: add unit tests for memory parsing and word computation
test: add aggregator tests for resource gas accumulation and nested frames
test: add column tests for new resource gas fields
* master:
  build(goreleaser): disable provenance attestation in docker builds
…e to empty account

The classifier now removes the 25 000 gas charged for creating a new
account before deciding how many cold accesses occurred. This prevents
false positives when the large new-account cost would otherwise be
mis-classified as extra cold accesses.

docs: clarify CALL value-transfer and stipend comments
test: add cases covering CALL to empty accounts with value transfer
…on logic

- Add detailed inline comments explaining CALL and EXTCODECOPY gas
 composition, normalization steps, and range-based classification rules.
- Clarify why 200/2600/5200 thresholds are safe (gaps >2000 gas).
- Document precompile warm-up via EIP-2929 and fallback stack reads.
- No functional change; improves future maintainability.
…pped

feat(aggregator): add exact memory expansion gas tracking per opcode
refactor: replace hard-coded thresholds with warmAccessCost constant
feat(structlog): add cold access detection and memory expansion utilities
…consistency

Replace nullable pointer with zero-value semantics to simplify code and
align with the fact that refund is always 0 for failed transactions,
per-opcode rows, and non-root frames.
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.

2 participants