From 8ebc9ac2debead747ab70a7e8feccf6aeea759ba Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 6 Sep 2026 10:08:41 +0000 Subject: [PATCH] proto.eth.params: new `max_data_len` attr --- mmgen/proto/eth/params.py | 1 + mmgen/proto/eth/tx/new.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mmgen/proto/eth/params.py b/mmgen/proto/eth/params.py index fafa4732..b6d104b6 100755 --- a/mmgen/proto/eth/params.py +++ b/mmgen/proto/eth/params.py @@ -40,6 +40,7 @@ class mainnet(CoinProtocol.DummyWIF, CoinProtocol.Secp256k1): address_reuse_ok = True is_vm = True is_evm = True + max_data_len = 1024 * 10 # arbitrary value (Token.bin is 3.24 kb) # https://www.chainid.dev chain_ids = { diff --git a/mmgen/proto/eth/tx/new.py b/mmgen/proto/eth/tx/new.py index 46ee7cc6..4370b6ab 100755 --- a/mmgen/proto/eth/tx/new.py +++ b/mmgen/proto/eth/tx/new.py @@ -36,7 +36,10 @@ class New(VmNew, Base, TxBase.New): m = "'--contract-data' option may not be used with token transaction" assert 'Token' not in self.name, m with open(self.cfg.contract_data) as fp: - self.usr_contract_data = bytes.fromhex(fp.read().strip()) + data = bytes.fromhex(fp.read().strip()) + assert len(data) <= self.proto.max_data_len, ( + f'{len(data)}: data length too large (>{self.proto.max_data_len})') + self.usr_contract_data = data self.disable_fee_check = True def process_data_output_arg(self, arg):