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

Use new ExitCode type and values. #200

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 22 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 18 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ members = [
"test_vm",
]

[patch.crates-io]
# Needed until a new release is published
fvm_shared = { git = "https://github.com/filecoin-project/ref-fvm" }
fvm_sdk = { git = "https://github.com/filecoin-project/ref-fvm" }
fvm_ipld_hamt = { git = "https://github.com/filecoin-project/ref-fvm" }
fvm_ipld_amt = { git = "https://github.com/filecoin-project/ref-fvm" }
fvm_ipld_bitfield = { git = "https://github.com/filecoin-project/ref-fvm" }
fvm_ipld_encoding = { git = "https://github.com/filecoin-project/ref-fvm" }
fvm_ipld_blockstore = { git = "https://github.com/filecoin-project/ref-fvm" }

## Uncomment when working locally on ref-fvm and this repo simultaneously.
## Assumes the ref-fvm checkout is in a sibling directory with the same name.
## (Valid while FVM modules aren't published to crates.io)
Expand All @@ -54,14 +64,14 @@ members = [
## Uncomment entries below when working locally on ref-fvm and this repo simultaneously.
## Assumes the ref-fvm checkout is in a sibling directory with the same name.
## (Valid once FVM modules are published to crates.io)
#[patch.crates-io]
#fvm_shared = { path = "../ref-fvm/shared" }
#fvm_sdk = { path = "../ref-fvm/sdk" }
#fvm_ipld_hamt = { path = "../ref-fvm/ipld/hamt" }
#fvm_ipld_amt = { path = "../ref-fvm/ipld/amt" }
#fvm_ipld_bitfield = { path = "../ref-fvm/ipld/bitfield"}
#fvm_ipld_encoding = { path = "../ref-fvm/ipld/encoding"}
#fvm_ipld_blockstore = { path = "../ref-fvm/ipld/blockstore"}
# [patch.crates-io]
# fvm_shared = { path = "../ref-fvm/shared" }
# fvm_sdk = { path = "../ref-fvm/sdk" }
# fvm_ipld_hamt = { path = "../ref-fvm/ipld/hamt" }
# fvm_ipld_amt = { path = "../ref-fvm/ipld/amt" }
# fvm_ipld_bitfield = { path = "../ref-fvm/ipld/bitfield"}
# fvm_ipld_encoding = { path = "../ref-fvm/ipld/encoding"}
# fvm_ipld_blockstore = { path = "../ref-fvm/ipld/blockstore"}

[profile.wasm]
inherits = "release"
Expand Down
2 changes: 1 addition & 1 deletion actors/account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ crate-type = ["cdylib", "lib"]

[dependencies]
fil_actors_runtime = { version = "8.0.0-alpha.1", path = "../runtime", features = ["fil-actor"] }
fvm_shared = { version = "0.4.0", default-features = false }
fvm_shared = { version = "0.4.1", default-features = false }
serde = { version = "1.0.136", features = ["derive"] }
num-traits = "0.2.14"
num-derive = "0.3.3"
Expand Down
4 changes: 2 additions & 2 deletions actors/account/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Actor {
match address.protocol() {
Protocol::Secp256k1 | Protocol::BLS => {}
protocol => {
return Err(actor_error!(ErrIllegalArgument;
return Err(actor_error!(illegal_argument;
"address must use BLS or SECP protocol, got {}", protocol));
}
}
Expand Down Expand Up @@ -82,7 +82,7 @@ impl ActorCode for Actor {
let addr = Self::pubkey_address(rt)?;
Ok(RawBytes::serialize(addr)?)
}
None => Err(actor_error!(SysErrInvalidMethod; "Invalid method")),
None => Err(actor_error!(unhandled_message; "Invalid method")),
}
}
}
8 changes: 4 additions & 4 deletions actors/account/tests/account_actor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ macro_rules! account_tests {
account_tests! {
happy_construct_secp256k1_address: (
Address::new_secp256k1(&[2; fvm_shared::address::SECP_PUB_LEN]).unwrap(),
ExitCode::Ok
ExitCode::OK
),
happy_construct_bls_address: (
Address::new_bls(&[1; fvm_shared::address::BLS_PUB_LEN]).unwrap(),
ExitCode::Ok
ExitCode::OK
),
fail_construct_id_address: (
Address::new_id(1),
ExitCode::ErrIllegalArgument
ExitCode::USR_ILLEGAL_ARGUMENT
),
fail_construct_actor_address: (
Address::new_actor(&[1, 2, 3]),
ExitCode::ErrIllegalArgument
ExitCode::USR_ILLEGAL_ARGUMENT
),
}
2 changes: 1 addition & 1 deletion actors/cron/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ crate-type = ["cdylib", "lib"]

[dependencies]
fil_actors_runtime = { version = "8.0.0-alpha.1", path = "../runtime", features = ["fil-actor"] }
fvm_shared = { version = "0.4.0", default-features = false }
fvm_shared = { version = "0.4.1", default-features = false }
num-traits = "0.2.14"
num-derive = "0.3.3"
log = "0.4.14"
Expand Down
2 changes: 1 addition & 1 deletion actors/cron/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl ActorCode for Actor {
Self::epoch_tick(rt)?;
Ok(RawBytes::default())
}
None => Err(actor_error!(SysErrInvalidMethod; "Invalid method")),
None => Err(actor_error!(unhandled_message; "Invalid method")),
}
}
}
8 changes: 4 additions & 4 deletions actors/cron/tests/cron_actor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,31 @@ fn epoch_tick_with_entries() {
RawBytes::default(),
0u8.into(),
RawBytes::default(),
ExitCode::Ok,
ExitCode::OK,
);
rt.expect_send(
entry2.receiver,
entry2.method_num,
RawBytes::default(),
0u8.into(),
RawBytes::default(),
ExitCode::ErrIllegalArgument,
ExitCode::USR_ILLEGAL_ARGUMENT,
);
rt.expect_send(
entry3.receiver,
entry3.method_num,
RawBytes::default(),
0u8.into(),
RawBytes::default(),
ExitCode::Ok,
ExitCode::OK,
);
rt.expect_send(
entry4.receiver,
entry4.method_num,
RawBytes::default(),
0u8.into(),
RawBytes::default(),
ExitCode::Ok,
ExitCode::OK,
);

epoch_tick_and_verify(&mut rt);
Expand Down
2 changes: 1 addition & 1 deletion actors/init/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ crate-type = ["cdylib", "lib"]

[dependencies]
fil_actors_runtime = { version = "8.0.0-alpha.1", path = "../runtime", features = ["fil-actor"] }
fvm_shared = { version = "0.4.0", default-features = false }
fvm_shared = { version = "0.4.1", default-features = false }
fvm_ipld_hamt = "0.4.0"
serde = { version = "1.0.136", features = ["derive"] }
num-traits = "0.2.14"
Expand Down
10 changes: 5 additions & 5 deletions actors/init/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Actor {
let sys_ref: &Address = &SYSTEM_ACTOR_ADDR;
rt.validate_immediate_caller_is(std::iter::once(sys_ref))?;
let state = State::new(rt.store(), params.network_name).map_err(|e| {
e.downcast_default(ExitCode::ErrIllegalState, "failed to construct init actor state")
e.downcast_default(ExitCode::USR_ILLEGAL_STATE, "failed to construct init actor state")
})?;

rt.create(&state)?;
Expand All @@ -63,13 +63,13 @@ impl Actor {
log::trace!("called exec; params.code_cid: {:?}", &params.code_cid);

let caller_code = rt.get_actor_code_cid(&rt.message().caller()).ok_or_else(|| {
actor_error!(ErrIllegalState, "no code for caller as {}", rt.message().caller())
actor_error!(illegal_state, "no code for caller as {}", rt.message().caller())
})?;

log::trace!("caller code CID: {:?}", &caller_code);

if !can_exec(rt, &caller_code, &params.code_cid) {
return Err(actor_error!(ErrForbidden;
return Err(actor_error!(forbidden;
"called type {} cannot exec actor type {}",
&caller_code, &params.code_cid
));
Expand All @@ -87,7 +87,7 @@ impl Actor {
// Store mapping of pubkey or actor address to actor ID
let id_address: ActorID = rt.transaction(|s: &mut State, rt| {
s.map_address_to_new_id(rt.store(), &robust_address).map_err(|e| {
e.downcast_default(ExitCode::ErrIllegalState, "failed to allocate ID address")
e.downcast_default(ExitCode::USR_ILLEGAL_STATE, "failed to allocate ID address")
})
})?;

Expand Down Expand Up @@ -126,7 +126,7 @@ impl ActorCode for Actor {
let res = Self::exec(rt, cbor::deserialize_params(params)?)?;
Ok(RawBytes::serialize(res)?)
}
None => Err(actor_error!(SysErrInvalidMethod; "Invalid method")),
None => Err(actor_error!(unhandled_message; "Invalid method")),
}
}
}
Expand Down
Loading