From 9d86fbe9de270566afebf9569b8b98472d0ad8fc Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Thu, 8 May 2025 15:22:07 +0000 Subject: [PATCH] new `debug_evm` config option --- mmgen/cfg.py | 2 ++ mmgen/proto/eth/contract.py | 14 ++++++++++---- mmgen/proto/eth/tx/new.py | 6 +++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/mmgen/cfg.py b/mmgen/cfg.py index 4f480dd0..f939cd61 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -184,6 +184,7 @@ class Config(Lockable): # debug debug = False debug_daemon = False + debug_evm = False debug_opts = False debug_rpc = False debug_addrlist = False @@ -341,6 +342,7 @@ class Config(Lockable): 'MMGEN_BOGUS_UNSPENT_DATA', 'MMGEN_DEBUG', 'MMGEN_DEBUG_DAEMON', + 'MMGEN_DEBUG_EVM', 'MMGEN_DEBUG_OPTS', 'MMGEN_DEBUG_RPC', 'MMGEN_DEBUG_ADDRLIST', diff --git a/mmgen/proto/eth/contract.py b/mmgen/proto/eth/contract.py index 13a9a972..3ee64c0e 100755 --- a/mmgen/proto/eth/contract.py +++ b/mmgen/proto/eth/contract.py @@ -73,13 +73,19 @@ class Contract: if from_addr: args['from'] = '0x' + from_addr - if self.cfg.debug: - msg('ETH_CALL {}: {}'.format( - method_sig, - '\n '.join(parse_abi(data)))) + if self.cfg.debug_evm: + msg('{a}:\n {b} {c}'.format( + a = method, + b = method_sig, + c = '\n '.join(parse_abi(data)))) ret = await self.rpc.call(method, args, block) + if self.cfg.debug_evm: + msg(' ==> {a}{b}'.format( + a = ret, + b = f' [{int(ret, 16)}]' if ret.startswith('0x') and len(ret) <= 66 else '')) + await erigon_sleep(self) return int(ret, 16) * self.base_unit if toUnit else ret diff --git a/mmgen/proto/eth/tx/new.py b/mmgen/proto/eth/tx/new.py index 080fac4f..219712f7 100755 --- a/mmgen/proto/eth/tx/new.py +++ b/mmgen/proto/eth/tx/new.py @@ -238,7 +238,11 @@ class TokenNew(TokenBase, New): op = self.token_op) try: - res = await t.do_call(method='eth_estimateGas', from_addr=self.inputs[0].addr, data=data) + res = await t.do_call( + f'{self.token_op}(address,uint256)', + method = 'eth_estimateGas', + from_addr = self.inputs[0].addr, + data = data) except Exception as e: ymsg( 'Unable to estimate gas limit via node. '