Skip to content

Commit

Permalink
fix: set tombstone on reload (#1434)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien authored and arajasek committed Oct 11, 2023
1 parent 582b0be commit 82dd420
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions actors/evm/src/interpreter/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ impl<'r, RT: Runtime> System<'r, RT> {
self.nonce = state.nonce;
self.saved_state_root = Some(root);
self.bytecode = Some(EvmBytecode::new(state.bytecode, state.bytecode_hash));
self.tombstone = state.tombstone;
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion actors/evm/tests/contracts/Factory.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
608060405234801561000f575f80fd5b5061051a8061001d5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c80630876a11e146100385780631e19329414610068575b5f80fd5b610052600480360381019061004d919061018a565b610098565b60405161005f9190610207565b60405180910390f35b610082600480360381019061007d9190610220565b6100d7565b60405161008f9190610207565b60405180910390f35b5f82826040516100a790610110565b6100b1919061025a565b8190604051809103905ff59050801580156100ce573d5f803e3d5ffd5b50905092915050565b5f816040516100e590610110565b6100ef919061025a565b604051809103905ff080158015610108573d5f803e3d5ffd5b509050919050565b6102718061027483390190565b5f80fd5b5f819050919050565b61013381610121565b811461013d575f80fd5b50565b5f8135905061014e8161012a565b92915050565b5f8160030b9050919050565b61016981610154565b8114610173575f80fd5b50565b5f8135905061018481610160565b92915050565b5f80604083850312156101a05761019f61011d565b5b5f6101ad85828601610140565b92505060206101be85828601610176565b9150509250929050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6101f1826101c8565b9050919050565b610201816101e7565b82525050565b5f60208201905061021a5f8301846101f8565b92915050565b5f602082840312156102355761023461011d565b5b5f61024284828501610176565b91505092915050565b61025481610154565b82525050565b5f60208201905061026d5f83018461024b565b9291505056fe608060405234801561000f575f80fd5b50604051610271380380610271833981810160405281019061003191906100d9565b5f8160030b1215610077576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161006e9061015e565b60405180910390fd5b805f806101000a81548163ffffffff021916908360030b63ffffffff1602179055505061017c565b5f80fd5b5f8160030b9050919050565b6100b8816100a3565b81146100c2575f80fd5b50565b5f815190506100d3816100af565b92915050565b5f602082840312156100ee576100ed61009f565b5b5f6100fb848285016100c5565b91505092915050565b5f82825260208201905092915050565b7f637265617465206661696c6564000000000000000000000000000000000000005f82015250565b5f610148600d83610104565b915061015382610114565b602082019050919050565b5f6020820190508181035f8301526101758161013c565b9050919050565b60e9806101885f395ff3fe6080604052348015600e575f80fd5b50600436106030575f3560e01c806333cf508014603457806335f4699414604e575b5f80fd5b603a6056565b60405160459190609c565b60405180910390f35b6054606a565b005b5f805f9054906101000a900460030b905090565b3373ffffffffffffffffffffffffffffffffffffffff16ff5b5f8160030b9050919050565b6096816083565b82525050565b5f60208201905060ad5f830184608f565b9291505056fea2646970667358221220010091073d3812b09a309a7b0030633391face9b5be6e3ee4fb2872d38c7b13664736f6c63430008150033a26469706673582212201f027bdadc64c1983cbb0ead43545c936db42976c5b87a4bb0eef19f6a5c269f64736f6c63430008150033
608060405234801561000f575f80fd5b506105bf8061001d5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c80630876a11e146100385780631e19329414610068575b5f80fd5b610052600480360381019061004d919061018a565b610098565b60405161005f9190610207565b60405180910390f35b610082600480360381019061007d9190610220565b6100d7565b60405161008f9190610207565b60405180910390f35b5f82826040516100a790610110565b6100b1919061025a565b8190604051809103905ff59050801580156100ce573d5f803e3d5ffd5b50905092915050565b5f816040516100e590610110565b6100ef919061025a565b604051809103905ff080158015610108573d5f803e3d5ffd5b509050919050565b6103168061027483390190565b5f80fd5b5f819050919050565b61013381610121565b811461013d575f80fd5b50565b5f8135905061014e8161012a565b92915050565b5f8160030b9050919050565b61016981610154565b8114610173575f80fd5b50565b5f8135905061018481610160565b92915050565b5f80604083850312156101a05761019f61011d565b5b5f6101ad85828601610140565b92505060206101be85828601610176565b9150509250929050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6101f1826101c8565b9050919050565b610201816101e7565b82525050565b5f60208201905061021a5f8301846101f8565b92915050565b5f602082840312156102355761023461011d565b5b5f61024284828501610176565b91505092915050565b61025481610154565b82525050565b5f60208201905061026d5f83018461024b565b9291505056fe608060405234801561000f575f80fd5b50604051610316380380610316833981810160405281019061003191906100d9565b5f8160030b1215610077576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161006e9061015e565b60405180910390fd5b805f806101000a81548163ffffffff021916908360030b63ffffffff1602179055505061017c565b5f80fd5b5f8160030b9050919050565b6100b8816100a3565b81146100c2575f80fd5b50565b5f815190506100d3816100af565b92915050565b5f602082840312156100ee576100ed61009f565b5b5f6100fb848285016100c5565b91505092915050565b5f82825260208201905092915050565b7f637265617465206661696c6564000000000000000000000000000000000000005f82015250565b5f610148600d83610104565b915061015382610114565b602082019050919050565b5f6020820190508181035f8301526101758161013c565b9050919050565b61018d806101895f395ff3fe608060405234801561000f575f80fd5b506004361061003f575f3560e01c806333cf50801461004357806335f46994146100615780636e6032741461006b575b5f80fd5b61004b610075565b604051610058919061013e565b60405180910390f35b610069610089565b005b6100736100a2565b005b5f805f9054906101000a900460030b905090565b3373ffffffffffffffffffffffffffffffffffffffff16ff5b3073ffffffffffffffffffffffffffffffffffffffff166335f469946040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156100e7575f80fd5b505af11580156100f9573d5f803e3d5ffd5b505050506104d25f806101000a81548163ffffffff021916908360030b63ffffffff160217905550565b5f8160030b9050919050565b61013881610123565b82525050565b5f6020820190506101515f83018461012f565b9291505056fea264697066735822122010b40085348b2f051b9be5c090441938c60efc4361424c7792e4ee01b133f49964736f6c63430008150033a2646970667358221220a2a3c532e4664184f354d3757731ecefd8b00c8569a400be543710e4867b7c3664736f6c63430008150033
2 changes: 1 addition & 1 deletion actors/evm/tests/contracts/FactoryChild.abi
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"inputs":[{"internalType":"int32","name":"arg","type":"int32"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"die","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"get_value","outputs":[{"internalType":"int32","name":"","type":"int32"}],"stateMutability":"view","type":"function"}]
[{"inputs":[{"internalType":"int32","name":"arg","type":"int32"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"die","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dieRecursive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"get_value","outputs":[{"internalType":"int32","name":"","type":"int32"}],"stateMutability":"view","type":"function"}]
2 changes: 1 addition & 1 deletion actors/evm/tests/contracts/FactoryChild.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
608060405234801561000f575f80fd5b50604051610271380380610271833981810160405281019061003191906100d9565b5f8160030b1215610077576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161006e9061015e565b60405180910390fd5b805f806101000a81548163ffffffff021916908360030b63ffffffff1602179055505061017c565b5f80fd5b5f8160030b9050919050565b6100b8816100a3565b81146100c2575f80fd5b50565b5f815190506100d3816100af565b92915050565b5f602082840312156100ee576100ed61009f565b5b5f6100fb848285016100c5565b91505092915050565b5f82825260208201905092915050565b7f637265617465206661696c6564000000000000000000000000000000000000005f82015250565b5f610148600d83610104565b915061015382610114565b602082019050919050565b5f6020820190508181035f8301526101758161013c565b9050919050565b60e9806101885f395ff3fe6080604052348015600e575f80fd5b50600436106030575f3560e01c806333cf508014603457806335f4699414604e575b5f80fd5b603a6056565b60405160459190609c565b60405180910390f35b6054606a565b005b5f805f9054906101000a900460030b905090565b3373ffffffffffffffffffffffffffffffffffffffff16ff5b5f8160030b9050919050565b6096816083565b82525050565b5f60208201905060ad5f830184608f565b9291505056fea2646970667358221220010091073d3812b09a309a7b0030633391face9b5be6e3ee4fb2872d38c7b13664736f6c63430008150033
608060405234801561000f575f80fd5b50604051610316380380610316833981810160405281019061003191906100d9565b5f8160030b1215610077576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161006e9061015e565b60405180910390fd5b805f806101000a81548163ffffffff021916908360030b63ffffffff1602179055505061017c565b5f80fd5b5f8160030b9050919050565b6100b8816100a3565b81146100c2575f80fd5b50565b5f815190506100d3816100af565b92915050565b5f602082840312156100ee576100ed61009f565b5b5f6100fb848285016100c5565b91505092915050565b5f82825260208201905092915050565b7f637265617465206661696c6564000000000000000000000000000000000000005f82015250565b5f610148600d83610104565b915061015382610114565b602082019050919050565b5f6020820190508181035f8301526101758161013c565b9050919050565b61018d806101895f395ff3fe608060405234801561000f575f80fd5b506004361061003f575f3560e01c806333cf50801461004357806335f46994146100615780636e6032741461006b575b5f80fd5b61004b610075565b604051610058919061013e565b60405180910390f35b610069610089565b005b6100736100a2565b005b5f805f9054906101000a900460030b905090565b3373ffffffffffffffffffffffffffffffffffffffff16ff5b3073ffffffffffffffffffffffffffffffffffffffff166335f469946040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156100e7575f80fd5b505af11580156100f9573d5f803e3d5ffd5b505050506104d25f806101000a81548163ffffffff021916908360030b63ffffffff160217905550565b5f8160030b9050919050565b61013881610123565b82525050565b5f6020820190506101515f83018461012f565b9291505056fea264697066735822122010b40085348b2f051b9be5c090441938c60efc4361424c7792e4ee01b133f49964736f6c63430008150033
1 change: 1 addition & 0 deletions actors/evm/tests/contracts/FactoryChild.signatures
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Function signatures:
35f46994: die()
6e603274: dieRecursive()
33cf5080: get_value()
2 changes: 1 addition & 1 deletion actors/evm/tests/contracts/FactoryChild_storage.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"storage":[{"astId":42,"contract":"Lifecycle.sol:FactoryChild","label":"value","offset":0,"slot":"0","type":"t_int32"}],"types":{"t_int32":{"encoding":"inplace","label":"int32","numberOfBytes":"4"}}}
{"storage":[{"astId":42,"contract":"tests/contracts/Lifecycle.sol:FactoryChild","label":"value","offset":0,"slot":"0","type":"t_int32"}],"types":{"t_int32":{"encoding":"inplace","label":"int32","numberOfBytes":"4"}}}
2 changes: 1 addition & 1 deletion actors/evm/tests/contracts/Lifecycle.hex
Original file line number Diff line number Diff line change
@@ -1 +1 @@
608060405234801561000f575f80fd5b5061051a8061001d5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c80630876a11e146100385780631e19329414610068575b5f80fd5b610052600480360381019061004d919061018a565b610098565b60405161005f9190610207565b60405180910390f35b610082600480360381019061007d9190610220565b6100d7565b60405161008f9190610207565b60405180910390f35b5f82826040516100a790610110565b6100b1919061025a565b8190604051809103905ff59050801580156100ce573d5f803e3d5ffd5b50905092915050565b5f816040516100e590610110565b6100ef919061025a565b604051809103905ff080158015610108573d5f803e3d5ffd5b509050919050565b6102718061027483390190565b5f80fd5b5f819050919050565b61013381610121565b811461013d575f80fd5b50565b5f8135905061014e8161012a565b92915050565b5f8160030b9050919050565b61016981610154565b8114610173575f80fd5b50565b5f8135905061018481610160565b92915050565b5f80604083850312156101a05761019f61011d565b5b5f6101ad85828601610140565b92505060206101be85828601610176565b9150509250929050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6101f1826101c8565b9050919050565b610201816101e7565b82525050565b5f60208201905061021a5f8301846101f8565b92915050565b5f602082840312156102355761023461011d565b5b5f61024284828501610176565b91505092915050565b61025481610154565b82525050565b5f60208201905061026d5f83018461024b565b9291505056fe608060405234801561000f575f80fd5b50604051610271380380610271833981810160405281019061003191906100d9565b5f8160030b1215610077576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161006e9061015e565b60405180910390fd5b805f806101000a81548163ffffffff021916908360030b63ffffffff1602179055505061017c565b5f80fd5b5f8160030b9050919050565b6100b8816100a3565b81146100c2575f80fd5b50565b5f815190506100d3816100af565b92915050565b5f602082840312156100ee576100ed61009f565b5b5f6100fb848285016100c5565b91505092915050565b5f82825260208201905092915050565b7f637265617465206661696c6564000000000000000000000000000000000000005f82015250565b5f610148600d83610104565b915061015382610114565b602082019050919050565b5f6020820190508181035f8301526101758161013c565b9050919050565b60e9806101885f395ff3fe6080604052348015600e575f80fd5b50600436106030575f3560e01c806333cf508014603457806335f4699414604e575b5f80fd5b603a6056565b60405160459190609c565b60405180910390f35b6054606a565b005b5f805f9054906101000a900460030b905090565b3373ffffffffffffffffffffffffffffffffffffffff16ff5b5f8160030b9050919050565b6096816083565b82525050565b5f60208201905060ad5f830184608f565b9291505056fea2646970667358221220010091073d3812b09a309a7b0030633391face9b5be6e3ee4fb2872d38c7b13664736f6c63430008150033a26469706673582212201f027bdadc64c1983cbb0ead43545c936db42976c5b87a4bb0eef19f6a5c269f64736f6c63430008150033
608060405234801561000f575f80fd5b506105bf8061001d5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c80630876a11e146100385780631e19329414610068575b5f80fd5b610052600480360381019061004d919061018a565b610098565b60405161005f9190610207565b60405180910390f35b610082600480360381019061007d9190610220565b6100d7565b60405161008f9190610207565b60405180910390f35b5f82826040516100a790610110565b6100b1919061025a565b8190604051809103905ff59050801580156100ce573d5f803e3d5ffd5b50905092915050565b5f816040516100e590610110565b6100ef919061025a565b604051809103905ff080158015610108573d5f803e3d5ffd5b509050919050565b6103168061027483390190565b5f80fd5b5f819050919050565b61013381610121565b811461013d575f80fd5b50565b5f8135905061014e8161012a565b92915050565b5f8160030b9050919050565b61016981610154565b8114610173575f80fd5b50565b5f8135905061018481610160565b92915050565b5f80604083850312156101a05761019f61011d565b5b5f6101ad85828601610140565b92505060206101be85828601610176565b9150509250929050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6101f1826101c8565b9050919050565b610201816101e7565b82525050565b5f60208201905061021a5f8301846101f8565b92915050565b5f602082840312156102355761023461011d565b5b5f61024284828501610176565b91505092915050565b61025481610154565b82525050565b5f60208201905061026d5f83018461024b565b9291505056fe608060405234801561000f575f80fd5b50604051610316380380610316833981810160405281019061003191906100d9565b5f8160030b1215610077576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161006e9061015e565b60405180910390fd5b805f806101000a81548163ffffffff021916908360030b63ffffffff1602179055505061017c565b5f80fd5b5f8160030b9050919050565b6100b8816100a3565b81146100c2575f80fd5b50565b5f815190506100d3816100af565b92915050565b5f602082840312156100ee576100ed61009f565b5b5f6100fb848285016100c5565b91505092915050565b5f82825260208201905092915050565b7f637265617465206661696c6564000000000000000000000000000000000000005f82015250565b5f610148600d83610104565b915061015382610114565b602082019050919050565b5f6020820190508181035f8301526101758161013c565b9050919050565b61018d806101895f395ff3fe608060405234801561000f575f80fd5b506004361061003f575f3560e01c806333cf50801461004357806335f46994146100615780636e6032741461006b575b5f80fd5b61004b610075565b604051610058919061013e565b60405180910390f35b610069610089565b005b6100736100a2565b005b5f805f9054906101000a900460030b905090565b3373ffffffffffffffffffffffffffffffffffffffff16ff5b3073ffffffffffffffffffffffffffffffffffffffff166335f469946040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156100e7575f80fd5b505af11580156100f9573d5f803e3d5ffd5b505050506104d25f806101000a81548163ffffffff021916908360030b63ffffffff160217905550565b5f8160030b9050919050565b61013881610123565b82525050565b5f6020820190506101515f83018461012f565b9291505056fea264697066735822122010b40085348b2f051b9be5c090441938c60efc4361424c7792e4ee01b133f49964736f6c63430008150033a2646970667358221220a2a3c532e4664184f354d3757731ecefd8b00c8569a400be543710e4867b7c3664736f6c63430008150033
4 changes: 4 additions & 0 deletions actors/evm/tests/contracts/Lifecycle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ contract FactoryChild {
function die() public {
selfdestruct(payable(msg.sender));
}
function dieRecursive() public {
this.die();
value = 1234;
}
function get_value() public view returns (int32) {
return value;
}
Expand Down
17 changes: 11 additions & 6 deletions integration_tests/src/tests/evm_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub fn evm_create_test(v: &dyn VM) {
let create_return: fil_actor_eam::CreateExternalReturn =
create_result.ret.unwrap().deserialize().expect("failed to decode results");

let test_func = |create_func: ContractCall<_, EthAddress>| {
let test_func = |create_func: ContractCall<_, EthAddress>, recursive: bool| {
let child_addr_eth: EthAddress = {
let call_params = create_func.calldata().expect("should serialize");
let call_result = v
Expand Down Expand Up @@ -229,7 +229,7 @@ pub fn evm_create_test(v: &dyn VM) {

// Kill it.
{
let func = factory_child.die();
let func = if recursive { factory_child.die_recursive() } else { factory_child.die() };
let call_params = func.calldata().expect("should serialize");
let call_result = v
.execute_message(
Expand Down Expand Up @@ -273,13 +273,18 @@ pub fn evm_create_test(v: &dyn VM) {
};

// Test CREATE2 twice because we should be able to deploy over an existing contract.
let eth_addr1 = test_func(factory.create_2([0; 32], 42));
let eth_addr2 = test_func(factory.create_2([0; 32], 42));
let eth_addr1 = test_func(factory.create_2([0; 32], 42), false);
let eth_addr2 = test_func(factory.create_2([0; 32], 42), false);
assert_eq!(eth_addr1, eth_addr2);

// Recursive self-destruct should work.
let eth_addr1 = test_func(factory.create_2([1; 32], 42), true);
let eth_addr2 = test_func(factory.create_2([1; 32], 42), false);
assert_eq!(eth_addr1, eth_addr2);

// Then test create and expect two different addrs.
let eth_addr1 = test_func(factory.create(42));
let eth_addr2 = test_func(factory.create(42));
let eth_addr1 = test_func(factory.create(42), false);
let eth_addr2 = test_func(factory.create(42), false);
assert_ne!(eth_addr1, eth_addr2);

// Then test a failure
Expand Down

0 comments on commit 82dd420

Please sign in to comment.