Skip to content

Commit

Permalink
Added 0x7b transaction type for celo (#10660)
Browse files Browse the repository at this point in the history
* added 0x7b tx type for celo

* linting

---------

Co-authored-by: Simson <simsonraj.easvarasakthi@smartcontract.com>
  • Loading branch information
finleydecker and simsonraj authored Sep 17, 2023
1 parent 8b96864 commit 157870f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion core/chains/evm/gas/block_history_estimator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1316,13 +1316,17 @@ func TestBlockHistoryEstimator_IsUsable(t *testing.T) {
assert.Equal(t, true, bhe.IsUsable(tx, block, cfg.ChainType(), geCfg.PriceMin(), logger.TestLogger(t)))
})

t.Run("returns false if transaction is of type 0x7c only on Celo", func(t *testing.T) {
t.Run("returns false if transaction is of type 0x7c or 0x7b only on Celo", func(t *testing.T) {
cfg.ChainTypeF = "celo"
tx := evmtypes.Transaction{Type: 0x7c, GasPrice: assets.NewWeiI(10), GasLimit: 42, Hash: utils.NewHash()}
assert.Equal(t, false, bhe.IsUsable(tx, block, cfg.ChainType(), geCfg.PriceMin(), logger.TestLogger(t)))

tx2 := evmtypes.Transaction{Type: 0x7b, GasPrice: assets.NewWeiI(10), GasLimit: 42, Hash: utils.NewHash()}
assert.Equal(t, false, bhe.IsUsable(tx2, block, cfg.ChainType(), geCfg.PriceMin(), logger.TestLogger(t)))

cfg.ChainTypeF = ""
assert.Equal(t, true, bhe.IsUsable(tx, block, cfg.ChainType(), geCfg.PriceMin(), logger.TestLogger(t)))
assert.Equal(t, true, bhe.IsUsable(tx2, block, cfg.ChainType(), geCfg.PriceMin(), logger.TestLogger(t)))
})

t.Run("returns false if transaction has base fee higher than the gas price only on Celo", func(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions core/chains/evm/gas/chain_specific.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func chainSpecificIsUsable(tx evmtypes.Transaction, baseFee *assets.Wei, chainTy
}
}
if chainType == config.ChainCelo {
// Celo specific transaction type that utilizes the feeCurrency field.
if tx.Type == 0x7c {
// Celo specific transaction types that utilize the feeCurrency field.
if tx.Type == 0x7c || tx.Type == 0x7b {
return false
}
// Celo has not yet fully migrated to the 0x7c type for special feeCurrency transactions
Expand All @@ -40,7 +40,6 @@ func chainSpecificIsUsable(tx evmtypes.Transaction, baseFee *assets.Wei, chainTy
// until they fully migrate to 0x7c.
if baseFee != nil && tx.GasPrice.Cmp(baseFee) < 0 {
return false

}
}
return true
Expand Down

0 comments on commit 157870f

Please sign in to comment.