Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small mempool fixes #1943

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions go/enclave/evm/evm_facade.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import (
gethrpc "github.com/ten-protocol/go-ten/lib/gethfork/rpc"
)

var ErrGasNotEnoughForL1 = errors.New("gas limit too low to pay for execution and l1 fees")

// ExecuteTransactions
// header - the header of the rollup where this transaction will be included
// fromTxIndex - for the receipts and events, the evm needs to know for each transaction the order in which it was executed in the block.
Expand Down Expand Up @@ -91,7 +93,12 @@ func ExecuteTransactions(
if err != nil {
tCountRollback++
result[t.Tx.Hash()] = err
logger.Info("Failed to execute tx:", log.TxKey, t.Tx.Hash(), log.CtrErrKey, err)
// only log tx execution errors if they are unexpected
logFailedTx := logger.Info
if errors.Is(err, gethcore.ErrNonceTooHigh) || errors.Is(err, gethcore.ErrNonceTooLow) || errors.Is(err, gethcore.ErrFeeCapTooLow) || errors.Is(err, ErrGasNotEnoughForL1) {
logFailedTx = logger.Debug
}
logFailedTx("Failed to execute tx:", log.TxKey, t.Tx.Hash(), log.CtrErrKey, err)
continue
}
result[t.Tx.Hash()] = r
Expand Down Expand Up @@ -160,8 +167,9 @@ func executeTransaction(

// The gas limit of the transaction (evm message) should always be higher than the gas overhead
// used to cover the l1 cost
// todo - this check has to be added to the mempool as well
if msg.GasLimit < l1Gas.Uint64() {
return nil, fmt.Errorf("gas limit set by user is too low to pay for execution and l1 fees. Want at least: %d have: %d", l1Gas, msg.GasLimit)
return nil, fmt.Errorf("%w. Want at least: %d have: %d", ErrGasNotEnoughForL1, l1Gas, msg.GasLimit)
}

// Remove the gas overhead for l1 publishing from the gas limit in order to define
Expand Down
14 changes: 9 additions & 5 deletions go/enclave/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ import (
"math/big"
"strings"
"sync"
_ "unsafe"

gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/holiman/uint256"

// unsafe package imported in order to link to a private function in go-ethereum.
// This allows us to validate transactions against the tx pool rules.
_ "unsafe"

gethlog "github.com/ethereum/go-ethereum/log"
"github.com/ten-protocol/go-ten/go/common/log"

gethcommon "github.com/ethereum/go-ethereum/common"
gethtxpool "github.com/ethereum/go-ethereum/core/txpool"
"github.com/ethereum/go-ethereum/core/txpool/legacypool"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -67,9 +69,11 @@ func (t *TxPool) Start() error {

// PendingTransactions returns all pending transactions grouped per address and ordered per nonce
func (t *TxPool) PendingTransactions() map[gethcommon.Address][]*gethtxpool.LazyTransaction {
// todo
// todo - for now using the base fee from the block
baseFee := t.Chain.CurrentBlock().BaseFee
return t.pool.Pending(gethtxpool.PendingFilter{
// BaseFee:
BaseFee: uint256.NewInt(baseFee.Uint64()),
OnlyPlainTxs: true,
})
}

Expand Down Expand Up @@ -121,5 +125,5 @@ func (t *TxPool) Close() error {
t.logger.Error("Could not close legacy pool", log.ErrKey, err)
}
}()
return t.legacyPool.Close()
return t.pool.Close()
}
Loading