-
Notifications
You must be signed in to change notification settings - Fork 79
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
EVM: Implement CALLACTOR/METHODNUM and REVERT abort semantics #633
Conversation
such a hack, but no other way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Just two nits for nicer code.
let input_data = if let Some(MemoryRegion { offset, size }) = input_region { | ||
&memory[offset..][..size.get()] | ||
} else { | ||
&[] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use unwrap_or_default()
here:
let input_data = if let Some(MemoryRegion { offset, size }) = input_region { | |
&memory[offset..][..size.get()] | |
} else { | |
&[] | |
} | |
let input_data = input_region | |
.map(|MemoryRegion { offset, size }| &memory[offset..][..size.get()]) | |
.unwrap_or_default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uhm, more scala.....
What's up with the war on IF
? Programming is impossible without it.
Also note that the compiler will have to apply smarts to ultimately generate the code we are substituting, so the only thing achieved by this so called "idiomatic" nonsense is obfuscation and ever increasing compile times....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not Scala, it's Rust. You have an Option here and a type that implements Default. So doing this is the natural way. The Rust compiler optimises for code like this, but we can check with https://godbolt.org if you're in doubt (not sure if it supports Wasm).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that doesnt resolve either obfuscation or ever increasing compile times ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, I just to be clear here: I am not getting git blamed for this. If you feel too strongly about it, feel free to apply the obfuscator in the EXT* pr :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and don't forget the environment 😆
Then I guess we are already using a small nation's energy output to compile our warez, so that's just a drop in the bucket.
actors/evm/tests/asm.rs
Outdated
// this is a hack to support mnemonics for the FEVM extension opcodes | ||
// it is really ugly, but the etk assmebler doesn't currently support any way to | ||
// directly embed (otherwise invalid) asm instructions in the stream... sigh. | ||
// Ideally we would just do them as macros like | ||
// %macro methodnum() | ||
// %0xb1 | ||
// %end | ||
// Note that to add insult to injury, macros cannot %include_hex... double sigh. | ||
// So fuck it, we'll just hack this until there is support. | ||
// See also https://github.com/quilt/etk/issues/110 | ||
fn with_fevm_extensions(body: &str) -> String { | ||
body.to_owned() | ||
.replace("@callactor", "%include_hex(\"tests/opcodes/callactor.hex\")") | ||
.replace("@methodnum", "%include_hex(\"tests/opcodes/methodnum.hex\")") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work figuring out a workaround!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it was really annoying.... Not perfect, but we can live with it until upstream gets support for arbitrary instructions. If they don't act on my issue, I'll send them a pr.
we had a github down snafu, will edit a comment and do another push. |
0c25f19
to
234434d
Compare
Codecov Report
@@ Coverage Diff @@
## next #633 +/- ##
==========================================
- Coverage 82.17% 82.14% -0.04%
==========================================
Files 111 111
Lines 19635 19691 +56
==========================================
+ Hits 16136 16176 +40
- Misses 3499 3515 +16
|
…in-project#633) * implement CALLACTOR/METHODNUM * signal EVM_CONTRACT_REVERTED error on reverts * handle REVERT in CALL/CALLACTOR result * update comments about REVERT semantics * simplify call error handling * fix tests * fix empty input data handling for calls * add mnemonic opcodes for CALLACTOR and METHODNUM to assembler such a hack, but no other way. * add methodnum and callactor tests * rustfmt * lift return * fix comment
This pr completes our cross-contract call story:
Notes:
Partially addresses filecoin-project/ref-fvm#811.
Closes filecoin-project/ref-fvm#805.