Skip to content
Draft
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
16 changes: 8 additions & 8 deletions core/txpool/legacypool/legacypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,15 @@ func (ao *astriaOrdered) clear() {
}

func (pool *LegacyPool) ValidateTx(tx *types.Transaction) error {
return pool.validateTxBasics(tx, false)
return pool.validateTxBasics(tx, false, false)
}

func (pool *LegacyPool) SetAstriaOrdered(txs types.Transactions) {
astriaRequestedMeter.Mark(int64(len(txs)))

valid := []*types.Transaction{}
for idx, tx := range txs {
err := pool.validateTxBasics(tx, false)
err := pool.validateTxBasics(tx, false, true)
if err != nil {
log.Warn("astria tx failed validation", "index", idx, "hash", tx.Hash(), "error", err)
continue
Expand Down Expand Up @@ -706,16 +706,16 @@ func (pool *LegacyPool) local() map[common.Address]types.Transactions {
// rules, but does not check state-dependent validation such as sufficient balance.
// This check is meant as an early check which only needs to be performed once,
// and does not require the pool mutex to be held.
func (pool *LegacyPool) validateTxBasics(tx *types.Transaction, local bool) error {
func (pool *LegacyPool) validateTxBasics(tx *types.Transaction, local bool, isAstriaOrdered bool) error {
opts := &txpool.ValidationOptions{
Config: pool.chainconfig,
Accept: 0 |
1<<types.LegacyTxType |
1<<types.AccessListTxType |
1<<types.DynamicFeeTxType |
1<<types.DepositTxType,
MaxSize: txMaxSize,
MinTip: pool.gasTip.Load().ToBig(),
1<<types.DynamicFeeTxType,
MaxSize: txMaxSize,
MinTip: pool.gasTip.Load().ToBig(),
AcceptDeposits: isAstriaOrdered,
}
if local {
opts.MinTip = new(big.Int)
Expand Down Expand Up @@ -1096,7 +1096,7 @@ func (pool *LegacyPool) Add(txs []*types.Transaction, local, sync bool) []error
// Exclude transactions with basic errors, e.g invalid signatures and
// insufficient intrinsic gas as soon as possible and cache senders
// in transactions before obtaining lock
if err := pool.validateTxBasics(tx, local); err != nil {
if err := pool.validateTxBasics(tx, local, false); err != nil {
errs[i] = err
log.Trace("Discarding invalid transaction", "hash", tx.Hash(), "err", err)
invalidTxMeter.Mark(1)
Expand Down
4 changes: 3 additions & 1 deletion core/txpool/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type ValidationOptions struct {
Accept uint8 // Bitmap of transaction types that should be accepted for the calling pool
MaxSize uint64 // Maximum size of a transaction that the caller can meaningfully handle
MinTip *big.Int // Minimum gas tip needed to allow a transaction into the caller pool

AcceptDeposits bool // Whether the pool accepts deposit transactions
}

// ValidateTransaction is a helper method to check whether a transaction is valid
Expand All @@ -59,7 +61,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
}

// Ensure transactions not implemented by the calling pool are rejected
if opts.Accept&(1<<tx.Type()) == 0 {
if opts.Accept&(1<<tx.Type()) == 0 && !(tx.Type() == types.DepositTxType && opts.AcceptDeposits == true) {
return fmt.Errorf("%w: tx type %v not supported by this pool", core.ErrTxTypeNotSupported, tx.Type())
}
// Before performing any expensive validations, sanity check that the tx is
Expand Down
17 changes: 8 additions & 9 deletions core/types/deposit_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rlp"
primitivev1 "buf.build/gen/go/astria/primitives/protocolbuffers/go/astria/primitive/v1"
)

var _ TxData = &DepositTx{}
Expand All @@ -26,8 +25,8 @@ type DepositTx struct {
// to the `mint` function calldata.
Data []byte
// the transaction ID of the source action for the deposit, consisting
// of the transaction hash.
SourceTransactionId primitivev1.TransactionId
// of the transaction hash.
SourceTransactionId string
// index of the deposit's source action within its transaction
SourceTransactionIndex uint64
}
Expand All @@ -39,12 +38,12 @@ func (tx *DepositTx) copy() TxData {
}

cpy := &DepositTx{
From: tx.From,
Value: new(big.Int),
Gas: tx.Gas,
To: to,
Data: make([]byte, len(tx.Data)),
SourceTransactionId: tx.SourceTransactionId,
From: tx.From,
Value: new(big.Int),
Gas: tx.Gas,
To: to,
Data: make([]byte, len(tx.Data)),
SourceTransactionId: tx.SourceTransactionId,
SourceTransactionIndex: tx.SourceTransactionIndex,
}

Expand Down
2 changes: 1 addition & 1 deletion core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const (
AccessListTxType = 0x01
DynamicFeeTxType = 0x02
BlobTxType = 0x03
DepositTxType = 0x04
DepositTxType = 0x5a
)

// Transaction is an Ethereum transaction.
Expand Down
4 changes: 2 additions & 2 deletions grpc/shared/rollupdata_handling.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func validateAndUnmarshalDepositTx(
Gas: 64000,
To: &bac.Erc20Asset.ContractAddress,
Data: calldata,
SourceTransactionId: *deposit.SourceTransactionId,
SourceTransactionId: deposit.SourceTransactionId.Inner,
SourceTransactionIndex: deposit.SourceActionIndex,
}

Expand All @@ -105,7 +105,7 @@ func validateAndUnmarshalDepositTx(
To: &recipient,
Value: amount,
Gas: 0,
SourceTransactionId: *deposit.SourceTransactionId,
SourceTransactionId: deposit.SourceTransactionId.Inner,
SourceTransactionIndex: deposit.SourceActionIndex,
}
return types.NewTx(&txdata), nil
Expand Down