contract-registry

Ethereum Smart Contract key-value registry
Log | Files | Refs

commit 657137efb0279c007007307861d3804d353dbb51
parent ddfb1d3e01d1bdd4587922be377eaf194d9a9b1b
Author: nolash <dev@holbrook.no>
Date:   Fri, 30 Apr 2021 12:01:08 +0200

rehabilitate tests, replace seal with transferownership

Diffstat:
M.gitignore | 4++++
Mpython/eth_contract_registry/data/Registry.bin | 4++--
Mpython/eth_contract_registry/data/Registry.json | 2+-
Mpython/gmon.out | 0
Mpython/setup.cfg | 2+-
Mpython/tests/conftest.py | 2+-
Mpython/tests/test_basic.py | 30++++++++++--------------------
Msolidity/Makefile | 2+-
Msolidity/Registry.sol | 13++++++++-----
9 files changed, 28 insertions(+), 31 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,2 +1,6 @@ +build/ +dist/ +*.egg-info +gmon.out __pycache__ *.pyc diff --git a/python/eth_contract_registry/data/Registry.bin b/python/eth_contract_registry/data/Registry.bin @@ -1 +1 @@ -60806040523480156200001157600080fd5b5060405162000a7138038062000a718339818101604052810190620000379190620001c5565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060005b815181101562000104576001828281518110620000c0577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015190806001815401808255809150506001900390600052602060002001600090919091909150558080620000fb90620002ac565b9150506200007a565b505062000383565b6000620001236200011d8462000233565b6200020a565b905080838252602082019050828560208602820111156200014357600080fd5b60005b858110156200017757816200015c8882620001ae565b84526020840193506020830192505060018101905062000146565b5050509392505050565b600082601f8301126200019357600080fd5b8151620001a58482602086016200010c565b91505092915050565b600081519050620001bf8162000369565b92915050565b600060208284031215620001d857600080fd5b600082015167ffffffffffffffff811115620001f357600080fd5b620002018482850162000181565b91505092915050565b60006200021662000229565b905062000224828262000276565b919050565b6000604051905090565b600067ffffffffffffffff82111562000251576200025062000329565b5b602082029050602081019050919050565b6000819050919050565b6000819050919050565b620002818262000358565b810181811067ffffffffffffffff82111715620002a357620002a262000329565b5b80604052505050565b6000620002b9826200026c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415620002ef57620002ee620002fa565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b620003748162000262565b81146200038057600080fd5b50565b6106de80620003936000396000f3fe608060405234801561001057600080fd5b506004361061007f576000357c01000000000000000000000000000000000000000000000000000000009004806328f2d4da146100845780635deed44e146100b45780638da5cb5b146100e45780639648eca214610102578063bb34534c14610132578063f0f86f7114610162575b600080fd5b61009e600480360381019061009991906104f2565b610192565b6040516100ab919061057e565b60405180910390f35b6100ce60048036038101906100c99190610466565b6101b6565b6040516100db919061057e565b60405180910390f35b6100ec6101d3565b6040516100f99190610548565b60405180910390f35b61011c60048036038101906101179190610466565b6101f7565b604051610129919061057e565b60405180910390f35b61014c60048036038101906101479190610466565b610214565b6040516101599190610548565b60405180910390f35b61017c6004803603810190610177919061048f565b610251565b6040516101899190610563565b60405180910390f35b600181815481106101a257600080fd5b906000526020600020016000915090505481565b600060046000838152602001908152602001600020549050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060036000838152602001908152602001600020549050919050565b60006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102ac57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166002600087815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461031857600080fd5b6000805b60018054905081101561038d578660018281548110610364577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154141561037a57600191505b8080610385906105eb565b91505061031c565b508061039857600080fd5b846002600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508360036000888152602001908152602001600020819055508260046000868152602001908152602001600020819055506001915050949350505050565b60008135905061043681610663565b92915050565b60008135905061044b8161067a565b92915050565b60008135905061046081610691565b92915050565b60006020828403121561047857600080fd5b60006104868482850161043c565b91505092915050565b600080600080608085870312156104a557600080fd5b60006104b38782880161043c565b94505060206104c487828801610427565b93505060406104d58782880161043c565b92505060606104e68782880161043c565b91505092959194509250565b60006020828403121561050457600080fd5b600061051284828501610451565b91505092915050565b61052481610599565b82525050565b610533816105ab565b82525050565b610542816105b7565b82525050565b600060208201905061055d600083018461051b565b92915050565b6000602082019050610578600083018461052a565b92915050565b60006020820190506105936000830184610539565b92915050565b60006105a4826105c1565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006105f6826105e1565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561062957610628610634565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b61066c81610599565b811461067757600080fd5b50565b610683816105b7565b811461068e57600080fd5b50565b61069a816105e1565b81146106a557600080fd5b5056fea2646970667358221220c55a8666b79abd3b9abfdd11a7f7afb300ab9783847b841595839f89b1401e6064736f6c63430008020033 -\ No newline at end of file +60806040523480156200001157600080fd5b5060405162000b8938038062000b898339818101604052810190620000379190620001c5565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060005b815181101562000104576001828281518110620000c0577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015190806001815401808255809150506001900390600052602060002001600090919091909150558080620000fb90620002ac565b9150506200007a565b505062000383565b6000620001236200011d8462000233565b6200020a565b905080838252602082019050828560208602820111156200014357600080fd5b60005b858110156200017757816200015c8882620001ae565b84526020840193506020830192505060018101905062000146565b5050509392505050565b600082601f8301126200019357600080fd5b8151620001a58482602086016200010c565b91505092915050565b600081519050620001bf8162000369565b92915050565b600060208284031215620001d857600080fd5b600082015167ffffffffffffffff811115620001f357600080fd5b620002018482850162000181565b91505092915050565b60006200021662000229565b905062000224828262000276565b919050565b6000604051905090565b600067ffffffffffffffff82111562000251576200025062000329565b5b602082029050602081019050919050565b6000819050919050565b6000819050919050565b620002818262000358565b810181811067ffffffffffffffff82111715620002a357620002a262000329565b5b80604052505050565b6000620002b9826200026c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415620002ef57620002ee620002fa565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b620003748162000262565b81146200038057600080fd5b50565b6107f680620003936000396000f3fe608060405234801561001057600080fd5b506004361061009a576000357c0100000000000000000000000000000000000000000000000000000000900480639648eca2116100785780639648eca21461011d578063bb34534c1461014d578063f0f86f711461017d578063f2fde38b146101ad5761009a565b806328f2d4da1461009f5780635deed44e146100cf5780638da5cb5b146100ff575b600080fd5b6100b960048036038101906100b4919061060a565b6101dd565b6040516100c69190610696565b60405180910390f35b6100e960048036038101906100e4919061057e565b610201565b6040516100f69190610696565b60405180910390f35b61010761021e565b6040516101149190610660565b60405180910390f35b6101376004803603810190610132919061057e565b610242565b6040516101449190610696565b60405180910390f35b6101676004803603810190610162919061057e565b61025f565b6040516101749190610660565b60405180910390f35b610197600480360381019061019291906105a7565b61029c565b6040516101a4919061067b565b60405180910390f35b6101c760048036038101906101c29190610555565b610472565b6040516101d4919061067b565b60405180910390f35b600181815481106101ed57600080fd5b906000526020600020016000915090505481565b600060046000838152602001908152602001600020549050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060036000838152602001908152602001600020549050919050565b60006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102f757600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166002600087815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461036357600080fd5b6000805b6001805490508110156103d85786600182815481106103af577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015414156103c557600191505b80806103d090610703565b915050610367565b50806103e357600080fd5b846002600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508360036000888152602001908152602001600020819055508260046000868152602001908152602001600020819055506001915050949350505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104cd57600080fd5b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b6000813590506105258161077b565b92915050565b60008135905061053a81610792565b92915050565b60008135905061054f816107a9565b92915050565b60006020828403121561056757600080fd5b600061057584828501610516565b91505092915050565b60006020828403121561059057600080fd5b600061059e8482850161052b565b91505092915050565b600080600080608085870312156105bd57600080fd5b60006105cb8782880161052b565b94505060206105dc87828801610516565b93505060406105ed8782880161052b565b92505060606105fe8782880161052b565b91505092959194509250565b60006020828403121561061c57600080fd5b600061062a84828501610540565b91505092915050565b61063c816106b1565b82525050565b61064b816106c3565b82525050565b61065a816106cf565b82525050565b60006020820190506106756000830184610633565b92915050565b60006020820190506106906000830184610642565b92915050565b60006020820190506106ab6000830184610651565b92915050565b60006106bc826106d9565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061070e826106f9565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156107415761074061074c565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b610784816106b1565b811461078f57600080fd5b50565b61079b816106cf565b81146107a657600080fd5b50565b6107b2816106f9565b81146107bd57600080fd5b5056fea26469706673582212202898d5ed10ba7e08345b4c1bd9157618892bc47e48034196efd910944d2f3e3d64736f6c63430008030033 +\ No newline at end of file diff --git a/python/eth_contract_registry/data/Registry.json b/python/eth_contract_registry/data/Registry.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"bytes32[]","name":"_identifiers","type":"bytes32[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"}],"name":"chainOf","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_chain","type":"bytes32"}],"name":"configSumOf","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"identifiers","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"},{"internalType":"address","name":"_address","type":"address"},{"internalType":"bytes32","name":"_chainDescriptor","type":"bytes32"},{"internalType":"bytes32","name":"_chainConfig","type":"bytes32"}],"name":"set","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] +[{"inputs":[{"internalType":"bytes32[]","name":"_identifiers","type":"bytes32[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"}],"name":"addressOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"}],"name":"chainOf","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_chain","type":"bytes32"}],"name":"configSumOf","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"identifiers","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_identifier","type":"bytes32"},{"internalType":"address","name":"_address","type":"address"},{"internalType":"bytes32","name":"_chainDescriptor","type":"bytes32"},{"internalType":"bytes32","name":"_chainConfig","type":"bytes32"}],"name":"set","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] diff --git a/python/gmon.out b/python/gmon.out Binary files differ. diff --git a/python/setup.cfg b/python/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = eth-contract-registry -version = 0.5.4a10 +version = 0.5.5a1 description = Ethereum Smart Contract key-value registry author = Louis Holbrook author_email = dev@holbrook.no diff --git a/python/tests/conftest.py b/python/tests/conftest.py @@ -1,4 +1,4 @@ # external imports from chainlib.eth.pytest import * -from contract_registry.pytest import * +from eth_contract_registry.pytest import * diff --git a/python/tests/test_basic.py b/python/tests/test_basic.py @@ -22,9 +22,9 @@ from hexathon import ( ) # local imports -from contract_registry.registry import Registry -from contract_registry.encoding import from_identifier_hex -from contract_registry.pytest.fixtures_registry import valid_identifiers +from eth_contract_registry.registry import Registry +from eth_contract_registry.encoding import from_identifier_hex +from eth_contract_registry.pytest.fixtures_registry import valid_identifiers logg = logging.getLogger() @@ -33,43 +33,33 @@ valid_identifiers += [ ] def test_set( + default_chain_spec, registry, eth_accounts, eth_rpc, eth_signer, + roles, ): addr_registry = to_checksum_address(os.urandom(20).hex()) addr_foo = to_checksum_address(os.urandom(20).hex()) bogus_hash = add_0x(os.urandom(32).hex()) - #conn = RPCConnection.connect('default') - nonce_oracle = RPCNonceOracle(eth_accounts[0], eth_rpc) - builder = Registry(signer=eth_signer, nonce_oracle=nonce_oracle) - (tx_hash_hex, o) = builder.set(registry, eth_accounts[0], 'ContractRegistry', addr_registry, bogus_hash, bogus_hash) - r = eth_rpc.do(o) - - o = receipt(r) - rcpt = eth_rpc.do(o) - assert rcpt['status'] == 1 - - o = builder.identifier(registry, 0, sender_address=eth_accounts[0]) - r = eth_rpc.do(o) - r = from_identifier_hex(r) - assert r == 'ContractRegistry' + nonce_oracle = RPCNonceOracle(roles['CONTRACT_DEPLOYER'], eth_rpc) + builder = Registry(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle) o = builder.address_of(registry, 'ContractRegistry', sender_address=eth_accounts[0]) r = eth_rpc.do(o) r = abi_decode_single(ABIContractType.ADDRESS, r) - assert r == addr_registry + assert r == registry - (tx_hash_hex, o) = builder.set(registry, eth_accounts[0], 'ContractRegistry', addr_registry, bogus_hash, bogus_hash) + (tx_hash_hex, o) = builder.set(registry, roles['CONTRACT_DEPLOYER'], 'ContractRegistry', addr_registry, bogus_hash, bogus_hash) r = eth_rpc.do(o) o = receipt(r) rcpt = eth_rpc.do(o) assert rcpt['status'] == 0 - (tx_hash_hex, o) = builder.set(registry, eth_accounts[0], 'FooContract', addr_foo, bogus_hash, bogus_hash) + (tx_hash_hex, o) = builder.set(registry, roles['CONTRACT_DEPLOYER'], 'FooContract', addr_foo, bogus_hash, bogus_hash) r = eth_rpc.do(o) o = receipt(r) rcpt = eth_rpc.do(o) diff --git a/solidity/Makefile b/solidity/Makefile @@ -6,5 +6,5 @@ all: $(SOLC) --abi Registry.sol --evm-version byzantium | awk 'NR>3' > Registry.json install: all - cp -v *{json,bin} ../python/contract_registry/data/ + cp -v *{json,bin} ../python/eth_contract_registry/data/ diff --git a/solidity/Registry.sol b/solidity/Registry.sol @@ -7,6 +7,7 @@ pragma solidity >0.6.11; contract CICRegistry { + // Implements EIP 173 address public owner; bytes32[] public identifiers; @@ -38,12 +39,14 @@ contract CICRegistry { return true; } -// function seal() public returns (bool) { -// require(msg.sender == owner); -// owner = address(0); -// return true; -// } + // Implements EIP 173 + function transferOwnership(address _newOwner) public returns (bool) { + require(msg.sender == owner); + owner = _newOwner; + return true; + } + // Implements Registry function addressOf(bytes32 _identifier) public view returns (address) { return entries[_identifier]; }