Skip to content

Commit

Permalink
Add signing support for migrated dynamic fee transactions take2 (#181)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
piersy authored Jul 19, 2024
1 parent ef08d99 commit b7adc8d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/types/celo_transaction_signing_forks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions core/types/celo_transaction_signing_tx_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit b7adc8d

Please sign in to comment.