Skip to content

Commit

Permalink
Upgrade OpenEthereum from 2.6.8 to 2.7.2. (#3506) (#3595)
Browse files Browse the repository at this point in the history
As the next step in #3506, and following up from #3542 and #3558, upgrade Parity Ethereum (now OpenEthereum) from [2.6.8] (Dec 2019) to [2.7.2] (Feb 2020), the last release in the 2.x series.

This harmonizes our dependency graph with upstream, fixing numerous build errors from the upgrade and eliminating multiple versions of the same crates. This concerns the [bn], [ethabi], [ethabi-contract], [ethabi-derive], [ethereum-types], [keccak-hash], [primitive-types], and [uint] crates as well as their transitive dependencies and their interdependencies.

The [near/bn] fork exists to upgrade [bn]'s [rand] dependency. That's necessary because of a particularly complex dependency issue (rust-random/rand#645) in old versions of rand. We will eliminate the fork going forward once upstream upgrades their dependency (I will open a pull request for them).

The upstream changelog for 2.7.2 is at: https://github.com/openethereum/openethereum/blob/v2.7.2/CHANGELOG.md

The upstream diff from 2.6.8 to 2.7.2 is at: openethereum/openethereum@v2.6.8...v2.7.2

[2.6.8]: https://github.com/openethereum/openethereum/releases/tag/v2.6.8
[2.7.2]: https://github.com/openethereum/openethereum/releases/tag/v2.7.2

[near/bn]: https://github.com/near/bn
[bn]: https://crates.io/crates/bn
[ethabi]: https://crates.io/crates/ethabi
[ethabi-contract]: https://crates.io/crates/ethabi-contract
[ethabi-derive]: https://crates.io/crates/ethabi-derive
[ethereum-types]: https://crates.io/crates/ethereum-types
[keccak-hash]: https://crates.io/crates/keccak-hash
[primitive-types]: https://crates.io/crates/primitive-types
[rand]: https://crates.io/crates/rand
[uint]: https://crates.io/crates/uint
  • Loading branch information
artob authored Nov 12, 2020
1 parent 2b3583a commit 8a45140
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 187 deletions.
239 changes: 103 additions & 136 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion chain/epoch_manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ rand = "0.7"
serde = { version = "1", features = [ "derive" ] }
serde_json = "1"
smart-default = "0.6"
primitive-types = { version = "0.7", default-features = false }
primitive-types = "0.6"
num-rational = "0.2.4"

near-crypto = { path = "../../core/crypto" }
Expand Down
2 changes: 1 addition & 1 deletion core/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ reed-solomon-erasure = "4"
jemallocator = { version = "0.3", optional = true }
hex = "0.4"
num-rational = "0.2.4"
primitive-types = { version = "0.7", default-features = false }
primitive-types = "0.6"
lazy_static = "1.4"

borsh = "0.7.1"
Expand Down
36 changes: 22 additions & 14 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@ targets = [
[bans]
multiple-versions = "deny"
deny = [
# See: https://github.com/rust-random/rand/issues/645
{ name = "rand", version = "<0.6" },

# See: https://github.com/near/nearcore/pull/3595
{ name = "ethabi", version = "<9.0.1" },
{ name = "ethabi-contract", version = "<9.0.0" },
{ name = "ethabi-derive", version = "<9.0.1" },
{ name = "ethereum-types", version = "<0.8.0" },
{ name = "keccak-hash", version = "<0.4.1" },
{ name = "primitive-types", version = "<0.6.2" },
{ name = "uint", version = "<0.8.2" },
]

skip = [
# actix 0.9.0 still uses it
{ name = "tokio-util", version = "=0.2.0" },
Expand Down Expand Up @@ -56,21 +68,17 @@ skip = [

# evm support has some legacy. Updating it fails at this point.
# to fully update, need to fork half of parity libraries, as they stopped development.
{ name = "unicode-xid", version = "=0.1.0" },
{ name = "uint", version = "=0.7.1" },
{ name = "syn", version = "=0.15.44" },
{ name = "static_assertions", version = "=0.2.5" },
# See: https://github.com/near/nearcore/issues/3506
{ name = "digest", version = "=0.8.1" },
{ name = "elastic-array", version = "=0.10.3" },
{ name = "impl-serde", version = "=0.2.3" },
{ name = "num-bigint", version = "=0.2.6" },
{ name = "parking_lot", version = "=0.11.0" },
{ name = "parking_lot_core", version = "=0.6.2" },
{ name = "smallvec", version = "=0.6.13" },
{ name = "rustc-hex", version = "=1.0.0" },
{ name = "rand", version = "=0.5.6" },
{ name = "quote", version = "=0.6.13" },
{ name = "proc-macro2", version = "=0.4.30" },
{ name = "primitive-types", version = "=0.3.0" },
{ name = "num-bigint", version = "=0.2.6" },
{ name = "fixed-hash", version = "=0.3.2" },
{ name = "elastic-array", version = "=0.10.3" },
{ name = "digest", version = "=0.8.1" },
{ name = "arrayvec", version = "=0.4.12" },
{ name = "quote", version = "=0.6.13" },
{ name = "rustc-hex", version = "=1.0.0" },
{ name = "smallvec", version = "=0.6.13" },
{ name = "syn", version = "=0.15.44" },
{ name = "unicode-xid", version = "=0.1.0" },
]
16 changes: 8 additions & 8 deletions runtime/near-evm-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ enum-primitive-derive = "0.2"
sha2 = ">=0.8,<0.10"
sha3 = "0.8"
rlp = "0.4.2"
keccak-hash = "0.2.0"
keccak-hash = "0.4.1"
ripemd160 = "0.9.0"
libsecp256k1 = "0.3.5"

evm = { git = "https://github.com/openethereum/openethereum", rev = "v2.6.8" }
vm = { git = "https://github.com/openethereum/openethereum", rev = "v2.6.8" }
bn = { git = "https://github.com/paritytech/bn", default-features = false }
evm = { git = "https://github.com/openethereum/openethereum", rev = "v2.7.2" }
vm = { git = "https://github.com/openethereum/openethereum", rev = "v2.7.2" }
bn = { git = "https://github.com/near/bn", branch = "upgrade-rand", rev = "43953916ed1a314b78320771734f36af77993dd9" }
parity-bytes = "0.1.0"
ethereum-types = "0.6.0"
ethereum-types = "0.8.0"

near-vm-logic = { path = "../near-vm-logic" }
near-vm-errors = { path = "../near-vm-errors" }
Expand All @@ -38,9 +38,9 @@ near-runtime-fees = { path = "../near-runtime-fees" }
derivative = "2.1.1"

[dev-dependencies]
ethabi = "8.0.0"
ethabi-contract = "8.0.0"
ethabi-derive = "8.0.0"
ethabi = "9.0.1"
ethabi-contract = "9.0.0"
ethabi-derive = "9.0.1"
lazy_static = "1.4"
lazy-static-include = "2.2.2"

Expand Down
20 changes: 11 additions & 9 deletions runtime/near-evm-runner/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use ethereum_types::{Address, U256};
use evm::{CreateContractAddress, Factory};
use near_runtime_fees::EvmCostConfig;
use vm::{
ActionParams, ActionValue, CallType, ContractCreateResult, ExecTrapResult, Ext, GasLeft,
ActionParams, ActionType, ActionValue, ContractCreateResult, ExecTrapResult, Ext, GasLeft,
MessageCallResult, ParamsType, ReturnData, Schedule,
};

Expand Down Expand Up @@ -91,16 +91,17 @@ pub fn _create<T: EvmState>(

let params = ActionParams {
code_address: *address,
code_hash: None,
code_version: U256::zero(),
address: *address,
sender: *sender,
origin: *origin,
gas: *gas,
gas_price: 1.into(),
value: ActionValue::Transfer(value),
code: Some(Arc::new(code.to_vec())),
code_hash: None,
data: None,
call_type: CallType::None,
action_type: ActionType::Create,
params_type: vm::ParamsType::Embedded,
};

Expand Down Expand Up @@ -145,7 +146,7 @@ pub fn call<T: EvmState>(
sender,
value,
call_stack_depth,
CallType::Call,
ActionType::Call,
contract_address,
contract_address,
input,
Expand Down Expand Up @@ -175,7 +176,7 @@ pub fn delegate_call<T: EvmState>(
sender,
None,
call_stack_depth,
CallType::DelegateCall,
ActionType::DelegateCall,
context,
delegee,
input,
Expand Down Expand Up @@ -204,7 +205,7 @@ pub fn static_call<T: EvmState>(
sender,
None,
call_stack_depth,
CallType::StaticCall,
ActionType::StaticCall,
contract_address,
contract_address,
input,
Expand All @@ -223,7 +224,7 @@ fn run_and_commit_if_success<T: EvmState>(
sender: &Address,
value: Option<U256>,
call_stack_depth: usize,
call_type: CallType,
call_type: ActionType,
state_address: &Address,
code_address: &Address,
input: &[u8],
Expand Down Expand Up @@ -284,7 +285,7 @@ fn run_against_state<T: EvmState>(
sender: &Address,
value: Option<U256>,
call_stack_depth: usize,
call_type: CallType,
call_type: ActionType,
state_address: &Address,
code_address: &Address,
input: &[u8],
Expand All @@ -307,6 +308,7 @@ fn run_against_state<T: EvmState>(
let mut params = ActionParams {
code_address: *code_address,
code_hash: None,
code_version: U256::zero(),
address: *state_address,
sender: *sender,
origin: *origin,
Expand All @@ -315,7 +317,7 @@ fn run_against_state<T: EvmState>(
value: ActionValue::Apparent(0.into()),
code: Some(Arc::new(code)),
data: Some(input.to_vec()),
call_type,
action_type: call_type,
params_type: ParamsType::Separate,
};

Expand Down
17 changes: 9 additions & 8 deletions runtime/near-evm-runner/src/near_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use keccak_hash::keccak;
use near_runtime_fees::EvmCostConfig;
use parity_bytes::Bytes;
use vm::{
CallType, ContractCreateResult, CreateContractAddress, EnvInfo, Error as VmError,
ActionType, ContractCreateResult, CreateContractAddress, EnvInfo, Error as VmError,
MessageCallResult, Result as EvmResult, ReturnData, Schedule, TrapKind,
};

Expand Down Expand Up @@ -142,6 +142,7 @@ impl<'a> vm::Ext for NearExt<'a> {
gas: &U256,
value: &U256,
code: &[u8],
_parent_version: &U256,
address_type: CreateContractAddress,
_trap: bool,
) -> Result<ContractCreateResult, TrapKind> {
Expand Down Expand Up @@ -179,10 +180,10 @@ impl<'a> vm::Ext for NearExt<'a> {
value: Option<U256>,
data: &[u8],
code_address: &Address,
call_type: CallType,
call_type: ActionType,
_trap: bool,
) -> Result<MessageCallResult, TrapKind> {
if self.is_static() && call_type != CallType::StaticCall {
if self.is_static() && call_type != ActionType::StaticCall {
panic!("MutableCallInStaticContext")
}

Expand All @@ -197,11 +198,11 @@ impl<'a> vm::Ext for NearExt<'a> {
}

let result = match call_type {
CallType::None => {
ActionType::Create | ActionType::Create2 => {
// Is not used.
return Err(TrapKind::Call(ActionParams::default()));
}
CallType::Call => interpreter::call(
ActionType::Call => interpreter::call(
self.sub_state,
&self.origin,
sender_address,
Expand All @@ -214,7 +215,7 @@ impl<'a> vm::Ext for NearExt<'a> {
&self.evm_gas_config,
self.chain_id,
),
CallType::StaticCall => interpreter::static_call(
ActionType::StaticCall => interpreter::static_call(
self.sub_state,
&self.origin,
sender_address,
Expand All @@ -225,11 +226,11 @@ impl<'a> vm::Ext for NearExt<'a> {
&self.evm_gas_config,
self.chain_id,
),
CallType::CallCode => {
ActionType::CallCode => {
// Call another contract using storage of the current contract. No longer used.
return Err(TrapKind::Call(ActionParams::default()));
}
CallType::DelegateCall => interpreter::delegate_call(
ActionType::DelegateCall => interpreter::delegate_call(
self.sub_state,
&self.origin,
sender_address,
Expand Down
2 changes: 1 addition & 1 deletion runtime/near-vm-errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ borsh = "0.7.1"

near-rpc-error-macro = { path = "../../tools/rpctypegen/macro", version = "0.1.0" }

ethereum-types = "0.6.0"
ethereum-types = "0.8.0"

[features]
dump_errors_schema = ["near-rpc-error-macro/dump_errors_schema"]
8 changes: 4 additions & 4 deletions runtime/runtime-params-estimator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ glob = "0.3.0"
walrus = "0.18.0"
near-evm-runner = { path = "../../runtime/near-evm-runner", features = ["costs_counting"] }
hex = "0.4"
ethabi = "8.0.0"
ethabi-contract = "8.0.0"
ethabi-derive = "8.0.0"
ethereum-types = "0.6.0"
ethabi = "9.0.1"
ethabi-contract = "9.0.0"
ethabi-derive = "9.0.1"
ethereum-types = "0.8.0"
lazy-static-include = "2.2.2"
num-traits = "0.2.12"

Expand Down
2 changes: 1 addition & 1 deletion runtime/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ num-rational = "0.2.4"
num-bigint = "0.2.6"
num-traits = "0.2.11"
hex = "0.4.2"
ethereum-types = "0.6.0"
ethereum-types = "0.8.0"

borsh = "0.7.1"

Expand Down
8 changes: 4 additions & 4 deletions test-utils/testlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ tempfile = "3"
assert_matches = "1.3"
num-rational = "0.2.4"
hex = "0.4"
ethabi = "8.0.0"
ethabi-contract = "8.0.0"
ethabi-derive = "8.0.0"
ethereum-types = "0.6.0"
ethabi = "9.0.1"
ethabi-contract = "9.0.0"
ethabi-derive = "9.0.1"
ethereum-types = "0.8.0"

borsh = "0.7.1"

Expand Down

0 comments on commit 8a45140

Please sign in to comment.