Skip to content

Commit

Permalink
txMaxSize configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Daisuke Kanda <[email protected]>
  • Loading branch information
Daisuke Kanda committed Sep 20, 2024
1 parent 545bae0 commit bb6588a
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 61 deletions.
13 changes: 10 additions & 3 deletions pkg/relay/ethereum/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ type Chain struct {
ibcHandler *ibchandler.Ibchandler
multicall3 *multicall3.Multicall3

txMaxSize uint64

ethereumSigner EthereumSigner

errorRepository ErrorRepository

txMaxSize uint64

// cache
connectionOpenedConfirmed bool
allowLCFunctions *AllowLCFunctions
Expand All @@ -61,6 +61,8 @@ type Chain struct {
var _ core.Chain = (*Chain)(nil)

func NewChain(config ChainConfig) (*Chain, error) {
logger := GetModuleLogger()

id := big.NewInt(int64(config.EthChainId))
client, err := client.NewETHClient(
config.RpcAddr,
Expand Down Expand Up @@ -107,6 +109,11 @@ func NewChain(config ChainConfig) (*Chain, error) {
if err != nil {
return nil, fmt.Errorf("failed to create error repository: %v", err)
}
txMaxSize := config.GetTxMaxSize()
if txMaxSize == 0 {
txMaxSize = 128 * 1024 // go-ethereum/core/txpool/legacypool/legacypool.go
logger.Info(fmt.Sprintf("txMaxSize is zero. set to %v", txMaxSize));
}

return &Chain{
config: config,
Expand All @@ -120,7 +127,7 @@ func NewChain(config ChainConfig) (*Chain, error) {

errorRepository: errorRepository,

txMaxSize: 1024 * 128, // go-ethereum/core/txpool/legacypool/legacypool.go
txMaxSize: txMaxSize,

allowLCFunctions: alfs,
}, nil
Expand Down
207 changes: 150 additions & 57 deletions pkg/relay/ethereum/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/relay/ethereum/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ func (iter *CallIter) buildMultiTx(ctx context.Context, c *Chain) (*CallIterBuil
}

if c.txMaxSize < multiTx.Size() {
return fmt.Errorf("tx exceeds txMaxSize");
return fmt.Errorf("tx size exceeds txMaxSize: tx=%v, max=%v", multiTx.Size(), c.txMaxSize)
}

txGasLimit, err := estimateGas(ctx, c, multiTx, 1 == count, logger)
Expand Down
2 changes: 2 additions & 0 deletions proto/relayer/chains/ethereum/config/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ message ChainConfig {
repeated string abi_paths = 17;

string multicall3_address = 18;

optional uint64 tx_max_size = 19;
}

message AllowLCFunctionsConfig {
Expand Down

0 comments on commit bb6588a

Please sign in to comment.