Skip to content

Commit

Permalink
fix(evm): add zoltu predeploy
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxMustermann2 committed Mar 1, 2025
1 parent 04df216 commit b19fe9c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion x/evm/predeploys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ func (suite *KeeperTestSuite) TestPredeploysExist() {
func (suite *KeeperTestSuite) TestBalanceRetention() {
evmParams := suite.App.EvmKeeper.GetParams(suite.Ctx)
evmDenom := evmParams.GetEvmDenom()
beforeSupply := suite.App.BankKeeper.GetSupply(suite.Ctx, evmDenom).Amount
targetBalance := sdkmath.NewInt(100)
// set balance > 0 for all of the predeployed address
// set balance > 0 for all of the predeployed address, at genesis.
for _, predeploy := range types.DefaultPredeploys {
addr := predeploy.GetByteAddress()
suite.Balances = append(
Expand All @@ -90,6 +91,7 @@ func (suite *KeeperTestSuite) TestBalanceRetention() {
},
)
}
expectedSupply := beforeSupply.Add(sdkmath.NewInt(int64(len(types.DefaultPredeploys))).Mul(targetBalance))
// now redo the genesis
suite.SetupTest()
// check the state of the predeploys
Expand Down Expand Up @@ -118,6 +120,8 @@ func (suite *KeeperTestSuite) TestBalanceRetention() {
// check that code exists
suite.Require().NotNil(suite.App.EvmKeeper.GetCode(suite.Ctx, predeploy.GetCodeHash()))
}
afterSupply := suite.App.BankKeeper.GetSupply(suite.Ctx, evmDenom).Amount
suite.Require().Equal(expectedSupply, afterSupply)
}

// Tests if create2 can be used to deploy another contract successfully.
Expand Down
14 changes: 11 additions & 3 deletions x/evm/types/predeploys.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ type Predeploy struct {

// DefaultPredeploys is a list of predeploys that are included at genesis.
var DefaultPredeploys = []Predeploy{
create2, create2Deployer, createX, safeSingletonFactory, multicall3,
arachnidCreate2, zoltuCreate2,
create2Deployer, createX,
safeSingletonFactory, multicall3,
create3, create3Deterministic,
}

Expand Down Expand Up @@ -73,10 +75,15 @@ func init() {
var (
// https://github.com/Arachnid/deterministic-deployment-proxy
// Include here because it is deployed with a pre-EIP155 tx which is not supported.
create2 = Predeploy{
arachnidCreate2 = Predeploy{
Address: "0x4e59b44847b379578588920cA78FbF26c0B4956C",
Code: "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3",
}
// https://github.com/Zoltu/deterministic-deployment-proxy
zoltuCreate2 = Predeploy{
Address: "0x7A0D94F55792C434d74a40883C6ed8545E406D12",
Code: "60003681823780368234f58015156014578182fd5b80825250506014600cf3",
}
// https://github.com/pcaversaccio/create2deployer
// Can be deployed with a request to the dev. But easier to predeploy it.
create2Deployer = Predeploy{
Expand All @@ -95,7 +102,7 @@ var (
// https://github.com/safe-global/safe-singleton-factory?tab=readme-ov-file#op-stack
safeSingletonFactory = Predeploy{
Address: "0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7",
Code: create2.Code,
Code: arachnidCreate2.Code,
}
// https://github.com/mds1/multicall
// The key to deploy this is compromised. Therefore, we instead make it a predeploy.
Expand All @@ -112,6 +119,7 @@ var (
Code: "6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610489565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e6100853660046104fd565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346102b2565b604080518082018252601081527f67363d3d37363d34f03d5260086018f30000000000000000000000000000000060209182015290517fff00000000000000000000000000000000000000000000000000000000000000918101919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b166021820152603581018290527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f60558201526000908190610228906075015b6040516020818303038152906040528051906020012090565b6040517fd69400000000000000000000000000000000000000000000000000000000000060208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201529091506100e79060370161020f565b6000806040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000858251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff811661037d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4445504c4f594d454e545f4641494c454400000000000000000000000000000060448201526064015b60405180910390fd5b6103868661014c565b925060008173ffffffffffffffffffffffffffffffffffffffff1685876040516103b091906105d6565b60006040518083038185875af1925050503d80600081146103ed576040519150601f19603f3d011682016040523d82523d6000602084013e6103f2565b606091505b50509050808015610419575073ffffffffffffffffffffffffffffffffffffffff84163b15155b61047f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e495449414c495a4154494f4e5f4641494c454400000000000000000000006044820152606401610374565b5050509392505050565b6000806040838503121561049c57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff811681146104c057600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806040838503121561051057600080fd5b82359150602083013567ffffffffffffffff8082111561052f57600080fd5b818501915085601f83011261054357600080fd5b813581811115610555576105556104ce565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561059b5761059b6104ce565b816040528281528860208487010111156105b457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b818110156105f757602081860181015185830152016105dd565b50600092019182525091905056fea2646970667358221220a194c2eaa665b9a3b7df63a08195224328c42d9f7f651494deafa8b9a230d5ee64736f6c63430008160033",
}
create3Deterministic = Predeploy{
// https://github.com/ZeframLou/create3-factory/issues/4#issuecomment-1640992276
Address: "0x6aa3d87e99286946161dca02b97c5806fc5ed46f",
Code: "6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610489565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e6100853660046104fd565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346102b2565b604080518082018252601081527f67363d3d37363d34f03d5260086018f30000000000000000000000000000000060209182015290517fff00000000000000000000000000000000000000000000000000000000000000918101919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b166021820152603581018290527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f60558201526000908190610228906075015b6040516020818303038152906040528051906020012090565b6040517fd69400000000000000000000000000000000000000000000000000000000000060208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201529091506100e79060370161020f565b6000806040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000858251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff811661037d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4445504c4f594d454e545f4641494c454400000000000000000000000000000060448201526064015b60405180910390fd5b6103868661014c565b925060008173ffffffffffffffffffffffffffffffffffffffff1685876040516103b091906105d6565b60006040518083038185875af1925050503d80600081146103ed576040519150601f19603f3d011682016040523d82523d6000602084013e6103f2565b606091505b50509050808015610419575073ffffffffffffffffffffffffffffffffffffffff84163b15155b61047f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e495449414c495a4154494f4e5f4641494c454400000000000000000000006044820152606401610374565b5050509392505050565b6000806040838503121561049c57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff811681146104c057600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806040838503121561051057600080fd5b82359150602083013567ffffffffffffffff8082111561052f57600080fd5b818501915085601f83011261054357600080fd5b813581811115610555576105556104ce565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561059b5761059b6104ce565b816040528281528860208487010111156105b457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b818110156105f757602081860181015185830152016105dd565b50600092019182525091905056fea2646970667358221220fd377c185926b3110b7e8a544f897646caf36a0e82b2629de851045e2a5f937764736f6c63430008100033",
}
Expand Down

0 comments on commit b19fe9c

Please sign in to comment.