-
Notifications
You must be signed in to change notification settings - Fork 982
feat: Gas params #3132
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
Merged
Merged
feat: Gas params #3132
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
da31f27
dyn gas table
rakita 479c9dc
continuation of work
rakita 8e5b4fe
rename to GasParams
rakita 0eaacda
gas params
rakita fbed8f4
sstore_dyn and sstore refund
rakita 470192d
continuation, first test passing
rakita 54f11f1
cleanup prints
rakita ab5b80d
fix selfdestruct
rakita d594d7f
run-tests keep-going, fixes to pass tests
rakita ee1073e
rename to gas params, sstore/call fixes
rakita a161465
fix balance
rakita 9184127
Merge remote-tracking branch 'origin/main' into rakita/gas-params
rakita d2aee56
cache on spec change
rakita f9097b5
use instruction gas params
rakita 6cdad9a
fix tests
rakita 3d6e8a8
fix tests
rakita f74afcb
fix tests
rakita ca2bb6b
fix tests
rakita 2da26ed
fix doc
rakita e5f12bf
fmt
rakita 697e1d1
cleanup
rakita 89c589e
Merge remote-tracking branch 'origin/main' into rakita/gas-params
rakita 46f3226
Merge remote-tracking branch 'origin/main' into gasparams
rakita fdf606d
cleanup
rakita 42fdec6
move first values to table
rakita ab210c0
cleanup
rakita b495901
Apply suggestion from @rakita
rakita dbfd6e9
Apply suggestions from code review
rakita ce4f3e7
Apply suggestion from @rakita
rakita 6e31ece
Apply suggestion from @rakita
rakita 403f28f
Add GasId struct
rakita 563c3bd
nits
rakita e6d9b74
copilot nits
rakita d54bcdd
Merge remote-tracking branch 'origin/main' into gasparams
rakita 0ee23df
Merge remote-tracking branch 'origin/main' into gasparam
rakita 53141bd
nit, use resize_memory macro in place of fn
rakita 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| use crate::instructions::InstructionProvider; | ||
| use crate::{ | ||
| evm::FrameTr, | ||
| execution, post_execution, | ||
|
|
@@ -98,13 +99,23 @@ pub trait Handler { | |
| &mut self, | ||
| evm: &mut Self::Evm, | ||
| ) -> Result<ExecutionResult<Self::HaltReason>, Self::Error> { | ||
| self.configure(evm); | ||
|
Collaborator
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. will this not work properly now for any impl overriding this trait? i don't think this is acceptable and we need to either hide this deeper or make it so this change is obvious from compilation issues after the bump |
||
| // Run inner handler and catch all errors to handle cleanup. | ||
| match self.run_without_catch_error(evm) { | ||
| Ok(output) => Ok(output), | ||
| Err(e) => self.catch_error(evm, e), | ||
| } | ||
| } | ||
|
|
||
| /// Configure the handler: | ||
| /// * Set Instruction gas table to the spec id. | ||
| #[inline] | ||
| fn configure(&mut self, evm: &mut Self::Evm) { | ||
| let spec_id = evm.ctx().cfg().spec().into(); | ||
| // sets static gas depending on the spec id. | ||
| evm.ctx_instructions().1.set_spec(spec_id); | ||
| } | ||
|
|
||
| /// Runs the system call. | ||
| /// | ||
| /// System call is a special transaction where caller is a [`crate::SYSTEM_ADDRESS`] | ||
|
|
@@ -126,6 +137,8 @@ pub trait Handler { | |
| ) -> Result<ExecutionResult<Self::HaltReason>, Self::Error> { | ||
| // dummy values that are not used. | ||
| let init_and_floor_gas = InitialAndFloorGas::new(0, 0); | ||
| // configure the evm for system call. | ||
| self.configure(evm); | ||
| // call execution and than output. | ||
| match self | ||
| .execution(evm, &init_and_floor_gas) | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
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.
can
gas_paramsnot be part of theContext?this should allow us to avoid any changes to
InstructionProviderand to the frame init logic which now propagate theGasParamsquite deeply just to set theinterpreterfield while this is technically an externally provided contextit would also only retain the actual dynamic runtime data in
InterpretertypeThere 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.
this also makes me wonder if
GasParamscould be entirely hidden inside of theInstructionProvider? so that I just do something likeEthInstructions::new(gas_params)and it produces an instruction table that uses my gas params?