-
Notifications
You must be signed in to change notification settings - Fork 720
fix(state): omit no-op nonce change from block access list #12830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: eip8141-frame-txs-devnet7
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,6 +110,29 @@ public void NonceOp_RecordsNonceChange( | |
| } | ||
| } | ||
|
|
||
| [TestCase(1ul, 1ul, false, TestName = "SetNonce_UnchangedValue_RecordsNoNonceChange")] | ||
| [TestCase(1ul, 2ul, true, TestName = "SetNonce_ChangedValue_RecordsNonceChange")] | ||
| public void SetNonce_RecordsNonceChange_OnlyWhenValueChanges( | ||
| ulong initialNonce, ulong newNonce, bool expectRecorded) | ||
| { | ||
| (TracedAccessWorldState tws, IDisposable scope) = CreateTracingState(ws => | ||
| ws.CreateAccount(TestItem.AddressA, 0, initialNonce)); | ||
| using (scope) | ||
| { | ||
| tws.SetNonce(TestItem.AddressA, newNonce); | ||
|
|
||
| AccountChangesAtIndex? ac = tws.GetGeneratingBlockAccessList()!.GetAccountChanges(TestItem.AddressA); | ||
| using (Assert.EnterMultipleScope()) | ||
| { | ||
| Assert.That(ac?.NonceChange is not null, Is.EqualTo(expectRecorded)); | ||
| if (expectRecorded) | ||
| { | ||
| Assert.That(ac!.NonceChange!.Value.Value, Is.EqualTo(newNonce)); | ||
| } | ||
| } | ||
|
Comment on lines
+124
to
+132
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Low — the unchanged case tolerates two different outcomes.
Minor: the changed case ( |
||
| } | ||
| } | ||
|
|
||
| [Test] | ||
| public void InsertCode_RecordsCodeChange() | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,8 +101,12 @@ public override void IncrementNonce(Address address, ulong delta, out ulong oldN | |
|
|
||
| public override void SetNonce(Address address, in ulong nonce) | ||
| { | ||
| ulong oldNonce = GetNonceInternal(address); | ||
| base.SetNonce(address, nonce); | ||
| _generatingBlockAccessList.AddNonceChange(address, nonce); | ||
| if (nonce != oldNonce) | ||
| { | ||
| _generatingBlockAccessList.AddNonceChange(address, nonce); | ||
| } | ||
|
Comment on lines
+104
to
+109
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Low — touched-but-unchanged account is now dropped entirely. The guard skips the Not reachable today — both production callers touch the address first ( |
||
| } | ||
|
|
||
| public override bool InsertCode(Address address, in ValueHash256 codeHash, ReadOnlyMemory<byte> code, IReleaseSpec spec, bool isGenesis = false) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[LOW] Dependent assertions can turn a nonce regression into an exception
When the changed-value case regresses so that
acis null or lacks a nonce change, the first assertion records a failure but the multiple-assert scope continues into this dereference, producingNullReferenceExceptionorInvalidOperationException. This dependent null-check/dereference pattern makes the regression failure less diagnostic.