From ee6c97f581c4ac7d92fcf38cf47de9060239c824 Mon Sep 17 00:00:00 2001 From: nolash Date: Mon, 11 Oct 2021 21:12:59 +0200 Subject: [PATCH 01/17] Add tx wait method to test rpc --- chainlib/eth/cli.py | 1 + chainlib/eth/unittest/base.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/chainlib/eth/cli.py b/chainlib/eth/cli.py index 985f1ef..3a3c670 100644 --- a/chainlib/eth/cli.py +++ b/chainlib/eth/cli.py @@ -41,6 +41,7 @@ class Wallet(BaseWallet): super(Wallet, self).__init__(EIP155Signer, checksummer=checksummer) +# TODO: how is the keystore implemented in rpc here? class Rpc(BaseRpc): """Convenience constructor to set Ethereum defaults for chainlib cli Rpc object diff --git a/chainlib/eth/unittest/base.py b/chainlib/eth/unittest/base.py index 533c168..0ae8be0 100644 --- a/chainlib/eth/unittest/base.py +++ b/chainlib/eth/unittest/base.py @@ -23,6 +23,7 @@ from hexathon import ( add_0x, strip_0x, ) +from chainlib.eth.tx import receipt from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer from crypto_dev_signer.encoding import private_key_to_address @@ -81,6 +82,11 @@ class TestRPCConnection(RPCConnection): return jsonrpc_result(r, error_parser) + def wait(self, tx_hash_hex): + o = receipt(tx_hash_hex) + return self.do(o) + + def eth_blockNumber(self, p): block = self.backend.get_block_by_number('latest') return block['number'] From 2204c512c35055c9305cb3bf86ec282138e3dfcd Mon Sep 17 00:00:00 2001 From: nolash Date: Mon, 18 Oct 2021 13:57:42 +0200 Subject: [PATCH 02/17] Rehabilitate tests --- tests/test_address.py | 2 +- tests/test_sign.py | 23 ++++++++++++++--------- tests/test_tx.py | 9 ++++++--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/tests/test_address.py b/tests/test_address.py index 693f603..1c839ee 100644 --- a/tests/test_address.py +++ b/tests/test_address.py @@ -12,7 +12,7 @@ from tests.base import TestBase class TestChain(TestBase): def test_chain_spec(self): - checksum_address = '0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C' + checksum_address = 'Eb3907eCad74a0013c259D5874AE7f22DcBcC95C' plain_address = checksum_address.lower() self.assertEqual(checksum_address, to_checksum(checksum_address)) diff --git a/tests/test_sign.py b/tests/test_sign.py index 8175600..414fb1a 100644 --- a/tests/test_sign.py +++ b/tests/test_sign.py @@ -7,16 +7,19 @@ import logging import json # external imports -from crypto_dev_signer.eth.transaction import EIP155Transaction -from crypto_dev_signer.eth.signer.defaultsigner import ReferenceSigner -from crypto_dev_signer.keystore.dict import DictKeystore +from funga.eth.transaction import EIP155Transaction +from funga.eth.signer.defaultsigner import EIP155Signer +from funga.eth.keystore.dict import DictKeystore # local imports import chainlib from chainlib.eth.connection import EthUnixSignerConnection from chainlib.eth.sign import sign_transaction from chainlib.eth.tx import TxFactory -from chainlib.eth.address import to_checksum_address +from chainlib.eth.address import ( + to_checksum_address, + is_same_address, + ) from chainlib.jsonrpc import ( jsonrpc_response, jsonrpc_error, @@ -52,11 +55,13 @@ class Mocket(socket.socket): logg.debug('mocket received {}'.format(v)) Mocket.req_id = o['id'] params = o['params'][0] - if to_checksum_address(params.get('from')) != alice: - logg.error('from does not match alice {}'.format(params)) + from_address = to_checksum_address(params.get('from')) + if not is_same_address(alice, from_address): + logg.error('from {} does not match alice {}'.format(from_address, alice)) #params)) Mocket.error = True - if to_checksum_address(params.get('to')) != bob: - logg.error('to does not match bob {}'.format(params)) + to_address = to_checksum_address(params.get('to')) + if not is_same_address(bob, to_address): + logg.error('to {} does not match bob {}'.format(to_address, bob)) #params)) Mocket.error = True if not Mocket.error: Mocket.tx = EIP155Transaction(params, params['nonce'], params['chainId']) @@ -92,7 +97,7 @@ class TestSign(TestBase): logg.debug('alice {}'.format(alice)) logg.debug('bob {}'.format(bob)) - self.signer = ReferenceSigner(keystore) + self.signer = EIP155Signer(keystore) Mocket.signer = self.signer diff --git a/tests/test_tx.py b/tests/test_tx.py index f64ec80..bb86dc7 100644 --- a/tests/test_tx.py +++ b/tests/test_tx.py @@ -23,7 +23,10 @@ from chainlib.eth.contract import ( ABIContractEncoder, ABIContractType, ) -from chainlib.eth.address import to_checksum_address +from chainlib.eth.address import ( + to_checksum_address, + is_same_address, + ) from hexathon import ( strip_0x, add_0x, @@ -43,8 +46,8 @@ class TxTestCase(EthTesterCase): c = Gas(signer=self.signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle, chain_spec=self.chain_spec) (tx_hash_hex, o) = c.create(self.accounts[0], self.accounts[1], 1024, tx_format=TxFormat.RLP_SIGNED) tx = unpack(bytes.fromhex(strip_0x(o)), self.chain_spec) - self.assertEqual(tx['from'], self.accounts[0]) - self.assertEqual(tx['to'], self.accounts[1]) + self.assertTrue(is_same_address(tx['from'], self.accounts[0])) + self.assertTrue(is_same_address(tx['to'], self.accounts[1])) def test_tx_pack(self): From 47b7fa7eef969f271699a02a41b247d80212d97d Mon Sep 17 00:00:00 2001 From: nolash Date: Mon, 18 Oct 2021 14:23:54 +0200 Subject: [PATCH 03/17] Replace crypto_dev_signer with funga --- chainlib/eth/address.py | 2 +- chainlib/eth/cli/wallet.py | 2 +- chainlib/eth/gas.py | 2 +- chainlib/eth/pytest/fixtures_ethtester.py | 4 ++-- chainlib/eth/pytest/fixtures_signer.py | 1 - chainlib/eth/runnable/balance.py | 2 +- chainlib/eth/runnable/count.py | 4 ++-- chainlib/eth/runnable/encode.py | 4 ++-- chainlib/eth/runnable/info.py | 2 +- chainlib/eth/runnable/raw.py | 4 ++-- chainlib/eth/tx.py | 8 +++++--- chainlib/eth/unittest/base.py | 4 ++-- chainlib/eth/unittest/ethtester.py | 4 ++-- requirements.txt | 4 ++-- setup.cfg | 2 +- 15 files changed, 25 insertions(+), 24 deletions(-) diff --git a/chainlib/eth/address.py b/chainlib/eth/address.py index 151fc9e..8bcbe5a 100644 --- a/chainlib/eth/address.py +++ b/chainlib/eth/address.py @@ -4,7 +4,7 @@ from hexathon import ( strip_0x, uniform, ) -from crypto_dev_signer.encoding import ( +from funga.eth.encoding import ( is_address, is_checksum_address, to_checksum_address, diff --git a/chainlib/eth/cli/wallet.py b/chainlib/eth/cli/wallet.py index 94c3f78..a0d664e 100644 --- a/chainlib/eth/cli/wallet.py +++ b/chainlib/eth/cli/wallet.py @@ -1,5 +1,5 @@ # external imports -from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer +from funga.eth.signer import EIP155Signer from chainlib.cli import Wallet as BaseWallet # local imports diff --git a/chainlib/eth/gas.py b/chainlib/eth/gas.py index 8295c73..6b76a13 100644 --- a/chainlib/eth/gas.py +++ b/chainlib/eth/gas.py @@ -6,7 +6,7 @@ from hexathon import ( add_0x, strip_0x, ) -from crypto_dev_signer.eth.transaction import EIP155Transaction +from funga.eth.transaction import EIP155Transaction # local imports from chainlib.fee import FeeOracle diff --git a/chainlib/eth/pytest/fixtures_ethtester.py b/chainlib/eth/pytest/fixtures_ethtester.py index da593c9..53ad810 100644 --- a/chainlib/eth/pytest/fixtures_ethtester.py +++ b/chainlib/eth/pytest/fixtures_ethtester.py @@ -5,8 +5,8 @@ import logging # external imports import eth_tester import pytest -from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer -from crypto_dev_signer.keystore.dict import DictKeystore +from funga.eth.signer import EIP155Signer +from funga.eth.keystore.dict import DictKeystore # local imports from chainlib.eth.unittest.base import * diff --git a/chainlib/eth/pytest/fixtures_signer.py b/chainlib/eth/pytest/fixtures_signer.py index 484a52b..8131f09 100644 --- a/chainlib/eth/pytest/fixtures_signer.py +++ b/chainlib/eth/pytest/fixtures_signer.py @@ -3,7 +3,6 @@ # external imports import pytest -#from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer @pytest.fixture(scope='function') diff --git a/chainlib/eth/runnable/balance.py b/chainlib/eth/runnable/balance.py index bfb205f..f605b22 100644 --- a/chainlib/eth/runnable/balance.py +++ b/chainlib/eth/runnable/balance.py @@ -24,7 +24,7 @@ from chainlib.eth.gas import ( balance, ) from chainlib.chain import ChainSpec -from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer +from funga.eth.signer import EIP155Signer logging.basicConfig(level=logging.WARNING) logg = logging.getLogger() diff --git a/chainlib/eth/runnable/count.py b/chainlib/eth/runnable/count.py index 48763ec..5ae76f8 100644 --- a/chainlib/eth/runnable/count.py +++ b/chainlib/eth/runnable/count.py @@ -15,8 +15,8 @@ from chainlib.eth.connection import EthHTTPConnection from chainlib.eth.tx import count from chainlib.chain import ChainSpec from chainlib.jsonrpc import IntSequenceGenerator -from crypto_dev_signer.keystore.dict import DictKeystore -from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer +from funga.eth.keystore.dict import DictKeystore +from funga.eth.signer import ReferenceSigner as EIP155Signer from hexathon import add_0x logging.basicConfig(level=logging.WARNING) diff --git a/chainlib/eth/runnable/encode.py b/chainlib/eth/runnable/encode.py index af7680c..0efaffa 100644 --- a/chainlib/eth/runnable/encode.py +++ b/chainlib/eth/runnable/encode.py @@ -13,8 +13,8 @@ import sha3 # external imports import chainlib.eth.cli from chainlib.eth.cli.encode import CLIEncoder -from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer -from crypto_dev_signer.keystore.dict import DictKeystore +from funga.eth.signer import ReferenceSigner as EIP155Signer +from funga.eth.keystore.dict import DictKeystore from hexathon import ( add_0x, strip_0x, diff --git a/chainlib/eth/runnable/info.py b/chainlib/eth/runnable/info.py index 9ee0458..f4a4f53 100644 --- a/chainlib/eth/runnable/info.py +++ b/chainlib/eth/runnable/info.py @@ -16,7 +16,7 @@ from hexathon import ( even, ) import sha3 -from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer +from funga.eth.signer import EIP155Signer # local imports from chainlib.eth.address import AddressChecksum diff --git a/chainlib/eth/runnable/raw.py b/chainlib/eth/runnable/raw.py index 784d537..0571b71 100644 --- a/chainlib/eth/runnable/raw.py +++ b/chainlib/eth/runnable/raw.py @@ -11,8 +11,8 @@ import urllib # external imports import chainlib.eth.cli -from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer -from crypto_dev_signer.keystore.dict import DictKeystore +from funga.eth.signer import EIP155Signer +from funga.eth.keystore.dict import DictKeystore from hexathon import ( add_0x, strip_0x, diff --git a/chainlib/eth/tx.py b/chainlib/eth/tx.py index b0e0c6f..fcc04d5 100644 --- a/chainlib/eth/tx.py +++ b/chainlib/eth/tx.py @@ -13,9 +13,11 @@ from hexathon import ( ) from rlp import decode as rlp_decode from rlp import encode as rlp_encode -from crypto_dev_signer.eth.transaction import EIP155Transaction -from crypto_dev_signer.encoding import public_key_to_address -from crypto_dev_signer.eth.encoding import chain_id_to_v +from funga.eth.transaction import EIP155Transaction +from funga.eth.encoding import ( + public_key_to_address, + chain_id_to_v, + ) from potaahto.symbols import snake_and_camel from chainlib.hash import keccak256_hex_to_hex from chainlib.status import Status diff --git a/chainlib/eth/unittest/base.py b/chainlib/eth/unittest/base.py index 0ae8be0..ea2d6ce 100644 --- a/chainlib/eth/unittest/base.py +++ b/chainlib/eth/unittest/base.py @@ -25,8 +25,8 @@ from hexathon import ( ) from chainlib.eth.tx import receipt -from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer -from crypto_dev_signer.encoding import private_key_to_address +from funga.eth.signer import EIP155Signer +from funga.eth.encoding import private_key_to_address logg = logging.getLogger().getChild(__name__) diff --git a/chainlib/eth/unittest/ethtester.py b/chainlib/eth/unittest/ethtester.py index 1c54c0b..ad450cb 100644 --- a/chainlib/eth/unittest/ethtester.py +++ b/chainlib/eth/unittest/ethtester.py @@ -5,8 +5,8 @@ import logging # external imports import eth_tester -from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer -from crypto_dev_signer.keystore.dict import DictKeystore +from funga.eth.signer import EIP155Signer +from funga.eth.keystore.dict import DictKeystore from hexathon import ( strip_0x, add_0x, diff --git a/requirements.txt b/requirements.txt index 3ba976b..d9daa70 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ -crypto-dev-signer>=0.4.15rc2,<=0.4.15 +funga>=0.5.1a1,<0.6.0 pysha3==1.0.2 hexathon~=0.0.1a8 websocket-client==0.57.0 potaahto~=0.0.1a1 -chainlib==0.0.9rc1 +chainlib==0.0.10a2 confini>=0.4.1a1,<0.5.0 diff --git a/setup.cfg b/setup.cfg index 43e28c4..88ee2c3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.0.9rc5 +version = 0.0.10a1 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no From 6cadad372f76fafa4d998ad2d478a31e860ab868 Mon Sep 17 00:00:00 2001 From: nolash Date: Mon, 18 Oct 2021 14:27:40 +0200 Subject: [PATCH 04/17] Upgrade deps --- requirements.txt | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index d9daa70..99d76b5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,5 @@ pysha3==1.0.2 hexathon~=0.0.1a8 websocket-client==0.57.0 potaahto~=0.0.1a1 -chainlib==0.0.10a2 +chainlib==0.0.10a3 confini>=0.4.1a1,<0.5.0 diff --git a/setup.cfg b/setup.cfg index 88ee2c3..bad7c05 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.0.10a1 +version = 0.0.10a2 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no From 8c23535ffeebdb9bab72d3647baa28998331af56 Mon Sep 17 00:00:00 2001 From: nolash Date: Tue, 19 Oct 2021 19:40:31 +0200 Subject: [PATCH 05/17] Add wait for hashes script --- chainlib/eth/cli/wallet.py | 3 +- chainlib/eth/runnable/wait.py | 114 ++++++++++++++++++++++++++++++++++ requirements.txt | 4 +- setup.cfg | 3 +- 4 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 chainlib/eth/runnable/wait.py diff --git a/chainlib/eth/cli/wallet.py b/chainlib/eth/cli/wallet.py index a0d664e..1f0cc6a 100644 --- a/chainlib/eth/cli/wallet.py +++ b/chainlib/eth/cli/wallet.py @@ -1,5 +1,6 @@ # external imports from funga.eth.signer import EIP155Signer +from funga.eth.keystore.dict import DictKeystore from chainlib.cli import Wallet as BaseWallet # local imports @@ -13,7 +14,7 @@ class Wallet(BaseWallet): :type checksummer: Implementation of chainlib.eth.address.AddressChecksum """ def __init__(self, checksummer=AddressChecksum): - super(Wallet, self).__init__(EIP155Signer, checksummer=checksummer) + super(Wallet, self).__init__(EIP155Signer, checksummer=checksummer, keystore=DictKeystore()) diff --git a/chainlib/eth/runnable/wait.py b/chainlib/eth/runnable/wait.py new file mode 100644 index 0000000..0806239 --- /dev/null +++ b/chainlib/eth/runnable/wait.py @@ -0,0 +1,114 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# standard imports +import io +import sys +import os +import json +import argparse +import logging +import urllib + +# external imports +import chainlib.eth.cli +from funga.eth.signer import EIP155Signer +from funga.eth.keystore.dict import DictKeystore +from hexathon import ( + add_0x, + strip_0x, + uniform as hex_uniform, + ) + +# local imports +from chainlib.eth.address import to_checksum +from chainlib.eth.connection import EthHTTPConnection +from chainlib.jsonrpc import ( + JSONRPCRequest, + IntSequenceGenerator, + ) +from chainlib.eth.nonce import ( + RPCNonceOracle, + OverrideNonceOracle, + ) +from chainlib.eth.gas import ( + RPCGasOracle, + OverrideGasOracle, + ) +from chainlib.eth.tx import ( + TxFactory, + raw, + ) +from chainlib.eth.error import RevertEthException +from chainlib.chain import ChainSpec +from chainlib.eth.runnable.util import decode_for_puny_humans +from chainlib.eth.jsonrpc import to_blockheight_param + +logging.basicConfig(level=logging.WARNING) +logg = logging.getLogger() + +script_dir = os.path.dirname(os.path.realpath(__file__)) +config_dir = os.path.join(script_dir, '..', 'data', 'config') + +arg_flags = chainlib.eth.cli.argflag_std_read +argparser = chainlib.eth.cli.ArgumentParser(arg_flags) +argparser.add_argument('--ignore', type=str, action='append', default=[], help='Ignore error from the given transaction') +argparser.add_argument('--ignore-all', action='store_true', dest='ignore_all', help='Ignore errors from all transactions') +argparser.add_positional('hashes', append=True, type=str, help='Transaction hashes to wait for') +args = argparser.parse_args() +extra_args = { + 'ignore': None, + 'ignore_all': None, + 'hashes': None, + } +config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_config_dir=config_dir) + +rpc = chainlib.eth.cli.Rpc() +conn = rpc.connect_by_config(config) + +chain_spec = None +try: + chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC')) +except AttributeError: + pass + + +def main(): + + hashes_ready = [] + hashes_ignore = [] + + for hsh in config.get('_IGNORE'): + hashes_ignore.append(add_0x(hex_uniform(strip_0x(hsh)))) + + if len(config.get('_HASHES')) == 1: + try: + hsh = add_0x(hex_uniform(strip_0x(config.get('_HASHES')[0]))) + hashes_ready = [hsh] + except ValueError: + logg.debug('hash argument not a hash, will try it as a file name') + f = open(config.get('_HASHES')[0]) + for hsh in f: + logg.debug('hshs {}'.format(hsh)) + hashes_ready.append(add_0x(hex_uniform(strip_0x(hsh.rstrip())))) + f.close() + else: + for hsh in config.get('_HASHES'): + logg.debug('hsh {}'.format(hsh)) + hashes_ready.append(add_0x(hex_uniform(strip_0x(hsh)))) + + for hsh in hashes_ready: + logg.debug('processing transaction hash {}'.format(hsh)) + try: + r = conn.wait(hsh) + except RevertEthException: + if config.get('_IGNORE_ALL') or hsh in hashes_ignore: + logg.info('ignoring revert in transaction hash {}'.format(hsh)) + continue + sys.stderr.write('revert in transaction hash {}\n'.format(hsh)) + sys.exit(1) + + +if __name__ == '__main__': + main() + + diff --git a/requirements.txt b/requirements.txt index 99d76b5..0032fea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ -funga>=0.5.1a1,<0.6.0 +funga-eth>=0.5.1a1,<0.6.0 pysha3==1.0.2 hexathon~=0.0.1a8 websocket-client==0.57.0 potaahto~=0.0.1a1 -chainlib==0.0.10a3 +chainlib==0.0.10a5 confini>=0.4.1a1,<0.5.0 diff --git a/setup.cfg b/setup.cfg index bad7c05..ba88de7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.0.10a2 +version = 0.0.10a7 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no @@ -45,4 +45,5 @@ console_scripts = eth-encode = chainlib.eth.runnable.encode:main eth-info = chainlib.eth.runnable.info:main eth-nonce = chainlib.eth.runnable.count:main + eth-wait = chainlib.eth.runnable.wait:main eth = chainlib.eth.runnable.info:main From b51e5dc408ac168008a7c91aeb4216ea51f178d1 Mon Sep 17 00:00:00 2001 From: nolash Date: Thu, 21 Oct 2021 07:28:00 +0200 Subject: [PATCH 06/17] Bump chainlib --- chainlib/eth/runnable/count.py | 4 ++-- requirements.txt | 2 +- setup.cfg | 3 ++- test_requirements.txt | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/chainlib/eth/runnable/count.py b/chainlib/eth/runnable/count.py index 5ae76f8..c7c6f27 100644 --- a/chainlib/eth/runnable/count.py +++ b/chainlib/eth/runnable/count.py @@ -16,7 +16,7 @@ from chainlib.eth.tx import count from chainlib.chain import ChainSpec from chainlib.jsonrpc import IntSequenceGenerator from funga.eth.keystore.dict import DictKeystore -from funga.eth.signer import ReferenceSigner as EIP155Signer +from funga.eth.signer import EIP155Signer from hexathon import add_0x logging.basicConfig(level=logging.WARNING) @@ -43,7 +43,7 @@ conn = rpc.connect_by_config(config) def main(): # TODO: should tolerate if address not prefixed with 0x - o = count(holder_address, id_generator=rpc.id_generator) + o = count(add_0x(holder_address), id_generator=rpc.id_generator) r = conn.do(o) count_result = None try: diff --git a/requirements.txt b/requirements.txt index 0032fea..26af1bc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,5 @@ pysha3==1.0.2 hexathon~=0.0.1a8 websocket-client==0.57.0 potaahto~=0.0.1a1 -chainlib==0.0.10a5 +chainlib==0.0.10a6 confini>=0.4.1a1,<0.5.0 diff --git a/setup.cfg b/setup.cfg index ba88de7..a41be34 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.0.10a7 +version = 0.0.10a11 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no @@ -36,6 +36,7 @@ packages = [options.entry_points] console_scripts = + eth-count = chainlib.eth.runnable.count:main eth-balance = chainlib.eth.runnable.balance:main eth-checksum = chainlib.eth.runnable.checksum:main eth-gas = chainlib.eth.runnable.gas:main diff --git a/test_requirements.txt b/test_requirements.txt index 62ab455..0783771 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -2,3 +2,4 @@ eth_tester==0.5.0b3 py-evm==0.3.0a20 rlp==2.0.1 pytest==6.0.1 +coverage==5.5 From 31e75f60dee5a03ee7488f7829f7d4c42755c9c4 Mon Sep 17 00:00:00 2001 From: nolash Date: Mon, 25 Oct 2021 09:57:31 +0200 Subject: [PATCH 07/17] Fix missing conflict resolution in eth-encode, non-0x address fallthrough in eth-info --- chainlib/eth/cli/encode.py | 14 ++++++++++++++ chainlib/eth/runnable/encode.py | 5 +---- chainlib/eth/runnable/info.py | 6 +++++- setup.cfg | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/chainlib/eth/cli/encode.py b/chainlib/eth/cli/encode.py index 7dbb14e..4343090 100644 --- a/chainlib/eth/cli/encode.py +++ b/chainlib/eth/cli/encode.py @@ -16,10 +16,12 @@ class CLIEncoder(ABIContractEncoder): __re_uint = r'^([uU])[int]*([0-9]+)?$' __re_bytes = r'^([bB])[ytes]*([0-9]+)?$' __re_string = r'^([sS])[tring]*$' + __re_address = r'^([aA])[ddress]*?$' __translations = [ 'to_uint', 'to_bytes', 'to_string', + 'to_address', ] def __init__(self, signature=None): @@ -58,6 +60,18 @@ class CLIEncoder(ABIContractEncoder): return (s, a) + def to_address(self, typ): + s = None + a = None + m = re.match(self.__re_address, typ) + if m == None: + return None + + s = 'ADDRESS' + a = getattr(ABIContractType, s) + return (s, a) + + def to_string(self, typ): m = re.match(self.__re_string, typ) if m == None: diff --git a/chainlib/eth/runnable/encode.py b/chainlib/eth/runnable/encode.py index 0efaffa..071d3b3 100644 --- a/chainlib/eth/runnable/encode.py +++ b/chainlib/eth/runnable/encode.py @@ -13,7 +13,7 @@ import sha3 # external imports import chainlib.eth.cli from chainlib.eth.cli.encode import CLIEncoder -from funga.eth.signer import ReferenceSigner as EIP155Signer +from funga.eth.signer import EIP155Signer from funga.eth.keystore.dict import DictKeystore from hexathon import ( add_0x, @@ -45,10 +45,7 @@ from chainlib.error import SignerMissingException from chainlib.chain import ChainSpec from chainlib.eth.runnable.util import decode_for_puny_humans from chainlib.eth.jsonrpc import to_blockheight_param -<<<<<<< HEAD from chainlib.eth.address import to_checksum_address -======= ->>>>>>> d6b258f2140f5ce555f765a90c14a65a5f3fc6de logging.basicConfig(level=logging.WARNING) logg = logging.getLogger() diff --git a/chainlib/eth/runnable/info.py b/chainlib/eth/runnable/info.py index f4a4f53..156b90f 100644 --- a/chainlib/eth/runnable/info.py +++ b/chainlib/eth/runnable/info.py @@ -51,7 +51,11 @@ args = argparser.parse_args() config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args={'long': None}, default_config_dir=config_dir) -holder_address = args.address +holder_address = None +try: + holder_address = add_0x(args.address) +except ValueError: + pass wallet = chainlib.eth.cli.Wallet() wallet.from_config(config) if wallet.get_signer_address() == None and holder_address != None: diff --git a/setup.cfg b/setup.cfg index a41be34..39813b9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.0.10a11 +version = 0.0.10a13 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no From 6ee3ea4638aa9e03fa9009cee4d28a7b0ee8e5be Mon Sep 17 00:00:00 2001 From: nolash Date: Mon, 25 Oct 2021 11:24:55 +0200 Subject: [PATCH 08/17] Handle null-value block hashes on receipts --- chainlib/eth/block.py | 14 +++++++ chainlib/eth/connection.py | 16 ++++--- chainlib/eth/runnable/info.py | 78 +++++++++++++++++++++++++---------- setup.cfg | 2 +- 4 files changed, 82 insertions(+), 28 deletions(-) diff --git a/chainlib/eth/block.py b/chainlib/eth/block.py index 7114f08..4829fad 100644 --- a/chainlib/eth/block.py +++ b/chainlib/eth/block.py @@ -60,6 +60,20 @@ def transaction_count(block_hash, id_generator=None): return j.finalize(o) +def syncing(id_generator=None): + """Request the syncing state of the node + + :param id_generator: JSONRPC id generator + :type id_generator: JSONRPCIdGenerator + :rtype: dict + :returns: rpc query object + """ + j = JSONRPCRequest(id_generator) + o = j.template() + o['method'] = 'eth_syncing' + return j.finalize(o) + + class Block(BaseBlock): """Encapsulates an Ethereum block diff --git a/chainlib/eth/connection.py b/chainlib/eth/connection.py index f0e198a..9ae6582 100644 --- a/chainlib/eth/connection.py +++ b/chainlib/eth/connection.py @@ -36,6 +36,7 @@ from chainlib.jsonrpc import ( from chainlib.eth.tx import ( unpack, ) +from potaahto.symbols import snake_and_camel logg = logging.getLogger(__name__) @@ -88,11 +89,16 @@ class EthHTTPConnection(JSONRPCHTTPConnection): e = jsonrpc_result(r, error_parser) if e != None: - logg.debug('({}) poll receipt completed {}'.format(str(self), r)) - logg.debug('e {}'.format(strip_0x(e['status']))) - if strip_0x(e['status']) == '00': - raise RevertEthException(tx_hash_hex) - return e + e = snake_and_camel(e) + # In openethereum we encounter receipts that have NONE block hashes and numbers. WTF... + if e['block_hash'] == None: + logg.warning('poll receipt attempt {} returned receipt but with a null block hash value!'.format(i)) + else: + logg.debug('({}) poll receipt completed {}'.format(str(self), r)) + logg.debug('e {}'.format(strip_0x(e['status']))) + if strip_0x(e['status']) == '00': + raise RevertEthException(tx_hash_hex) + return e if timeout > 0.0: delta = (datetime.datetime.utcnow() - t) + datetime.timedelta(seconds=delay) diff --git a/chainlib/eth/runnable/info.py b/chainlib/eth/runnable/info.py index 156b90f..6f700ba 100644 --- a/chainlib/eth/runnable/info.py +++ b/chainlib/eth/runnable/info.py @@ -24,6 +24,7 @@ from chainlib.eth.chain import network_id from chainlib.eth.block import ( block_latest, block_by_number, + syncing, Block, ) from chainlib.eth.tx import count @@ -43,25 +44,35 @@ logg = logging.getLogger() script_dir = os.path.dirname(os.path.realpath(__file__)) config_dir = os.path.join(script_dir, '..', 'data', 'config') +results_translation = { + 'network_id': 'Network Id', + 'block': 'Block', + 'syncing': 'Syncing', + 'gas_limit': 'Gas Limit', + 'gas_price': 'Gas Price', + 'block_time': 'Block time', + } + + arg_flags = chainlib.eth.cli.argflag_std_read argparser = chainlib.eth.cli.ArgumentParser(arg_flags) -argparser.add_positional('address', type=str, help='Address to retrieve info for', required=False) argparser.add_argument('--long', action='store_true', help='Calculate averages through sampling of blocks and txs') +argparser.add_argument('--local', action='store_true', help='Include local info') +argparser.add_positional('entry', required=False, help='Output single item') args = argparser.parse_args() -config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args={'long': None}, default_config_dir=config_dir) +extra_args = { + 'local': None, + 'long': None, + 'entry': None, + } +config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_config_dir=config_dir) -holder_address = None -try: - holder_address = add_0x(args.address) -except ValueError: - pass -wallet = chainlib.eth.cli.Wallet() -wallet.from_config(config) -if wallet.get_signer_address() == None and holder_address != None: - wallet.from_address(holder_address) +if config.get('_ENTRY') != None: + if config.get('_ENTRY') not in results_translation.keys(): + raise ValueError('Unknown entry {}'.format(config.get('_ENTRY'))) -rpc = chainlib.eth.cli.Rpc(wallet=wallet) +rpc = chainlib.eth.cli.Rpc() conn = rpc.connect_by_config(config) token_symbol = 'eth' @@ -72,12 +83,25 @@ human = not config.true('_RAW') longmode = config.true('_LONG') +def set_result(results, k, v, w=sys.stdout): + kt = results_translation[k] + if str(config.get('_ENTRY')) == k: + w.write('{}'.format(v)) + return True + logg.info('{}: {}\n'.format(kt, v)) + results[k] = v + return False + + def main(): + results = {} + o = network_id(id_generator=rpc.id_generator) r = conn.do(o) #if human: # n = format(n, ',') - sys.stdout.write('Network id: {}\n'.format(r)) + if set_result(results, 'network_id', r): + return o = block_latest(id_generator=rpc.id_generator) r = conn.do(o) @@ -85,7 +109,8 @@ def main(): first_block_number = n if human: n = format(n, ',') - sys.stdout.write('Block: {}\n'.format(n)) + if set_result(results, 'block', n): + return o = block_by_number(first_block_number, False, id_generator=rpc.id_generator) r = conn.do(o) @@ -111,22 +136,31 @@ def main(): if human: n = format(n, ',') - sys.stdout.write('Gaslimit: {}\n'.format(n)) - sys.stdout.write('Blocktime: {}\n'.format(aggr_time / BLOCK_SAMPLES)) + if set_result(results, 'gas_limit', n): + return + if set_result(results, 'block_time', aggr_time / BLOCK_SAMPLES): + return o = price(id_generator=rpc.id_generator) r = conn.do(o) n = int(r, 16) if human: n = format(n, ',') - sys.stdout.write('Gasprice: {}\n'.format(n)) + if set_result(results, 'gas_price', n): + return - if holder_address != None: - o = count(holder_address) + if config.get('_LOCAL'): + o = syncing() r = conn.do(o) - n = int(r, 16) - sys.stdout.write('Address: {}\n'.format(holder_address)) - sys.stdout.write('Nonce: {}\n'.format(n)) + if set_result(results, 'syncing', r): + return + + if config.get('_ENTRY') != None: + raise RuntimeError('entry {} ({}) not processed, please review the flag settings'.format(config.get('_ENTRY'), results_translation[config.get('_ENTRY')])) + + for k in results.keys(): + kt = results_translation[k] + sys.stdout.write('{}: {}\n'.format(kt, results[k])) if __name__ == '__main__': diff --git a/setup.cfg b/setup.cfg index 39813b9..f55778c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.0.10a13 +version = 0.0.10a15 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no From 5f9634d5a448dd6c27e4d0607ee451d3557748e2 Mon Sep 17 00:00:00 2001 From: nolash Date: Thu, 28 Oct 2021 12:17:32 +0200 Subject: [PATCH 09/17] Upgrade chainlib --- chainlib/eth/connection.py | 2 +- chainlib/eth/data/config/config.ini | 3 +-- chainlib/eth/runnable/gas.py | 8 ++++++-- requirements.txt | 4 ++-- setup.cfg | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/chainlib/eth/connection.py b/chainlib/eth/connection.py index 9ae6582..a20c775 100644 --- a/chainlib/eth/connection.py +++ b/chainlib/eth/connection.py @@ -91,10 +91,10 @@ class EthHTTPConnection(JSONRPCHTTPConnection): if e != None: e = snake_and_camel(e) # In openethereum we encounter receipts that have NONE block hashes and numbers. WTF... + logg.debug('({}) poll receipt received {}'.format(str(self), r)) if e['block_hash'] == None: logg.warning('poll receipt attempt {} returned receipt but with a null block hash value!'.format(i)) else: - logg.debug('({}) poll receipt completed {}'.format(str(self), r)) logg.debug('e {}'.format(strip_0x(e['status']))) if strip_0x(e['status']) == '00': raise RevertEthException(tx_hash_hex) diff --git a/chainlib/eth/data/config/config.ini b/chainlib/eth/data/config/config.ini index 10d94e5..c405cc0 100644 --- a/chainlib/eth/data/config/config.ini +++ b/chainlib/eth/data/config/config.ini @@ -1,5 +1,4 @@ [rpc] -http_provider = http://localhost:8545 provider = http://localhost:8545 auth = credentials = @@ -7,7 +6,7 @@ dialect = default scheme = http [chain] -spec = evm:ethereum:1 +spec = evm:berlin:1:ethereum [wallet] key_file = diff --git a/chainlib/eth/runnable/gas.py b/chainlib/eth/runnable/gas.py index 8cfd57c..b3f4a6e 100644 --- a/chainlib/eth/runnable/gas.py +++ b/chainlib/eth/runnable/gas.py @@ -63,8 +63,12 @@ send = config.true('_RPC_SEND') def balance(address, id_generator): o = gas_balance(address, id_generator=id_generator) r = conn.do(o) - hx = strip_0x(r) - return int(hx, 16) + try: + balance = int(r) + except ValueError: + balance = strip_0x(r) + balance = int(balance, 16) + return balance def main(): diff --git a/requirements.txt b/requirements.txt index 26af1bc..94431e6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,5 @@ pysha3==1.0.2 hexathon~=0.0.1a8 websocket-client==0.57.0 potaahto~=0.0.1a1 -chainlib==0.0.10a6 -confini>=0.4.1a1,<0.5.0 +chainlib==0.0.10a9 +confini>=0.4.2rc3,<0.5.0 diff --git a/setup.cfg b/setup.cfg index f55778c..6540182 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.0.10a15 +version = 0.0.10a18 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no From 53cea0817e854372b789899707776da8a60ef497 Mon Sep 17 00:00:00 2001 From: nolash Date: Sat, 30 Oct 2021 16:49:36 +0200 Subject: [PATCH 10/17] Fix remaining 0x problems --- chainlib/eth/gas.py | 2 +- chainlib/eth/nonce.py | 2 +- chainlib/eth/runnable/gas.py | 5 ++++- chainlib/eth/runnable/get.py | 2 ++ requirements.txt | 2 +- setup.cfg | 2 +- 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/chainlib/eth/gas.py b/chainlib/eth/gas.py index 6b76a13..a793e58 100644 --- a/chainlib/eth/gas.py +++ b/chainlib/eth/gas.py @@ -55,7 +55,7 @@ def balance(address, id_generator=None, height=BlockSpec.LATEST): j = JSONRPCRequest(id_generator) o = j.template() o['method'] = 'eth_getBalance' - o['params'].append(address) + o['params'].append(add_0x(address)) height = to_blockheight_param(height) o['params'].append(height) return j.finalize(o) diff --git a/chainlib/eth/nonce.py b/chainlib/eth/nonce.py index f425318..de00c95 100644 --- a/chainlib/eth/nonce.py +++ b/chainlib/eth/nonce.py @@ -44,7 +44,7 @@ class NonceOracle(BaseNonceOracle): """ def __init__(self, address, id_generator=None): self.id_generator = id_generator - super(NonceOracle, self).__init__(address) + super(NonceOracle, self).__init__(add_0x(address)) def get_nonce(self): diff --git a/chainlib/eth/runnable/gas.py b/chainlib/eth/runnable/gas.py index b3f4a6e..5a48929 100644 --- a/chainlib/eth/runnable/gas.py +++ b/chainlib/eth/runnable/gas.py @@ -26,7 +26,10 @@ from chainlib.eth.gas import Gas from chainlib.eth.gas import balance as gas_balance from chainlib.chain import ChainSpec from chainlib.eth.runnable.util import decode_for_puny_humans -from chainlib.eth.address import is_same_address +from chainlib.eth.address import ( + is_same_address, + is_checksum_address, + ) import chainlib.eth.cli logging.basicConfig(level=logging.WARNING) diff --git a/chainlib/eth/runnable/get.py b/chainlib/eth/runnable/get.py index 754e01e..dea7d1b 100644 --- a/chainlib/eth/runnable/get.py +++ b/chainlib/eth/runnable/get.py @@ -63,6 +63,7 @@ item = add_0x(args.item) def get_transaction(conn, tx_hash, id_generator): + tx_hash = add_0x(tx_hash) j = JSONRPCRequest(id_generator=id_generator) o = j.template() o['method'] = 'eth_getTransactionByHash' @@ -104,6 +105,7 @@ def get_transaction(conn, tx_hash, id_generator): def get_address(conn, address, id_generator, height): + address = add_0x(address) j = JSONRPCRequest(id_generator=id_generator) o = j.template() o['method'] = 'eth_getCode' diff --git a/requirements.txt b/requirements.txt index 94431e6..d152033 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,5 @@ pysha3==1.0.2 hexathon~=0.0.1a8 websocket-client==0.57.0 potaahto~=0.0.1a1 -chainlib==0.0.10a9 +chainlib==0.0.10a10 confini>=0.4.2rc3,<0.5.0 diff --git a/setup.cfg b/setup.cfg index 6540182..08a04d9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.0.10a18 +version = 0.0.10a20 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no From 80e5339886e626240491d67e4a190a0f06c879d0 Mon Sep 17 00:00:00 2001 From: nolash Date: Thu, 4 Nov 2021 12:20:42 +0100 Subject: [PATCH 11/17] Fix wrong symbol for rpc call in eth-encode --- chainlib/eth/runnable/encode.py | 2 +- setup.cfg | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/chainlib/eth/runnable/encode.py b/chainlib/eth/runnable/encode.py index 071d3b3..a4f4dbd 100644 --- a/chainlib/eth/runnable/encode.py +++ b/chainlib/eth/runnable/encode.py @@ -144,7 +144,7 @@ def main(): tx_format = TxFormat.RLP_SIGNED (tx_hash_hex, o) = c.finalize(tx, tx_format=tx_format) if send: - r = conn.do(r) + r = conn.do(o) print(r) else: if config.get('_RAW'): diff --git a/setup.cfg b/setup.cfg index 08a04d9..ef5e57b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.0.10a20 +version = 0.0.10a21 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no @@ -14,6 +14,7 @@ classifiers = Programming Language :: Python :: 3 Operating System :: OS Independent Development Status :: 3 - Alpha + Topic :: Software Development :: Libraries Environment :: Console Intended Audience :: Developers License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) From d3c73c7e5b659acab58fd6bf1c9e89ed8c33b8b6 Mon Sep 17 00:00:00 2001 From: nolash Date: Wed, 10 Nov 2021 09:59:28 +0100 Subject: [PATCH 12/17] Upgrade deps. commit patch version --- requirements.txt | 10 +++++----- setup.cfg | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index d152033..ad3127e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ -funga-eth>=0.5.1a1,<0.6.0 +funga-eth~=0.5.1 pysha3==1.0.2 -hexathon~=0.0.1a8 +hexathon~=0.1.0 websocket-client==0.57.0 -potaahto~=0.0.1a1 -chainlib==0.0.10a10 -confini>=0.4.2rc3,<0.5.0 +potaahto~=0.1.0 +chainlib==0.0.11 +confini~=0.5.1 diff --git a/setup.cfg b/setup.cfg index ef5e57b..d6680e1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.0.10a21 +version = 0.0.11 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no From 6474a2399aab94b8eed25483f309e89ddc4ec551 Mon Sep 17 00:00:00 2001 From: nolash Date: Mon, 15 Nov 2021 14:29:20 +0100 Subject: [PATCH 13/17] Enable call when wallet set for encode cli command --- chainlib/eth/runnable/encode.py | 4 +++- requirements.txt | 2 +- setup.cfg | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/chainlib/eth/runnable/encode.py b/chainlib/eth/runnable/encode.py index a4f4dbd..f69bea1 100644 --- a/chainlib/eth/runnable/encode.py +++ b/chainlib/eth/runnable/encode.py @@ -55,12 +55,14 @@ config_dir = os.path.join(script_dir, '..', 'data', 'config') arg_flags = chainlib.eth.cli.argflag_std_write | chainlib.eth.cli.Flag.EXEC argparser = chainlib.eth.cli.ArgumentParser(arg_flags) +argparser.add_argument('--notx', type=str, help='Network send is not a transaction') argparser.add_argument('--signature', type=str, help='Method signature to encode') argparser.add_argument('contract_args', type=str, nargs='*', help='arguments to encode') args = argparser.parse_args() extra_args = { 'signature': None, 'contract_args': None, + 'notx': None, } config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_config_dir=config_dir) @@ -109,7 +111,7 @@ def main(): exec_address = add_0x(to_checksum_address(config.get('_EXEC_ADDRESS'))) - if signer == None: + if signer == None or config.true('_NOTX'): c = TxFactory(chain_spec) j = JSONRPCRequest(id_generator=rpc.id_generator) o = j.template() diff --git a/requirements.txt b/requirements.txt index ad3127e..8c3da97 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,5 @@ pysha3==1.0.2 hexathon~=0.1.0 websocket-client==0.57.0 potaahto~=0.1.0 -chainlib==0.0.11 +chainlib~=0.0.12 confini~=0.5.1 diff --git a/setup.cfg b/setup.cfg index d6680e1..32be722 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.0.11 +version = 0.0.13a1 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no From bfbb1dea26c3c68d042436b0852c96ae90e123a3 Mon Sep 17 00:00:00 2001 From: nolash Date: Mon, 6 Dec 2021 19:00:55 +0100 Subject: [PATCH 14/17] Add raw args option --- chainlib/eth/runnable/encode.py | 2 +- chainlib/eth/tx.py | 2 ++ requirements.txt | 2 +- setup.cfg | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/chainlib/eth/runnable/encode.py b/chainlib/eth/runnable/encode.py index f69bea1..33fc11d 100644 --- a/chainlib/eth/runnable/encode.py +++ b/chainlib/eth/runnable/encode.py @@ -55,7 +55,7 @@ config_dir = os.path.join(script_dir, '..', 'data', 'config') arg_flags = chainlib.eth.cli.argflag_std_write | chainlib.eth.cli.Flag.EXEC argparser = chainlib.eth.cli.ArgumentParser(arg_flags) -argparser.add_argument('--notx', type=str, help='Network send is not a transaction') +argparser.add_argument('--notx', action='store_true', help='Network send is not a transaction') argparser.add_argument('--signature', type=str, help='Method signature to encode') argparser.add_argument('contract_args', type=str, nargs='*', help='arguments to encode') args = argparser.parse_args() diff --git a/chainlib/eth/tx.py b/chainlib/eth/tx.py index fcc04d5..bf3d4de 100644 --- a/chainlib/eth/tx.py +++ b/chainlib/eth/tx.py @@ -420,6 +420,8 @@ class TxFactory: return self.build(tx, id_generator=id_generator) elif tx_format == TxFormat.RLP_SIGNED: return self.build_raw(tx) + elif tx_format == TxFormat.RAW_ARGS: + return strip_0x(tx['data']) raise NotImplementedError('tx formatting {} not implemented'.format(tx_format)) diff --git a/requirements.txt b/requirements.txt index 8c3da97..8d34a5e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,5 @@ pysha3==1.0.2 hexathon~=0.1.0 websocket-client==0.57.0 potaahto~=0.1.0 -chainlib~=0.0.12 +chainlib~=0.0.13 confini~=0.5.1 diff --git a/setup.cfg b/setup.cfg index 32be722..d208611 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.0.13a1 +version = 0.0.13 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no From 2ef596df8620fc21ca512905f520382f88929a91 Mon Sep 17 00:00:00 2001 From: nolash Date: Mon, 6 Dec 2021 19:03:08 +0100 Subject: [PATCH 15/17] Upgrade chainlib and self --- requirements.txt | 4 ++-- setup.cfg | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8d34a5e..5132627 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,5 @@ pysha3==1.0.2 hexathon~=0.1.0 websocket-client==0.57.0 potaahto~=0.1.0 -chainlib~=0.0.13 -confini~=0.5.1 +chainlib~=0.0.14 +confini~=0.5.2 diff --git a/setup.cfg b/setup.cfg index d208611..19751ef 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.0.13 +version = 0.0.14 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no From 6bc0caaad7442da80742cfcb329cfc6b906fb214 Mon Sep 17 00:00:00 2001 From: nolash Date: Fri, 10 Dec 2021 02:35:38 +0100 Subject: [PATCH 16/17] Correct inverted addess checksum check for gas cli --- CHANGELOG | 4 +++- chainlib/eth/runnable/gas.py | 2 +- setup.cfg | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0aaeda4..fceabd2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ -- 0.0.5-pending +- 0.0.15: + * Correct inverted addess checksum check for gas cli +- 0.0.5-unreleased: * Receive all ethereum components from chainlib package * Make settings configurable diff --git a/chainlib/eth/runnable/gas.py b/chainlib/eth/runnable/gas.py index 5a48929..8540590 100644 --- a/chainlib/eth/runnable/gas.py +++ b/chainlib/eth/runnable/gas.py @@ -81,7 +81,7 @@ def main(): g = Gas(chain_spec, signer=signer, gas_oracle=rpc.get_gas_oracle(), nonce_oracle=rpc.get_nonce_oracle()) recipient = to_checksum_address(config.get('_RECIPIENT')) - if not config.true('_UNSAFE') and is_checksum_address(recipient): + if not config.true('_UNSAFE') and not is_checksum_address(recipient): raise ValueError('invalid checksum address') logg.info('gas transfer from {} to {} value {}'.format(signer_address, recipient, value)) diff --git a/setup.cfg b/setup.cfg index 19751ef..7faeacf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.0.14 +version = 0.0.15 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no From f618a5c9d7155ebe7531c0c660f4ebb42fac8617 Mon Sep 17 00:00:00 2001 From: nolash Date: Tue, 21 Dec 2021 14:50:38 +0000 Subject: [PATCH 17/17] Add missing rpc verify config directive --- chainlib/eth/data/config/config.ini | 1 + chainlib/eth/runnable/get.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/chainlib/eth/data/config/config.ini b/chainlib/eth/data/config/config.ini index c405cc0..aaf46b5 100644 --- a/chainlib/eth/data/config/config.ini +++ b/chainlib/eth/data/config/config.ini @@ -4,6 +4,7 @@ auth = credentials = dialect = default scheme = http +verify = 1 [chain] spec = evm:berlin:1:ethereum diff --git a/chainlib/eth/runnable/get.py b/chainlib/eth/runnable/get.py index dea7d1b..d1f9892 100644 --- a/chainlib/eth/runnable/get.py +++ b/chainlib/eth/runnable/get.py @@ -98,7 +98,6 @@ def get_transaction(conn, tx_hash, id_generator): r = conn.do(o) block = Block(r) tx.apply_block(block) - logg.debug('foo {}'.format(tx_src)) tx.generate_wire(chain_spec) return tx