Skip to content

Commit

Permalink
Remove ChainID + GetCodeSize check from create2deployer precompile de…
Browse files Browse the repository at this point in the history
…ployment (#170)

* Remove chainID check from create2deployer pre-compile deployment

* Also remove GetCodeSize check
  • Loading branch information
mdehoog authored Oct 26, 2023
1 parent e8f25a6 commit dda1a26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 30 deletions.
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

0 comments on commit dda1a26

Please sign in to comment.