-
Notifications
You must be signed in to change notification settings - Fork 318
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
EIP-2681: Limit account nonce to 2^64-1 #934
Conversation
10932c7
to
e17ac4f
Compare
working to revive ttTransaction Tests |
checked now with new transaction tests |
ah wait its the state tests |
b94f5374fce5edbc8e2a8697c15331677e6ebf0b: | ||
nonce: '0xffffffffffffffff' | ||
storage: | ||
'1': 1 |
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.
The EIP states that the CREATE opcodes should "abort with an exceptional halt" when the nonce is about to overflow.
I would expect the storage remains unchanged, is this ok?
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.
Good question, I interpret the EIP text as opcodes themselves end with an exceptional halt, but not the execution frame they're called from (similar to not having enough balance for CREATE's value transfer, call stack overflow, address already existing etc.)
Test cases look good to me, but I think we should add a positive test case for both CREATE/CREATE2 where the nonce is (2**64) - 2, and the contract is still created. |
Yes, current geth's behavior is wrapping around, I linked the possible patch in the description ewasm/go-ethereum@36580c6 which I used to generate.
EIP specifies exceptional halt, I think this implies 0 returned on stack, as in all other exceptional cases. |
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.
Request for two extra test cases and two minor changes.
b94f5374fce5edbc8e2a8697c15331677e6ebf0b: | ||
nonce: '0xffffffffffffffff' | ||
storage: | ||
'1': 1 |
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.
Could you add a check here for:
storage:
'0': 0
and
04e9a8460199e670ffb592f93a2f74bdcb44b0bd:
'shouldnotexist': '1'
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.
storage '0': 0 is implicitly checked I think (error if some storage present that is not in test expectations), but added.
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.
yes.
but look after cases where you have
sstore(0, test())
and a pre storage is empty.
if smth goes wrong, the transaction reverted, storage remains unchanged and the expect section not showing any error, but the actual exection of test() was aborted or not performed properly
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.
If I understand you correctly, that's why sstore(1, 1)
is done there in the end
(adding storage '0': 0
wouldn't help this or change anything)
sstore(0, create(0, 0, 5)) | ||
sstore(1, 1) | ||
} | ||
nonce: '0xffffffffffffffff' |
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.
Could we add a positive test case CREATE_HighNonceMinus1, where nonce is '0xfffffffffffffffe' and contract '0xd061b08a84ebc70fe797f9bd62f4269ef8274a13' is actually created?
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.
Added.
nonce: 1 | ||
b94f5374fce5edbc8e2a8697c15331677e6ebf0b: | ||
nonce: '0xffffffffffffffff' | ||
storage: |
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.
We should also check:
storage:
'0': 0
and
77dd5d2a2b742ca01ee2cfff306445e3741ef744:
'shouldnotexist': '1'
sstore(0, create2(0, 0, 5, 0)) | ||
sstore(1, 1) | ||
} | ||
nonce: '0xffffffffffffffff' |
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.
Could we also add here a positive test case CREATE2_HighNonceMinus1, where nonce is '0xfffffffffffffffe' and contract '0x77dd5d2a2b742ca01ee2cfff306445e3741ef744' is actually created?
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.
Added.
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.
Looks good to me, thanks for the changes.
I think this PR still requires ewasm/go-ethereum@eip-2681 to be merged onto ethereum/go-ethereum though.
@gumb0 there's no open PR about it, is there? If not, would you mind opening one? |
I have also updated transaction tests for a new rule that |
@@ -3,6 +3,7 @@ | |||
{ | |||
"expectException" : | |||
{ | |||
">=Frontier": "NonceMax" |
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.
This new error also has to be added to retesteth config.
The corresponding geth string is
"NonceMax" : "nonce exceeds 2^64-1",
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.
@winsvega should it be called TR_NonceMax
?
(Some transaction tests use errors with TR_
prefix, and others without, so not sure)
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.
Added ethereum/retesteth#156 for this.
@@ -0,0 +1,20 @@ | |||
{ | |||
"TransactionWithHighNonce64Minus1" : |
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.
Should be TransactionWithHighNonce64Minus2
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.
Looks good to me 👍
Rebased. |
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.
ok. looks good.
how about a case where a contract with high nonce calls contract via delegate
and that subcall creates a contract. but since the context of execution moved. the actual contract creator changes.
|
I mean when A having nonce 0, delegatecall B which has maxnonce, and B creates contract what happens? |
Yes, should work, will work |
Rebased, removed change to |
https://eips.ethereum.org/EIPS/eip-2681
Geth change is in ethereum/go-ethereum#23853
EIP applies retroactively, therefore I put
>=Frontier
forCREATE
and>=Constantinople
forCREATE2
.(Also not sure what should be done with already generated legacy transaction tests, probably should be updated)