Skip to content

Commit

Permalink
Merge branch 'celo10' into piersy/smoketest
Browse files Browse the repository at this point in the history
  • Loading branch information
piersy authored Nov 25, 2024
2 parents acb90f1 + 68fc35a commit 6622671
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions contracts/addresses/addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ var (
CeloTokenAlfajoresAddress = common.HexToAddress("0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9")
FeeHandlerAlfajoresAddress = common.HexToAddress("0xEAaFf71AB67B5d0eF34ba62Ea06Ac3d3E2dAAA38")

CeloTokenBaklavaAddress = common.HexToAddress("0xdDc9bE57f553fe75752D61606B94CBD7e0264eF8")
FeeHandlerBaklavaAddress = common.HexToAddress("0xeed0A69c51079114C280f7b936C79e24bD94013e")

AlfajoresChainID uint64 = 44787
BaklavaChainID uint64 = 62320
)
3 changes: 3 additions & 0 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,9 @@ func (st *StateTransition) distributeTxFees() error {
if st.evm.ChainConfig().ChainID != nil && st.evm.ChainConfig().ChainID.Uint64() == addresses.AlfajoresChainID {
feeHandlerAddress = addresses.FeeHandlerAlfajoresAddress
}
if st.evm.ChainConfig().ChainID != nil && st.evm.ChainConfig().ChainID.Uint64() == addresses.BaklavaChainID {
feeHandlerAddress = addresses.FeeHandlerBaklavaAddress
}

log.Trace("distributeTxFees", "from", from, "refund", refund, "feeCurrency", st.msg.FeeCurrency,
"coinbaseFeeRecipient", st.evm.Context.Coinbase, "coinbaseFee", tipTxFee,
Expand Down
4 changes: 4 additions & 0 deletions core/vm/celo_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func (ctx *celoPrecompileContext) IsCallerCeloToken() (bool, error) {
if ctx.evm.ChainConfig().ChainID != nil && ctx.evm.ChainConfig().ChainID.Uint64() == addresses.AlfajoresChainID {
tokenAddress = addresses.CeloTokenAlfajoresAddress
}
if ctx.evm.ChainConfig().ChainID != nil && ctx.evm.ChainConfig().ChainID.Uint64() == addresses.BaklavaChainID {
tokenAddress = addresses.CeloTokenBaklavaAddress
}

return tokenAddress == ctx.caller, nil
}

Expand Down
10 changes: 4 additions & 6 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1610,18 +1610,16 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
} else if isGingerbread && isNativeFeeCurrency {
// Post gingerbread mined transaction with a native fee currency, we can compute the effective gas price.
result.GasPrice = (*hexutil.Big)(effectiveGasPrice(tx, baseFee))
} else if isCel2 && tx.Type() == types.CeloDynamicFeeTxV2Type {
// Mined post Cel2 celoDynamicFeeTxV2 transaction, we can get the gas price from the receipt
// Assert that we should have a receipt
if receipt == nil {
panic(fmt.Sprintf("no corresponding receipt provided for celoDynamicFeeTxV2 transaction %s", tx.Hash().Hex()))
}
} else if isCel2 && tx.Type() == types.CeloDynamicFeeTxV2Type && receipt != nil {
// Mined post Cel2 celoDynamicFeeTxV2 transaction with non native fee currency, we get the gas price from
// the receipt.
result.GasPrice = (*hexutil.Big)(receipt.EffectiveGasPrice)
} else {
// Otherwise this is either a:
// - pre-gingerbread transaction
// - post-gingerbread native fee currency transaction but no base fee was provided
// - post-gingerbread pre-cel2 transaction with a non-native fee currency
// - post cel2 transaction with a non-native fee currency in a bad block (and therefore without a receipt)
//
// In these cases we can't calculate the gas price.
result.GasPrice = nil
Expand Down

0 comments on commit 6622671

Please sign in to comment.