-
Notifications
You must be signed in to change notification settings - Fork 84
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: fix EXTCODE_ ops #870
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## next #870 +/- ##
==========================================
+ Coverage 87.10% 87.23% +0.12%
==========================================
Files 126 127 +1
Lines 23278 23677 +399
==========================================
+ Hits 20276 20654 +378
- Misses 3002 3023 +21
|
just need to fix tests |
tests implemented! review time :) |
let actor_id = rt.resolve_address(&addr).ok_or_else(|| { | ||
StatusCode::InvalidArgument("failed to resolve address".to_string()) | ||
StatusCode::InvalidArgument("EVM EXT opcode failed to resolve address".to_string()) | ||
// TODO better error code | ||
})?; |
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.
This should return empty bytecode.
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 is, by definition, all actors that don't exist have empty bytecode (in the EVM).
3df8736
to
abe04a7
Compare
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.
What are all these unrelated changes?
Please remove them from this 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.
the relevant parts look ok at first glance however.
Also, and this is important, please dont change toolchain like this in a totally irrelevant pr. This is an important change that should be its own pr. |
…sserting for better debugging help
89bf664
to
4952b9b
Compare
- address todo - use the new get_cid_type
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.
Couple of small nits remaining. I made some larger changes because it was difficult to review this patch due to the added indentation and deep indentation (see the changes I pushed).
let raw_bytecode = rt | ||
.store() | ||
.get(cid) // TODO this is inefficient; should call stat here. | ||
.get(&cid) // TODO this is inefficient; should call stat here. |
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.
This is fine. Note: we don't actually ever expect this error as it should be impossible.
pub fn get_cid_type(rt: &impl Runtime, addr: U256) -> CodeCid { | ||
let addr: EthAddress = addr.into(); | ||
|
||
addr.try_into() |
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.
I flattened this to make it easier to read.
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.
ty
) | ||
} | ||
// If we're calling an account or a non-existent actor, return nothing because | ||
// this is how the EVM behaves. |
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.
I changed this to return "ok" in these cases.
TokenAmount::from(&value), | ||
) | ||
} | ||
CallKind::DelegateCall => match get_cid_type(system.rt, dst) { |
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.
I removed the closure/return. We didn't need them.
Generally speaking, jumping like that is a "last resort" kind of thing as it can make code really hard to follow. It also increases diffs by changing indent.
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 diff was gross for sure. In all honesty this method ended up a lot cleaner than i was thinking (idk what i was thinking tbh). I probably should've given it at least a few minutes of poking before dismissing it as unfeasible.
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.
The important parts look good now, but we probably want to address steven's remarks before merging.
.map(|bytecode| bytecode.len())?; | ||
let len = match get_cid_type(system.rt, addr) { | ||
CodeCid::EVM(addr) => get_evm_bytecode(system.rt, &addr).map(|bytecode| bytecode.len())?, | ||
CodeCid::Native(_) => 1, |
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.
why 1?
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.
ah, 0xfe below.
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.
yes, but has more to do with playing nicely with solidity's behavior of isContract
Can we wait for #885 before merging? |
I mean we already have conflicts, and it will certainly create more with 885. |
* wip fixes * cleanup implementation * return 0 for non existient address in extcodesize * use enum instead of result result maddness * fmt & cleanup some logic * update tests for the remaining two ext opcodes * redo logic to make things a bit more clearn * fix bugs & keep bytecode logic seperate, verify expectations before asserting for better debugging help * add another test case for ext op * use closure for early return * nit: reduce indentation * fix: formatting * remove unnecessary closure * fix: make delegatecall behave more like the EVM - address todo - use the new get_cid_type * fix some review nits Co-authored-by: Steven Allen <steven@stebalien.com>
fixes filecoin-project/ref-fvm#1134