Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
1 change: 1 addition & 0 deletions src/lotus_json/actor_states/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mod init_exec_params;
mod miner_change_worker_params;
mod miner_constructor_params;
mod multisig_actor;
mod paych_params;
mod power_actor;
mod reward_methods;
pub mod verified_reg_actor;
546 changes: 546 additions & 0 deletions src/lotus_json/actor_states/methods/paych_params.rs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/rpc/registry/actors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub(crate) mod evm;
pub(crate) mod init;
pub(crate) mod miner;
pub(crate) mod multisig;
pub(crate) mod payment_channel;
pub(crate) mod power;
pub(crate) mod reward;
pub(crate) mod system;
Expand Down
44 changes: 44 additions & 0 deletions src/rpc/registry/actors/payment_channel.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2019-2025 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use crate::rpc::registry::methods_reg::{MethodRegistry, register_actor_methods};
use crate::shim::message::MethodNum;
use cid::Cid;

macro_rules! register_payment_channel_reg_versions {
($registry:expr, $code_cid:expr, $state_version:path) => {{
use $state_version::{ConstructorParams, Method, UpdateChannelStateParams};

// Register methods with parameters
register_actor_methods!(
$registry,
$code_cid,
[
(Method::Constructor, ConstructorParams),
(Method::UpdateChannelState, UpdateChannelStateParams),
]
);

// Register methods without parameters
register_actor_methods!(
$registry,
$code_cid,
[(Method::Settle, empty), (Method::Collect, empty),]
);
}};
}

pub(crate) fn register_actor_methods(registry: &mut MethodRegistry, cid: Cid, version: u64) {
match version {
8 => register_payment_channel_reg_versions!(registry, cid, fil_actor_paych_state::v8),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better not to duplicate version literals here to avoid typos.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we are planning to use enum tracking issue #5937, so we won't have typos.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By typo, I mean the pair of 8 and ::v8, I think it compiles if we write 8 => ::v9 by mistake. My suggested change is in #5996 (comment)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

9 => register_payment_channel_reg_versions!(registry, cid, fil_actor_paych_state::v9),
10 => register_payment_channel_reg_versions!(registry, cid, fil_actor_paych_state::v10),
11 => register_payment_channel_reg_versions!(registry, cid, fil_actor_paych_state::v11),
12 => register_payment_channel_reg_versions!(registry, cid, fil_actor_paych_state::v12),
13 => register_payment_channel_reg_versions!(registry, cid, fil_actor_paych_state::v13),
14 => register_payment_channel_reg_versions!(registry, cid, fil_actor_paych_state::v14),
15 => register_payment_channel_reg_versions!(registry, cid, fil_actor_paych_state::v15),
16 => register_payment_channel_reg_versions!(registry, cid, fil_actor_paych_state::v16),
_ => {}
}
}
Comment thread
akaladarshi marked this conversation as resolved.
6 changes: 5 additions & 1 deletion src/rpc/registry/methods_reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ impl MethodRegistry {

fn register_known_methods(&mut self) {
use crate::rpc::registry::actors::{
account, cron, datacap, evm, init, miner, multisig, power, reward, system, verified_reg,
account, cron, datacap, evm, init, miner, multisig, payment_channel, power, reward,
system, verified_reg,
};

for (&cid, &(actor_type, version)) in ACTOR_REGISTRY.iter() {
Expand All @@ -96,6 +97,9 @@ impl MethodRegistry {
BuiltinActor::VerifiedRegistry => {
verified_reg::register_actor_methods(self, cid, version)
}
BuiltinActor::PaymentChannel => {
payment_channel::register_actor_methods(self, cid, version)
}
_ => {}
}
}
Expand Down
60 changes: 60 additions & 0 deletions src/tool/subcommands/api_cmd/api_compare_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1894,10 +1894,70 @@ fn state_decode_params_api_tests(tipset: &Tipset) -> anyhow::Result<Vec<RpcTest>
tests.extend(datacap_actor_state_decode_params_tests(tipset)?);
tests.extend(multisig_actor_state_decode_params_tests(tipset)?);
tests.extend(verified_reg_actor_state_decode_params_tests(tipset)?);
tests.extend(paych_actor_state_decode_params_tests(tipset)?);

Ok(tests)
}

fn paych_actor_state_decode_params_tests(tipset: &Tipset) -> anyhow::Result<Vec<RpcTest>> {
// payment channel actor address `t066116`
// https://calibration.filscan.io/en/address/t066116/
let paych_address = Address::new_id(66116);

let constructor_params = fil_actor_paych_state::v16::ConstructorParams {
from: Address::new_id(1234).into(),
to: Address::new_id(8457).into(),
};

let update_channel_state = fil_actor_paych_state::v16::UpdateChannelStateParams {
sv: fil_actor_paych_state::v16::SignedVoucher {
channel_addr: Address::new_id(1000).into(),
time_lock_min: 21,
time_lock_max: 234,
secret_pre_image: vec![],
extra: Some(fil_actor_paych_state::v16::ModVerifyParams {
actor: Address::new_id(1234).into(),
method: 223,
data: Default::default(),
}),
lane: 234,
nonce: 231,
amount: Default::default(),
min_settle_height: 0,
merges: vec![],
signature: None,
},
secret: vec![0x11, 0x22, 0x33, 0x44, 0x55], // dummy data
};

Ok(vec![
RpcTest::identity(StateDecodeParams::request((
paych_address,
fil_actor_paych_state::v16::Method::Constructor as u64,
to_vec(&constructor_params).unwrap(),
tipset.key().into(),
))?),
RpcTest::identity(StateDecodeParams::request((
paych_address,
fil_actor_paych_state::v16::Method::UpdateChannelState as u64,
to_vec(&update_channel_state).unwrap(),
tipset.key().into(),
))?),
RpcTest::identity(StateDecodeParams::request((
paych_address,
fil_actor_paych_state::v16::Method::Settle as u64,
vec![],
tipset.key().into(),
))?),
RpcTest::identity(StateDecodeParams::request((
paych_address,
fil_actor_paych_state::v16::Method::Collect as u64,
vec![],
tipset.key().into(),
))?),
])
}

fn evm_actor_state_decode_params_tests(tipset: &Tipset) -> anyhow::Result<Vec<RpcTest>> {
let evm_constructor_params = fil_actor_evm_state::v16::ConstructorParams {
creator: fil_actor_evm_state::evm_shared::v16::address::EthAddress([0; 20]),
Expand Down
4 changes: 4 additions & 0 deletions src/tool/subcommands/api_cmd/test_snapshots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ filecoin_verified_reg_statedecodeparams_1754401651147022.rpcsnap.json.zst
filecoin_verified_reg_statedecodeparams_1754401651147091.rpcsnap.json.zst
filecoin_verified_reg_statedecodeparams_1754401651147157.rpcsnap.json.zst
filecoin_verified_reg_statedecodeparams_1754401651147231.rpcsnap.json.zst
filecoin_payment_channel_statedecodeparams_1756194613312797.rpcsnap.json.zst
filecoin_payment_channel_statedecodeparams_1756194613312868.rpcsnap.json.zst
filecoin_payment_channel_statedecodeparams_1756194613312941.rpcsnap.json.zst
filecoin_payment_channel_statedecodeparams_1756194613313007.rpcsnap.json.zst
Comment thread
coderabbitai[bot] marked this conversation as resolved.
filecoin_statereplay_1743504051038215.rpcsnap.json.zst
filecoin_statesearchmsg_1741784596636715.rpcsnap.json.zst
filecoin_statesearchmsglimited_1741784596704876.rpcsnap.json.zst
Expand Down
Loading