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

V14 Builtin Actors #311

Merged
merged 33 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ca6a039
Add fil actors shared v14 verbatimly
sudo-shashank Jun 21, 2024
ae2b7f6
Add accounts v14
sudo-shashank Jun 21, 2024
1b3aba5
Added cron actor v14
sudo-shashank Jun 21, 2024
21d9a71
Added datacap actor v14
sudo-shashank Jun 21, 2024
29b6248
Added eam actor v14
sudo-shashank Jun 21, 2024
6532386
Added ethaccount actor v14
sudo-shashank Jun 21, 2024
7f9a42e
Added evm actor v14
sudo-shashank Jun 21, 2024
d43c0ad
Added init actor v14
sudo-shashank Jun 21, 2024
80c6b3c
init actor v14
sudo-shashank Jun 21, 2024
801430e
Added market actor v14
sudo-shashank Jun 21, 2024
ab77a55
Added miner actor v14
sudo-shashank Jun 21, 2024
04ea25b
Added multisig actor v14
sudo-shashank Jun 21, 2024
8d0cd22
Added paych actor v14
sudo-shashank Jun 21, 2024
94968fd
Added power actor v14
sudo-shashank Jun 21, 2024
329d359
Added reward actor v14
sudo-shashank Jun 21, 2024
4e66c92
Added system actor v14
sudo-shashank Jun 21, 2024
1879352
Added verifreg actor v14
sudo-shashank Jun 21, 2024
2d45c98
fmt
sudo-shashank Jun 21, 2024
495a9b2
remove actor code
sudo-shashank Jun 21, 2024
c9623a5
remove unused deps
sudo-shashank Jun 21, 2024
53015cf
lint fix
sudo-shashank Jun 23, 2024
1525c38
fix
sudo-shashank Jun 23, 2024
48e4d88
fmt
sudo-shashank Jun 23, 2024
0a805fa
remove unused deps
sudo-shashank Jun 23, 2024
55f8fc2
remove actor code fil actors shared
sudo-shashank Jun 24, 2024
b33b2ad
Update v14 actor cid's
sudo-shashank Jun 24, 2024
ad1a427
Update fil actor interface
sudo-shashank Jun 24, 2024
61d88fb
increase stack size
sudo-shashank Jun 24, 2024
76fe03e
remove unused code
sudo-shashank Jun 24, 2024
2bf3e42
Updated with v14 rc1
sudo-shashank Jun 25, 2024
ab9c888
lint-fix
sudo-shashank Jun 25, 2024
da1fd64
fix: expose `AddressMap`
LesnyRumcajs Jul 2, 2024
027c2f6
fix: add missing modules to the tree
LesnyRumcajs Jul 2, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
CC: "sccache clang"
CXX: "sccache clang++"
- name: Run tests
run: cargo test --workspace --all-features --all-targets
run: RUST_MIN_STACK=8388608 cargo test --workspace --all-features --all-targets
env:
CC: "sccache clang"
CXX: "sccache clang++"
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ base64 = "0.22"
bitflags = "2.4.2"
byteorder = "1.4.3"
cid = { version = "0.10", default-features = false, features = ["std"] }
frc42_dispatch = "7.0.0"
frc42_macros = "5"
frc46_token = "11"
fvm_ipld_amt = "0.6.1"
Expand Down
1 change: 1 addition & 0 deletions actors/account/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ pub mod v10;
pub mod v11;
pub mod v12;
pub mod v13;
pub mod v14;
pub mod v8;
pub mod v9;
22 changes: 22 additions & 0 deletions actors/account/src/v14/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use fvm_shared4::METHOD_CONSTRUCTOR;
use num_derive::FromPrimitive;

pub use self::state::State;
pub use types::*;

mod state;
mod types;

/// Account actor methods available
#[derive(FromPrimitive)]
#[repr(u64)]
pub enum Method {
Constructor = METHOD_CONSTRUCTOR,
PubkeyAddress = 2,
// Deprecated in v10
// AuthenticateMessage = 3,
AuthenticateMessageExported = frc42_macros::method_hash!("AuthenticateMessage"),
}
11 changes: 11 additions & 0 deletions actors/account/src/v14/state.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use fvm_ipld_encoding::tuple::*;
use fvm_shared4::address::Address;

/// State includes the address for the actor
#[derive(Serialize_tuple, Deserialize_tuple, Debug, Clone)]
pub struct State {
pub address: Address,
}
29 changes: 29 additions & 0 deletions actors/account/src/v14/types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use fvm_ipld_encoding::strict_bytes;
use fvm_ipld_encoding::tuple::*;
use fvm_shared4::address::Address;

#[derive(Debug, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct ConstructorParams {
pub address: Address,
}

#[derive(Debug, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct PubkeyAddressReturn {
pub address: Address,
}

#[derive(Debug, Serialize_tuple, Deserialize_tuple)]
pub struct AuthenticateMessageParams {
#[serde(with = "strict_bytes")]
pub signature: Vec<u8>,
#[serde(with = "strict_bytes")]
pub message: Vec<u8>,
}

#[derive(Debug, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct AuthenticateMessageReturn {
pub authenticated: bool,
}
1 change: 1 addition & 0 deletions actors/cron/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ pub mod v10;
pub mod v11;
pub mod v12;
pub mod v13;
pub mod v14;
pub mod v8;
pub mod v9;
27 changes: 27 additions & 0 deletions actors/cron/src/v14/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use fvm_ipld_encoding::tuple::*;

use fvm_shared4::METHOD_CONSTRUCTOR;
use num_derive::FromPrimitive;

pub use self::state::{Entry, State};

mod state;

/// Cron actor methods available
#[derive(FromPrimitive)]
#[repr(u64)]
pub enum Method {
Constructor = METHOD_CONSTRUCTOR,
EpochTick = 2,
}

/// Constructor parameters for Cron actor, contains entries
/// of actors and methods to call on each epoch
#[derive(Default, Debug, Serialize_tuple, Deserialize_tuple)]
pub struct ConstructorParams {
/// Entries is a set of actors (and corresponding methods) to call during EpochTick.
pub entries: Vec<Entry>,
}
21 changes: 21 additions & 0 deletions actors/cron/src/v14/state.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use fvm_ipld_encoding::tuple::*;
use fvm_shared4::address::Address;
use fvm_shared4::MethodNum;

/// Cron actor state which holds entries to call during epoch tick
#[derive(Default, Serialize_tuple, Deserialize_tuple, Clone, Debug)]
pub struct State {
/// Entries is a set of actors (and corresponding methods) to call during EpochTick.
pub entries: Vec<Entry>,
}

#[derive(Clone, PartialEq, Eq, Debug, Serialize_tuple, Deserialize_tuple)]
pub struct Entry {
/// The actor to call (ID address)
pub receiver: Address,
/// The method number to call (must accept empty parameters)
pub method_num: MethodNum,
}
1 change: 1 addition & 0 deletions actors/datacap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ pub mod v10;
pub mod v11;
pub mod v12;
pub mod v13;
pub mod v14;
pub mod v9;
63 changes: 63 additions & 0 deletions actors/datacap/src/v14/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use frc46_token::token::TOKEN_PRECISION;
use fvm_shared4::bigint::BigInt;
use fvm_shared4::econ::TokenAmount;
use fvm_shared4::METHOD_CONSTRUCTOR;
use lazy_static::lazy_static;
use num_derive::FromPrimitive;

pub use self::state::State;
pub use self::types::*;

mod state;
mod types;

pub const DATACAP_GRANULARITY: u64 = TOKEN_PRECISION;

lazy_static! {
// > 800 EiB
pub static ref INFINITE_ALLOWANCE: TokenAmount = TokenAmount::from_atto(
BigInt::from(TOKEN_PRECISION)
* BigInt::from(1_000_000_000_000_000_000_000_i128)
);
}

/// Datacap actor methods available
#[derive(FromPrimitive)]
#[repr(u64)]
pub enum Method {
Constructor = METHOD_CONSTRUCTOR,
// Deprecated in v10
// Mint = 2,
// Destroy = 3,
// Name = 10,
// Symbol = 11,
// TotalSupply = 12,
// BalanceOf = 13,
// Transfer = 14,
// TransferFrom = 15,
// IncreaseAllowance = 16,
// DecreaseAllowance = 17,
// RevokeAllowance = 18,
// Burn = 19,
// BurnFrom = 20,
// Allowance = 21,
// Method numbers derived from FRC-0042 standards
MintExported = frc42_macros::method_hash!("Mint"),
DestroyExported = frc42_macros::method_hash!("Destroy"),
NameExported = frc42_macros::method_hash!("Name"),
SymbolExported = frc42_macros::method_hash!("Symbol"),
GranularityExported = frc42_macros::method_hash!("Granularity"),
TotalSupplyExported = frc42_macros::method_hash!("TotalSupply"),
BalanceExported = frc42_macros::method_hash!("Balance"),
TransferExported = frc42_macros::method_hash!("Transfer"),
TransferFromExported = frc42_macros::method_hash!("TransferFrom"),
IncreaseAllowanceExported = frc42_macros::method_hash!("IncreaseAllowance"),
DecreaseAllowanceExported = frc42_macros::method_hash!("DecreaseAllowance"),
RevokeAllowanceExported = frc42_macros::method_hash!("RevokeAllowance"),
BurnExported = frc42_macros::method_hash!("Burn"),
BurnFromExported = frc42_macros::method_hash!("BurnFrom"),
AllowanceExported = frc42_macros::method_hash!("Allowance"),
}
37 changes: 37 additions & 0 deletions actors/datacap/src/v14/state.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use frc46_token::token;
use fvm_ipld_blockstore::Blockstore;
use fvm_ipld_encoding::tuple::*;
use fvm_shared4::address::Address;
use fvm_shared4::econ::TokenAmount;
use fvm_shared4::error::ExitCode;
use fvm_shared4::ActorID;

use fil_actors_shared::v14::{ActorError, AsActorError};

#[derive(Debug, Serialize_tuple, Deserialize_tuple)]
pub struct State {
pub governor: Address,
pub token: token::state::TokenState,
}

impl State {
pub fn new<BS: Blockstore>(store: &BS, governor: Address) -> Result<State, ActorError> {
let token_state = token::state::TokenState::new(store)
.context_code(ExitCode::USR_ILLEGAL_STATE, "failed to create token state")?;
Ok(State {
governor,
token: token_state,
})
}

// Visible for testing
pub fn balance<BS: Blockstore>(
&self,
bs: &BS,
owner: ActorID,
) -> Result<TokenAmount, ActorError> {
self.token
.get_balance(bs, owner)
.context_code(ExitCode::USR_ILLEGAL_STATE, "failed to get balance")
}
}
85 changes: 85 additions & 0 deletions actors/datacap/src/v14/types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
use fvm_ipld_encoding::tuple::*;
use fvm_shared4::address::Address;
use fvm_shared4::econ::TokenAmount;

#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct ConstructorParams {
pub governor: Address,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct NameReturn {
pub name: String,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct SymbolReturn {
pub symbol: String,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct TotalSupplyReturn {
pub supply: TokenAmount,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct BalanceParams {
pub address: Address,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct BalanceReturn {
pub balance: TokenAmount,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct GetAllowanceReturn {
pub allowance: TokenAmount,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct IncreaseAllowanceReturn {
pub new_allowance: TokenAmount,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct DecreaseAllowanceReturn {
pub new_allowance: TokenAmount,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct RevokeAllowanceReturn {
pub old_allowance: TokenAmount,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
pub struct MintParams {
// Recipient of the newly minted tokens.
pub to: Address,
// Amount of tokens to mint.
pub amount: TokenAmount,
// Addresses to be granted effectively-infinite operator allowance for the recipient.
pub operators: Vec<Address>,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
pub struct DestroyParams {
pub owner: Address,
pub amount: TokenAmount,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
#[serde(transparent)]
pub struct GranularityReturn {
pub granularity: u64,
}
1 change: 1 addition & 0 deletions actors/eam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ pub mod v10;
pub mod v11;
pub mod v12;
pub mod v13;
pub mod v14;
14 changes: 14 additions & 0 deletions actors/eam/src/v14/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use fvm_shared4::METHOD_CONSTRUCTOR;
use num_derive::FromPrimitive;

#[derive(FromPrimitive)]
#[repr(u64)]
pub enum Method {
Constructor = METHOD_CONSTRUCTOR,
Create = 2,
Create2 = 3,
CreateExternal = 4,
}
1 change: 1 addition & 0 deletions actors/ethaccount/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ pub mod v10;
pub mod v11;
pub mod v12;
pub mod v13;
pub mod v14;
16 changes: 16 additions & 0 deletions actors/ethaccount/src/v14/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use fvm_shared4::METHOD_CONSTRUCTOR;
use num_derive::FromPrimitive;

pub use types::*;

mod types;

/// Ethereum Account actor methods.
#[derive(FromPrimitive)]
#[repr(u64)]
pub enum Method {
Constructor = METHOD_CONSTRUCTOR,
}
10 changes: 10 additions & 0 deletions actors/ethaccount/src/v14/types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use fvm_ipld_encoding::strict_bytes;
use fvm_ipld_encoding::tuple::*;

#[derive(Debug, Serialize_tuple, Deserialize_tuple)]
pub struct AuthenticateMessageParams {
#[serde(with = "strict_bytes")]
pub signature: Vec<u8>,
#[serde(with = "strict_bytes")]
pub message: Vec<u8>,
}
1 change: 1 addition & 0 deletions actors/evm/src/evm_shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ pub mod v10;
pub mod v11;
pub mod v12;
pub mod v13;
pub mod v14;
Loading
Loading