get transaction count erigon#2863
Closed
leonardchinonso wants to merge 6 commits into
Closed
Conversation
…onardchinonso_get_transaction_count_erigon � Conflicts: � go.mod � go.sum
Contributor
|
Remove LeonardChinoso from the PR name, just some styling ;-) . |
Contributor
|
Before using the modified dependency of Erigon-Lib, perhaps you should wait until the PR from @AlexeyAkhunov is merged. Also i see it is a draft PR so another reason you should not change it yet. maybe for now mark this as draft :) |
Collaborator
|
I thought Alex's PR is just an example. |
Contributor
Author
|
Yes its just an example. I followed his example to recreate it on here. However, as you know, I'm still having bugs |
5 tasks
Sahil-4555
pushed a commit
to Sahil-4555/erigon
that referenced
this pull request
May 20, 2026
## Summary Bumps the EEST devnet fixtures from `tests-bal@v7.1.1` to `tests-bal@v7.2.0` and adapts Erigon to the EIP-8037 spec change that ships with it. ### What changed in EEST v7.2.0 The only behavioural change in the new fixtures is execution-specs PR [erigontech#2863](ethereum/execution-specs#2863) — "EIP-8037 SSTORE/collision clear dynamics": - Inline `state_gas` refunds (`SSTORE` original-zero reset, `CREATE` collision/revert) now credit the local frame's `state_gas_left` **immediately**, instead of being clamped to a per-frame `state_gas_used` counter and bubbled up as a pending credit. - `Evm.state_gas_used` becomes a **signed** counter — it goes negative when refunds in a frame outweigh the frame's own charges (typical for `DELEGATECALL`/`CALLCODE` callees that clear a slot an ancestor set). - `incorporate_child_on_success` no longer propagates a pending refund; `incorporate_child_on_error` restores the parent's reservoir via the `state_gas_left + state_gas_used` invariant. - `process_transaction` computes block state gas as `Uint(max(0, intrinsic_state + state_gas_used − state_refund))`. Bulk of the rest of the v7.2.0 diff is additional BAL test coverage synchronised from `forks/amsterdam`. ### Erigon changes - `test-fixtures.json`: bump `eest_devnet` to `tests-bal@v7.2.0` (sha256 `fc1d9ae1…`, 611 743 632 bytes). - `execution/protocol/mdgas/md_gas.go`: `MdGasUsage` keeps `Regular uint64` but `State` becomes `int64`. Adds `MdGasUsage.PlusIntrinsic(MdGas)`, `MdGasUsage.StateClamped()` (= `uint64(max(0, State))`), and `MdGasUsage.Total() = Regular + StateClamped()`. `MdGas` (reservoirs / leftover) keeps both fields `uint64`. - `execution/vm/interpreter.go`: `CallContext.frameStateUsed` is now `int64`. `refundCreditPending` is removed. `creditStateGasRefund` drops the clamp — it does `stateGas += amount; frameStateUsed -= int64(amount)` directly. - `execution/vm/instructions.go`: `op{Call,CallCode,DelegateCall,StaticCall,execCreate}` drop the `PendingStateGasCredit` absorption; success path is just `scope.frameStateUsed += childUsed.State` (signed). - `execution/vm/evm.go`: - `evm.call` / `evm.create` use a named return `gasRemaining` (renamed from `leftOverGas`) and `gas` as the parameter; mutations are visible in the body. - `handleFrameRevert(gasRemaining *MdGas, …, stateGasUsed int64)` takes the signed state usage and restores the parent reservoir via `gasRemaining.State + stateGasUsed`. Includes a panic on the invariant violation `state_gas_left + state_gas_used < 0` so any future regression in the `useMdGas`/`creditStateGasRefund` pairing surfaces loudly rather than silently wrapping the `uint64` cast. - The depth-0 defers fold the spec's error semantics into `gasUsed.State`: CALL error resets it to `0`; CREATE error sets it to `-StateGasNewAccount` (mirrors the spec's `state_refund += STATE_BYTES_PER_NEW_ACCOUNT * COST_PER_STATE_BYTE` on CREATE-tx failure). `TxnExecutor` then reads `gasUsed.State` directly without an error-path branch. - Extracts `deriveFrameRegularGasUsed(inputTotal, gasRemainingTotal uint64, stateGasUsed int64) uint64` — `Regular = (input − leftover) − state` in signed `int64` so a refund-heavy frame whose `gasRemaining.State` grew above the input still yields the correct positive regular-ops count (a guarded `uint64` subtraction would mis-skip and return 0). - `execution/protocol/txn_executor.go`: Amsterdam branches collapse the spec's `tx_state_gas = intrinsic_state + state_gas_used` + `block_state_gas_used += max(0, tx_state_gas)` into `combined := gasUsed.PlusIntrinsic(imdGas); st.blockStateGasUsed = combined.StateClamped(); st.txnGasUsedB4Refunds = combined.Total()`. ### Tests - `execution/vm/evm_test.go` (new): `TestDeriveFrameRegularGasUsed` with four sub-cases — charges-only, with-spillover, refunds-exceed-charges (the edge case the old guarded subtraction returned `0` for), and pure-refund. Worked numeric examples are documented inline. ## Test plan - [x] `make lint` clean. - [x] `go test ./execution/vm/... ./execution/protocol/...` — unit tests green. - [x] EEST shards on the new fixtures, 0 failures: - `statetests-devnet` (65 202 tests) - `blocktests-devnet` (82 941 tests) - `blocktests-devnet-race-amsterdam` (21 368 tests) - [x] Regression check against stable fixtures, 0 failures: - `statetests-stable` (63 556 tests) - `blocktests-stable-{sequential,parallel}` (69 256 tests each) - `enginextests-stable-{sequential,parallel}` (63 920 tests each) - [x] The originally failing variants now pass: `tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_sstore.py::test_sstore_restoration_refund_credits_local_reservoir[fork_Amsterdam-state_test-depth_{1,3,10}-refund_funds_create]`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trying to detect the bug for eth_getTransactionCount as 'pending' returns 0x0 all the time. Meanwhile, Found is true and Nonce is 0.
Also, 'latest' returns the wrong Nonce value as its not consistent with goerli etherscan.