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

Remove ChainID + GetCodeSize check from create2deployer precompile deployment #170

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions consensus/misc/create2deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,7 @@ import (
// file applies the contract code to the canonical address manually in the Canyon
// hardfork.

// create2deployer is already deployed to Base testnets at 0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2,
// so we deploy it to 0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF1 for hardfork testing purposes
var create2DeployerAddresses = map[uint64]common.Address{
11763071: common.HexToAddress("0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF1"), // Base Goerli devnet
params.BaseGoerliChainID: common.HexToAddress("0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF1"), // Base Goerli testnet
11763072: common.HexToAddress("0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF1"), // Base Sepolia devnet
84532: common.HexToAddress("0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF1"), // Base Sepolia testnet
params.BaseMainnetChainID: common.HexToAddress("0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2"), // Base mainnet
}
var create2DeployerAddress = common.HexToAddress("0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2")
var create2DeployerCodeHash = common.HexToHash("0xb0550b5b431e30d38000efb7107aaa0ade03d48a7198a140edda9d27134468b2")
var create2DeployerCode []byte

Expand All @@ -40,10 +32,6 @@ func EnsureCreate2Deployer(c *params.ChainConfig, timestamp uint64, db vm.StateD
if !c.IsOptimism() || c.CanyonTime == nil || *c.CanyonTime != timestamp {
return
}
address, ok := create2DeployerAddresses[c.ChainID.Uint64()]
if !ok || db.GetCodeSize(address) > 0 {
return
}
log.Info("Setting Create2Deployer code", "address", address, "codeHash", create2DeployerCodeHash)
db.SetCode(address, create2DeployerCode)
log.Info("Setting Create2Deployer code", "address", create2DeployerAddress, "codeHash", create2DeployerCodeHash)
db.SetCode(create2DeployerAddress, create2DeployerCode)
}
22 changes: 7 additions & 15 deletions consensus/misc/create2deployer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,18 @@ func TestEnsureCreate2Deployer(t *testing.T) {
applied: true,
},
{
name: "non-optimism chain",
name: "another chain ID",
override: func(cfg *params.ChainConfig) {
cfg.Optimism = nil
cfg.ChainID = big.NewInt(params.OPMainnetChainID)
},
timestamp: canyonTime,
applied: false,
applied: true,
},
{
name: "non-base chain",
override: func(cfg *params.ChainConfig) {
cfg.ChainID = big.NewInt(params.OPMainnetChainID)
},
timestamp: canyonTime,
applied: false,
name: "code already exists",
timestamp: canyonTime,
codeExists: true,
applied: true,
},
{
name: "pre canyon",
Expand All @@ -59,12 +57,6 @@ func TestEnsureCreate2Deployer(t *testing.T) {
timestamp: canyonTime,
applied: false,
},
{
name: "code already exists",
timestamp: canyonTime,
codeExists: true,
applied: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down