Skip to content
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

Tests for EIP-3855: PUSH0 instruction #1033

Merged
merged 8 commits into from
Nov 28, 2022
Merged

Conversation

hugo-dc
Copy link
Member

@hugo-dc hugo-dc commented May 24, 2022

This PR contains the test cases in PR #1000 and some changes according to the comments in such PR.

@hugo-dc
Copy link
Member Author

hugo-dc commented Aug 15, 2022

Tests updated based on comments.

@gumb0
Copy link
Member

gumb0 commented Aug 24, 2022

@winsvega Do you think it's ok to add these new tests to GeneralStateTests/VMTests/vmTests or is this path kinda legacy not to be updated?

@winsvega
Copy link
Collaborator

Yes, its not a legacy anymore. Ori updated it to GStateTests format

@hugo-dc hugo-dc marked this pull request as ready for review August 25, 2022 02:22
@hugo-dc
Copy link
Member Author

hugo-dc commented Aug 25, 2022

I have updated the PR, it is currently ready for review.

cc. @gumb0 @winsvega

Copy link
Collaborator

@winsvega winsvega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the gas difference when measuring the gas used.

0000000000000000000000000000000000000100:
balance: 0
code: ':raw 0x5f'
nonce: '0'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test for gasPrice
(sstore 0 (gas))
Push0
(Sstore 0 (sub (gas) (sload 0)))

Make it irrelevant from other gas that is affected by other evm changes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to record gas usage in storage.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use memory for it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a version using MSTORE/MLOAD: https://gist.github.com/hugo-dc/4740c46803771c701b12d417a348f3b8#file-push0gasfiller-yml-L21

Looks very similar to the SSTORE/SLOAD version, although the expect section looks cleaner.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memory is also ok as long as the result is checed in sstore. and memory does not intersect with some other region that is in use

- 'London'
result:
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
balance: 9099500
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Use difference.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed, now gas is not tested by checking final balance but using values recorded to storage.

0x00: 0x01
b94f5374fce5edbc8e2a8697c15331677e6ebf0b:
storage:
0x00: 0x01
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put more comments what we expect here. (In all expect sections of this test) what does sstore equals 1 mean.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more comments.

0000000000000000000000000000000000000100:
balance: 0
# sstore(0, gas) push0 sstore(0, (sub(sload(0), gas))) stop
code: ':raw 0x5a6000555f5a6000540360015500'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raw?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think PUSH0 is available in Solidity, that's why.

Copy link
Collaborator

@winsvega winsvega Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can use custom lllc
mstore(0, gas) push0 sstore(0, (sub(mload(0), gas))) stop
the first gas will be affected by intrinsic transaction cost which might be changed by other eip

code: ':raw 0x60ff5f5360016000f3'
nonce: 0
storage: {}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a test where we have a JUMPDEST right in front of a PUSH0 and then jump to it ?
This could help us make sure that jumpdest-analysis is not affected somehow by this opcode.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new test case, with a contract having a JUMPDEST after PUSH0 and jumping into it.

storage: {} # Nothing is stored, PUSH0 (0x5f) is undefined/invalid in London
- indexes:
data: ':label use_push0'
gas: !!int -1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw -1 is set by default can now be omited from the filler

result:
0000000000000000000000000000000000000100:
balance: 0
storage: {} # Nothing is stored, PUSH0 (0x5f) is undefined/invalid in London
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will require update invalidOpcodes test once the eip is merged

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is merged in geth as "+3855".

Expectations in the tests could be changed to Merge / Merge+3855 though.

@winsvega winsvega merged commit 53a3737 into ethereum:develop Nov 28, 2022
@axic axic deleted the push0 branch May 6, 2023 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants