Skip to content

Commit

Permalink
Merge branch 'feat/transient_storage' of github.com:filecoin-project/…
Browse files Browse the repository at this point in the history
…builtin-actors into feat/transient_storage
  • Loading branch information
snissn committed Dec 14, 2024
2 parents b7ac7ba + b96dbe5 commit a43f34a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
16 changes: 7 additions & 9 deletions actors/evm/src/interpreter/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,16 @@ impl<'r, RT: Runtime> System<'r, RT> {
.context_code(ExitCode::USR_SERIALIZATION, "failed to decode state")?
.context_code(ExitCode::USR_ILLEGAL_STATE, "state not in blockstore")?;

if let Some(transient_data) = state.transient_data {
let state_transient_data_lifespan = transient_data.transient_data_lifespan;
if self.current_transient_data_lifespan == state_transient_data_lifespan {
self.transient_slots.set_root(&transient_data.transient_data_state).context_code(
match &state.transient_data {
Some(TransientData { transient_data_state, transient_data_lifespan })
if transient_data_lifespan == &self.current_transient_data_lifespan =>
{
self.transient_slots.set_root(transient_data_state).context_code(
ExitCode::USR_ILLEGAL_STATE,
"transient_state not in blockstore",
)?;
} else {
self.transient_slots.clear();
)?
}
} else {
self.transient_slots.clear();
_ => self.transient_slots.clear(),
}

self.slots
Expand Down
4 changes: 2 additions & 2 deletions actors/evm/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ fn transient_storage_test(transient_storage_bytecode: Vec<u8>) {
// We expect this to fail because no changes are made
util::invoke_contract_expect_fail(&rt, &solidity_params_test_cleared);

//use a new address for our calling context
//This will cause the transient storage data to reset because the transient storage lifecycle value has changed
// use a new address for our calling context; this will cause the transient storage
// data to reset because the transient storage lifecycle value has changed
let new_context = Address::new_id(200);
rt.set_origin(new_context);

Expand Down
5 changes: 2 additions & 3 deletions actors/evm/tests/contracts/TransientStorageTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.24;
contract TransientStorageTest {

constructor(){
_runTests();
_runTests();
}

function runTests() public returns (bool) {
Expand Down Expand Up @@ -79,7 +79,6 @@ contract TransientStorageTest {

// Test 2.2: Verify nested contract independence
function testNestedContracts(address other) public returns (bool) {

uint256 slot = 4;
uint256 value = 88;

Expand All @@ -106,7 +105,7 @@ contract TransientStorageTest {
return true;
}

// New function to test reentry scenario
// New function to test reentry scenario
function testReentry(address otherContract) public returns (bool){
uint256 slot = 5;
uint256 value = 123;
Expand Down

0 comments on commit a43f34a

Please sign in to comment.