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

EIP-116 (214), #4833 #4851

Merged
merged 1 commit into from
Jun 19, 2017
Merged

EIP-116 (214), #4833 #4851

merged 1 commit into from
Jun 19, 2017

Conversation

debris
Copy link
Collaborator

@debris debris commented Mar 10, 2017

Everything should be working, but there are no tests. Opened a pr to test all existing tests && to get second pair of eyes on this code.

side-notes, executive / externalities types need to be decoupled from ipc types. I got the impression that some global imports are misused and it's quite annoying

@debris debris added A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. M4-core ⛓ Core client code / Rust. labels Mar 10, 2017
@debris debris requested a review from tomusdrw March 10, 2017 09:56
instruction: instruction
});
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

after looking at Arkadiy eip86, I guess this should be under verify_instruction

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.

Couple of issues noted.

Also one thing bothers me:
I think currently STATICCALL will kill empty accounts when it touches them - that is arguably a state alteration. Since we don't allow empty accounts to be created any more it shouldn't cause a problem if there are no empty accounts already existing on chain, but nevertheless I think we should either avoid killing empty accounts in such case or clarify that in the specification.

@@ -352,7 +352,7 @@ pub fn get_temp_state_db() -> GuardedTempResult<StateDB> {

impl MiningBlockChainClient for TestBlockChainClient {
fn latest_schedule(&self) -> Schedule {
Schedule::new_post_eip150(24576, true, true, true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMHO this is reaching a point where a struct would look much better than the 4 boolean flags.

Schedule::new_post_eip150(PostEip150 {
   max_code_size: 24576,
   fix_exp: true,
   no_empty: true,
   kill_empty: true,
   static_call: true,
});

Copy link
Collaborator Author

@debris debris Mar 10, 2017

Choose a reason for hiding this comment

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

I will change that after #4697 is merged, cause includes the same changes

Copy link
Collaborator

Choose a reason for hiding this comment

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

@@ -94,15 +94,15 @@ pub trait Ext {
fn extcodesize(&self, address: &Address) -> trie::Result<usize>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't all functions here return evm::Result instead of trie::Result?

Copy link
Collaborator Author

@debris debris Mar 10, 2017

Choose a reason for hiding this comment

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

I agree, it visually looks better 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Really it should be an associated type Error. Externalities are lower level than the machine itself, so it doesn't make that much sense to return an evm::Result there.

@@ -253,13 +259,17 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
// backup used in case of running out of gas
self.state.checkpoint();

trace!("Executive::call(params={:?}) self.env_info={:?}", params, self.info);
if (params.call_type == CallType::StaticCall || self.static_flag) && params.value.value() > 0.into() {
return Err(evm::Error::MutableCallInStaticContext);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Two issues:

  1. Shouldn't such calls be traced anyway?
  2. Seems that state.checkpoint is being made, but since we are not enacting_result it will not be reverted, is that correct?

@@ -359,6 +369,10 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
// backup used in case of running out of gas
self.state.checkpoint();

if params.call_type == CallType::StaticCall || self.static_flag {
return Err(evm::Error::MutableCallInStaticContext);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same issues with tracing and state.checkpoint()

@@ -292,14 +292,21 @@ impl<Cost: CostType> Interpreter<Cost> {
}
};
},
instructions::CALL | instructions::CALLCODE | instructions::DELEGATECALL => {
instructions::CALL | instructions::CALLCODE | instructions::DELEGATECALL | instructions::STATICCALL => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that gas calculation for staticcall is not implemented (I suppose it should be the same as for CALL)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks for pointing that out!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

imo, it actually should be the same as DELEGATECALL, since we are not creating new accounts, nor transfering value

@debris debris changed the title EIP-214, #4833 EIP-116 (214), #4833 Mar 10, 2017
@debris debris added A0-pleasereview 🤓 Pull request needs code review. and removed A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. labels Mar 10, 2017
@debris debris dismissed tomusdrw’s stale review March 10, 2017 13:14

applied requested changes

@arkpar arkpar mentioned this pull request Mar 10, 2017
12 tasks
@@ -23,6 +23,7 @@
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"eip116Transition": "0x7fffffffffffff",
Copy link
Contributor

Choose a reason for hiding this comment

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

stick to 0x7fffffffffffffff for consistency

@@ -23,6 +23,7 @@
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"eip116Transition": "0x7fffffffffffff",
Copy link
Contributor

Choose a reason for hiding this comment

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

as above

stack.pop_back();
let call_gas = provided.expect("`provided` comes through Self::exec from `Gasometer::get_gas_cost_mem`; `gas_gas_mem_cost` guarantees `Some` when instruction is `CALL`/`CALLCODE`/`DELEGATECALL`/`CREATE`; this is one of `CALL`/`CALLCODE`/`DELEGATECALL`; qed");
let code_address = stack.pop_back();
let code_address = u256_to_address(&code_address);

let value = if instruction == instructions::DELEGATECALL {
let value = if instruction == instructions::DELEGATECALL || instruction == instructions::STATICCALL {
Copy link
Contributor

Choose a reason for hiding this comment

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

double after ==

@gavofyork gavofyork added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Mar 30, 2017
@@ -250,6 +256,13 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
tracer: &mut T,
vm_tracer: &mut V
) -> evm::Result<U256> where T: Tracer, V: VMTracer {
trace!("Executive::call(params={:?}) self.env_info={:?}", params, self.info);
if (params.call_type == CallType::StaticCall || self.static_flag) && params.value.value() > 0.into() {
Copy link
Contributor

Choose a reason for hiding this comment

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

params are for this call, no? in which case, if this call type is StaticCall (or DelegateCall, for that matter) then it should be fine even if it is a static context (static_flag == true)

@gavofyork gavofyork added A4-gotissues 💥 Pull request is reviewed and has significant issues which must be addressed. and removed A8-looksgood 🦄 Pull request is reviewed well. labels Mar 30, 2017
@gavofyork
Copy link
Contributor

@tomusdrw we'll have to see how the yellow paper prefers it. i think it'll end up being easier to consider STATIC_CALL as "touching" accounts, even if it's not allowing direct state changes.

@gavofyork gavofyork closed this Mar 30, 2017
@gavofyork gavofyork reopened this Mar 30, 2017
@debris
Copy link
Collaborator Author

debris commented Mar 30, 2017

@gavofyork touching accounts has been already clarified -> ethereum/EIPs#214 (comment)

my Yellow Paper PR would also kill dead accounts that are touched during a STATICCALL ethereum/yellowpaper#270

@arkpar arkpar force-pushed the eip214 branch 2 times, most recently from edba366 to debc1e2 Compare May 31, 2017 11:55
@arkpar arkpar added A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. and removed A4-gotissues 💥 Pull request is reviewed and has significant issues which must be addressed. labels May 31, 2017
@arkpar arkpar added the A0-pleasereview 🤓 Pull request needs code review. label Jun 14, 2017
@arkpar arkpar removed the A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. label Jun 14, 2017
pub fn apply_params(&mut self, block_number: u64, params: &CommonParams) {
self.have_create2 = block_number >= params.eip86_transition;
self.have_revert = block_number >= params.eip140_transition;
self.have_static_call = block_number >= params.eip214_transition;
Copy link
Contributor

Choose a reason for hiding this comment

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

nice, this is better than have_metropolis_instructions

self.state.set_storage(&self.origin_info.address, key, value)
fn set_storage(&mut self, key: H256, value: H256) -> evm::Result<()> {
if self.static_flag {
Err(evm::Error::MutableCallInStaticContext)
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be interesting if the static mode just had immutable references so mutable calls could literally not be made -- but this works too.

@rphmeier
Copy link
Contributor

LGTM, but tests would be nice.

@rphmeier rphmeier added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jun 16, 2017
@gavofyork gavofyork merged commit 575c51f into master Jun 19, 2017
@gavofyork gavofyork deleted the eip214 branch June 19, 2017 09:41
self.have_revert = block_number >= params.eip140_transition;
self.have_static_call = block_number >= params.eip214_transition;
if block_number >= params.eip210_transition {
self.blockhash_gas = 350;

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks, added to #5855

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. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants