-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EVM: Implement reverts correctly (#864)
* add exit to runtime interface * propagate revert data in contract invocations * add data to ActorError * propagate data in actor errors from send * correctly handle reverts in calls * implement exit with panics in mock runtime * implement exit with panics in test vm * fix clippy * fix test vm: exit data should be in new context * use pop instead of ugly gets in ret * cosmetics * add naked revert test * rustfmt * only test naked revert in unit test nested call revert should go in integration test, really * fix callvariants contract to check reverts * really fix callvariants contract: iszero is what you want * test_vm: missing panic handler * callvariants is also testing mutation * deduplicate actor exit handler code * rustfmt * remove unnecessary replaces for exits. * fix runtime trampoline to propagate data from errors * perform contract/constructor invocation abortive returns with errors * don't synethesize exit data if it is not there * propagate error data in test_vm * rustfmt * simplify/dedup identical code
- Loading branch information
Showing
12 changed files
with
259 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1 +1 @@ | ||
306000556101cf8060106000396000f360003560e01c80600114607557806002146101af5780600314609157806004146101bb578060051460ad578060061460cf578060071460ed578060081461010f578060091461012d5780600a146101495780600b1461016b5780600c1461012d5780600d1461018d5780600e1461014957600080fd5b60206000600260e01b600052600460006004356000fa60206000f35b60206000600460e01b600052600460006004356000fa60206000f35b60206000600660e01b600052602435600452602460006004356000fa60206000f35b60206000600260e01b6000526004600060006004356000f160206000f35b60206000600860e01b600052602435600452602460006004356000fa60206000f35b60206000600460e01b6000526004600060006004356000f160206000f35b60206000600260e01b600052600460006004356000f460206000f35b60206000600460e01b600052600460006004356000f460005460005260206000f35b60206000600c60e01b600052602435600452602460006004356000fa60206000f35b60206000600e60e01b600052602435600452602460006004356000fa60206000f35b60005460005260206000f35b63ffffff4260005560005460005260206000f3 | ||
306000556102108060106000396000f360003560e01c80600114607657806002146101e25780600314609757806004146101ee578060051460b8578060061460df57806007146101025780600814610129578060091461014c5780600a1461016d5780600b146101945780600c1461014c5780600d146101bb5780600e1461016d57600080fd5b60206000600260e01b600052600460006004356000fa156102025760206000f35b60206000600460e01b600052600460006004356000fa156102025760206000f35b60206000600660e01b600052602435600452602460006004356000fa156102025760206000f35b60206000600260e01b6000526004600060006004356000f1156102025760206000f35b60206000600860e01b600052602435600452602460006004356000fa156102025760206000f35b60206000600460e01b6000526004600060006004356000f1156102025760206000f35b60206000600260e01b600052600460006004356000f4156102025760206000f35b60206000600460e01b600052600460006004356000f4156102025760005460005260206000f35b60206000600c60e01b600052602435600452602460006004356000fa156102025760206000f35b60206000600e60e01b600052602435600452602460006004356000fa156102025760206000f35b60005460005260206000f35b63ffffff4260005560005460005260206000f35b63deadbeef6000526004601cfd |
This file contains 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 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,34 @@ | ||
use fil_actor_evm as evm; | ||
use fvm_ipld_encoding::{BytesSer, RawBytes}; | ||
|
||
mod asm; | ||
mod util; | ||
|
||
#[test] | ||
fn test_revert() { | ||
let contract = asm::new_contract( | ||
"naked-revert", | ||
"", | ||
r#" | ||
%push(0xdeadbeef) | ||
push1 0x00 | ||
mstore | ||
push1 0x04 | ||
push1 0x1c # skip top 28 bytes | ||
revert | ||
"#, | ||
) | ||
.unwrap(); | ||
|
||
let mut rt = util::construct_and_verify(contract); | ||
rt.expect_validate_caller_any(); | ||
|
||
let result = rt.call::<evm::EvmContractActor>( | ||
evm::Method::InvokeContract as u64, | ||
&RawBytes::serialize(BytesSer(&[])).unwrap(), | ||
); | ||
assert!(result.is_err()); | ||
let e = result.unwrap_err(); | ||
assert_eq!(e.exit_code(), evm::EVM_CONTRACT_REVERTED); | ||
assert_eq!(e.data(), RawBytes::from(vec![0xde, 0xad, 0xbe, 0xef])); | ||
} |
Oops, something went wrong.