Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

fix (light/provider) : Make read_only executions read-only #9591

Merged
merged 4 commits into from
Oct 8, 2018

Conversation

niklasad1
Copy link
Collaborator

@niklasad1 niklasad1 commented Sep 19, 2018

Attempt to close #9551 and fix #9535

/cc @Tbaut can you try this with fether?

This changes so all ExecutionRequests from light-clients are executed
as read-only which the virtual flag == true ensures.

This boost up the current transaction to always succeed such as account balance and similar!

Note, this only affects eth_estimateGas and eth_call AFAIK.

Manual tests on (kovan)

  1. Started a provider (full node)
  2. Request from light client with unknown account 0x0066Dc48bb833d2B59f730F33952B3c29fE926ff
curl --data '{"method":"eth_estimateGas","params":[{"from":"0x0066Dc48bb833d2B59f730F33952B3c29fE926ff", "gas":"0xffff" }, "latest"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8555
{"jsonrpc":"2.0","result":"0xcf08","id":1}

@niklasad1 niklasad1 added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Sep 19, 2018
@@ -2357,7 +2358,7 @@ impl ProvingBlockChainClient for Client {
self.engine.machine(),
&env_info,
self.factories.clone(),
false,
true,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will now use transact_virtual to ensure that the account has enough balance for the execution

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about removing virt parameter from state::prove_transaction (always set to true) and add docs to prove_transaction trait method?

@@ -61,7 +61,7 @@ pub enum Request {
/// A request for a contract's code.
Code(Code),
/// A request for proof of execution.
Execution(TransactionProof),
Execution(ReadOnlyTransactionProof),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More explicit name

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a mixed feelings about this rename, because ReadOnlyTransactionProof implies there is NonReadOnlyTransactionProof.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will revert this!

@5chdn 5chdn added this to the 2.2 milestone Sep 19, 2018
@Tbaut
Copy link
Contributor

Tbaut commented Sep 19, 2018

Thanks for tackling that @niklasad1
I gave it a shot and unfortunately this did not succeed. Here is a trace with the RPCs: https://gist.github.com/Tbaut/f13f6c26e80d20227cb46d5c3765daab

@ordian
Copy link
Collaborator

ordian commented Sep 19, 2018

@Tbaut note, that it fixes full node's side of light client, so to properly test this, you need to connect light client to a patched full node (reserved and reserved-only connection is broken on master)

@Tbaut
Copy link
Contributor

Tbaut commented Sep 19, 2018

Thanks @ordian, I definitely did not test it (and I couldn't have had indeed :( ).

@niklasad1
Copy link
Collaborator Author

@Tbaut @ordian

I brute-forced this and spinned up a regular full-node (not reserved) along with a light client and it works (eventually found) my full node!

From your logs it looks like eth_call is the problem which this PR fixes.
Also, eth_getBalance will return as long as it gets at least one reply from its peers regardless whether the account exists or not!

@Tbaut
Copy link
Contributor

Tbaut commented Sep 19, 2018

FWIW, I tested Fether about 1-2 months ago by connecting it directly to a light client that was connected to a full node using reserved peers, and I had fewer problems than when the light client was connecting to nodes in the wild.

@niklasad1 niklasad1 changed the title [light/provider] Fix that read_only executions always succeed fix (light/provider) : Make read_only executions only read-only Sep 26, 2018
Copy link
Collaborator

@ordian ordian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm that it fixes estimateGas problem. Not sure about #9551 though.

@@ -61,7 +61,7 @@ pub enum Request {
/// A request for a contract's code.
Code(Code),
/// A request for proof of execution.
Execution(TransactionProof),
Execution(ReadOnlyTransactionProof),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a mixed feelings about this rename, because ReadOnlyTransactionProof implies there is NonReadOnlyTransactionProof.

@@ -2374,6 +2374,7 @@ impl ProvingBlockChainClient for Client {
}

fn prove_transaction(&self, transaction: SignedTransaction, id: BlockId) -> Option<(Bytes, Vec<DBValue>)> {
trace!(target: "pip_provider", "prove_transaction: {:?}", transaction);
Copy link
Collaborator

@ordian ordian Sep 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like prove_transaction is also used in full node to ensure genesis epoch proof in the DB, so not sure about this trace target.

@@ -2357,7 +2358,7 @@ impl ProvingBlockChainClient for Client {
self.engine.machine(),
&env_info,
self.factories.clone(),
false,
true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about removing virt parameter from state::prove_transaction (always set to true) and add docs to prove_transaction trait method?

@5chdn 5chdn added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Sep 27, 2018
This was referenced Sep 30, 2018
@niklasad1 niklasad1 force-pushed the light/introduce-readonly-exec branch from 1b0f601 to 9acd419 Compare October 1, 2018 09:01
This changes so all `ExecutionRequests` from light-clients are executed
as read-only which the `virtual``flag == true ensures.

This boost up the current transaction to always succeed

Note, this only affects `eth_estimateGas` and `eth_call` AFAIK.
Remove the boolean flag to determine that a `state::prove_transaction`
whether it should be executed in a virtual context or not.

Because of that also rename the function to
`state::prove_transction_virtual` to make more clear
@niklasad1 niklasad1 force-pushed the light/introduce-readonly-exec branch from 9acd419 to 9a36cf3 Compare October 2, 2018 09:30
@niklasad1 niklasad1 changed the title fix (light/provider) : Make read_only executions only read-only fix (light/provider) : Make read_only executions read-only Oct 2, 2018
@ordian ordian requested a review from cheme October 8, 2018 12:33
@ordian ordian added the B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. label Oct 8, 2018
@cheme
Copy link
Contributor

cheme commented Oct 8, 2018

I am starting to wonder if it is really fine to run transaction as virtual in this case. For instance if I want to send a transaction and do not put enough gas maybe I would rather have a failure than a success (success leading me to send my transaction and lose my gas).

What I am saying, is that we probably want light client 'eth_estimateGas' call to run as virtual, but 'eth_call' to run as normal. With this PR it always run as virtual.
I am also not sure with the renaming (for the same reason as stated before).

I need confirmation that I am incorrect before approving, maybe @rphmeier .

Even if I am correct, the problem remains: in 'rpc/src/v1/helpers/light_fetch.rs' both call and estimategas run on the same rpc call (proved_execution) and we probably want to run virtual only for estimateGas which does not seems possible with current LES definition. So the change from this PR will make estimateGas works for light client but might break call for light client. I do not really see a good solution that does not required changing LES a bit (if changing LES there is also certainly something to do about #6155 ).

@ordian
Copy link
Collaborator

ordian commented Oct 8, 2018

@cheme IIUC eth_call is a read-only operation by design and for full node it is implemented as virtual call.

@cheme
Copy link
Contributor

cheme commented Oct 8, 2018

Indeed, so it is the same behavior, must be correct.

Copy link
Contributor

@cheme cheme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Maybe the renaming of the function is a bit overdoing it (I do not think that there is other version of the function, the comment change would have been enough for me).

@niklasad1 niklasad1 merged commit 5b54442 into master Oct 8, 2018
@niklasad1 niklasad1 deleted the light/introduce-readonly-exec branch October 8, 2018 19:30
dvdplm added a commit that referenced this pull request Oct 9, 2018
…mon-deps

* origin/master:
  fix (light/provider) : Make `read_only executions` read-only (#9591)
  ethcore: fix detection of major import (#9552)
  return 0 on error (#9705)
  ethcore: delay ropsten hardfork (#9704)
  make instantSeal engine backwards compatible, closes #9696 (#9700)
  Implement CREATE2 gas changes and fix some potential overflowing (#9694)
  Don't hash the init_code of CREATE. (#9688)
  ethcore: minor optimization of modexp by using LR exponentiation (#9697)
  removed redundant clone before each block import (#9683)
5chdn pushed a commit that referenced this pull request Oct 9, 2018
* `ExecutionsRequest` from light-clients as read-only

This changes so all `ExecutionRequests` from light-clients are executed
as read-only which the `virtual``flag == true ensures.

This boost up the current transaction to always succeed

Note, this only affects `eth_estimateGas` and `eth_call` AFAIK.

* grumbles(revert renaming) : TransactionProof

* grumbles(trace) : remove incorrect trace

* grumbles(state/prove_tx) : explicit `virt`

Remove the boolean flag to determine that a `state::prove_transaction`
whether it should be executed in a virtual context or not.

Because of that also rename the function to
`state::prove_transction_virtual` to make more clear
5chdn added a commit that referenced this pull request Oct 9, 2018
* parity-version: bump beta to 2.1.2

* docs(rpc): push the branch along with tags (#9578)

* docs(rpc): push the branch along with tags

* ci: remove old rpc docs script

* Remove snapcraft clean (#9585)

* Revert " add snapcraft package image (master) (#9584)"

This reverts commit ceaedbb.

* Update package-snap.sh

* Update .gitlab-ci.yml

* ci: fix regex 🙄 (#9597)

* docs(rpc): annotate tag with the provided message (#9601)

* Update ropsten.json (#9602)

* HF in POA Sokol (2018-09-19) (#9607)

poanetwork/poa-chain-spec#86

* fix(network): don't disconnect reserved peers (#9608)

The priority of && and || was borked.

* fix failing node-table tests on mac os, closes #9632 (#9633)

* ethcore-io retries failed work steal (#9651)

* ethcore-io uses newer version of crossbeam && retries failed work steal

* ethcore-io non-mio service uses newer crossbeam

* remove master from releasable branches (#9655)

* remove master from releasable branches

need backporting in beta 
fix https://gitlab.parity.io/parity/parity-ethereum/-/jobs/101065 etc

* add except for snap packages for master

* Test fix for windows cache name... (#9658)

* Test fix for windows cache name...

* Fix variable name.

* fix(light_fetch): avoid race with BlockNumber::Latest (#9665)

* Calculate sha3 instead of sha256 for push-release. (#9673)

* Calculate sha3 instead of sha256 for push-release.

* Add pushes to the script.

* Hardfork the testnets (#9562)

* ethcore: propose hardfork block number 4230000 for ropsten

* ethcore: propose hardfork block number 9000000 for kovan

* ethcore: enable kip-4 and kip-6 on kovan

* etcore: bump kovan hardfork to block 9.2M

* ethcore: fix ropsten constantinople block number to 4.2M

* ethcore: disable difficulty_test_ropsten until ethereum/tests are updated upstream

* ci: fix push script (#9679)

* ci: fix push script

* Fix copying & running on windows.

* CI: Remove unnecessary pipes (#9681)

* ci: reduce gitlab pipelines significantly

* ci: build pipeline for PR

* ci: remove dead weight

* ci: remove github release script

* ci: remove forever broken aura tests

* ci: add random stuff to the end of the pipes

* ci: add wind and mac to the end of the pipe

* ci: remove snap artifacts

* ci: (re)move dockerfiles

* ci: clarify job names

* ci: add cargo audit job

* ci: make audit script executable

* ci: ignore snap and docker files for rust check

* ci: simplify audit script

* ci: rename misc to optional

* ci: add publish script to releaseable branches

* ci: more verbose cp command for windows build

* ci: fix weird binary checksum logic in push script

* ci: fix regex in push script for windows

* ci: simplify gitlab caching

* docs: align README with ci changes

* ci: specify default cargo target dir

* ci: print verbose environment

* ci: proper naming of scripts

* ci: restore docker files

* ci: use docker hub file

* ci: use cargo home instead of cargo target dir

* ci: touch random rust file to trigger real builds

* ci: set cargo target dir for audit script

* ci: remove temp file

* ci: don't export the cargo target dir in the audit script

* ci: fix windows unbound variable

* docs: fix gitlab badge path

* rename deprecated gitlab ci variables

https://docs.gitlab.com/ee/ci/variables/#9-0-renaming

* ci: fix git compare for nightly builds

* test: skip c++ example for all platforms but linux

* ci: add random rust file to trigger tests

* ci: remove random rust file

* disable cpp lib test for mac, win and beta (#9686)

* cleanup ci merge

* ci: fix tests

* fix bad-block reporting no reason (#9638)

* ethcore: fix detection of major import (#9552)

* sync: set state to idle after sync is completed

* sync: refactor sync reset

* Don't hash the init_code of CREATE. (#9688)

* Docker: run as parity user (#9689)

* Implement CREATE2 gas changes and fix some potential overflowing (#9694)

* Implement CREATE2 gas changes and fix some potential overflowing

* Ignore create2 state tests

* Split CREATE and CREATE2 in gasometer

* Generalize rounding (x + 31) / 32 to to_word_size

* make instantSeal engine backwards compatible, closes #9696 (#9700)

* ethcore: delay ropsten hardfork (#9704)

* fix (light/provider) : Make `read_only executions` read-only (#9591)

* `ExecutionsRequest` from light-clients as read-only

This changes so all `ExecutionRequests` from light-clients are executed
as read-only which the `virtual``flag == true ensures.

This boost up the current transaction to always succeed

Note, this only affects `eth_estimateGas` and `eth_call` AFAIK.

* grumbles(revert renaming) : TransactionProof

* grumbles(trace) : remove incorrect trace

* grumbles(state/prove_tx) : explicit `virt`

Remove the boolean flag to determine that a `state::prove_transaction`
whether it should be executed in a virtual context or not.

Because of that also rename the function to
`state::prove_transction_virtual` to make more clear

* CI: Skip docs job for nightly (#9693)

* ci: force-tag wiki changes

* ci: force-tag wiki changes

* ci: skip docs job for master and nightly

* ci: revert docs job checking for nightly tag

* ci: exclude docs job from nightly builds in gitlab script
5chdn pushed a commit that referenced this pull request Oct 9, 2018
* `ExecutionsRequest` from light-clients as read-only

This changes so all `ExecutionRequests` from light-clients are executed
as read-only which the `virtual``flag == true ensures.

This boost up the current transaction to always succeed

Note, this only affects `eth_estimateGas` and `eth_call` AFAIK.

* grumbles(revert renaming) : TransactionProof

* grumbles(trace) : remove incorrect trace

* grumbles(state/prove_tx) : explicit `virt`

Remove the boolean flag to determine that a `state::prove_transaction`
whether it should be executed in a virtual context or not.

Because of that also rename the function to
`state::prove_transction_virtual` to make more clear
5chdn added a commit that referenced this pull request Oct 10, 2018
* parity-version: bump stable to 2.0.7

* HF in POA Sokol (2018-09-19) (#9607)

poanetwork/poa-chain-spec#86

* fix failing node-table tests on mac os, closes #9632 (#9633)

* fix(light_fetch): avoid race with BlockNumber::Latest (#9665)

* CI: Remove unnecessary pipes (#9681)

* ci: reduce gitlab pipelines significantly

* ci: build pipeline for PR

* ci: remove dead weight

* ci: remove github release script

* ci: remove forever broken aura tests

* ci: add random stuff to the end of the pipes

* ci: add wind and mac to the end of the pipe

* ci: remove snap artifacts

* ci: (re)move dockerfiles

* ci: clarify job names

* ci: add cargo audit job

* ci: make audit script executable

* ci: ignore snap and docker files for rust check

* ci: simplify audit script

* ci: rename misc to optional

* ci: add publish script to releaseable branches

* ci: more verbose cp command for windows build

* ci: fix weird binary checksum logic in push script

* ci: fix regex in push script for windows

* ci: simplify gitlab caching

* docs: align README with ci changes

* ci: specify default cargo target dir

* ci: print verbose environment

* ci: proper naming of scripts

* ci: restore docker files

* ci: use docker hub file

* ci: use cargo home instead of cargo target dir

* ci: touch random rust file to trigger real builds

* ci: set cargo target dir for audit script

* ci: remove temp file

* ci: don't export the cargo target dir in the audit script

* ci: fix windows unbound variable

* docs: fix gitlab badge path

* rename deprecated gitlab ci variables

https://docs.gitlab.com/ee/ci/variables/#9-0-renaming

* ci: fix git compare for nightly builds

* test: skip c++ example for all platforms but linux

* ci: add random rust file to trigger tests

* ci: remove random rust file

* disable cpp lib test for mac, win and beta (#9686)

* cleanup ci merge

* parity: bump clib

* ci: fix tests

* ci: disable c++ example

* Docker: run as parity user (#9689)

* CI: Skip docs job for nightly (#9693)

* ci: force-tag wiki changes

* ci: force-tag wiki changes

* ci: skip docs job for master and nightly

* ci: revert docs job checking for nightly tag

* ci: exclude docs job from nightly builds in gitlab script

* fix (light/provider) : Make `read_only executions` read-only (#9591)

* `ExecutionsRequest` from light-clients as read-only

This changes so all `ExecutionRequests` from light-clients are executed
as read-only which the `virtual``flag == true ensures.

This boost up the current transaction to always succeed

Note, this only affects `eth_estimateGas` and `eth_call` AFAIK.

* grumbles(revert renaming) : TransactionProof

* grumbles(trace) : remove incorrect trace

* grumbles(state/prove_tx) : explicit `virt`

Remove the boolean flag to determine that a `state::prove_transaction`
whether it should be executed in a virtual context or not.

Because of that also rename the function to
`state::prove_transction_virtual` to make more clear

* ethcore: fix detection of major import (#9552)

* sync: set state to idle after sync is completed

* sync: refactor sync reset

* parity: revert clib bump and fix tests

* Fix path to parity.h (#9274)

* Fix path to parity.h

* Fix other paths as well

* ethcore-io retries failed work steal (#9651)

* ethcore-io uses newer version of crossbeam && retries failed work steal

* ethcore-io non-mio service uses newer crossbeam
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. M4-core ⛓ Core client code / Rust.
Projects
None yet
5 participants