-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Conversation
e28fbb5
to
775c967
Compare
ethcore/src/executive.rs
Outdated
params: &ActionParams, | ||
blocknumber: BlockNumber, | ||
) -> Box<vm::Vm> { | ||
if machine.supports_wasm(blocknumber) && params.code.as_ref().map_or(false, |code| code.len() > 4 && &code[0..4] == WASM_MAGIC_NUMBER) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this change at all. The if
statement that we have right now is terrible and this change makes it even worse. This function/interface needs to be completely reworked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, perhaps it should just go to vm_factory
? This function seems to be another factory that delegates to vm_factory
in case it's not wasm.
vm_factory.create(params.gas, params.code, blocknumber)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to go this way, but last time I checked it was just not possible for some reason I can't recall. perhaps I should try again and find this reason again
ethcore/Cargo.toml
Outdated
@@ -70,6 +70,9 @@ unexpected = { path = "../util/unexpected" } | |||
journaldb = { path = "../util/journaldb" } | |||
tempdir = "0.3" | |||
|
|||
[dev-dependencies] | |||
wabt = "0.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refuse pulling a huge c++ dependency to ethcore as a mandatory dependency. It needs to be do differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not mandatory, it's only for running tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's mandatory for everyone working on daily basis on the project. It adds cmake
with all of it's burden to our toolchain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np, but it will be just bytecode dump as a test
we already have c++ build tools prerequisites by the way (rocksdb will be first notable example), they just don't use cmake crate directly and instead use some obscure build scripts, so this cmake reference does not add anything to the list instead of one-time compilation of wabt
"eip211Transition": 5067000, | ||
"eip214Transition": 5067000, | ||
"eip658Transition": 5067000, | ||
"wasmActivation": 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention seems to be *Transition
, would keep it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"wasmTransition" might imply that evm no longer works, i think it's not the best convention in this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe enableWasmTransition
or supportWasmTransition
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both enableWasmTransition
and supportWasmTransition
imply the possibilty of such transition at all, not some blocknumber where it is activated
it is not really about transition as eip-s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supportWasmTransition
and enableWasmTransition
implies for me that wasm is supported
or wasm is enabled
starting at some block. Similar to how eip658Transition
implies that eip658
is active at some point (it doesn't disable any previous eips).
That said my main reason is to complain is to keep the naming consistent here, if in the future we support a fork to wasm-only network we can either have: wasmOnlyTransition
or disableEvmTransition
there. Introducing another convention will make the file even messier imho.
ethcore/src/machine.rs
Outdated
@@ -377,8 +377,8 @@ impl EthereumMachine { | |||
} | |||
|
|||
/// If this machine supports wasm. | |||
pub fn supports_wasm(&self) -> bool { | |||
self.params().wasm | |||
pub fn supports_wasm(&self, blocknumber: BlockNumber) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a separate public method for that? perhaps use Schedule
directly on the call site.
ethcore/src/spec/spec.rs
Outdated
@@ -111,6 +111,8 @@ pub struct CommonParams { | |||
pub remove_dust_contracts: bool, | |||
/// Wasm support | |||
pub wasm: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is that needed? Seems that it's just wasmTransition: 0
. We already did breaking changes to spec files in the past, we should just highlight that in the release notes.
ethcore/vm/src/action_params.rs
Outdated
@@ -112,6 +112,14 @@ impl Default for ActionParams { | |||
} | |||
} | |||
|
|||
impl ActionParams { | |||
pub fn from_origin(mut self, address: Address) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be used only for tests, might be misleading to include it everwhere in the code.
ethcore/vm/src/schedule.rs
Outdated
@@ -113,6 +113,8 @@ pub struct Schedule { | |||
pub kill_dust: CleanDustMode, | |||
/// Enable EIP-86 rules | |||
pub eip86: bool, | |||
/// Is wasm active | |||
pub wasm_activated: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe wasm: Option<WasmCosts>
will be more future proof?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do you imagine this line then:
if self.wasm || block_number >= self.wasm_activation {
schedule.wasm_activated = true;
}
in CommonParams::update_schedule
schedule.wasm = Some(...<WHAT?>)
?
where the prices will be held until they are suddenly active?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the second thought, no need to keep them, they can be just default :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, they can be default for now, but later probably come from spec (that's why I suggested merging them with the flag).
ethcore/src/executive.rs
Outdated
params: &ActionParams, | ||
blocknumber: BlockNumber, | ||
) -> Box<vm::Vm> { | ||
if machine.supports_wasm(blocknumber) && params.code.as_ref().map_or(false, |code| code.len() > 4 && &code[0..4] == WASM_MAGIC_NUMBER) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, perhaps it should just go to vm_factory
? This function seems to be another factory that delegates to vm_factory
in case it's not wasm.
vm_factory.create(params.gas, params.code, blocknumber)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two more minor grumbles. Looks good otherwise.
@@ -79,8 +79,8 @@ impl vm::Vm for WasmInterpreter { | |||
&wasmi::ImportsBuilder::new().with_resolver("env", &instantiation_resolover) | |||
).map_err(Error)?; | |||
|
|||
let adjusted_gas = params.gas * U256::from(ext.schedule().wasm.opcodes_div) / | |||
U256::from(ext.schedule().wasm.opcodes_mul); | |||
let adjusted_gas = params.gas * U256::from(ext.schedule().wasm().opcodes_div) / |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each call to ext.schedule()
is virtual, can we cache it in a variable somewhere at the top?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, it's mutably borrows self all the way down the end of the function few times
I think it will be also optimized / devirtualized anyway
ethcore/wasm/src/parser.rs
Outdated
vals.insert(rules::InstructionType::Store, schedule.wasm.mem as u32); | ||
vals.insert(rules::InstructionType::Div, schedule.wasm.div as u32); | ||
vals.insert(rules::InstructionType::Mul, schedule.wasm.mul as u32); | ||
vals.insert(rules::InstructionType::Load, schedule.wasm().mem as u32); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering, maybe all these methods could just do with WasmCost
instead of entire schedule?
Prefer to put this in after #7605 -- should be easier to merge this on top (if it even has conflicts, which I'm not sure of actually) |
@@ -0,0 +1,74 @@ | |||
{ | |||
"name": "Kovan", | |||
"dataDir": "kovan", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these should reflect the test-ness of the spec
}, | ||
"nodes": [ | ||
"enode://56abaf065581a5985b8c5f4f88bd202526482761ba10be9bfdcd14846dd01f652ec33fde0f8c0fd1db19b59a4c04465681fcef50e11380ca88d25996191c52de@40.71.221.215:30303", | ||
"enode://d07827483dc47b368eaf88454fb04b41b7452cf454e194e2bd4c14f98a3278fed5d819dbecd0d010407fc7688d941ee1e58d4f9c6354d3da3be92f55c17d7ce3@52.166.117.77:30303", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are these bootnodes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's just copy from kovan.json
ethcore/vm/src/tests.rs
Outdated
@@ -85,6 +85,11 @@ impl FakeExt { | |||
ext.schedule = Schedule::new_byzantium(); | |||
ext | |||
} | |||
|
|||
pub fn with_wasm(mut self) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc-string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
json/src/spec/params.rs
Outdated
@@ -117,6 +115,11 @@ pub struct Params { | |||
/// Transaction permission contract address. | |||
#[serde(rename="transactionPermissionContract")] | |||
pub transaction_permission_contract: Option<Address>, | |||
/// Wasm support flag | |||
pub wasm: Option<bool>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it still needed? What if it's set to wasm: true && wasm_activiation_transition: 500
is it activated right away or at block 500
?
IMHO we should keep spec files clean (even if it requires a migration of existing spec files), especially given wasm
was always experimental to date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, not needed, probably should mention that it requires to change in json spec to replace
wasm: true
with wasmActivationTransition: "0x0"
|
||
impl VmFactory { | ||
pub fn create(&self, params: &ActionParams, schedule: &Schedule) -> Box<Vm> { | ||
if schedule.wasm.is_some() && params.code.as_ref().map_or(false, |code| code.len() > 4 && &code[0..4] == WASM_MAGIC_NUMBER) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does WASM work with gas > u64::max_value()
? I think I saw couple of low_u64
calls below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will fail later in the vm itself:
https://github.com/paritytech/parity/blob/master/ethcore/wasm/src/lib.rs#L85
* kovan fork code * introduce ethcore level vm_factory and let it fail * fix json tests * wasmcosts as option * review changes * wasm costs in parser * fix evm tests * review fixes * fix test * remove redundant json field
* kovan fork code * introduce ethcore level vm_factory and let it fail * fix json tests * wasmcosts as option * review changes * wasm costs in parser * fix evm tests * review fixes * fix test * remove redundant json field
* ECIP 1041 - Remove Difficulty Bomb (#7905) Enable difficulty bomb defusion at block: - 5900000 on Ethereum Classic mainnet, - 2300000 on morden testnet. Reference: https://github.com/ethereumproject/ECIPs/blob/master/ECIPs/ECIP-1041.md * spec: Validate required divisor fields are not 0 (#7933) * Add validate_non_zero function It's used to validate that a Spec's uint field used as a divisor is not zero. * Add deserialize_with to gas_limit_bound_divisor Prevents panics due to divide-by-zero on the gas_limit_bound_divisor field. * Add deserialize_with to difficulty_bound_divisor Prevents panics due to divide-by-zero on the difficulty_bound_divisor field. * Add validate_optional_non_zero function Used to validate Option<Uint> divisor fields. * Use deserialize_with on optional divisor fields. * Add #[serde(default)] attribute to divisor fields When using `#[serde(deserialize_with)]`, `#[serde(default)]` must be specified so that missing fields can be deserialized with the deserializer for `None`. * Kovan WASM fork code (#7849) * kovan fork code * introduce ethcore level vm_factory and let it fail * fix json tests * wasmcosts as option * review changes * wasm costs in parser * fix evm tests * review fixes * fix test * remove redundant json field
in chainspec json files, there is a breaking change with wasm flag, one should replace
wasm: true
withwasmActivationTransition: "0x0"