From b7adc8da288c06d600c7621fe5e7230c1a510e62 Mon Sep 17 00:00:00 2001 From: piersy Date: Fri, 19 Jul 2024 14:19:17 +0100 Subject: [PATCH] Add signing support for migrated dynamic fee transactions take2 (#181) Add support for signing pre cel2 DynamicFeeTxs Op-geth adds this support in the London hardfork, but that is enabled at the cel2 block, and shouldn't be enabled earlier since it includes many features beyond just singing DynamicFeeTxs. Celo added this signing support in the Espresso hardfork. So we add signing support for DynamicFeeTxs to the celoLegacy signing meta fork (which is a stand in for all signing of celo forks before cel2). --- core/types/celo_transaction_signing_forks.go | 9 +++++++++ core/types/celo_transaction_signing_tx_funcs.go | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/core/types/celo_transaction_signing_forks.go b/core/types/celo_transaction_signing_forks.go index 5aa3c79dd3..2c20c03d9b 100644 --- a/core/types/celo_transaction_signing_forks.go +++ b/core/types/celo_transaction_signing_forks.go @@ -97,6 +97,15 @@ func (c *celoLegacy) txFuncs(tx *Transaction) *txFuncs { return celoLegacyProtectedTxFuncs } return celoLegacyUnprotectedTxFuncs + case t == DynamicFeeTxType: + // We handle the dynamic fee tx type here because we need to handle + // migrated dynamic fee txs. These were enabeled in celo in the Espresso + // hardfork, which doesn't have any analogue in op-geth. Even though + // op-geth does enable support for dynamic fee txs in the London + // hardfork (which we set to the cel2 block) that fork contains a lot of + // changes that were not part of Espresso. So instead we ned to handle + // DynamicFeeTxTypes here. + return dynamicFeeTxFuncs case t == CeloDynamicFeeTxV2Type: return celoDynamicFeeTxV2Funcs case t == CeloDynamicFeeTxType: diff --git a/core/types/celo_transaction_signing_tx_funcs.go b/core/types/celo_transaction_signing_tx_funcs.go index 9f22b43439..6f631e4fc4 100644 --- a/core/types/celo_transaction_signing_tx_funcs.go +++ b/core/types/celo_transaction_signing_tx_funcs.go @@ -61,6 +61,18 @@ var ( }, } + dynamicFeeTxFuncs = &txFuncs{ + hash: func(tx *Transaction, chainID *big.Int) common.Hash { + return NewLondonSigner(chainID).Hash(tx) + }, + signatureValues: func(tx *Transaction, sig []byte, signerChainID *big.Int) (r *big.Int, s *big.Int, v *big.Int, err error) { + return NewLondonSigner(signerChainID).SignatureValues(tx, sig) + }, + sender: func(tx *Transaction, hashFunc func(tx *Transaction, chainID *big.Int) common.Hash, signerChainID *big.Int) (common.Address, error) { + return NewLondonSigner(signerChainID).Sender(tx) + }, + } + celoDynamicFeeTxFuncs = &txFuncs{ hash: func(tx *Transaction, chainID *big.Int) common.Hash { return prefixedRlpHash(