filecoin-project / builtin-actors Goto Github PK
View Code? Open in Web Editor NEWThe Filecoin built-in actors
License: Other
The Filecoin built-in actors
License: Other
refer to https://github.com/filecoin-project/specs-actors/blob/master/actors/test/commit_post_test.go
refer to https://github.com/filecoin-project/specs-actors/blob/master/actors/test/power_scenario_test.go
|| actors/cron/src/lib.rs: 23/28
cron $ go test -v ./... | grep PASS | sed 's/--- PASS:/- [ ]/g' | sed 's/ (.*)//g' | grep -v PASS
#68 extracted miner policy constants to a runtime Policy
object, but ignored other built-in actors with similar policy settings.
Restructure to make room for configurable policy settings for all built-in actors, maybe something like Policy.Miner.xyz
.
specs-actors implements the CheckState
function for all actors. This function traverses actor state looking for inconsistencies. This check is used both in testing (unit and integration) and in live checks of main net state.
This issue tracks work to duplicate the existing CheckState methods and the top-level traversal of filecoin network state
Move the runtime directory out from under actors so that only actors are in the actors dir.
|| actors/reward/src/expneg.rs: 6/6
|| actors/reward/src/lib.rs: 67/115
|| actors/reward/src/logic.rs: 30/30
|| actors/reward/src/state.rs: 39/50
go test -v ./... | grep PASS | sed 's/--- PASS:/- [ ]/g' | sed 's/ (.*)//g' | grep -v PASS
Similar to https://github.com/filecoin-project/specs-actors/blob/master/support/vm/vm.go - we need a simplified message execution framework that FVM like for integration tests.
Prefer ActorID where possible - check that's the case in rust actor (may impact gases)
similar to filecoin-project/ref-fvm#289
Proposal
I'm switching out our "hash" maps/sets with "btree" maps/sets (in actors, at least) due to filecoin-project/ref-fvm#232. Given this, I'd like to switch some of our parameter processing from "first encountered deadline/partition" to "sorted order" because btrees are ordered anyways.
If we do this right, clients that pass pre-sorted parameters should get a bit of a gas discount as well.
Background
In order to be deterministic pre-FVM, built-in actors that need to "group" inputs either needed to execute these groups based on the order in which they were encountered in the params, or sort them before executing.
By example:
Group, then execute based on first encountered:
let mut grouped = HashMap::<_, Vec<_>>::new();
// Keep track of the order in which we first encounter "keys" (groups).
let mut keys = Vec::new();
for inp in inputs {
let key = key(&inp);
grouped.entry(key).or_insert_with(||{ keys.push(key); key }).push(inp);
}
// Execute based on that order.
for key in keys {
let value = grouped[key];
}
Group then sort:
let mut grouped = HashMap::<_, Vec<_>>::new();
for inp in inputs {
grouped.entry(key(&inp)).or_default().push(inp);
}
// Once we've grouped, extract the keys.
let mut keys = grouped.keys();
// Sort them.
keys.sort();
// Execute based on these keys.
for key in keys {
let value = grouped[key];
}
However, two things have changed:
HashMap
s and HashSet
s to BTreeMap/Set
s.|| actors/power/src/lib.rs: 0/368
|| actors/power/src/state.rs: 16/166
power ⟩ go test -v ./... | grep PASS | sed 's/--- PASS:/- [ ]/g' | sed 's/ (.*)//g' | grep -v PASS
We've discussed bringing these testing helpers to rust actors and this issue tracks the discussion.
I think it makes sense to bring both things over. Less controversially we should at least try to bring ExpectAbort over. There's probably some reason this wasn't added in the first place related to things being different in rust. We should try adding this functionality to the mock runtime and see what happens.
|| actors/init/src/lib.rs: 41/55
|| actors/init/src/state.rs: 17/19
init $ go test -v ./... | grep PASS | sed 's/--- PASS:/- [ ]/g' | sed 's/ (.*)//g' | grep -v PASS
Add basic rules to help people unfamiliar with Rust development environment get started.
Ensure there is a rule that replicates the checks that will run on CI.
|| actors/account/src/lib.rs: 17/22
account $ go test -v ./... | grep PASS | sed 's/--- PASS:/- [ ]/g' | sed 's/ (.*)//g' | grep -v PASS
Currently, we validate proof types manually inside our actors to match go's behavior. It would be safer to simply reject invalid proof types when we attempt to decode state/messages.
Doing this for NV16 (M1) is pretty easy: we'd just remove the Invalid
cases from our enums. E.g.:
Doing this after Nv16 is possible, but slightly tricker as these types tend to be "shared" between versions. Although it shouldn't be too bad as we won't re-compile nv16 actors in nv17.
refer to https://github.com/filecoin-project/specs-actors/blob/master/actors/test/replica_update_test.go
As agreed with @raulk and @Stebalien - we will add error handling, next to the V7 actor's version.
We will then put everything together in the actors V8, which will be used for internal and external audits, which we plan to conduct from Mid March.
warning: bundle=/home/dtynn/proj/github.com/filecoin-project/builtin-actors/target/release/build/filecoin_canonical_actors_bundle-29a911457ca77f1f/out/bundle/bundle.car
error: couldn't read /home/dtynn/proj/github.com/filecoin-project/builtin-actors/target/release/build/filecoin_canonical_actors_bundle-29a911457ca77f1f/out/bundle.car: No such file or directory (os error 2)
--> bundle/src/lib.rs:23:31
|
23 | pub const BUNDLE_CAR: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/bundle.car"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info)
The following warnings were emitted during compilation:
error occurs for cargo build --release
difference between
https://github.com/filecoin-project/builtin-actors/blob/master/bundle/build.rs#L41
and
https://github.com/filecoin-project/builtin-actors/blob/master/bundle/src/lib.rs#L23
In the past, without a real VM, a name like spec-actors or canonical-actors made sense because there were no other actors and this code defined the precise behaviour. But the FVM will introduce a flourishing of new, user-programmed actors that will do all kinds of wonderful things. Some of those will become "canonical" in the loose sense of the work, e.g. by setting standard APIs for tokens, loans, deals, derivatives etc. Using the name canonical for this repo somehow downgrades the importance of the user actors we're seeking to enable.
The axis that will distinguish the actors in this repo from all the others will be that these are built-in to the network, forming part of the consensus rules, and change only with network upgrades. The built-in/user-programmed axis is clear, but I don't think canonical/non-canonical makes as much sense.
refer to https://github.com/filecoin-project/specs-actors/blob/master/actors/test/extend_sectors_test.go
The rust actors lazily validate bitfields because that's what go does. We do want to lazily validate bitfields in state (too expensive to validate them every time we load state), but we should be eagerly validating bitfields in parameters and return values.
Once we start making consensus breaking changes, we should replace all UnvalidatedBitField
s in parameters with BitField
.
Now SnapDeal is live in the network, we should remove all code that's only for the old cc upgrade path, including ReplaceCapacity params.ReplaceSectorNumber and so on.
See #6 (comment).
Currently, we have a lot of "anyhow" errors and rely on error downcasting to figure out the right exit code. Unfortunately, this makes it very difficult to figure out what the exit code should be.
Instead, we'd ideally:
|| actors/market/src/deal.rs: 0/15
|| actors/market/src/lib.rs: 9/816
|| actors/market/src/policy.rs: 0/18
|| actors/market/src/state.rs: 21/311
market $ go test -v ./... | grep PASS | sed 's/--- PASS:/- [ ]/g' | sed 's/ (.*)//g' | grep -v PASS
|| actors/paych/src/lib.rs: 113/171
|| actors/paych/src/state.rs: 2/2
|| actors/paych/src/types.rs: 14/14
paych $ go test -v ./... | grep PASS | sed 's/--- PASS:/- [ ]/g' | sed 's/ (.*)//g' | grep -v PASS
To
Continuing the discussion started in #12.
There are two version numbers that come into play when reasoning about built-in actor evolution and versioning schemes:
IMO, there are roughly two approaches we can take:
Try to make crate versions numbers align with network actor versions numbers.
Only match on the major version, but give total freedom for bumping minor and patch versions in crate versioning.
Currently, we use a vector to match go's behavior of decoding any byte array as "randomness", then later asserting that it's the right length. In M1, we should be able to change this type to just a fixed-length byte array.
Our task is to improve coverage across the board, by porting the spec-actors test suite and ensuring 1-to-1 correspondence (to the point it makes sense).
This issue is here to track progress towards that goal
This is the current coverage as reported by tarpaulin:
Mar 02 18:29:54.671 INFO cargo_tarpaulin::report: Coverage Results:
|| Tested/Total Lines:
|| actors/account/src/lib.rs: 17/22
|| actors/account/tests/account_actor_test.rs: 30/32
|| actors/cron/src/lib.rs: 23/28
|| actors/cron/tests/cron_actor_test.rs: 71/71
|| actors/init/src/lib.rs: 41/55
|| actors/init/src/state.rs: 17/19
|| actors/init/tests/init_actor_test.rs: 130/132
|| actors/market/src/deal.rs: 0/15
|| actors/market/src/lib.rs: 9/816
|| actors/market/src/policy.rs: 0/18
|| actors/market/src/state.rs: 21/311
|| actors/market/tests/market_actor_test.rs: 23/69
|| actors/miner/src/bitfield_queue.rs: 0/55
|| actors/miner/src/deadline_assignment.rs: 0/51
|| actors/miner/src/deadline_info.rs: 0/40
|| actors/miner/src/deadline_state.rs: 0/594
|| actors/miner/src/deadlines.rs: 0/34
|| actors/miner/src/expiration_queue.rs: 0/438
|| actors/miner/src/lib.rs: 0/2353
|| actors/miner/src/monies.rs: 0/65
|| actors/miner/src/partition_state.rs: 0/382
|| actors/miner/src/policy.rs: 0/52
|| actors/miner/src/sector_map.rs: 0/64
|| actors/miner/src/sectors.rs: 0/67
|| actors/miner/src/state.rs: 0/475
|| actors/miner/src/termination.rs: 0/15
|| actors/miner/src/vesting_state.rs: 0/55
|| actors/multisig/src/lib.rs: 0/345
|| actors/multisig/src/state.rs: 0/41
|| actors/multisig/src/types.rs: 0/2
|| actors/paych/src/lib.rs: 113/171
|| actors/paych/src/state.rs: 2/2
|| actors/paych/src/types.rs: 14/14
|| actors/paych/tests/paych_actor_test.rs: 478/500
|| actors/power/src/lib.rs: 0/368
|| actors/power/src/state.rs: 16/166
|| actors/reward/src/expneg.rs: 6/6
|| actors/reward/src/lib.rs: 67/115
|| actors/reward/src/logic.rs: 30/30
|| actors/reward/src/state.rs: 39/50
|| actors/reward/tests/reward_actor_test.rs: 131/137
|| actors/runtime/src/actor_error.rs: 6/16
|| actors/runtime/src/builtin/network.rs: 0/3
|| actors/runtime/src/builtin/sector.rs: 0/4
|| actors/runtime/src/builtin/shared.rs: 3/16
|| actors/runtime/src/builtin/singletons.rs: 4/10
|| actors/runtime/src/lib.rs: 13/13
|| actors/runtime/src/runtime/actor_blockstore.rs: 0/3
|| actors/runtime/src/runtime/fvm.rs: 0/160
|| actors/runtime/src/runtime/mod.rs: 2/12
|| actors/runtime/src/test_utils.rs: 232/369
|| actors/runtime/src/util/balance_table.rs: 33/41
|| actors/runtime/src/util/chaos/mod.rs: 0/84
|| actors/runtime/src/util/downcast.rs: 16/56
|| actors/runtime/src/util/multimap.rs: 27/34
|| actors/runtime/src/util/set.rs: 23/27
|| actors/runtime/src/util/set_multimap.rs: 31/42
|| actors/runtime/src/util/unmarshallable.rs: 9/13
|| actors/runtime/tests/alpha_beta_filter_test.rs: 82/82
|| actors/runtime/tests/balance_table_test.rs: 31/31
|| actors/runtime/tests/multimap_test.rs: 39/39
|| actors/runtime/tests/set_multimap_test.rs: 27/27
|| actors/runtime/tests/set_test.rs: 26/26
|| actors/system/src/lib.rs: 0/8
|| actors/verifreg/src/lib.rs: 0/294
|| actors/verifreg/src/state.rs: 0/7
|| actors/verifreg/src/types.rs: 0/1
|| bundle/bundler/src/bin/bundler.rs: 0/13
|| bundle/bundler/src/lib.rs: 71/75
||
19.97% coverage, 1953/9781 lines covered
As we can see, we have quite low coverage with some actors not covered at all.
See filecoin-project/FIPs#187 and https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0027.md.
At the moment, we reject non-utf8 labels. But we need to make a decision before we ship.
Needed to support nv15 onwards
@jennijuju points out that after we have the revised gas values from the FVM, we should audit those params in actors that could be affected. It's possible that the PreCommitBatch max size, for instance, might need to be lowered if the old max can't theoretically fit in a message anymore.
I do not expect any of these to need to change.
This issue tracks work being carried out in the raulk/initial
branch of this repo:
runtime-wasm
feature from all actors.bundle
module.actor::is_builtin_actor
syscall that returns whether a given CodeCID corresponds to a builtin actor, and to which from an enumerated set.
|| actors/verifreg/src/lib.rs: 0/294
|| actors/verifreg/src/state.rs: 0/7
|| actors/verifreg/src/types.rs: 0/1
verifreg $ go test -v ./... | grep PASS | sed 's/--- PASS:/- [ ]/g' | sed 's/ (.*)//g' | grep -v PASS
details to be added later , parallel with filecoin-project/ref-fvm#349
The specs-actors project has a rich backlog of potential improvements to the built-in actors and supporting code. We should migrate a relevant set of those issues over to this project.
I suggest we do that after these Rust actors have taken over as the ones executing on the network, since we won't make any of the changes until after that point anyway.
refer to https://github.com/filecoin-project/specs-actors/blob/master/actors/test/publish-deals_test.go
We should abort in rust actors as well:
|| actors/system/src/lib.rs: 0/8
system $ go test -v ./... | grep PASS | sed 's/--- PASS:/- [ ]/g' | sed 's/ (.*)//g' | grep -v PASS
|| actors/multisig/src/lib.rs: 0/345
|| actors/multisig/src/state.rs: 0/41
|| actors/multisig/src/types.rs: 0/2
multisig $ go test -v ./... | grep PASS | sed 's/--- PASS:/- [ ]/g' | sed 's/ (.*)//g' | grep -v PASS
|| actors/miner/src/bitfield_queue.rs: 0/55
|| actors/miner/src/deadline_assignment.rs: 0/51
|| actors/miner/src/deadline_info.rs: 0/40
|| actors/miner/src/deadline_state.rs: 0/594
|| actors/miner/src/deadlines.rs: 0/34
|| actors/miner/src/expiration_queue.rs: 0/438
|| actors/miner/src/lib.rs: 0/2353
|| actors/miner/src/monies.rs: 0/65
|| actors/miner/src/partition_state.rs: 0/382
|| actors/miner/src/policy.rs: 0/52
|| actors/miner/src/sector_map.rs: 0/64
|| actors/miner/src/sectors.rs: 0/67
|| actors/miner/src/state.rs: 0/475
|| actors/miner/src/termination.rs: 0/15
|| actors/miner/src/vesting_state.rs: 0/55
go test -v ./... | grep PASS | sed 's/--- PASS:/- [ ]/g' | sed 's/ (.*)//g' | grep -v PASS
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.