diff --git a/devnet/applayer/genesis.json b/devnet/applayer/genesis.json index 844cee8..3f58d4a 100644 --- a/devnet/applayer/genesis.json +++ b/devnet/applayer/genesis.json @@ -30,6 +30,9 @@ "max": 9, "baseFeeUpdateFraction": 5007716 } + }, + "evolve": { + "mintAdmin": "0xfc28736049e1ea4a315bfc4cfc6e09240250dfdf" } }, "nonce": "0x0", diff --git a/genutil/main.go b/genutil/main.go index 60529c1..2cd90a3 100644 --- a/genutil/main.go +++ b/genutil/main.go @@ -12,69 +12,78 @@ import ( "github.com/ethereum/go-ethereum/params" ) -func ChainConfig(chainType ChainType) *params.ChainConfig { - return ¶ms.ChainConfig{ - ChainID: getChainID(chainType), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: true, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: nil, - GrayGlacierBlock: nil, - TerminalTotalDifficulty: big.NewInt(0), - MergeNetsplitBlock: big.NewInt(0), - ShanghaiTime: newUint64(0), - CancunTime: newUint64(0), - PragueTime: newUint64(0), - BlobScheduleConfig: ¶ms.BlobScheduleConfig{ - Cancun: params.DefaultCancunBlobConfig, - Prague: params.DefaultPragueBlobConfig, +func ChainConfig(chainType ChainType, mintAdmin *common.Address) *ChainConfigWithEvolve { + return &ChainConfigWithEvolve{ + ChainConfig: ¶ms.ChainConfig{ + ChainID: getChainID(chainType), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: nil, + GrayGlacierBlock: nil, + TerminalTotalDifficulty: big.NewInt(0), + MergeNetsplitBlock: big.NewInt(0), + ShanghaiTime: newUint64(0), + CancunTime: newUint64(0), + PragueTime: newUint64(0), + BlobScheduleConfig: ¶ms.BlobScheduleConfig{ + Cancun: params.DefaultCancunBlobConfig, + Prague: params.DefaultPragueBlobConfig, + }, + }, + Evolve: &EvolveChainConfig{ + MintAdmin: mintAdmin, }, } } // DefaultDevnetGenesisBlock returns the Devnet network genesis block. -func DefaultDevnetGenesisBlock() *core.Genesis { - return &core.Genesis{ - Config: ChainConfig(Devnet), - GasLimit: 60_000_000, - Difficulty: big.NewInt(0), - Timestamp: 1758708000, - Alloc: coretypes.GenesisAlloc{ - common.HexToAddress("0xFC28736049E1ea4A315bFc4CfC6e09240250dfdf"): coretypes.Account{ - Code: nil, - Storage: nil, - Balance: new(big.Int).Mul(big.NewInt(1_000_000_000), DECIMALS), - Nonce: 0, - }, - common.HexToAddress("0x00000000000000000000000000000000011d0b1e"): coretypes.Account{ - Code: common.Hex2Bytes("6080604052600436106100bc5760003560e01c8063313ce56711610074578063a9059cbb1161004e578063a9059cbb146102cb578063d0e30db0146100bc578063dd62ed3e14610311576100bc565b8063313ce5671461024b57806370a082311461027657806395d89b41146102b6576100bc565b806318160ddd116100a557806318160ddd146101aa57806323b872dd146101d15780632e1a7d4d14610221576100bc565b806306fdde03146100c6578063095ea7b314610150575b6100c4610359565b005b3480156100d257600080fd5b506100db6103a8565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101155781810151838201526020016100fd565b50505050905090810190601f1680156101425780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015c57600080fd5b506101966004803603604081101561017357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610454565b604080519115158252519081900360200190f35b3480156101b657600080fd5b506101bf6104c7565b60408051918252519081900360200190f35b3480156101dd57600080fd5b50610196600480360360608110156101f457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602081013590911690604001356104cb565b34801561022d57600080fd5b506100c46004803603602081101561024457600080fd5b503561066b565b34801561025757600080fd5b50610260610700565b6040805160ff9092168252519081900360200190f35b34801561028257600080fd5b506101bf6004803603602081101561029957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610709565b3480156102c257600080fd5b506100db61071b565b3480156102d757600080fd5b50610196600480360360408110156102ee57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610793565b34801561031d57600080fd5b506101bf6004803603604081101561033457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166107a7565b33600081815260036020908152604091829020805434908101909155825190815291517fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9281900390910190a2565b6000805460408051602060026001851615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f8101849004840282018401909252818152929183018282801561044c5780601f106104215761010080835404028352916020019161044c565b820191906000526020600020905b81548152906001019060200180831161042f57829003601f168201915b505050505081565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b4790565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600360205260408120548211156104fd57600080fd5b73ffffffffffffffffffffffffffffffffffffffff84163314801590610573575073ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14155b156105ed5773ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020548211156105b557600080fd5b73ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020805483900390555b73ffffffffffffffffffffffffffffffffffffffff808516600081815260036020908152604080832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060019392505050565b3360009081526003602052604090205481111561068757600080fd5b33600081815260036020526040808220805485900390555183156108fc0291849190818181858888f193505050501580156106c6573d6000803e3d6000fd5b5060408051828152905133917f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65919081900360200190a250565b60025460ff1681565b60036020526000908152604090205481565b60018054604080516020600284861615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f8101849004840282018401909252818152929183018282801561044c5780601f106104215761010080835404028352916020019161044c565b60006107a03384846104cb565b9392505050565b60046020908152600092835260408084209091529082529020548156fea265627a7a72315820ce46270f9809b3f50df3da6f813f6a969fa3ee71ad75e448d4322c98224207a664736f6c63430005110032"), - Storage: map[common.Hash]common.Hash{ - // Name - Slot 0 - common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"): getStorageSlotValue("Wrapped Noble"), - // Symbol - Slot 1 - common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000001"): getStorageSlotValue("WNOBLE"), - // Decimals - Slot 2 - common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000002"): getStorageSlotValue(big.NewInt(18)), +func DefaultDevnetGenesisBlock() *GenesisWithEvolve { + authority := common.HexToAddress("0xFC28736049E1ea4A315bFc4CfC6e09240250dfdf") + + return &GenesisWithEvolve{ + Genesis: &core.Genesis{ + GasLimit: 60_000_000, + Difficulty: big.NewInt(0), + Timestamp: 1758708000, + Alloc: coretypes.GenesisAlloc{ + authority: coretypes.Account{ + Code: nil, + Storage: nil, + Balance: new(big.Int).Mul(big.NewInt(1_000_000_000), DECIMALS), + Nonce: 0, + }, + common.HexToAddress("0x00000000000000000000000000000000011d0b1e"): coretypes.Account{ + Code: common.Hex2Bytes("6080604052600436106100bc5760003560e01c8063313ce56711610074578063a9059cbb1161004e578063a9059cbb146102cb578063d0e30db0146100bc578063dd62ed3e14610311576100bc565b8063313ce5671461024b57806370a082311461027657806395d89b41146102b6576100bc565b806318160ddd116100a557806318160ddd146101aa57806323b872dd146101d15780632e1a7d4d14610221576100bc565b806306fdde03146100c6578063095ea7b314610150575b6100c4610359565b005b3480156100d257600080fd5b506100db6103a8565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101155781810151838201526020016100fd565b50505050905090810190601f1680156101425780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015c57600080fd5b506101966004803603604081101561017357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610454565b604080519115158252519081900360200190f35b3480156101b657600080fd5b506101bf6104c7565b60408051918252519081900360200190f35b3480156101dd57600080fd5b50610196600480360360608110156101f457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602081013590911690604001356104cb565b34801561022d57600080fd5b506100c46004803603602081101561024457600080fd5b503561066b565b34801561025757600080fd5b50610260610700565b6040805160ff9092168252519081900360200190f35b34801561028257600080fd5b506101bf6004803603602081101561029957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610709565b3480156102c257600080fd5b506100db61071b565b3480156102d757600080fd5b50610196600480360360408110156102ee57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610793565b34801561031d57600080fd5b506101bf6004803603604081101561033457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166107a7565b33600081815260036020908152604091829020805434908101909155825190815291517fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9281900390910190a2565b6000805460408051602060026001851615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f8101849004840282018401909252818152929183018282801561044c5780601f106104215761010080835404028352916020019161044c565b820191906000526020600020905b81548152906001019060200180831161042f57829003601f168201915b505050505081565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b4790565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600360205260408120548211156104fd57600080fd5b73ffffffffffffffffffffffffffffffffffffffff84163314801590610573575073ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14155b156105ed5773ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020548211156105b557600080fd5b73ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020805483900390555b73ffffffffffffffffffffffffffffffffffffffff808516600081815260036020908152604080832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060019392505050565b3360009081526003602052604090205481111561068757600080fd5b33600081815260036020526040808220805485900390555183156108fc0291849190818181858888f193505050501580156106c6573d6000803e3d6000fd5b5060408051828152905133917f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65919081900360200190a250565b60025460ff1681565b60036020526000908152604090205481565b60018054604080516020600284861615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f8101849004840282018401909252818152929183018282801561044c5780601f106104215761010080835404028352916020019161044c565b60006107a03384846104cb565b9392505050565b60046020908152600092835260408084209091529082529020548156fea265627a7a72315820ce46270f9809b3f50df3da6f813f6a969fa3ee71ad75e448d4322c98224207a664736f6c63430005110032"), + Storage: map[common.Hash]common.Hash{ + // Name - Slot 0 + common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"): getStorageSlotValue("Wrapped Noble"), + // Symbol - Slot 1 + common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000001"): getStorageSlotValue("WNOBLE"), + // Decimals - Slot 2 + common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000002"): getStorageSlotValue(big.NewInt(18)), + }, + Balance: big.NewInt(0), + Nonce: 0, }, - Balance: big.NewInt(0), - Nonce: 0, }, }, + Config: ChainConfig(Devnet, &authority), } } func main() { - var genesis *core.Genesis + var genesis *GenesisWithEvolve if len(os.Args) < 2 { fmt.Fprintln(os.Stderr, "usage: genutil ") diff --git a/genutil/types.go b/genutil/types.go new file mode 100644 index 0000000..c595dbb --- /dev/null +++ b/genutil/types.go @@ -0,0 +1,74 @@ +package main + +import ( + "encoding/json" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/common/math" + "github.com/ethereum/go-ethereum/core" + coretypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" +) + +// ChainConfigWithEvolve defines a params.ChainConfig modified to support Evolve. +type ChainConfigWithEvolve struct { + *params.ChainConfig + Evolve *EvolveChainConfig `json:"evolve,omitempty"` +} + +// GenesisWithEvolve defines a core.Genesis modified to support Evolve. +type GenesisWithEvolve struct { + *core.Genesis + Config *ChainConfigWithEvolve `json:"config"` +} + +// https://github.com/evstack/ev-reth/blob/main/crates/node/src/config.rs#L5-L11 +type EvolveChainConfig struct { + BaseFeeSink *common.Address `json:"baseFeeSink,omitempty"` + MintAdmin *common.Address `json:"mintAdmin,omitempty"` +} + +// MarshalJSON is a modified version of the core.Genesis MarshalJSON function +// that supports the Evolve compatible ChainConfig. +func (g GenesisWithEvolve) MarshalJSON() ([]byte, error) { + type Genesis struct { + Config *ChainConfigWithEvolve `json:"config"` + Nonce math.HexOrDecimal64 `json:"nonce"` + Timestamp math.HexOrDecimal64 `json:"timestamp"` + ExtraData hexutil.Bytes `json:"extraData"` + GasLimit math.HexOrDecimal64 `json:"gasLimit" gencodec:"required"` + Difficulty *math.HexOrDecimal256 `json:"difficulty" gencodec:"required"` + Mixhash common.Hash `json:"mixHash"` + Coinbase common.Address `json:"coinbase"` + Alloc map[common.UnprefixedAddress]coretypes.Account `json:"alloc" gencodec:"required"` + Number math.HexOrDecimal64 `json:"number"` + GasUsed math.HexOrDecimal64 `json:"gasUsed"` + ParentHash common.Hash `json:"parentHash"` + BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"` + ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"` + BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"` + } + var enc Genesis + enc.Config = g.Config + enc.Nonce = math.HexOrDecimal64(g.Nonce) + enc.Timestamp = math.HexOrDecimal64(g.Timestamp) + enc.ExtraData = g.ExtraData + enc.GasLimit = math.HexOrDecimal64(g.GasLimit) + enc.Difficulty = (*math.HexOrDecimal256)(g.Difficulty) + enc.Mixhash = g.Mixhash + enc.Coinbase = g.Coinbase + if g.Alloc != nil { + enc.Alloc = make(map[common.UnprefixedAddress]coretypes.Account, len(g.Alloc)) + for k, v := range g.Alloc { + enc.Alloc[common.UnprefixedAddress(k)] = v + } + } + enc.Number = math.HexOrDecimal64(g.Number) + enc.GasUsed = math.HexOrDecimal64(g.GasUsed) + enc.ParentHash = g.ParentHash + enc.BaseFee = (*math.HexOrDecimal256)(g.BaseFee) + enc.ExcessBlobGas = (*math.HexOrDecimal64)(g.ExcessBlobGas) + enc.BlobGasUsed = (*math.HexOrDecimal64)(g.BlobGasUsed) + return json.Marshal(&enc) +}