-
Notifications
You must be signed in to change notification settings - Fork 998
feat: EOF (Ethereum Object Format) #1143
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
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
7ea084a
eof
rakita cd523c3
Merge remote-tracking branch 'origin/main' into eof
rakita 237068f
feat(EOF): Header decoder
rakita fabdc1b
EofBody decode
rakita 4dd7d3a
Merge remote-tracking branch 'origin/main' into eof
rakita 2ff0f28
disable eof deprecated opcodes
rakita 20fcdaf
add eof instructions
rakita 22bf551
temp tests
rakita 318d775
Merge remote-tracking branch 'origin/main' into eof
rakita 33974b3
rjump instructions
rakita a638385
eof rjump with tests
rakita 2d14e04
Merge remote-tracking branch 'origin/main' into eof
rakita ad45264
EOF bytecode
rakita 2c29f1b
callf, retf, jumpf
rakita ecc4467
tests for callf,retf,jumpf
rakita 3979a12
small rename
rakita a440503
add dataload, dataloadn and datacopy opcodes
rakita cb3d93a
refactor calls
rakita 1dabca4
blueprint for creates
rakita 788182f
Merge remote-tracking branch 'origin/main' into eof
rakita 4354b6d
eof create inputs
rakita 207ad21
some wip
rakita dc07460
Merge remote-tracking branch 'origin/main' into eof
rakita 2e48462
add eofcreate structs and exccall flow
rakita 48abbe6
wip eofcreate code flow and handlers
rakita 9d8f612
fix tests
rakita 0fc345a
eof creates
rakita 862d85b
Merge remote-tracking branch 'origin/main' into eof
rakita fab521a
refactor eofcreate a little
rakita e5abe46
some work on extcall
rakita d3dd1a9
Merge remote-tracking branch 'origin/main' into eof
rakita 4aa166a
feat: refactor simplify CallInput, eof extcalls
rakita 449f243
feat: restructure OpCode and add stack input/output num
rakita 183adaf
add flags for stack_io and not_eof
rakita 07c721a
wip eof verification
rakita 42a04c1
Merge remote-tracking branch 'origin/main' into eof
rakita 91d98c3
wip validation
rakita d28122e
EOF Bytecode validity
rakita 77939ac
insturction and jump validation seems good
rakita 28d1f74
merged eof validate function
rakita 2db230a
EOP test runner, fex fixes
rakita f219ed6
RETURNDATALOAD, fix call bugs, refactor gas warm/cold calc
rakita e996fac
Merge remote-tracking branch 'origin/main' into eof
rakita 8a4d9a2
debug session, rjumpv imm fix
rakita 54d3d23
fixing validation bugs, bytecode decoder for EOF in revme
rakita c1c31ec
pass most of validation tests
rakita b8f7fad
bounds check moved to decode
rakita fedbd70
Merge remote-tracking branch 'origin/main' into eof
rakita 605431c
Merge remote-tracking branch 'origin/main' into eof
rakita 1ae9563
Fix merge compilation, fmt
rakita 7b73779
TXCREATE work
rakita 761aa2b
remove training wheels, panic on eof
rakita 85d062b
Merge remote-tracking branch 'origin/main' into eof
rakita efa7327
test fix and std
rakita 691ad44
std
rakita 8faa75a
fix test
rakita 4af1988
fix valgrind
rakita c337cd9
fix tests
rakita a19865f
clippy
rakita 647a8d2
removed checked logic
rakita 98745cc
small change
rakita 65cf05c
no std revm-test
rakita 6294f0f
Merge remote-tracking branch 'origin/main' into eof
rakita 8162f32
check pending TODOs
rakita 63ffb17
Merge remote-tracking branch 'origin/main' into eof
rakita 0222cc0
build check no_std
rakita eeeb798
doc
rakita 4c60857
chore: move some files. cleanup comments
rakita 55c19ad
Merge remote-tracking branch 'origin/main' into eof
rakita d24dcbb
fix fmt,clippy and compile error
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
refactor calls
- Loading branch information
commit cb3d93a5042c1e71f3816f048af1e1245d0047ce
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| use crate::primitives::{Address, Bytes, TransactTo, TxEnv, U256}; | ||
| use core::ops::Range; | ||
| use std::boxed::Box; | ||
|
|
||
| /// Inputs for a call. | ||
| #[derive(Clone, Debug, PartialEq, Eq, Hash)] | ||
| #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] | ||
| pub struct CallInputs { | ||
| /// The target of the call. | ||
| pub contract: Address, | ||
| /// The transfer, if any, in this call. | ||
| pub transfer: Transfer, | ||
| /// The call data of the call. | ||
| pub input: Bytes, | ||
| /// The gas limit of the call. | ||
| pub gas_limit: u64, | ||
| /// The context of the call. | ||
| pub context: CallContext, | ||
| /// Whether this is a static call. | ||
| pub is_static: bool, | ||
| /// The return memory offset where the output of the call is written. | ||
| pub return_memory_offset: Range<usize>, | ||
| } | ||
|
|
||
| impl CallInputs { | ||
| /// Creates new call inputs. | ||
| pub fn new(tx_env: &TxEnv, gas_limit: u64) -> Option<Self> { | ||
| let TransactTo::Call(address) = tx_env.transact_to else { | ||
| return None; | ||
| }; | ||
|
|
||
| Some(CallInputs { | ||
| contract: address, | ||
| transfer: Transfer { | ||
| source: tx_env.caller, | ||
| target: address, | ||
| value: tx_env.value, | ||
| }, | ||
| input: tx_env.data.clone(), | ||
| gas_limit, | ||
| context: CallContext { | ||
| caller: tx_env.caller, | ||
| address, | ||
| code_address: address, | ||
| apparent_value: tx_env.value, | ||
| scheme: CallScheme::Call, | ||
| }, | ||
| is_static: false, | ||
| return_memory_offset: 0..0, | ||
| }) | ||
| } | ||
|
|
||
| /// Returns boxed call inputs. | ||
| pub fn new_boxed(tx_env: &TxEnv, gas_limit: u64) -> Option<Box<Self>> { | ||
| Self::new(tx_env, gas_limit).map(Box::new) | ||
| } | ||
| } | ||
|
|
||
| /// Call schemes. | ||
| #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | ||
| #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] | ||
| pub enum CallScheme { | ||
| /// `CALL`. | ||
| Call, | ||
| /// `CALLCODE` | ||
| CallCode, | ||
| /// `DELEGATECALL` | ||
| DelegateCall, | ||
| /// `STATICCALL` | ||
| StaticCall, | ||
| } | ||
|
|
||
| /// Context of a runtime call. | ||
| #[derive(Clone, Debug, PartialEq, Eq, Hash)] | ||
| #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] | ||
| pub struct CallContext { | ||
| /// Execution address. | ||
| pub address: Address, | ||
| /// Caller address of the EVM. | ||
| pub caller: Address, | ||
| /// The address the contract code was loaded from, if any. | ||
| pub code_address: Address, | ||
| /// Apparent value of the EVM. | ||
| pub apparent_value: U256, | ||
| /// The scheme used for the call. | ||
| pub scheme: CallScheme, | ||
| } | ||
|
|
||
| impl Default for CallContext { | ||
| fn default() -> Self { | ||
| CallContext { | ||
| address: Address::default(), | ||
| caller: Address::default(), | ||
| code_address: Address::default(), | ||
| apparent_value: U256::default(), | ||
| scheme: CallScheme::Call, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Transfer from source to target, with given value. | ||
| #[derive(Clone, Debug, PartialEq, Eq, Hash)] | ||
| #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] | ||
| pub struct Transfer { | ||
| /// The source address. | ||
| pub source: Address, | ||
| /// The target address. | ||
| pub target: Address, | ||
| /// The transfer value. | ||
| pub value: U256, | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| pub use crate::primitives::CreateScheme; | ||
| use crate::primitives::{Address, Bytes, TransactTo, TxEnv, U256}; | ||
| use std::boxed::Box; | ||
|
|
||
| /// Inputs for a create call. | ||
| #[derive(Clone, Debug, PartialEq, Eq, Hash)] | ||
| #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] | ||
| pub struct CreateInputs { | ||
| /// Caller address of the EVM. | ||
| pub caller: Address, | ||
| /// The create scheme. | ||
| pub scheme: CreateScheme, | ||
| /// The value to transfer. | ||
| pub value: U256, | ||
| /// The init code of the contract. | ||
| pub init_code: Bytes, | ||
| /// The gas limit of the call. | ||
| pub gas_limit: u64, | ||
| } | ||
|
|
||
| impl CreateInputs { | ||
| /// Creates new create inputs. | ||
| pub fn new(tx_env: &TxEnv, gas_limit: u64) -> Option<Self> { | ||
| let TransactTo::Create(scheme) = tx_env.transact_to else { | ||
| return None; | ||
| }; | ||
|
|
||
| Some(CreateInputs { | ||
| caller: tx_env.caller, | ||
| scheme, | ||
| value: tx_env.value, | ||
| init_code: tx_env.data.clone(), | ||
| gas_limit, | ||
| }) | ||
| } | ||
|
|
||
| /// Returns boxed create inputs. | ||
| pub fn new_boxed(tx_env: &TxEnv, gas_limit: u64) -> Option<Box<Self>> { | ||
| Self::new(tx_env, gas_limit).map(Box::new) | ||
| } | ||
|
|
||
| /// Returns the address that this create call will create. | ||
| pub fn created_address(&self, nonce: u64) -> Address { | ||
| match self.scheme { | ||
| CreateScheme::Create => self.caller.create(nonce), | ||
| CreateScheme::Create2 { salt } => self | ||
| .caller | ||
| .create2_from_code(salt.to_be_bytes(), &self.init_code), | ||
| } | ||
| } | ||
| } |
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
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.
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.
Uh oh!
There was an error while loading. Please reload this page.