diff --git a/compat_test/compat_test.go b/compat_test/compat_test.go index 2f9ec740c7..164ea96aae 100644 --- a/compat_test/compat_test.go +++ b/compat_test/compat_test.go @@ -19,6 +19,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" "github.com/stretchr/testify/require" @@ -40,7 +41,7 @@ var ( celoRpcURL string opGethRpcURL string startBlock uint64 - gingerbreadBlocks = map[uint64]uint64{42220: 21616000, 62320: 18785000, 44787: 19814000} + gingerbreadBlocks = map[uint64]uint64{params.CeloMainnetChainID: 21616000, params.CeloBaklavaChainID: 18785000, params.CeloAlfajoresChainID: 19814000} ) func init() { diff --git a/contracts/addresses/addresses.go b/contracts/addresses/addresses.go index 593e3d36e5..500054bc70 100644 --- a/contracts/addresses/addresses.go +++ b/contracts/addresses/addresses.go @@ -12,7 +12,4 @@ var ( CeloTokenBaklavaAddress = common.HexToAddress("0xdDc9bE57f553fe75752D61606B94CBD7e0264eF8") FeeHandlerBaklavaAddress = common.HexToAddress("0xeed0A69c51079114C280f7b936C79e24bD94013e") - - AlfajoresChainID uint64 = 44787 - BaklavaChainID uint64 = 62320 ) diff --git a/core/state_transition.go b/core/state_transition.go index 01040ac39d..acab219086 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -766,10 +766,10 @@ func (st *StateTransition) distributeTxFees() error { feeCurrency := st.msg.FeeCurrency feeHandlerAddress := addresses.FeeHandlerAddress - if st.evm.ChainConfig().ChainID != nil && st.evm.ChainConfig().ChainID.Uint64() == addresses.AlfajoresChainID { + if st.evm.ChainConfig().ChainID != nil && st.evm.ChainConfig().ChainID.Uint64() == params.CeloAlfajoresChainID { feeHandlerAddress = addresses.FeeHandlerAlfajoresAddress } - if st.evm.ChainConfig().ChainID != nil && st.evm.ChainConfig().ChainID.Uint64() == addresses.BaklavaChainID { + if st.evm.ChainConfig().ChainID != nil && st.evm.ChainConfig().ChainID.Uint64() == params.CeloBaklavaChainID { feeHandlerAddress = addresses.FeeHandlerBaklavaAddress } diff --git a/core/types/rollup_cost.go b/core/types/rollup_cost.go index e0bc26d92f..9df5aa2049 100644 --- a/core/types/rollup_cost.go +++ b/core/types/rollup_cost.go @@ -124,6 +124,11 @@ func NewL1CostFunc(config *params.ChainConfig, statedb StateGetter) L1CostFunc { forBlock := ^uint64(0) var cachedFunc l1CostFunc selectFunc := func(blockTime uint64) l1CostFunc { + // Alfajores requires a custom cost function see link for a detailed explanation + // https://github.com/celo-org/op-geth/pull/271 + if config.IsCel2(blockTime) && config.ChainID.Uint64() == params.CeloAlfajoresChainID { + return func(rcd RollupCostData) (fee, gasUsed *big.Int) { return new(big.Int), new(big.Int) } + } if !config.IsOptimismEcotone(blockTime) { return newL1CostFuncBedrock(config, statedb, blockTime) } diff --git a/core/vm/celo_contracts.go b/core/vm/celo_contracts.go index f1e0a0f207..a95baa728e 100644 --- a/core/vm/celo_contracts.go +++ b/core/vm/celo_contracts.go @@ -48,10 +48,10 @@ func celoPrecompileAddress(index byte) common.Address { func (ctx *celoPrecompileContext) IsCallerCeloToken() (bool, error) { tokenAddress := addresses.CeloTokenAddress - if ctx.evm.ChainConfig().ChainID != nil && ctx.evm.ChainConfig().ChainID.Uint64() == addresses.AlfajoresChainID { + if ctx.evm.ChainConfig().ChainID != nil && ctx.evm.ChainConfig().ChainID.Uint64() == params.CeloAlfajoresChainID { tokenAddress = addresses.CeloTokenAlfajoresAddress } - if ctx.evm.ChainConfig().ChainID != nil && ctx.evm.ChainConfig().ChainID.Uint64() == addresses.BaklavaChainID { + if ctx.evm.ChainConfig().ChainID != nil && ctx.evm.ChainConfig().ChainID.Uint64() == params.CeloBaklavaChainID { tokenAddress = addresses.CeloTokenBaklavaAddress } diff --git a/internal/ethapi/celo_api_test.go b/internal/ethapi/celo_api_test.go index 7cf030547e..cf93b4f573 100644 --- a/internal/ethapi/celo_api_test.go +++ b/internal/ethapi/celo_api_test.go @@ -405,7 +405,7 @@ func TestNewRPCTransactionDynamicFee(t *testing.T) { func allEnabledChainConfig() *params.ChainConfig { zeroTime := uint64(0) return ¶ms.ChainConfig{ - ChainID: big.NewInt(44787), + ChainID: big.NewInt(params.CeloAlfajoresChainID), HomesteadBlock: big.NewInt(0), EIP150Block: big.NewInt(0), EIP155Block: big.NewInt(0), diff --git a/params/config.go b/params/config.go index 876e584a31..1377b8e7b6 100644 --- a/params/config.go +++ b/params/config.go @@ -36,6 +36,8 @@ const ( OPMainnetChainID = 10 OPGoerliChainID = 420 CeloMainnetChainID = 42220 + CeloBaklavaChainID = 62320 + CeloAlfajoresChainID = 44787 BaseMainnetChainID = 8453 BaseGoerliChainID = 84531 baseSepoliaChainID = 84532