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

backwards compatible call_type creation_method #11450

Merged
merged 13 commits into from
Feb 5, 2020

Conversation

ordian
Copy link
Collaborator

@ordian ordian commented Feb 4, 2020

on top of #11449

this should allow having tracing nodes db synced with 2.6 and 2.7

@ordian ordian added A0-pleasereview 🤓 Pull request needs code review. B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. M4-core ⛓ Core client code / Rust. labels Feb 4, 2020
@dvdplm
Copy link
Collaborator

dvdplm commented Feb 4, 2020

How should we test this change? Do you have a step-by-step recipe?

@dvdplm
Copy link
Collaborator

dvdplm commented Feb 4, 2020

@fleupold Can you take a look at this please?

@dvdplm dvdplm requested a review from tomusdrw February 4, 2020 18:10
@ordian
Copy link
Collaborator Author

ordian commented Feb 4, 2020

the #11427 was reverted in e188f47 and it shouldn't be reviewed (or the reversion can be extracted into a separate PR)

To test this

  1. Sync the tracing db from genesis a bit with 2.6
  2. Stop 2.6 and continue syncing with 2.7.0.
  3. Stop 2.7.0 and continue with this branch
  4. Curl some traces (trace_filter) in ranges synced with different versions.

There are some unit tests as well 8aca13b

ethcore/trace/src/types/trace.rs Outdated Show resolved Hide resolved
ethcore/trace/src/types/trace.rs Outdated Show resolved Hide resolved
ethcore/trace/src/types/trace.rs Outdated Show resolved Hide resolved
ethcore/trace/src/types/trace.rs Outdated Show resolved Hide resolved
ethcore/trace/src/types/trace.rs Show resolved Hide resolved
ethcore/trace/src/types/trace.rs Outdated Show resolved Hide resolved
ethcore/trace/src/types/trace.rs Outdated Show resolved Hide resolved
}))
}
}

/// Description of a _call_ action, either a `CALL` operation or a message transaction.
#[derive(Debug, Clone, PartialEq, RlpEncodable, RlpDecodable)]
pub struct Call {
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 annotating that data of this type end up rlp-ized in the database and thus any changes need to be made backwards compatibly?

@@ -113,6 +242,9 @@ pub struct Create {
pub gas: U256,
/// The init code.
pub init: Bytes,
/// Creation method (CREATE vs CREATE2).
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should add a not to the docs for this type that data of this type ends up in the database and so great care is necessary when making changes.

Copy link
Contributor

@fleupold fleupold left a comment

Choose a reason for hiding this comment

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

I'm very sorry for merging the #11311 in a bad state. I originally had backwards compatibility in mind and tested specifically for that. I didn't rerun the test plan after the last set of changes, which was very bad.

Generally I'm wondering if it's worth all this hassle in order to change an enum<None, a, b, ...> to an Option<enum<a, b, ...>> type. Aren't they semantically the same?

@@ -240,8 +244,6 @@ impl From<trace::Create> for Create {
#[derive(Debug, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum CallType {
/// None
None,
Copy link
Contributor

@fleupold fleupold Feb 5, 2020

Choose a reason for hiding this comment

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

Since all the trouble is coming from killing this variant here, would it maybe be better to leave the None type on the enum directly? Does it make much of a difference to have an enum with 5 variants vs a nested enum (Option where some has 4 variants)?

Copy link
Collaborator Author

@ordian ordian Feb 5, 2020

Choose a reason for hiding this comment

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

The difference is that Option<CallType> and CallType from 2.6 have different rlp serialization layout, the former is a list, and the latter is serialized as an int. If we want to be backwards compatible with both 2.6 and 2.7.0, we need to be able to deserialize both versions to the same struct.

impl Decodable for CallType {
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
rlp.as_val().and_then(|v| Ok(match v {
0u32 => CallType::Call,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this correct? In the old version, when we serialized a 0 this meant CallType::None, but it will now be read to CallType::Call. Shouldn't this all be shifted by 1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Option<CallType> is serialized as list https://github.com/paritytech/parity-common/blob/a8329435e19d46b3e50145a9b5a399bfac52a31f/rlp/src/impls.rs#L70-L99 and I assume that #11311 was reviewed properly, so we don't have to re-review it again 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, I think you're right, let me test this again.

Copy link
Collaborator

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

lgtm!

@@ -130,7 +130,7 @@ impl From<ethjson::vm::Transaction> for ActionParams {
gas: t.gas.into(),
gas_price: t.gas_price.into(),
value: ActionValue::Transfer(t.value.into()),
call_type: match address.is_zero() { true => CallType::None, false => CallType::Call }, // TODO @debris is this correct?
action_type: ActionType::Call,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't that change the JSON tests results?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I haven't touched that code, so I assume it was reviewed
#11311 (comment)

@dvdplm
Copy link
Collaborator

dvdplm commented Feb 5, 2020

To test this

1. Sync the tracing db from genesis a bit with 2.6

2. Stop 2.6 and continue syncing with 2.7.0.

3. Stop 2.7.0 and continue with this branch

4. Curl some traces (`trace_filter`) in ranges synced with different versions.

Works here. :)

* master:
  gcc to clang (#11453)
  Avoid copies (#11451)
  Cargo.lock: cargo lock translate (#11448)
  Avoid long state queries when serving GetNodeData requests (#11444)
  Cargo.lock: cargo update -p kvdb-rocksdb (#11447)
@dvdplm dvdplm merged commit 6265433 into master Feb 5, 2020
@dvdplm dvdplm deleted the ao-fix-rlp-calltype-backwards-compatible branch February 5, 2020 14:30
s3krit pushed a commit that referenced this pull request Feb 5, 2020
* rlp_derive: update syn & co

* rlp_derive: remove dummy_const

* rlp_derive: remove unused attirubutes

* rlp-derive: change authors

* rlp_derive: add rlp(default) attribute

* Revert "Revert "[Trace] Distinguish between `create` and `create2` (#11311)" (#11427)"

This reverts commit 5d4993b.

* trace: backwards compatible call_type and creation_method

* trace: add rlp backward compatibility tests

* cleanup

* i know, i hate backwards compatibility too

* address review grumbles
s3krit added a commit that referenced this pull request Feb 5, 2020
* update classic testnet bootnodes (#11398)

* update classic testnet bootnodes

* Update kotti.json

* Update kotti.json

* Update kotti.json

* Update mordor.json

* verification: fix race same block + misc (#11400)

* ethcore: fix race in verification

* verification: fix some nits

* verification: refactor err type `Kind::create`

* fix: tests

* address grumbles

* address grumbles: don't panic

* fix: export hardcoded sync format (#11416)

* fix: export hardcoded sync format

* address grumbles

* make tests compile with rustc_hex 2.0

* fix grumbles: impl LowerHex for encoded Header

* goerli: replace foundation bootnode (#11433)

* Remove dead bootnodes, add new geth bootnodes (#11441)

* update kvdb-rocksdb to 0.4 (#11442)

* Avoid long state queries when serving GetNodeData requests (#11444)

* Remove dead bootnodes, add new geth bootnodes

* More granular locking when fetching state
Finish GetDataNode requests early if queries take too long

* typo

* Use latest kvdb-rocksdb

* Cleanup

* Update ethcore/sync/src/chain/supplier.rs

Co-Authored-By: Andronik Ordian <write@reusable.software>

* Address review grumbles

* Fix compilation

* Address review grumbles

Co-authored-by: Andronik Ordian <write@reusable.software>

* rlp_derive: cleanup (#11446)

* rlp_derive: update syn & co

* rlp_derive: remove dummy_const

* rlp_derive: remove unused attirubutes

* rlp-derive: change authors

* Cargo.lock: cargo update -p kvdb-rocksdb (#11447)

* Cargo.lock: new lockfile format

Manual backport of #11448

* gcc to clang (#11453)

* gcc to clang

test
```
export CC="sccache "$CC
export CXX="sccache "$CXX
```
darwin build
```
CC=clang
CXX=clang
```

* darwin - > default clang

* Bump version and CHANGELOG.md

* chore: remove unused dependencies (#11432)

* fix: compiler warnings

* chore: remove unused dependencies

* Update CHANGELOG.md

* update Cargo.lock

* update CHANGELOG.md

* backwards compatible call_type creation_method (#11450)

* rlp_derive: update syn & co

* rlp_derive: remove dummy_const

* rlp_derive: remove unused attirubutes

* rlp-derive: change authors

* rlp_derive: add rlp(default) attribute

* Revert "Revert "[Trace] Distinguish between `create` and `create2` (#11311)" (#11427)"

This reverts commit 5d4993b.

* trace: backwards compatible call_type and creation_method

* trace: add rlp backward compatibility tests

* cleanup

* i know, i hate backwards compatibility too

* address review grumbles

* update CHANGELOG.md

* just to make sure we don't screw up this again (#11455)

* Update CHANGELOG.md

Co-authored-by: Talha Cross <47772477+soc1c@users.noreply.github.com>
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: David <dvdplm@gmail.com>
Co-authored-by: Andronik Ordian <write@reusable.software>
Co-authored-by: Denis S. Soldatov aka General-Beck <general.beck@gmail.com>
dvdplm added a commit that referenced this pull request Feb 8, 2020
…pstream

* master:
  upgrade some of the dependencies (#11467)
  Some more release track changes to README.md (#11465)
  Update simple one-line installer due to switching to a single stable release track (#11463)
  update Dockerfile (#11461)
  Implement EIP-2124 (#11456)
  [eth classic chainspec]: remove `balance = 1` (#11459)
  just to make sure we don't screw up this again (#11455)
  backwards compatible call_type creation_method (#11450)
  gcc to clang (#11453)
  Avoid copies (#11451)
  Cargo.lock: cargo lock translate (#11448)
dvdplm added a commit that referenced this pull request Feb 10, 2020
* master:
  [eth classic chainspec]: remove `balance = 1` (#11459)
  just to make sure we don't screw up this again (#11455)
  backwards compatible call_type creation_method (#11450)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-pleasereview 🤓 Pull request needs code review. B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants