mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-08-27 04:11:08 +00:00
perf(lez)!: borrow account data in the guests instead of cloning
BREAKING CHANGE: six guest image ids move.
This commit is contained in:
@@ -89,7 +89,7 @@ fn lock(
|
||||
config_account_id(self_program_id),
|
||||
"first account must be the bridge-lock config PDA"
|
||||
);
|
||||
let (outbox_program_id, pinned_target) = read_config(&config.account.data.clone().into_inner())
|
||||
let (outbox_program_id, pinned_target) = read_config(&config.account.data)
|
||||
.expect("config account holds an outbox and a mint target");
|
||||
|
||||
// Value conservation: the forwarded payload must mint exactly what is locked.
|
||||
@@ -221,8 +221,8 @@ fn init_config(
|
||||
"bridge-lock config PDA is owned by another program"
|
||||
);
|
||||
assert_eq!(
|
||||
config.account.data.clone().into_inner(),
|
||||
config_bytes(outbox_program_id, target_program_id).to_vec(),
|
||||
*config.account.data,
|
||||
config_bytes(outbox_program_id, target_program_id),
|
||||
"bridge-lock config already pins a different outbox or mint target"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ fn main() {
|
||||
panic!("Clock accounts must be owned by the clock program");
|
||||
}
|
||||
|
||||
let prev_data = ClockAccountData::from_bytes(&pre_01.account.data.clone().into_inner());
|
||||
let prev_data = ClockAccountData::from_bytes(&pre_01.account.data);
|
||||
let current_block_id = prev_data
|
||||
.block_id
|
||||
.checked_add(1)
|
||||
|
||||
@@ -102,15 +102,13 @@ fn dispatch(
|
||||
"Third account must be the source marker PDA for this message"
|
||||
);
|
||||
|
||||
let cfg = InboxConfig::from_bytes(&config.account.data.clone().into_inner())
|
||||
.expect("inbox config decodes");
|
||||
let cfg = InboxConfig::from_bytes(&config.account.data).expect("inbox config decodes");
|
||||
|
||||
assert!(
|
||||
msg.src_zone != cfg.self_zone,
|
||||
"Source zone must not be this zone"
|
||||
);
|
||||
let mut shard =
|
||||
SeenShard::from_bytes(&seen.account.data.clone().into_inner()).expect("seen shard decodes");
|
||||
let mut shard = SeenShard::from_bytes(&seen.account.data).expect("seen shard decodes");
|
||||
|
||||
// One block id, one delivering block. The address binds the zone and block
|
||||
// id but not which block claimed them, so an equivocating peer's two blocks
|
||||
@@ -209,7 +207,7 @@ fn init_config(
|
||||
"inbox config PDA is owned by another program"
|
||||
);
|
||||
assert_eq!(
|
||||
config_meta.account.data.clone().into_inner(),
|
||||
*config_meta.account.data,
|
||||
config.to_bytes(),
|
||||
"inbox config already initialized differently"
|
||||
);
|
||||
|
||||
@@ -69,7 +69,7 @@ fn record(
|
||||
receiver_config_account_id(self_program_id),
|
||||
"second account must be the receiver config PDA"
|
||||
);
|
||||
let cfg = ReceiverConfig::from_bytes(&config.account.data.clone().into_inner())
|
||||
let cfg = ReceiverConfig::from_bytes(&config.account.data)
|
||||
.expect("config account holds a receiver config");
|
||||
assert_eq!(
|
||||
caller_program_id,
|
||||
@@ -128,7 +128,7 @@ fn renounce_authority(
|
||||
receiver_config_account_id(self_program_id),
|
||||
"first account must be the receiver config PDA"
|
||||
);
|
||||
let mut cfg = ReceiverConfig::from_bytes(&config_meta.account.data.clone().into_inner())
|
||||
let mut cfg = ReceiverConfig::from_bytes(&config_meta.account.data)
|
||||
.expect("config account holds a receiver config");
|
||||
// Top-level, or the governance program the config names; see
|
||||
// `ReceiverConfig::governance` for why the escape hatch exists.
|
||||
@@ -200,7 +200,7 @@ fn update_sources(
|
||||
receiver_config_account_id(self_program_id),
|
||||
"first account must be the receiver config PDA"
|
||||
);
|
||||
let mut cfg = ReceiverConfig::from_bytes(&config_meta.account.data.clone().into_inner())
|
||||
let mut cfg = ReceiverConfig::from_bytes(&config_meta.account.data)
|
||||
.expect("config account holds a receiver config");
|
||||
// Top-level, or the governance program the config names; see
|
||||
// `ReceiverConfig::governance` for why the escape hatch exists.
|
||||
@@ -285,7 +285,7 @@ fn init_config(
|
||||
"receiver config PDA is owned by another program"
|
||||
);
|
||||
assert_eq!(
|
||||
config.account.data.clone().into_inner(),
|
||||
*config.account.data,
|
||||
config_value.to_bytes(),
|
||||
"receiver config already initialized differently"
|
||||
);
|
||||
|
||||
@@ -81,8 +81,8 @@ fn send(
|
||||
sender_config_account_id(self_program_id),
|
||||
"first account must be the ping-sender config PDA"
|
||||
);
|
||||
let outbox_program_id = read_outbox(&config.account.data.clone().into_inner())
|
||||
.expect("config account holds an outbox program id");
|
||||
let outbox_program_id =
|
||||
read_outbox(&config.account.data).expect("config account holds an outbox program id");
|
||||
|
||||
let call = ChainedCall::new(
|
||||
outbox_program_id,
|
||||
@@ -135,8 +135,8 @@ fn init_config(
|
||||
"ping-sender config PDA is owned by another program"
|
||||
);
|
||||
assert_eq!(
|
||||
config.account.data.clone().into_inner(),
|
||||
outbox_bytes(outbox_program_id).to_vec(),
|
||||
*config.account.data,
|
||||
outbox_bytes(outbox_program_id),
|
||||
"ping-sender config already pins a different outbox"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ fn mint(
|
||||
config_account_id(self_program_id),
|
||||
"second account must be the wrapped-token config PDA"
|
||||
);
|
||||
let cfg = WrappedTokenConfig::from_bytes(&config.account.data.clone().into_inner())
|
||||
let cfg = WrappedTokenConfig::from_bytes(&config.account.data)
|
||||
.expect("config account holds a wrapped-token config");
|
||||
assert_eq!(
|
||||
caller_program_id,
|
||||
@@ -102,7 +102,7 @@ fn mint(
|
||||
"mint amount exceeds the per-mint cap"
|
||||
);
|
||||
// The backstop against accumulation, which the per-mint cap does not bound.
|
||||
let new_balance = read_balance(&holding.account.data.clone().into_inner())
|
||||
let new_balance = read_balance(&holding.account.data)
|
||||
.checked_add(amount)
|
||||
.expect("wrapped-token balance overflow");
|
||||
let mut holding_account = holding.account.clone();
|
||||
@@ -147,7 +147,7 @@ fn renounce_authority(
|
||||
config_account_id(self_program_id),
|
||||
"first account must be the wrapped-token config PDA"
|
||||
);
|
||||
let mut cfg = WrappedTokenConfig::from_bytes(&config_meta.account.data.clone().into_inner())
|
||||
let mut cfg = WrappedTokenConfig::from_bytes(&config_meta.account.data)
|
||||
.expect("config account holds a wrapped-token config");
|
||||
// Top-level, or the governance program the config names; see
|
||||
// `WrappedTokenConfig::governance` for why the escape hatch exists.
|
||||
@@ -219,7 +219,7 @@ fn update_sources(
|
||||
config_account_id(self_program_id),
|
||||
"first account must be the wrapped-token config PDA"
|
||||
);
|
||||
let mut cfg = WrappedTokenConfig::from_bytes(&config_meta.account.data.clone().into_inner())
|
||||
let mut cfg = WrappedTokenConfig::from_bytes(&config_meta.account.data)
|
||||
.expect("config account holds a wrapped-token config");
|
||||
// Top-level, or the governance program the config names; see
|
||||
// `WrappedTokenConfig::governance` for why the escape hatch exists.
|
||||
@@ -306,7 +306,7 @@ fn init_config(
|
||||
"wrapped-token config PDA is owned by another program"
|
||||
);
|
||||
assert_eq!(
|
||||
config.account.data.clone().into_inner(),
|
||||
*config.account.data,
|
||||
config_value.to_bytes(),
|
||||
"wrapped-token config already initialized differently"
|
||||
);
|
||||
|
||||
@@ -63,10 +63,10 @@ fn main() {
|
||||
// Check the clock account is the system clock account
|
||||
assert_eq!(clock_pre.account_id, CLOCK_01_PROGRAM_ACCOUNT_ID);
|
||||
|
||||
let clock_data = ClockAccountData::from_bytes(&clock_pre.account.data.clone().into_inner());
|
||||
let clock_data = ClockAccountData::from_bytes(&clock_pre.account.data);
|
||||
let current_timestamp = clock_data.timestamp;
|
||||
|
||||
let pinata_state = PinataState::from_bytes(&pinata.account.data.clone().into_inner());
|
||||
let pinata_state = PinataState::from_bytes(&pinata.account.data);
|
||||
|
||||
// Enforce cooldown: the elapsed time since the last claim must exceed the cooldown period.
|
||||
let elapsed = current_timestamp.saturating_sub(pinata_state.last_claim_timestamp);
|
||||
|
||||
@@ -34,7 +34,7 @@ fn main() {
|
||||
assert_eq!(clock_pre.account_id, CLOCK_01_PROGRAM_ACCOUNT_ID);
|
||||
|
||||
// Read the current timestamp from the clock account.
|
||||
let clock_data = ClockAccountData::from_bytes(&clock_pre.account.data.clone().into_inner());
|
||||
let clock_data = ClockAccountData::from_bytes(&clock_pre.account.data);
|
||||
|
||||
assert!(
|
||||
clock_data.timestamp >= deadline,
|
||||
|
||||
Reference in New Issue
Block a user