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

#656 Fix | actor market | refactor state mutation #726

Conversation

shamb0
Copy link
Contributor

@shamb0 shamb0 commented Sep 30, 2022

Fixes #656 | Remove the market actor state mutation pattern

Hello @anorth,

Took state mutation pattern of fil_actor_miner as reference,
and modified the fil_actor_market mutation pattern. following things are verified on proposed patch & ready for review.

  • State mutation refactor on state.rs - Done
  • Integration to struct Actor - Done
  • Existing Unittest - all OK

vyzo and others added 30 commits July 22, 2022 11:20
…d scripts (filecoin-project#504)

* add devnet-m2-native network with associated features to build scripts

* transitively activate m2-native on runtime

* add devnet-m2-native bundle build target

* fix output target for m2-native bundle

* pacify clippy.

* runtime: Cargo.toml sort dependencies.

* Cargo.toml: point patches to master.

* fix devnet-m2-bundle by propagating Cargo features.

* add build preset / bundle configurations for wallaby and devnet-wasm.

QoL finishing touches:
- The 1:N network/features mapping in runtime/build.rs wasn't cutting it any longer.
  I expanded this data structure to M:N.
- Added docs to runtime/build.rs.

Co-authored-by: vyzo <vyzo@hackzen.org>
* adjust Wallaby parameters.

- minimum consensus power is 16GiB.
- short precommit challenge delay (10 epochs).

* fix: minimum consensus power for wallaby

Co-authored-by: Aayush <arajasek94@gmail.com>
Co-authored-by: Raúl Kripalani <raul@protocol.ai>
…ect#510)

This change makes CI trigger whenever:
- a pull request is opened/updated
- a commit is pushed to `master` branch

The main advantage of this setup is that it enables CI runs on PRs originating from forks.
- removes the explicit instruction array.
- removes the undefined instructions.
- removes the need for ordering instructions in a specific way.
- ensures that we can't talk about invalid instructions.
* bump rust-toolchain to 1.63

[needed for const fn magic]

* fix new clippy warnings,
most changes is just adding `Eq` to derive, only others was avoiding reborrows and allowing a 'complex' type

* change .err.expect to .expect_err, and dont bind to a unit value

Co-authored-by: mriise <me@mriise.net>
Co-authored-by: Melanie Riise <me@mriise.net>
Fix compile when not compiling as a "fil actor" (e.g., for testing).
…-project#583)

This change upgrades to the v4 bundler that _does not_ depend on the FVM to map actor types to IDs. Instead, it relies on the Type enum defined in this repo.

This means new actor types can be added here without having to make changes in multiple places.
Avoid blake2b hashing in wasm

Co-authored-by: Jiaying Wang <42981373+jennijuju@users.noreply.github.com>
* Optimize test_vm get_actor

Improves extend_sector_with_deals by 40%

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>

* Keep the cache across invocations

Gives another 32%

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
…lecoin-project#586)

* refactor: move opcode handlers to appropriate modules.

* implement BASEFEE opcode handler.

* implement SELFBALANCE opcode handler.

* EVM runtime: add an initial Address type that performs ID address masking.

* EVM runtime: convert EVM errors to ActorErrors.

* EVM runtime: commented selfdestruct.

* EVM runtime: implement DIFFICULTY, NUMBER, COINBASE opcodes.

* EVM runtime: add conversion from actor ID to masked address.

Make CALLER, ADDRESS, ORIGIN use masked ID addresses.

* remove TODO.

* add comment.

* fix clippy.

* adjust test for ID address flag.
raulk and others added 28 commits October 3, 2022 07:17
This required a small refactor to allow us to mutably borrow the Runtime.
* add etk-asm dev dependency

* cargo lock

* basic contract assembler

* magic calc contract

* rustfmt

* clippy

* hide error details from magic calc contract constructor

* clippy

* add docs for asm::new_contract
* add dispatch macros for contract assembler

* avoid extraneous stack copy
* refactor evm contract invocation so that we can make cross contract calls

Limits the scope of the transaction to just saving the state.

* rustfmt

* clean up precompile calls and make scaffolding for actual implementation

- drops H160 -- wtf is that even useful
- adds dispatcher for actual call implementations
- removes inline directive from big things

* clean up error handling surrounding call; don't panic left and right

* fix error handling with status codes

* implement CALL

* propagate nested ActorErrors from bytecode execution

* more nested actor error handling

* rustfmt

* pass value through CALL

* rustfmt

* correctly handle call variant arguments

the value was missing from call/callcode.
also kill the useless create call kinds.

* rustfmt

* update comment, move common check outside of march arm

* clippy

* rustfmt

* fix typo

* ok_or_else instead of match.

* Precompile asm tests (filecoin-project#615)

* organize test files, WIP precompile ASM test

* fix precompile test asm, add tests for sha precompile

* use sha2-256 instead of keccak in precompiles

* un-reorg evm tests

* un-rename simplecoin test

* save return data

* fix handling of output memory regions

* address space is 32 bits

* names, names, names

* proxy call test

* fix overflow

Co-authored-by: Melanie Riise <me@mriise.net>
…#619)

* remove H160/H256 abstraction and transactions, use (safe) Address type for addresses.

* rustfmt

* store addresses as a 20-byte array internally

* rustfmt

* implement Debug for Address

* clippy

* improve error message in try_from conversion failure
- Fixes the non-test build by making libsecp256k1 _optional_ unless we're testing.
- Makes a lot of dependencies "test only".
- Removes some unnecessary dependencies.
* add note about gas

* barf with jumbo output addresses; can't do more than 32 bits anyway in wasm.

* add TODO comment about output memory limit
…n-project#631)

* EVM runtime: implement GetBytecode and GetStorageAt getters.

GetBytecode returns the CID of the bytecode block. In the future,
the FVM's reachability analysis should add this CID to the reachable set
of the caller. GetBytecode is publicly callable.

GetStorageAt returns the value stored in the supplied EVM storage key.
This method is private and only intended for calls from instrumentation and
client functionality, such as the eth_getStorageAt JSON-RPC API operation.
In order to make it private, it validates that the caller is the zero address.
It needs to be private to preserve EVM guarantees: no contract is able to
arbitrarily access storage keys from another contract. The client must form
a message from the 0x0 sender address for this method to work.

* it's not scala!

Co-authored-by: vyzo <vyzo@hackzen.org>
…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
* fix broken init test

* fix broken rand import

* only enable rand/std_rng when test_utils is specified
EVM contracts don't take parameters on construction.
…sts (filecoin-project#654)

* bn pair tests and errors

* add ec_recover test, fix broken implementation

* add modexp test, add more test cases for ec_recover

* only check lower bound for ec_recover

* Fix broken failure modes in precompiles
- ec_recover
- modexp
- ec_add
- ec_mul

Change error enum to include field error types + conversions
- forked bn to derive Eq on bn Errors

Add helper for reading padded bytes from input.

* rustfmt & clippy

* Update precompiles.rs

* use cow instead of custom container

* remove fork of bn

* remove bn for dep

* allocate ahead of time when reading sets of

* lazy_static secp256k1 lower bound

* left pad ecrecover

* hex literal and cargo lock

* add padding test

* space

* dont panic on modexp len

* few remaining nits

* rustfmt

* better read logic of bigints for modexp

* add notes to reading bigint lengths & refactor read group for more clarity

* rustfmt
The embryo actor:

- Has no constructor (the system is expected to simply "set" the embryo
  code CID, not construct it).
- Immediately aborts when called with a non-zero method.

We could, alternatively, use some well-known "id" address. But it's nice
to make this actual valid wasm.
Otherwise, we'll perform a hash in WASM when we first dereference (max
once per call) which is just wasteful.

This also fixes the integration tests to use the "correct" empty object.
Previously, they were using `()` which mapped to null, not `[]`.
- Adds a create4 method to the init actor.
- Adds embryo actor creation to the test vm.
* EVM-887: Makefile to generate Solidity compilation artifacts.

* EVM-887: Use solc 0.8.15

* EVM-887: Storage test contract

* EVM-887: Fix contract name.

* EVM-887: Just return the sum without writing it to the counter.
Signed-off-by: shamb0 <r.raajey@gmail.com>
Signed-off-by: shamb0 <r.raajey@gmail.com>
Signed-off-by: shamb0 <r.raajey@gmail.com>
Signed-off-by: shamb0 <r.raajey@gmail.com>
@shamb0
Copy link
Contributor Author

shamb0 commented Oct 3, 2022

Thanks @anorth,

for quick feedback, re-baseing to master went bad, will close this and open a Fresh & clean one 😄

@shamb0 shamb0 closed this Oct 3, 2022
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.

Remove the market actor state mutation pattern