This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Merged
EIP-116 (214), #4833 #4851
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! Cost schedule and other parameterisations for the EVM. | ||
use spec::CommonParams; | ||
|
||
/// Definition of the cost schedule and other parameterisations for the EVM. | ||
pub struct Schedule { | ||
|
@@ -105,6 +106,8 @@ pub struct Schedule { | |
pub kill_empty: bool, | ||
/// Blockhash instruction gas cost. | ||
pub blockhash_gas: usize, | ||
/// Static Call opcode enabled. | ||
pub have_static_call: bool, | ||
} | ||
|
||
impl Schedule { | ||
|
@@ -119,12 +122,12 @@ impl Schedule { | |
} | ||
|
||
/// Schedule for the post-EIP-150-era of the Ethereum main net. | ||
pub fn new_post_eip150(max_code_size: usize, fix_exp: bool, no_empty: bool, kill_empty: bool, have_metropolis_instructions: bool) -> Schedule { | ||
pub fn new_post_eip150(max_code_size: usize, fix_exp: bool, no_empty: bool, kill_empty: bool) -> Schedule { | ||
Schedule { | ||
exceptional_failed_code_deposit: true, | ||
have_delegate_call: true, | ||
have_create2: have_metropolis_instructions, | ||
have_revert: have_metropolis_instructions, | ||
have_create2: false, | ||
have_revert: false, | ||
stack_limit: 1024, | ||
max_depth: 1024, | ||
tier_step_gas: [0, 2, 3, 5, 8, 10, 20, 0], | ||
|
@@ -163,13 +166,36 @@ impl Schedule { | |
sub_gas_cap_divisor: Some(64), | ||
no_empty: no_empty, | ||
kill_empty: kill_empty, | ||
blockhash_gas: if have_metropolis_instructions { 350 } else { 20 }, | ||
blockhash_gas: 20, | ||
have_static_call: false, | ||
} | ||
} | ||
|
||
/// Schedule for the Metropolis era from common spec params. | ||
pub fn from_params(block_number: u64, params: &CommonParams) -> Schedule { | ||
let mut schedule = Schedule::new_post_eip150(usize::max_value(), true, true, true); | ||
schedule.apply_params(block_number, params); | ||
schedule | ||
} | ||
|
||
/// Apply common spec config parameters to the schedule. | ||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice, this is better than |
||
if block_number >= params.eip210_transition { | ||
self.blockhash_gas = 350; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the new gas cost is 800. https://github.com/ethereum/EIPs/pull/210/files#diff-e02a92c2fb96c1a1bfb05e4c6e2ef5daR42 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks, added to #5855 |
||
} | ||
} | ||
|
||
/// Schedule for the Metropolis of the Ethereum main net. | ||
pub fn new_metropolis() -> Schedule { | ||
Self::new_post_eip150(24576, true, true, true, true) | ||
let mut schedule = Self::new_post_eip150(24576, true, true, true); | ||
schedule.have_create2 = true; | ||
schedule.have_revert = true; | ||
schedule.have_static_call = true; | ||
schedule.blockhash_gas = 350; | ||
schedule | ||
} | ||
|
||
fn new(efcd: bool, hdc: bool, tcg: usize) -> Schedule { | ||
|
@@ -217,6 +243,7 @@ impl Schedule { | |
no_empty: false, | ||
kill_empty: false, | ||
blockhash_gas: 20, | ||
have_static_call: false, | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 seems that gas calculation for
staticcall
is not implemented (I suppose it should be the same as forCALL
)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.
thanks for pointing that out!
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.
imo, it actually should be the same as
DELEGATECALL
, since we are not creating new accounts, nor transfering value