new debug_evm config option

This commit is contained in:
The MMGen Project 2025-05-08 15:22:07 +00:00
commit 9d86fbe9de
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 17 additions and 5 deletions

View file

@ -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',

View file

@ -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

View file

@ -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. '