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

cmd/evm: fix evm basefee #30281

Merged
merged 1 commit into from
Aug 8, 2024
Merged

cmd/evm: fix evm basefee #30281

merged 1 commit into from
Aug 8, 2024

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Aug 8, 2024

This PR fixes #30279

We did not use the basefee from the genesis, and instead the defaults were used from runtime.go/setDefaults-function

	if cfg.BaseFee == nil {
		cfg.BaseFee = big.NewInt(params.InitialBaseFee)
	}

That method will still be used if it's not provided in genesis.


With this PR

[user@work go-ethereum]$ go run ./cmd/evm  --debug --gas 0xffffff --nomemory=false --json --code 4860005260406000f3 --prestate ./genesis.json run
INFO [08-08|15:55:21.436] Persisted trie from memory database      nodes=1 size=142.00B time="6.577µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=0 livesize=0.00B
{"pc":0,"op":72,"gas":"0xffffff","gasCost":"0x2","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"BASEFEE"}
{"pc":1,"op":96,"gas":"0xfffffd","gasCost":"0x3","memSize":0,"stack":["0x3b9aca00"],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":3,"op":82,"gas":"0xfffffa","gasCost":"0x6","memSize":0,"stack":["0x3b9aca00","0x0"],"depth":1,"refund":0,"opName":"MSTORE"}
{"pc":4,"op":96,"gas":"0xfffff4","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000003b9aca00","memSize":32,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":6,"op":96,"gas":"0xfffff1","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000003b9aca00","memSize":32,"stack":["0x40"],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":8,"op":243,"gas":"0xffffee","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000003b9aca00","memSize":32,"stack":["0x40","0x0"],"depth":1,"refund":0,"opName":"RETURN"}
{"output":"000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000000000000000000","gasUsed":"0x14"}
#### LOGS ####

Copy link
Member

@lightclient lightclient left a comment

Choose a reason for hiding this comment

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

Was able to replicate the issue and verify this fix works.

$ go run ./cmd/evm --debug --gas 0xffffff --nomemory=false --json --code 4860005260406000f3 --prestate ./genesis.json run
INFO [08-08|08:34:17.491] Persisted trie from memory database      nodes=35 size=4.99KiB time="37.75µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=0 livesize=0.00B
{"pc":0,"op":72,"gas":"0x23f3e20","gasCost":"0x2","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"BASEFEE"}
{"pc":1,"op":96,"gas":"0x23f3e1e","gasCost":"0x3","memSize":0,"stack":["0x3b9aca00"],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":3,"op":82,"gas":"0x23f3e1b","gasCost":"0x6","memSize":0,"stack":["0x3b9aca00","0x0"],"depth":1,"refund":0,"opName":"MSTORE"}
{"pc":4,"op":96,"gas":"0x23f3e15","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000003b9aca00","memSize":32,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":6,"op":96,"gas":"0x23f3e12","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000003b9aca00","memSize":32,"stack":["0x40"],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":8,"op":243,"gas":"0x23f3e0f","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000003b9aca00","memSize":32,"stack":["0x40","0x0"],"depth":1,"refund":0,"opName":"RETURN"}
{"output":"000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000000000000000000","gasUsed":"0x14"}
#### LOGS ####
$ git pr 30281 upstream
$ go run ./cmd/evm --debug --gas 0xffffff --nomemory=false --json --code 4860005260406000f3 --prestate ./genesis.json run
INFO [08-08|08:35:05.186] Persisted trie from memory database      nodes=35 size=4.99KiB time="40.167µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=0 livesize=0.00B
{"pc":0,"op":72,"gas":"0x23f3e20","gasCost":"0x2","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"BASEFEE"}
{"pc":1,"op":96,"gas":"0x23f3e1e","gasCost":"0x3","memSize":0,"stack":["0x7"],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":3,"op":82,"gas":"0x23f3e1b","gasCost":"0x6","memSize":0,"stack":["0x7","0x0"],"depth":1,"refund":0,"opName":"MSTORE"}
{"pc":4,"op":96,"gas":"0x23f3e15","gasCost":"0x3","memory":"0x0000000000000000000000000000000000000000000000000000000000000007","memSize":32,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":6,"op":96,"gas":"0x23f3e12","gasCost":"0x3","memory":"0x0000000000000000000000000000000000000000000000000000000000000007","memSize":32,"stack":["0x40"],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":8,"op":243,"gas":"0x23f3e0f","gasCost":"0x3","memory":"0x0000000000000000000000000000000000000000000000000000000000000007","memSize":32,"stack":["0x40","0x0"],"depth":1,"refund":0,"opName":"RETURN"}
{"output":"00000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000000","gasUsed":"0x14"}
#### LOGS ####

@holiman holiman merged commit 83e70aa into ethereum:master Aug 8, 2024
3 checks passed
@fjl fjl added this to the 1.14.8 milestone Aug 12, 2024
rjl493456442 pushed a commit to rjl493456442/go-ethereum that referenced this pull request Aug 13, 2024
fixes ethereum#30279 -- previously we did not use the basefee from the genesis, and instead the defaults were used from `runtime.go/setDefaults`-function
leeren pushed a commit to storyprotocol/story-geth that referenced this pull request Aug 16, 2024
fixes ethereum#30279 -- previously we did not use the basefee from the genesis, and instead the defaults were used from `runtime.go/setDefaults`-function
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.

cmd/evm ignores the baseFeePerGas setting in genesis.json when executing opcode BASEFEE
4 participants