-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create pure_call.md #195
Closed
Closed
Create pure_call.md #195
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
### Parameters | ||
|
||
* BASE_GAS_COST: 80 | ||
* CODE_BYTES_PER_GAS: 15 | ||
|
||
### Specification | ||
|
||
At `0xf5`, add an opcode `PURE_CALL` that takes seven arguments from the stack: GAS, CODESTART, CODELENGTH, DATASTART, DATALENGTH, OUTPUTSTART, OUTPUTLENGTH. | ||
|
||
Let: | ||
|
||
* `gas_cost = BASE_GAS_COST + floor(CODELENGTH / CODE_BYTES_PER_GAS)`. | ||
* `input_gas` be the remaining gas in the current context, minus gas costs for expanding memory to cover the three memory slices given above. | ||
|
||
Fail if `input_gas < gas_cost` or if `CODELENGTH > 24000`; otherwise execute a call with code equal to the memory slice `CODESTART...CODESTART + CODELENGTH - 1`, input data equal to the memory slice `DATASTART...DATASTART + DATALENGTH - 1`, gas equal to `min(GAS, (input_gas - gas_cost) - floor((input_gas - gas_cost) / 64))` and value 0. The inner context may NOT read state, write state or make any sub-calls except to non-state-changing precompiles; any attempt to do so throws an exception. If execution succeeds, fill the memory slice `OUTPUTSTART...OUTPUTSTART + OUTPUTLENGTH - 1` with the return data with similar rules to how this is handled in CALL, CALLCODE and DELEGATECALL, and push 1 onto the stack. If execution fails, push 0 onto the stack. | ||
|
||
### Rationale | ||
|
||
This is useful for: | ||
|
||
* Adding functional programming features for higher-level languages | ||
* Generally allowing for forms of computation that are safer and can be efficiently optimized/memoized due to their state-independence | ||
* Processing validation code for Casper validators in the future | ||
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. Please waive the copyright with CC0. |
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.
Assuming we want to switch to EVM 1.5 - is that really the amount of gas we want to charge? Or shall we completely revise the scheme with 1.5?
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 revisions do you have in mind?
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.
Perhaps to add some more explanation: In EVM1.5, code that is about to be executed needs to be analyzed and sightly processed first. For regular contracts, this is done once at creation time and we can use the gas from the code deposit to pay for this preprocessing. Here, 15 bytes per gas could be too low for that.
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.
Agreed. Not sure what the right amount is, as the preprocessing can run from simple validation to full compilation.