mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-06-29 10:29:32 +00:00
chore: some cleanup
This commit is contained in:
parent
7eda252ae8
commit
36ed949be0
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -8905,7 +8905,6 @@ dependencies = [
|
||||
"logos-blockchain-zone-sdk",
|
||||
"mempool",
|
||||
"num-bigint 0.4.6",
|
||||
"ping_core",
|
||||
"rand 0.8.6",
|
||||
"risc0-zkvm",
|
||||
"serde",
|
||||
|
||||
@ -67,10 +67,15 @@ async fn lock_on_zone_a_mints_wrapped_token_on_zone_b() -> Result<()> {
|
||||
let (seq_a, _seq_a_home) = setup_sequencer(partial, bedrock_addr, genesis_a, channel_a, None)
|
||||
.await
|
||||
.context("Failed to set up zone A sequencer")?;
|
||||
let (_seq_b, _seq_b_home) =
|
||||
setup_sequencer(partial, bedrock_addr, vec![], channel_b, Some(cross_zone.clone()))
|
||||
.await
|
||||
.context("Failed to set up zone B sequencer")?;
|
||||
let (_seq_b, _seq_b_home) = setup_sequencer(
|
||||
partial,
|
||||
bedrock_addr,
|
||||
vec![],
|
||||
channel_b,
|
||||
Some(cross_zone.clone()),
|
||||
)
|
||||
.await
|
||||
.context("Failed to set up zone B sequencer")?;
|
||||
let (idx_b, _idx_b_home) = setup_indexer(bedrock_addr, channel_b, Some(cross_zone))
|
||||
.await
|
||||
.context("Failed to set up zone B indexer")?;
|
||||
@ -101,11 +106,16 @@ async fn lock_on_zone_a_mints_wrapped_token_on_zone_b() -> Result<()> {
|
||||
// escrow now.
|
||||
let seq_a_client = sequencer_client(seq_a.addr())?;
|
||||
let escrow_id = bridge_lock_core::escrow_account_id(Program::bridge_lock().id());
|
||||
let escrowed =
|
||||
bridge_lock_core::read_balance(&seq_a_client.get_account(escrow_id).await?.data.into_inner());
|
||||
assert_eq!(escrowed, LOCK_AMOUNT, "zone A escrow must hold the locked amount");
|
||||
let remaining =
|
||||
bridge_lock_core::read_balance(&seq_a_client.get_account(holder_id).await?.data.into_inner());
|
||||
let escrowed = bridge_lock_core::read_balance(
|
||||
&seq_a_client.get_account(escrow_id).await?.data.into_inner(),
|
||||
);
|
||||
assert_eq!(
|
||||
escrowed, LOCK_AMOUNT,
|
||||
"zone A escrow must hold the locked amount"
|
||||
);
|
||||
let remaining = bridge_lock_core::read_balance(
|
||||
&seq_a_client.get_account(holder_id).await?.data.into_inner(),
|
||||
);
|
||||
assert_eq!(
|
||||
remaining,
|
||||
INITIAL_BALANCE - LOCK_AMOUNT,
|
||||
@ -116,7 +126,11 @@ async fn lock_on_zone_a_mints_wrapped_token_on_zone_b() -> Result<()> {
|
||||
|
||||
/// Builds a signed bridge_lock Lock that forwards a wrapped-token Mint of the
|
||||
/// locked amount to the recipient on the target zone.
|
||||
fn build_lock_tx(holder_key: &PrivateKey, holder_id: AccountId, target_zone: [u8; 32]) -> LeeTransaction {
|
||||
fn build_lock_tx(
|
||||
holder_key: &PrivateKey,
|
||||
holder_id: AccountId,
|
||||
target_zone: [u8; 32],
|
||||
) -> LeeTransaction {
|
||||
let bridge_lock_id = Program::bridge_lock().id();
|
||||
let wrapped_token_id = Program::wrapped_token().id();
|
||||
let outbox_id = Program::cross_zone_outbox().id();
|
||||
|
||||
@ -105,8 +105,13 @@ fn build_ping_tx(target_zone: [u8; 32], receiver_id: ProgramId) -> LeeTransactio
|
||||
};
|
||||
|
||||
let outbox_account = outbox_pda(outbox_id, &target_zone, ordinal);
|
||||
let message = Message::try_new(Program::ping_sender().id(), vec![outbox_account], vec![], send)
|
||||
.expect("build ping message");
|
||||
let message = Message::try_new(
|
||||
Program::ping_sender().id(),
|
||||
vec![outbox_account],
|
||||
vec![],
|
||||
send,
|
||||
)
|
||||
.expect("build ping message");
|
||||
LeeTransaction::Public(PublicTransaction::new(
|
||||
message,
|
||||
lee::public_transaction::WitnessSet::from_raw_parts(vec![]),
|
||||
|
||||
@ -60,10 +60,15 @@ async fn indexer_verifies_and_delivers_cross_zone_ping() -> Result<()> {
|
||||
let (_idx_a, _idx_a_home) = setup_indexer(bedrock_addr, channel_a, None)
|
||||
.await
|
||||
.context("Failed to set up zone A indexer")?;
|
||||
let (_seq_b, _seq_b_home) =
|
||||
setup_sequencer(partial, bedrock_addr, vec![], channel_b, Some(cross_zone.clone()))
|
||||
.await
|
||||
.context("Failed to set up zone B sequencer")?;
|
||||
let (_seq_b, _seq_b_home) = setup_sequencer(
|
||||
partial,
|
||||
bedrock_addr,
|
||||
vec![],
|
||||
channel_b,
|
||||
Some(cross_zone.clone()),
|
||||
)
|
||||
.await
|
||||
.context("Failed to set up zone B sequencer")?;
|
||||
let (idx_b, _idx_b_home) = setup_indexer(bedrock_addr, channel_b, Some(cross_zone))
|
||||
.await
|
||||
.context("Failed to set up zone B indexer")?;
|
||||
@ -112,8 +117,13 @@ fn build_ping_tx(target_zone: [u8; 32], receiver_id: ProgramId) -> LeeTransactio
|
||||
};
|
||||
|
||||
let outbox_account = outbox_pda(outbox_id, &target_zone, ordinal);
|
||||
let message = Message::try_new(Program::ping_sender().id(), vec![outbox_account], vec![], send)
|
||||
.expect("build ping message");
|
||||
let message = Message::try_new(
|
||||
Program::ping_sender().id(),
|
||||
vec![outbox_account],
|
||||
vec![],
|
||||
send,
|
||||
)
|
||||
.expect("build ping message");
|
||||
LeeTransaction::Public(PublicTransaction::new(
|
||||
message,
|
||||
lee::public_transaction::WitnessSet::from_raw_parts(vec![]),
|
||||
|
||||
@ -96,7 +96,9 @@ async fn wait_until_zone_live(
|
||||
loop {
|
||||
let finalized = indexer.get_last_finalized_block_id().await?.unwrap_or(0);
|
||||
if finalized >= target {
|
||||
log::info!("Zone {label} live: sequencer at {target}, indexer finalized {finalized}");
|
||||
log::info!(
|
||||
"Zone {label} live: sequencer at {target}, indexer finalized {finalized}"
|
||||
);
|
||||
return Ok::<u64, anyhow::Error>(finalized);
|
||||
}
|
||||
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||
|
||||
@ -102,17 +102,25 @@ fn lock_escrows_balance_and_emits_to_outbox() {
|
||||
|
||||
let holder_after =
|
||||
bridge_lock_core::read_balance(&public_diff[&holder_id].data.clone().into_inner());
|
||||
assert_eq!(holder_after, INITIAL_BALANCE - LOCK_AMOUNT, "holder debited");
|
||||
assert_eq!(
|
||||
holder_after,
|
||||
INITIAL_BALANCE - LOCK_AMOUNT,
|
||||
"holder debited"
|
||||
);
|
||||
|
||||
let escrow_after =
|
||||
bridge_lock_core::read_balance(&public_diff[&escrow_id].data.clone().into_inner());
|
||||
assert_eq!(escrow_after, LOCK_AMOUNT, "escrow credited");
|
||||
|
||||
let record = OutboxRecord::from_bytes(&public_diff[&outbox_record_id].data.clone().into_inner())
|
||||
.expect("outbox PDA holds an OutboxRecord");
|
||||
let record =
|
||||
OutboxRecord::from_bytes(&public_diff[&outbox_record_id].data.clone().into_inner())
|
||||
.expect("outbox PDA holds an OutboxRecord");
|
||||
assert_eq!(record.target_zone, zone_b);
|
||||
assert_eq!(record.target_program_id, wrapped_token_id);
|
||||
assert_eq!(record.payload, payload, "emitted payload is the wrapped mint");
|
||||
assert_eq!(
|
||||
record.payload, payload,
|
||||
"emitted payload is the wrapped mint"
|
||||
);
|
||||
}
|
||||
|
||||
/// Drives a hand-built `cross_zone_inbox::Dispatch` (as the watcher would inject)
|
||||
@ -179,7 +187,10 @@ fn inbox_dispatch_mints_wrapped_token() {
|
||||
|
||||
let minted =
|
||||
wrapped_token_core::read_balance(&public_diff[&holding_id].data.clone().into_inner());
|
||||
assert_eq!(minted, LOCK_AMOUNT, "recipient holding minted the locked amount");
|
||||
assert_eq!(
|
||||
minted, LOCK_AMOUNT,
|
||||
"recipient holding minted the locked amount"
|
||||
);
|
||||
}
|
||||
|
||||
/// A dispatch whose message key is already in the seen-shard is an idempotent
|
||||
@ -229,7 +240,10 @@ fn mint_replay_rejected() {
|
||||
Account {
|
||||
program_owner: inbox_id,
|
||||
balance: 0,
|
||||
data: shard.to_bytes().try_into().expect("shard fits in account data"),
|
||||
data: shard
|
||||
.to_bytes()
|
||||
.try_into()
|
||||
.expect("shard fits in account data"),
|
||||
nonce: 0_u128.into(),
|
||||
},
|
||||
);
|
||||
@ -261,15 +275,15 @@ fn mint_replay_rejected() {
|
||||
let public_diff = diff.public_diff();
|
||||
|
||||
// No mint: the holding is never credited on replay.
|
||||
let minted = public_diff
|
||||
.get(&holding_id)
|
||||
.map_or(0, |account| wrapped_token_core::read_balance(&account.data.clone().into_inner()));
|
||||
let minted = public_diff.get(&holding_id).map_or(0, |account| {
|
||||
wrapped_token_core::read_balance(&account.data.clone().into_inner())
|
||||
});
|
||||
assert_eq!(minted, 0, "a replayed message must not mint again");
|
||||
|
||||
// The seen-shard is untouched by the no-op.
|
||||
if let Some(seen) = public_diff.get(&seen_id) {
|
||||
let shard_after = SeenShard::from_bytes(&seen.data.clone().into_inner())
|
||||
.expect("seen shard decodes");
|
||||
let shard_after =
|
||||
SeenShard::from_bytes(&seen.data.clone().into_inner()).expect("seen shard decodes");
|
||||
assert_eq!(shard_after, shard, "replay must not modify the seen-shard");
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,11 +10,12 @@ use crate::{
|
||||
error::LeeError,
|
||||
program_methods::{
|
||||
AMM_ELF, AMM_ID, ASSOCIATED_TOKEN_ACCOUNT_ELF, ASSOCIATED_TOKEN_ACCOUNT_ID,
|
||||
AUTHENTICATED_TRANSFER_ELF, AUTHENTICATED_TRANSFER_ID, BRIDGE_ELF, BRIDGE_ID, CLOCK_ELF,
|
||||
CLOCK_ID, CROSS_ZONE_INBOX_ELF, CROSS_ZONE_INBOX_ID, CROSS_ZONE_OUTBOX_ELF,
|
||||
CROSS_ZONE_OUTBOX_ID, FAUCET_ELF, FAUCET_ID, PINATA_ELF, PINATA_ID, PING_RECEIVER_ELF,
|
||||
PING_RECEIVER_ID, PING_SENDER_ELF, PING_SENDER_ID, TOKEN_ELF, TOKEN_ID, VAULT_ELF,
|
||||
VAULT_ID, BRIDGE_LOCK_ELF, BRIDGE_LOCK_ID, WRAPPED_TOKEN_ELF, WRAPPED_TOKEN_ID,
|
||||
AUTHENTICATED_TRANSFER_ELF, AUTHENTICATED_TRANSFER_ID, BRIDGE_ELF, BRIDGE_ID,
|
||||
BRIDGE_LOCK_ELF, BRIDGE_LOCK_ID, CLOCK_ELF, CLOCK_ID, CROSS_ZONE_INBOX_ELF,
|
||||
CROSS_ZONE_INBOX_ID, CROSS_ZONE_OUTBOX_ELF, CROSS_ZONE_OUTBOX_ID, FAUCET_ELF, FAUCET_ID,
|
||||
PINATA_ELF, PINATA_ID, PING_RECEIVER_ELF, PING_RECEIVER_ID, PING_SENDER_ELF,
|
||||
PING_SENDER_ID, TOKEN_ELF, TOKEN_ID, VAULT_ELF, VAULT_ID, WRAPPED_TOKEN_ELF,
|
||||
WRAPPED_TOKEN_ID,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -752,7 +752,10 @@ pub mod tests {
|
||||
Program::cross_zone_outbox().id(),
|
||||
Program::cross_zone_outbox(),
|
||||
);
|
||||
this.insert(Program::cross_zone_inbox().id(), Program::cross_zone_inbox());
|
||||
this.insert(
|
||||
Program::cross_zone_inbox().id(),
|
||||
Program::cross_zone_inbox(),
|
||||
);
|
||||
this.insert(Program::ping_sender().id(), Program::ping_sender());
|
||||
this.insert(Program::ping_receiver().id(), Program::ping_receiver());
|
||||
this.insert(Program::bridge_lock().id(), Program::bridge_lock());
|
||||
|
||||
@ -127,7 +127,10 @@ impl CrossZoneVerifier {
|
||||
|
||||
let key = message_key(&msg.src_zone, msg.src_block_id, msg.src_tx_index);
|
||||
if self.seen.read().await.contains(&key) {
|
||||
bail!("cross-zone replay: message {} re-delivered", hex::encode(key));
|
||||
bail!(
|
||||
"cross-zone replay: message {} re-delivered",
|
||||
hex::encode(key)
|
||||
);
|
||||
}
|
||||
|
||||
let expected = self.rederive(&msg).await?;
|
||||
@ -192,7 +195,10 @@ impl CrossZoneVerifier {
|
||||
.transactions
|
||||
.get(msg.src_tx_index as usize)
|
||||
.ok_or_else(|| {
|
||||
anyhow::anyhow!("src_tx_index {} out of range in peer block", msg.src_tx_index)
|
||||
anyhow::anyhow!(
|
||||
"src_tx_index {} out of range in peer block",
|
||||
msg.src_tx_index
|
||||
)
|
||||
})?;
|
||||
|
||||
let LeeTransaction::Public(emission_tx) = emission_tx else {
|
||||
@ -241,7 +247,12 @@ impl CrossZoneVerifier {
|
||||
if let Some(block) = self.peers.get(zone, block_id).await {
|
||||
return Ok(block);
|
||||
}
|
||||
if self.peers.highest_seen(zone).await.is_some_and(|h| h >= block_id) {
|
||||
if self
|
||||
.peers
|
||||
.highest_seen(zone)
|
||||
.await
|
||||
.is_some_and(|h| h >= block_id)
|
||||
{
|
||||
bail!(
|
||||
"forged cross-zone reference: peer zone {} finalized past block {} but it is absent",
|
||||
hex::encode(zone),
|
||||
@ -269,7 +280,10 @@ async fn read_peer(
|
||||
peers: PeerBlocks,
|
||||
poll_interval: Duration,
|
||||
) {
|
||||
info!("Cross-zone peer reader started for {}", hex::encode(peer_zone));
|
||||
info!(
|
||||
"Cross-zone peer reader started for {}",
|
||||
hex::encode(peer_zone)
|
||||
);
|
||||
|
||||
let mut cursor = None;
|
||||
loop {
|
||||
@ -371,7 +385,10 @@ mod tests {
|
||||
let verifier = verifier();
|
||||
verifier
|
||||
.peers
|
||||
.insert(PEER_ZONE, produce_dummy_block(PEER_BLOCK_ID, None, vec![emission(b"hi")]))
|
||||
.insert(
|
||||
PEER_ZONE,
|
||||
produce_dummy_block(PEER_BLOCK_ID, None, vec![emission(b"hi")]),
|
||||
)
|
||||
.await;
|
||||
|
||||
let block = produce_dummy_block(9, None, vec![dispatch(b"hi")]);
|
||||
@ -388,12 +405,18 @@ mod tests {
|
||||
// different payload, so re-derivation does not reproduce it.
|
||||
verifier
|
||||
.peers
|
||||
.insert(PEER_ZONE, produce_dummy_block(PEER_BLOCK_ID, None, vec![emission(b"real")]))
|
||||
.insert(
|
||||
PEER_ZONE,
|
||||
produce_dummy_block(PEER_BLOCK_ID, None, vec![emission(b"real")]),
|
||||
)
|
||||
.await;
|
||||
|
||||
let block = produce_dummy_block(9, None, vec![dispatch(b"forged")]);
|
||||
let err = verifier.verify_block(&block).await.unwrap_err();
|
||||
assert!(err.to_string().contains("forged"), "unexpected error: {err}");
|
||||
assert!(
|
||||
err.to_string().contains("forged"),
|
||||
"unexpected error: {err}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@ -405,7 +428,10 @@ mod tests {
|
||||
let verifier = verifier_with_pinned_keys(keys);
|
||||
verifier
|
||||
.peers
|
||||
.insert(PEER_ZONE, produce_dummy_block(PEER_BLOCK_ID, None, vec![emission(b"hi")]))
|
||||
.insert(
|
||||
PEER_ZONE,
|
||||
produce_dummy_block(PEER_BLOCK_ID, None, vec![emission(b"hi")]),
|
||||
)
|
||||
.await;
|
||||
|
||||
let block = produce_dummy_block(9, None, vec![dispatch(b"hi")]);
|
||||
@ -423,12 +449,18 @@ mod tests {
|
||||
let verifier = verifier_with_pinned_keys(keys);
|
||||
verifier
|
||||
.peers
|
||||
.insert(PEER_ZONE, produce_dummy_block(PEER_BLOCK_ID, None, vec![emission(b"hi")]))
|
||||
.insert(
|
||||
PEER_ZONE,
|
||||
produce_dummy_block(PEER_BLOCK_ID, None, vec![emission(b"hi")]),
|
||||
)
|
||||
.await;
|
||||
|
||||
let block = produce_dummy_block(9, None, vec![dispatch(b"hi")]);
|
||||
let err = verifier.verify_block(&block).await.unwrap_err();
|
||||
assert!(err.to_string().contains("pinned"), "unexpected error: {err}");
|
||||
assert!(
|
||||
err.to_string().contains("pinned"),
|
||||
"unexpected error: {err}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@ -439,12 +471,18 @@ mod tests {
|
||||
// and must be rejected rather than waited on forever.
|
||||
verifier
|
||||
.peers
|
||||
.insert(PEER_ZONE, produce_dummy_block(PEER_BLOCK_ID + 1, None, vec![emission(b"hi")]))
|
||||
.insert(
|
||||
PEER_ZONE,
|
||||
produce_dummy_block(PEER_BLOCK_ID + 1, None, vec![emission(b"hi")]),
|
||||
)
|
||||
.await;
|
||||
|
||||
let block = produce_dummy_block(9, None, vec![dispatch(b"hi")]);
|
||||
let err = verifier.verify_block(&block).await.unwrap_err();
|
||||
assert!(err.to_string().contains("forged"), "unexpected error: {err}");
|
||||
assert!(
|
||||
err.to_string().contains("forged"),
|
||||
"unexpected error: {err}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@ -452,14 +490,23 @@ mod tests {
|
||||
let verifier = verifier();
|
||||
verifier
|
||||
.peers
|
||||
.insert(PEER_ZONE, produce_dummy_block(PEER_BLOCK_ID, None, vec![emission(b"hi")]))
|
||||
.insert(
|
||||
PEER_ZONE,
|
||||
produce_dummy_block(PEER_BLOCK_ID, None, vec![emission(b"hi")]),
|
||||
)
|
||||
.await;
|
||||
|
||||
let first = produce_dummy_block(9, None, vec![dispatch(b"hi")]);
|
||||
verifier.verify_block(&first).await.expect("first delivery verifies");
|
||||
verifier
|
||||
.verify_block(&first)
|
||||
.await
|
||||
.expect("first delivery verifies");
|
||||
|
||||
let replay = produce_dummy_block(10, None, vec![dispatch(b"hi")]);
|
||||
let err = verifier.verify_block(&replay).await.unwrap_err();
|
||||
assert!(err.to_string().contains("replay"), "unexpected error: {err}");
|
||||
assert!(
|
||||
err.to_string().contains("replay"),
|
||||
"unexpected error: {err}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@ faucet_core.workspace = true
|
||||
bridge_core.workspace = true
|
||||
vault_core.workspace = true
|
||||
cross_zone_inbox_core = { workspace = true, features = ["host"] }
|
||||
ping_core.workspace = true
|
||||
bridge_lock_core = { workspace = true, features = ["host"] }
|
||||
|
||||
logos-blockchain-key-management-system-service.workspace = true
|
||||
|
||||
@ -71,7 +71,10 @@ async fn watch_peer(
|
||||
poll_interval: Duration,
|
||||
mempool_handle: MemPoolHandle<(TransactionOrigin, LeeTransaction)>,
|
||||
) {
|
||||
info!("Cross-zone watcher started for peer {}", hex::encode(peer_zone));
|
||||
info!(
|
||||
"Cross-zone watcher started for peer {}",
|
||||
hex::encode(peer_zone)
|
||||
);
|
||||
|
||||
let mut cursor = None;
|
||||
loop {
|
||||
@ -183,7 +186,10 @@ async fn deliver_block(
|
||||
);
|
||||
|
||||
match mempool_handle
|
||||
.push((TransactionOrigin::Sequencer, LeeTransaction::Public(dispatch)))
|
||||
.push((
|
||||
TransactionOrigin::Sequencer,
|
||||
LeeTransaction::Public(dispatch),
|
||||
))
|
||||
.await
|
||||
{
|
||||
Ok(()) => info!(
|
||||
|
||||
@ -616,7 +616,9 @@ fn build_genesis_state(config: &SequencerConfig) -> (lee::V03State, Vec<LeeTrans
|
||||
GenesisAction::SupplyAccount {
|
||||
account_id,
|
||||
balance,
|
||||
} => Some(build_supply_account_genesis_transaction(account_id, *balance)),
|
||||
} => Some(build_supply_account_genesis_transaction(
|
||||
account_id, *balance,
|
||||
)),
|
||||
GenesisAction::SupplyBridgeAccount { balance } => {
|
||||
Some(build_supply_bridge_account_genesis_transaction(*balance))
|
||||
}
|
||||
@ -1744,7 +1746,9 @@ mod sequencer_only_program_tests {
|
||||
#[test]
|
||||
fn only_the_cross_zone_inbox_is_sequencer_only() {
|
||||
assert!(is_sequencer_only_program(Program::cross_zone_inbox().id()));
|
||||
assert!(!is_sequencer_only_program(Program::cross_zone_outbox().id()));
|
||||
assert!(!is_sequencer_only_program(
|
||||
Program::cross_zone_outbox().id()
|
||||
));
|
||||
assert!(!is_sequencer_only_program(Program::wrapped_token().id()));
|
||||
assert!(!is_sequencer_only_program(Program::ping_sender().id()));
|
||||
assert!(!is_sequencer_only_program(Program::clock().id()));
|
||||
|
||||
@ -96,7 +96,11 @@ fn main() {
|
||||
caller_program_id,
|
||||
instruction_words,
|
||||
vec![holder, escrow, outbox.clone()],
|
||||
vec![holder_post, escrow_post, AccountPostState::new(outbox.account)],
|
||||
vec![
|
||||
holder_post,
|
||||
escrow_post,
|
||||
AccountPostState::new(outbox.account),
|
||||
],
|
||||
)
|
||||
.with_chained_calls(vec![call])
|
||||
.write();
|
||||
|
||||
@ -34,7 +34,8 @@ fn main() {
|
||||
|
||||
let mut post_account = record.account.clone();
|
||||
post_account.data = payload.try_into().expect("payload fits in account data");
|
||||
let post = AccountPostState::new_claimed_if_default(post_account, Claim::Pda(ping_record_seed()));
|
||||
let post =
|
||||
AccountPostState::new_claimed_if_default(post_account, Claim::Pda(ping_record_seed()));
|
||||
|
||||
ProgramOutput::new(
|
||||
self_program_id,
|
||||
|
||||
@ -53,8 +53,10 @@ fn main() {
|
||||
.to_vec()
|
||||
.try_into()
|
||||
.expect("balance fits in account data");
|
||||
let holding_post =
|
||||
AccountPostState::new_claimed_if_default(holding_account, Claim::Pda(holding_seed(&recipient)));
|
||||
let holding_post = AccountPostState::new_claimed_if_default(
|
||||
holding_account,
|
||||
Claim::Pda(holding_seed(&recipient)),
|
||||
);
|
||||
let config_post = AccountPostState::new(config.account.clone());
|
||||
|
||||
ProgramOutput::new(
|
||||
|
||||
@ -286,7 +286,11 @@ pub fn build_dispatch_from_emission(
|
||||
payload,
|
||||
l1_inclusion_witness: None,
|
||||
};
|
||||
let target_ids = target_accounts.iter().copied().map(AccountId::new).collect();
|
||||
let target_ids = target_accounts
|
||||
.iter()
|
||||
.copied()
|
||||
.map(AccountId::new)
|
||||
.collect();
|
||||
build_inbox_dispatch_tx(inbox_id, &msg, target_ids)
|
||||
}
|
||||
|
||||
|
||||
@ -109,7 +109,13 @@ mod tests {
|
||||
#[test]
|
||||
fn holding_is_unique_per_recipient() {
|
||||
let id: ProgramId = [9; 8];
|
||||
assert_ne!(holding_account_id(id, &[1; 32]), holding_account_id(id, &[2; 32]));
|
||||
assert_eq!(holding_account_id(id, &[1; 32]), holding_account_id(id, &[1; 32]));
|
||||
assert_ne!(
|
||||
holding_account_id(id, &[1; 32]),
|
||||
holding_account_id(id, &[2; 32])
|
||||
);
|
||||
assert_eq!(
|
||||
holding_account_id(id, &[1; 32]),
|
||||
holding_account_id(id, &[1; 32])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user