Skip to content

Commit

Permalink
Merge branch 'master' into feat/optimise-cron-reward-vesting
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshkshah1992 authored Oct 11, 2023
2 parents 29f9cdf + fc80851 commit 74da997
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 14 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
1 change: 1 addition & 0 deletions actors/miner/tests/declare_recoveries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ fn recovery_fails_during_active_consensus_fault() {
epoch: epoch - 1,
fault_type: ConsensusFaultType::DoubleForkMining,
}),
ExitCode::OK,
)
.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion actors/miner/tests/miner_actor_test_commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ mod miner_actor_test_commitment {
fault_type: ConsensusFaultType::DoubleForkMining,
};
let test_addr = Address::new_id(1234);
h.report_consensus_fault(&rt, test_addr, Some(fault)).unwrap();
h.report_consensus_fault(&rt, test_addr, Some(fault), ExitCode::OK).unwrap();
let precommit_params =
h.make_pre_commit_params(102, challenge_epoch, expiration, vec![]);
let ret =
Expand Down
37 changes: 36 additions & 1 deletion actors/miner/tests/report_consensus_fault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,34 @@ fn invalid_report_rejected() {
rt.set_epoch(1);

let test_addr = Address::new_id(1234);
expect_abort(ExitCode::USR_ILLEGAL_ARGUMENT, h.report_consensus_fault(&rt, test_addr, None));
expect_abort(
ExitCode::USR_ILLEGAL_ARGUMENT,
h.report_consensus_fault(&rt, test_addr, None, ExitCode::OK),
);
rt.reset();
check_state_invariants(rt.policy(), &h.get_state(&rt), rt.store(), &rt.get_balance());
}

#[test]
fn consensus_fault_verification_fails_rejected() {
let (h, rt) = setup();

rt.set_epoch(2);
let epoch = *rt.epoch.borrow();
let test_addr = Address::new_id(1234);
expect_abort(
ExitCode::USR_FORBIDDEN,
h.report_consensus_fault(
&rt,
test_addr,
Some(ConsensusFault {
target: rt.receiver,
epoch: epoch - 1,
fault_type: ConsensusFaultType::DoubleForkMining,
}),
ExitCode::USR_FORBIDDEN,
),
);
rt.reset();
check_state_invariants(rt.policy(), &h.get_state(&rt), rt.store(), &rt.get_balance());
}
Expand All @@ -50,6 +77,7 @@ fn mistargeted_report_rejected() {
epoch: epoch - 1,
fault_type: ConsensusFaultType::DoubleForkMining,
}),
ExitCode::OK,
),
);
rt.reset();
Expand All @@ -72,6 +100,7 @@ fn report_consensus_fault_pays_reward_and_charges_fee() {
epoch: epoch - 1,
fault_type: ConsensusFaultType::DoubleForkMining,
}),
ExitCode::OK,
)
.unwrap();
check_state_invariants(rt.policy(), &h.get_state(&rt), rt.store(), &rt.get_balance());
Expand Down Expand Up @@ -99,6 +128,7 @@ fn report_consensus_fault_updates_consensus_fault_reported_field() {
epoch: report_epoch - 1,
fault_type: ConsensusFaultType::DoubleForkMining,
}),
ExitCode::OK,
)
.unwrap();
let end_info = h.get_info(&rt);
Expand Down Expand Up @@ -132,6 +162,7 @@ fn double_report_of_consensus_fault_fails() {
epoch: fault1,
fault_type: ConsensusFaultType::DoubleForkMining,
}),
ExitCode::OK,
)
.unwrap();
let end_info = h.get_info(&rt);
Expand All @@ -152,6 +183,7 @@ fn double_report_of_consensus_fault_fails() {
epoch: fault1,
fault_type: ConsensusFaultType::DoubleForkMining,
}),
ExitCode::OK,
),
);
rt.reset();
Expand All @@ -170,6 +202,7 @@ fn double_report_of_consensus_fault_fails() {
epoch: fault2,
fault_type: ConsensusFaultType::DoubleForkMining,
}),
ExitCode::OK,
),
);
rt.reset();
Expand All @@ -185,6 +218,7 @@ fn double_report_of_consensus_fault_fails() {
epoch: fault3,
fault_type: ConsensusFaultType::DoubleForkMining,
}),
ExitCode::OK,
)
.unwrap();
let end_info = h.get_info(&rt);
Expand All @@ -206,6 +240,7 @@ fn double_report_of_consensus_fault_fails() {
epoch: fault4,
fault_type: ConsensusFaultType::DoubleForkMining,
}),
ExitCode::OK,
),
);
rt.reset();
Expand Down
Loading

0 comments on commit 74da997

Please sign in to comment.