Skip to content
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

fix(levm): initialization of transient storage #1540

Merged
merged 9 commits into from
Dec 20, 2024
Prev Previous commit
Next Next commit
Add the transient storage in generic call
  • Loading branch information
damiramirez committed Dec 19, 2024
commit f9e9d51aa116d092e1016f56ece9eaadcd5efb01
2 changes: 2 additions & 0 deletions crates/vm/levm/src/call_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ impl CallFrame {
gas_used: U256,
depth: usize,
create_op_called: bool,
transient_storage: TransientStorage,
) -> Self {
let valid_jump_destinations = get_valid_jump_destinations(&bytecode).unwrap_or_default();
Self {
Expand All @@ -136,6 +137,7 @@ impl CallFrame {
gas_used,
valid_jump_destinations,
create_op_called,
transient_storage,
..Default::default()
}
}
Expand Down
9 changes: 8 additions & 1 deletion crates/vm/levm/src/opcode_handlers/system.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
call_frame::CallFrame,
call_frame::{CallFrame, TransientStorage},
constants::{CREATE_DEPLOYMENT_FAIL, INIT_CODE_MAX_SIZE, REVERT_FOR_CALL, SUCCESS_FOR_CALL},
db::cache,
errors::{InternalError, OpcodeSuccess, OutOfGasError, ResultReason, TxResult, VMError},
Expand Down Expand Up @@ -89,6 +89,7 @@ impl VM {
args_size,
return_data_start_offset,
return_data_size,
current_call_frame.transient_storage.clone(),
)
}

Expand Down Expand Up @@ -160,6 +161,7 @@ impl VM {
args_size,
return_data_start_offset,
return_data_size,
current_call_frame.transient_storage.clone(),
)
}

Expand Down Expand Up @@ -248,6 +250,7 @@ impl VM {
args_size,
return_data_start_offset,
return_data_size,
current_call_frame.transient_storage.clone(),
)
}

Expand Down Expand Up @@ -305,6 +308,7 @@ impl VM {
args_size,
return_data_start_offset,
return_data_size,
current_call_frame.transient_storage.clone(),
)
}

Expand Down Expand Up @@ -565,6 +569,7 @@ impl VM {
U256::zero(),
new_depth,
true,
current_call_frame.transient_storage.clone(),
);

self.accrued_substate.created_accounts.insert(new_address); // Mostly for SELFDESTRUCT during initcode.
Expand Down Expand Up @@ -615,6 +620,7 @@ impl VM {
args_size: usize,
ret_offset: U256,
ret_size: usize,
transient_storage: TransientStorage,
) -> Result<OpcodeSuccess, VMError> {
// 1. Validate sender has enough value
let sender_account_info = self.access_account(msg_sender).0;
Expand Down Expand Up @@ -653,6 +659,7 @@ impl VM {
U256::zero(),
new_depth,
false,
transient_storage,
);

// Transfer value from caller to callee.
Expand Down
4 changes: 3 additions & 1 deletion crates/vm/levm/src/vm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
account::{Account, StorageSlot},
call_frame::CallFrame,
call_frame::{CallFrame, TransientStorage},
constants::*,
db::{
cache::{self, remove_account},
Expand Down Expand Up @@ -179,6 +179,7 @@ impl VM {
U256::zero(),
0,
false,
TransientStorage::default(),
);

let substate = Substate {
Expand Down Expand Up @@ -233,6 +234,7 @@ impl VM {
U256::zero(),
0,
false,
TransientStorage::default(),
);

let substate = Substate {
Expand Down
Loading