Skip to content
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

[DO NOT MERGE] make eth compliance tester work #1199

Draft
wants to merge 359 commits into
base: fvm-next
Choose a base branch
from

Conversation

vyzo
Copy link
Contributor

@vyzo vyzo commented Feb 10, 2023

Stebalien and others added 30 commits November 11, 2022 14:43
* FVM specific EVM precompiles
- changes randomness functions to take a raw i64 since this is userspace now
- add precompiles: resolve_address, lookup_address, get_actor_code_cid, get_randomness(beacon/chain)

* leave context as TODO

* fixes after rebase

* rustfmt

* add new user randomness functions (that dont limit types to domain seperation tags)

* add some precompile docs, use ID addresses instead of ETH style ID addresses, assert reserved bytes are zeroes

* fmt & clippy

* Update precompiles.rs

* kill old expect randomness functions and route them through the new ones

* rename user get_randomness_x functions to be more consistient

* rustfmt
- CALL: truncates the return value, but doesn't zero fill.
- CALLDATA, EXTCODECOPY, CODECOPY: treat input as if it were followed by
  infinite zeros.
- RETURNDATACOPY: explicitly forbids out-of-bounds reads.

We might be able to change the behavior of EXTCODECOPY and CODECOPY to
match RETURNDATACOPY, but we _can't_ change CALLDATA as solidity abuses
this feature for zeroing memory. So we're just going to match what the
EVM does because it's safer (and because we need to implement that
behavior _anyways_ for CALLDATA).

fixes filecoin-project/ref-fvm#1021
fixes filecoin-project/ref-fvm#1024
We ran out of space.
We can already handle _executing_ with empty bytecode, we just didn't
allow construction.
Includes refactored network/message context syscalls.
* wip callactor precompile (very broken)

* fill out logic a bit

* rustfmt

* pass in context through to precompiles

* exit with error on static call to callactor, array chunks abstraction

* forgot increment cursor...

* actually use gas from call, assert unused bits in randomness params are zeroed

* pass precompile context to all precompiles
add a chunked parameter reader

* improve parameter reader, check for readonly, new precompiles only read u32 for dynamicly sized bytes

* update sdk

* review changes, fix fn name in runtime

* nit: don't comment out code
* 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
* clean up leftovers from CALLACTOR and METHODNUM refactor.

* fix callactor test

* rusftm

Co-authored-by: mriise <[email protected]>
* add unit tests for some opcodes

ADD MUL SUB DIV

* fmt
* fix call_actor precompile; modify error message

* revert modifying error message

* rustfmt
* check stack limits at dispatch, make stack ops unchecked

* use a growable vector for the stack

* fix growth check

* clippy wants default...

* optimize ensure somewhat

* remove implicit assumption about growth patterns

* drop error from Bytecode::new signature, it can't really err.

fix rebase artifact

* refactor part I: primops

* add arity/stack checks for primops

* dup and swap

* push

* immediates

* sugar

* first stdfun

* keccak256 as stdfun and prettier sugar

* moar stdfuns

* calldatacopy

* emacs auto-indent friendly sugar

* more functionoids

* moar funcionoids

* call opcodes

also kill leftover callactor

* primitive -> primop

* codesize and codecopy

* create and create2

* control flow

* mark stack ops as unsafe

only macro mechanically checked invocations for these

* fix tests

* rustfmt

* shut up clippy's frivolous complaints

* nit: macro magic

Co-authored-by: Steven Allen <[email protected]>
* defeat instruction zoo call convention complexity

it's just one, the intrinsic, which passes a machine.

* fix tests

* rip ControlFlow enum

* more macrology

* cosmetics

* shut up clippy
* Update FVM

* feat: correctly handle "read-only" errors.

Co-authored-by: Steven Allen <[email protected]>
* fix: correctly compute addresses in CREATE

And add some basic tests.

fixes #866

* Apply suggestions from code review

Co-authored-by: Melanie Riise <[email protected]>

Co-authored-by: Melanie Riise <[email protected]>
* Export Datacap Actor methods

* Export Init Actor methods

* Export Market Actor methods

* Export Miner Actor methods

* Export Multisig Actor methods

* Export Verifreg Actor methods

* Address review
* Power actor: Add exported getters for raw power

* FRC-XXXX is FRC-0042

* Power actor: network_raw_power: Return this_epoch_raw_byte_power

* Power actor: miner_raw_power: Return whether above consensus min power

* Power actor: types: serialize one-element structs transparently

* Address review

* Miner actor: Add exported getters for info and monies (#811)

* Miner actor: Add exported getters for info and monies

* Tweak comment

* Miner actor: Replace GetWorker and GetControls with IsControllingAddress

* Miner actor: Add exported GetAvailableBalance

* Miner actor: Add exported GetVestingFunds

* Miner actor: Remove exported monies getters

* Miner actor: types: serialize one-element structs transparently

* Address review

* Address review
* Market actor: GetDealTermExported: Return (start_epoch, duration)

* Market actor: Export getter for deal total price
mriise and others added 22 commits February 2, 2023 23:41
fix mockruntime tipset-cid, add unit test for opcode
* add tests for first half of context

* remove blockhash from this PR, fmt

* add remaining context tests
* EVM: reproduce ecMul precompile zero-scalar bug.

* EVM: fix encoding of zero

---------

Co-authored-by: Steven Allen <[email protected]>
* test sload

* test sstore

* make lint happy in macro expansion

* test log0

* test log1

* test log2,3,4
This was probably intended to reduce copying between EVM contracts, but
it makes no difference for us beyond introducing strange types.
- Remove OnceCell and replace it with an Option.
- Move lazy_static to the dev dependencies.
- Manually implement deref instead of importing a crate just for that.
- Remove a bunch of unused dependencies.
* fix: added hyperspace feature for build

* rustfmt
* test codesize

* test codecopy

* test extcode*

* rustfmt
* test address

* test origin

* test caller

* test gas

* test gasprice

* rustfmt
* test call happy path

* test call alternative paths

* test delegatecall

* test staticcall

* test invalid

* rustfmt

* add correctness check sled to test return/revert

* clippy
* test create

* test create edge cases

* test create2

* test create2 variants

* test selfdestruct

* rustfmt

* check nonce on create tests

* test read only conditions

* rustfmt

* add check for tombstone contents
check all instructions for stack underflow behaviour

none should panic.
That way, we:

1. Don't depend on a fork of an unmaintained library.
2. Use a much simpler blake2f implementation.
@vyzo vyzo marked this pull request as draft February 10, 2023 17:53
@vyzo vyzo changed the title [WIP] make eth compliance tester work [DO NOT MERGE] make eth compliance tester work Feb 10, 2023
@Stebalien Stebalien force-pushed the fvm-next branch 3 times, most recently from 3c56111 to 96654e3 Compare September 28, 2023 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.