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

Check txMaxSize. #53

Merged
merged 3 commits into from
Sep 20, 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
11 changes: 11 additions & 0 deletions pkg/relay/ethereum/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type Chain struct {
ibcHandler *ibchandler.Ibchandler
multicall3 *multicall3.Multicall3

txMaxSize uint64

ethereumSigner EthereumSigner

errorRepository ErrorRepository
Expand All @@ -59,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 @@ -105,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 @@ -118,6 +127,8 @@ func NewChain(config ChainConfig) (*Chain, error) {

errorRepository: errorRepository,

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.

1 change: 1 addition & 0 deletions pkg/relay/ethereum/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const (
logAttrRawErrorData = "raw_error_data"
logAttrRawTxData = "raw_tx_data"
logAttrTxHash = "tx_hash"
logAttrTxSize = "tx_size"
logAttrBlockHash = "block_hash"
logAttrBlockNumber = "block_number"
logAttrTxIndex = "tx_index"
Expand Down
9 changes: 8 additions & 1 deletion pkg/relay/ethereum/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ func (c *Chain) SendMsgs(msgs []sdk.Msg) ([]core.MsgID, error) {
break
} else {
logger = iter.updateLoggerMessageInfo(logger, from, built.count)
logger = &log.RelayLogger{Logger: logger.With(logAttrTxHash, built.tx.Hash())}
logger = &log.RelayLogger{Logger: logger.With(
logAttrTxHash, built.tx.Hash(),
logAttrTxSize, built.tx.Size(),
)}
}

if rawTxData, err := built.tx.MarshalBinary(); err != nil {
Expand Down Expand Up @@ -747,6 +750,10 @@ func (iter *CallIter) buildMultiTx(ctx context.Context, c *Chain) (*CallIterBuil
return err
}

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

txGasLimit, err := estimateGas(ctx, c, multiTx, 1 == count, logger)
if err != nil {
return err
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