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

core: implement EIP-3651, warm coinbase #25819

Merged
merged 6 commits into from
Nov 22, 2022

Conversation

MariusVanDerWijden
Copy link
Member

@MariusVanDerWijden MariusVanDerWijden commented Sep 19, 2022

Implements https://eips.ethereum.org/EIPS/eip-3651 for Shanghai.

@@ -320,6 +320,10 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
// Set up the initial access list.
if rules.IsBerlin {
st.state.PrepareAccessList(msg.From(), msg.To(), vm.ActivePrecompiles(rules), msg.AccessList())
// EIP-3651 warm COINBASE
if rules.IsShanghai {
st.state.AddAddressToAccessList(st.evm.Context.Coinbase)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not super-elegant, adding it like this means it's a journalled change. So it would be nicer to somehow integrate more closely in the "constructor" PrepareAccessList

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, there are a few other places where PrepareAccessList is invoked (e.g. core/vm/runtime/runtime.go:Create) which also needs to do this extra step, and are currently not.
If we turn it into only one step, then we don't have to worry about missing the warm-coinbase extra-step

Copy link
Contributor

Choose a reason for hiding this comment

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

How about changing the PrepareAccessList into

func (s *StateDB) PrepareAccessList(sender, coinbase common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList, rules params.Rules) {

I.e: adding coinbase common.Address, and also adding rules params.Rules, so the method can add the coinbase if we're in shanghai.

Copy link
Contributor

Choose a reason for hiding this comment

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

With the transient eip pr, the signature is changed (https://github.com/ethereum/go-ethereum/pull/26003/files#diff-c3757dc9e9d868f63bc84a0cc67159c1d5c22cc5d8c9468757098f0492e0658cR1071) , into

func (s *StateDB) Prepare(rules params.Rules, sender common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList) {

So you only need to add the coinbase

@holiman
Copy link
Contributor

holiman commented Nov 16, 2022

I have now pushed a couple of changes,

  • Now the warm-coinbase logic happens inside Prepare, so it's not something a caller can get wrong.
  • The initial access list additions are now not journalled. This is a change which I think is totally fine, but would appreciate if someone also thinks about and comes to the same conclusion (or not).

@@ -1068,25 +1068,29 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) {
//
// Potential EIPs:
// - Reset transient storage(1153)
func (s *StateDB) Prepare(rules params.Rules, sender common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList) {
func (s *StateDB) Prepare(rules params.Rules, sender, coinbase common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList) {
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick, can you also add the Shanghai Fork information here:

e.g.

Shanghai fork:

  • Add coinbase to access list(3651)

Copy link
Member

@rjl493456442 rjl493456442 left a comment

Choose a reason for hiding this comment

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

Just a nitpick, I feel like it's safe to not journal initial accessList change. These change will never be rollback IIUC.

But yeah, we can run the PR on a synced node, just ensure nothing broken?

@holiman
Copy link
Contributor

holiman commented Nov 17, 2022

Nov 17 12:40:43 bench01.ethdevops.io geth INFO [11-17|11:40:43.655] Starting peer-to-peer node instance=Geth/v1.11.0-unstable-e6af3a14-20221116/linux-amd64/go1.18.7

It's chugging along now, started at full block number=15,945,345, currently at number=15,947,346

Copy link
Member Author

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

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

Changes LGTM, can't approve since I'm author

@holiman
Copy link
Contributor

holiman commented Nov 22, 2022

Follow-up

 Nov 22 20:19:02 bench01.ethdevops.io geth INFO [11-22|19:19:02.118] Imported new potential chain segment number=16,027,581 hash=d31241..53c342 blocks=1 txs=...

All good

@@ -28,6 +28,7 @@ import (
"testing"
"time"

"github.com/ethereum/go-ethereum/common"
Copy link
Contributor

Choose a reason for hiding this comment

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

>>> build/cache/golangci-lint-1.49.0-linux-amd64/golangci-lint run --config .golangci.yml ./...
tests/state_test.go:31:2: "github.com/ethereum/go-ethereum/common" imported but not used (typecheck)
	"github.com/ethereum/go-ethereum/common"
	^
util.go:48: exit status 1

tests/state_test.go Outdated Show resolved Hide resolved
core/state/statedb.go Outdated Show resolved Hide resolved
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

core/state/statedb.go Outdated Show resolved Hide resolved
@holiman holiman merged commit ec2ec2d into ethereum:master Nov 22, 2022
@holiman holiman added this to the 1.11.0 milestone Nov 22, 2022
NazariiDenha pushed a commit to scroll-tech/go-ethereum that referenced this pull request May 9, 2023
Implements EIP-3651, "Warm Coinbase", for Shanghai hardfork. Specification: https://eips.ethereum.org/EIPS/eip-3651.
Thegaram pushed a commit to scroll-tech/go-ethereum that referenced this pull request May 12, 2023
* core: implement EIP-3651, warm coinbase (ethereum#25819)

Implements EIP-3651, "Warm Coinbase", for Shanghai hardfork. Specification: https://eips.ethereum.org/EIPS/eip-3651.

* improve test

* update to shanghai

* trigger ci

* fix comments

---------

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
shekhirin pushed a commit to shekhirin/go-ethereum that referenced this pull request Jun 6, 2023
Implements EIP-3651, "Warm Coinbase", for Shanghai hardfork. Specification: https://eips.ethereum.org/EIPS/eip-3651.
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 2, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 16, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 17, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 18, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 25, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 29, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 30, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 31, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 1, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 15, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 15, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 15, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 18, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 20, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 21, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 25, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 25, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Dec 2, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Dec 2, 2024
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.

3 participants