Parity-ethereum: [Permissioning, Contracts] support Solidity 0.5.5+ produced contract ABIs

Created on 23 Mar 2019  ยท  7Comments  ยท  Source: openethereum/parity-ethereum

_Before filing a new issue, please provide the following information._

  • Parity Ethereum version: master, tag/v2.3.7, tag/v2.4.3
  • Operating system: MacOS
  • Installation: built from source
  • Fully synchronized: โ€”
  • Network: โ€”
  • Restarted: โ€”

_Your issue description goes here below. Try to include actual vs. expected behavior and steps to reproduce the issue._

The problem

Compiling Permission Contracts (ethcore/src/tx_filter.rs) with Solidity 0.5.5 and greater and using as precompiled contracts in ethcore/res/tx_permission_tests/contract_ver_2_genesis.json and ethcore/res/tx_permission_tests/deprecated_contract_genesis.json will result the following ethcore tests to fail:

ERROR 2019-03-23T07:40:37Z: ethcore::tx_filter: Error calling tx permissions contract: "please ensure the contract and method you\'re calling exist! failed to decode empty bytes. if you\'re using jsonrpc this is likely due to jsonrpc returning `0x` in case contract or method don\'t exist"
ERROR 2019-03-23T07:40:37Z: ethcore::tx_filter: Error calling tx permissions contract: "please ensure the contract and method you\'re calling exist! failed to decode empty bytes. if you\'re using jsonrpc this is likely due to jsonrpc returning `0x` in case contract or method don\'t exist"
test tx_filter::test::transaction_filter ... FAILED
ERROR 2019-03-23T07:40:37Z: ethcore::tx_filter: Error calling tx permissions contract: "please ensure the contract and method you\'re calling exist! failed to decode empty bytes. if you\'re using jsonrpc this is likely due to jsonrpc returning `0x` in case contract or method don\'t exist"
ERROR 2019-03-23T07:40:37Z: ethcore::tx_filter: Error calling tx permissions contract: "please ensure the contract and method you\'re calling exist! failed to decode empty bytes. if you\'re using jsonrpc this is likely due to jsonrpc returning `0x` in case contract or method don\'t exist"
test tx_filter::test::transaction_filter_deprecated ... FAILED
failures:

---- tx_filter::test::transaction_filter stdout ----
thread 'tx_filter::test::transaction_filter' panicked at 'assertion failed: filter.transaction_allowed(&genesis, block_number,
                           &basic_tx.clone().sign(key1.secret(), None),
                           &*client)', ethcore/src/tx_filter.rs:208:3

---- tx_filter::test::transaction_filter_deprecated stdout ----
thread 'tx_filter::test::transaction_filter_deprecated' panicked at 'assertion failed: filter.transaction_allowed(&genesis, block_number,
                           &basic_tx.clone().sign(key1.secret(), None),
                           &*client)', ethcore/src/tx_filter.rs:271:3


failures:
    tx_filter::test::transaction_filter
    tx_filter::test::transaction_filter_deprecated

Exactly the same behaviour I see on real Parity chain (I can add logs and configs on Monday if it help) โ€” permissioning doesn't work, as Parity report "method doesn't exist".

Steps to reproduce

  1. Take both contracts (V2 - https://gist.github.com/kavu/5f20dca78989833a201a9a5492927f49, Deprecated โ€” https://gist.github.com/kavu/c25391606ef82854e1a2e30c3b516efe), and compile them with Solidity 0.5.5 or 0.5.6 (I used Remix for that). This will produce following bytecodes:

V2 Bytecode:

608060405234801561001057600080fd5b50610568806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c8063469ab1e31461005157806375d0c0dc1461006f578063a0a8e460146100f2578063d4b03ee014610110575b600080fd5b6100596101a9565b6040518082815260200191505060405180910390f35b61007761022b565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100b757808201518184015260208101905061009c565b50505050905090810190601f1680156100e45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100fa610268565b6040518082815260200191505060405180910390f35b61017c6004803603606081101561012657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610271565b604051808363ffffffff1663ffffffff168152602001821515151581526020019250505060405180910390f35b60006101b361022b565b6040516020018082805190602001908083835b6020831015156101eb57805182526020820191506020810190506020830392506101c6565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905090565b60606040518060400160405280601681526020017f54585f5045524d495353494f4e5f434f4e545241435400000000000000000000815250905090565b60006002905090565b600080737e5f4552091a69125d5dfcb7b8c2659029395bdf73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156102cc5763ffffffff600191509150610534565b732b5ad5c4795c026514f8317c7a215e218dccd6cf73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415610324576002600117600191509150610534565b736813eb9362372eef6200f3b1dbc3f819671cba6973ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156103785760018091509150610534565b73e1ab8145f7e55dc933d51a18c793f901a3a0b27673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161480156103c75750600083145b156103dc5763ffffffff600091509150610534565b73e57bfe9f44b819898f47bf37e5af72a0783e114173ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614801561046a575073d41c057fd1c78805aac12b0a94a405c0461a6fbb73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b1561047c576001600091509150610534565b73d41c057fd1c78805aac12b0a94a405c0461a6fbb73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614801561050a575073e57bfe9f44b819898f47bf37e5af72a0783e114173ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b80156105165750600083145b1561052b5763ffffffff600091509150610534565b60006001915091505b93509391505056fea165627a7a72305820eab93179941adc0a7105f5b98ac8c12b8ca284b3e1fa27b679be616d28ee7bfa0029

Deprecated Bytecode:

608060405234801561001057600080fd5b506101c5806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e175122114610030575b600080fd5b6100726004803603602081101561004657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610094565b604051808263ffffffff1663ffffffff16815260200191505060405180910390f35b6000737e5f4552091a69125d5dfcb7b8c2659029395bdf73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156100ea5763ffffffff9050610194565b732b5ad5c4795c026514f8317c7a215e218dccd6cf73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561013e5760026001179050610194565b736813eb9362372eef6200f3b1dbc3f819671cba6973ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561018f5760019050610194565b600090505b91905056fea165627a7a7230582005cfc0952f953e5a0f466e711ae498c545bd5e113e14dce050042a4665fe47b50029
  1. Insert these bytecodes as a constructors in according genesis files (ethcore/res/tx_permission_tests/contract_ver_2_genesis.json and ethcore/res/tx_permission_tests/deprecated_contract_genesis.json).

  2. Run the ethcore tests.

NB My versions of contracts are patched so it compile without warnings on Solidity 0.5.X.

EDIT 1: Here is the patch, which will help to check it quickly.
broken.txt

F8-enhancement ๐ŸŽŠ M8-contracts ๐Ÿค Z1-question ๐Ÿ™‹โ€โ™€๏ธ

Most helpful comment

_for all who will face this problem as I did_

I've digged a little bit more, and with a help of @kevinaquick in #10502 I figured out that the only parameter we need to enable in chain spec is eip145Transition from block 0.

Hope that helps.

All 7 comments

If you compile with these newer versions of solidity, the contract will have a different ABI, which parity-ethereum isn't aware of.

@joshua-mir And how is happening that these new ABIs (as far as I understand we are talking about new stateMutability variants) is supported on user-deployed contracts? Just curious.

@joshua-mir by the way, statement about 0.5.x is not correct. Contracts will work 0.5.4 bytecode.

@kavu what do you mean? Parity has the solidity 0.4.x generated ABIs hard-coded in order to communicate directly with contracts for things like permissioning and validatorSets. If you compile the same contract with 0.5.5+ you get a different ABI so these recompiled permissioning contracts won't match the hard-coded ABI in parity-ethereum.

For contracts that aren't hard-coded, there's no difference to end-users in how they are used, they just use the ABI generated by solidity and build transactions as they wish.

@joshua-mir okay, I get it. Do we talk about ethcore/res/contracts/tx_acl.json and ethcore/res/contracts/tx_acl_deprecated.json, or there is something deeper, which I don't know yet (of course there is ๐Ÿ˜„)? I tried to update ABI in this files, still no luck.

We might need to update how we parse ABIs, I'm not certain of the details.

_for all who will face this problem as I did_

I've digged a little bit more, and with a help of @kevinaquick in #10502 I figured out that the only parameter we need to enable in chain spec is eip145Transition from block 0.

Hope that helps.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacogr picture jacogr  ยท  4Comments

dukei picture dukei  ยท  3Comments

stone212 picture stone212  ยท  3Comments

tzapu picture tzapu  ยท  3Comments

bryaan picture bryaan  ยท  3Comments