From 545bae014ab23b7e0f297f43a34fe18dc25afd11 Mon Sep 17 00:00:00 2001 From: Daisuke Kanda Date: Fri, 20 Sep 2024 05:52:29 +0000 Subject: [PATCH] Check txMaxSize. The txMaxSize is written in code, it may be configurable. Signed-off-by: Daisuke Kanda --- pkg/relay/ethereum/chain.go | 4 ++++ pkg/relay/ethereum/tx.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/pkg/relay/ethereum/chain.go b/pkg/relay/ethereum/chain.go index ae12b04..d14cc29 100644 --- a/pkg/relay/ethereum/chain.go +++ b/pkg/relay/ethereum/chain.go @@ -51,6 +51,8 @@ type Chain struct { errorRepository ErrorRepository + txMaxSize uint64 + // cache connectionOpenedConfirmed bool allowLCFunctions *AllowLCFunctions @@ -118,6 +120,8 @@ func NewChain(config ChainConfig) (*Chain, error) { errorRepository: errorRepository, + txMaxSize: 1024 * 128, // go-ethereum/core/txpool/legacypool/legacypool.go + allowLCFunctions: alfs, }, nil } diff --git a/pkg/relay/ethereum/tx.go b/pkg/relay/ethereum/tx.go index 2f3aad7..d433f95 100644 --- a/pkg/relay/ethereum/tx.go +++ b/pkg/relay/ethereum/tx.go @@ -747,6 +747,10 @@ func (iter *CallIter) buildMultiTx(ctx context.Context, c *Chain) (*CallIterBuil return err } + if c.txMaxSize < multiTx.Size() { + return fmt.Errorf("tx exceeds txMaxSize"); + } + txGasLimit, err := estimateGas(ctx, c, multiTx, 1 == count, logger) if err != nil { return err