mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-08-27 04:11:08 +00:00
chore(lee,lez): fix pre-existing rustfmt violations (#776)
marvin/incremental-updates-2 was not cargo +nightly fmt --check clean; these files had drifted since the last fmt pass (mostly unwrapped long import lists). No functional changes.
This commit is contained in:
committed by
Marvin Jones
parent
687cc211f9
commit
b676c6c360
@@ -1,6 +1,9 @@
|
||||
use lee_core::{
|
||||
account::{Account, AccountDiff, BalanceDiff, Data},
|
||||
program::{AccountDiffOutput, Claim, ProgramCall, ProgramInput, ProgramOutput, read_lee_call, write_update_from_diff_output},
|
||||
program::{
|
||||
AccountDiffOutput, Claim, ProgramCall, ProgramInput, ProgramOutput, read_lee_call,
|
||||
write_update_from_diff_output,
|
||||
},
|
||||
};
|
||||
|
||||
// Hello-world example program.
|
||||
@@ -82,6 +85,9 @@ fn main() {
|
||||
.write();
|
||||
}
|
||||
|
||||
fn update_from_diff(_pre_state: Account, diff_data: Data) -> Result<Data, std::convert::Infallible> {
|
||||
fn update_from_diff(
|
||||
_pre_state: Account,
|
||||
diff_data: Data,
|
||||
) -> Result<Data, std::convert::Infallible> {
|
||||
Ok(diff_data)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
use lee_core::{
|
||||
account::{Account, AccountDiff, BalanceDiff, Data},
|
||||
program::{AccountDiffOutput, Claim, ProgramCall, ProgramInput, ProgramOutput, read_lee_call, write_update_from_diff_output},
|
||||
program::{
|
||||
AccountDiffOutput, Claim, ProgramCall, ProgramInput, ProgramOutput, read_lee_call,
|
||||
write_update_from_diff_output,
|
||||
},
|
||||
};
|
||||
|
||||
// Hello-world with authorization example program.
|
||||
@@ -89,6 +92,9 @@ fn main() {
|
||||
.write();
|
||||
}
|
||||
|
||||
fn update_from_diff(_pre_state: Account, diff_data: Data) -> Result<Data, std::convert::Infallible> {
|
||||
fn update_from_diff(
|
||||
_pre_state: Account,
|
||||
diff_data: Data,
|
||||
) -> Result<Data, std::convert::Infallible> {
|
||||
Ok(diff_data)
|
||||
}
|
||||
|
||||
@@ -48,10 +48,7 @@ fn write(pre_state: AccountWithMetadata, greeting: &[u8]) -> AccountDiffOutput {
|
||||
)
|
||||
}
|
||||
|
||||
fn move_data(
|
||||
from_pre: AccountWithMetadata,
|
||||
to_pre: AccountWithMetadata,
|
||||
) -> Vec<AccountDiffOutput> {
|
||||
fn move_data(from_pre: AccountWithMetadata, to_pre: AccountWithMetadata) -> Vec<AccountDiffOutput> {
|
||||
// Construct the post state account values
|
||||
let from_data: Vec<u8> = from_pre.account.data.clone().into();
|
||||
|
||||
@@ -131,6 +128,9 @@ fn main() {
|
||||
.write();
|
||||
}
|
||||
|
||||
fn update_from_diff(_pre_state: Account, diff_data: Data) -> Result<Data, std::convert::Infallible> {
|
||||
fn update_from_diff(
|
||||
_pre_state: Account,
|
||||
diff_data: Data,
|
||||
) -> Result<Data, std::convert::Infallible> {
|
||||
Ok(diff_data)
|
||||
}
|
||||
|
||||
@@ -445,9 +445,9 @@ impl ExecutionState {
|
||||
};
|
||||
let journal_words =
|
||||
to_vec(&expected_output).expect("UpdateFromDiffOutput must be serializable");
|
||||
env::verify(program_id, &journal_words).unwrap_or_else(
|
||||
|_: Infallible| unreachable!("Infallible error is never constructed"),
|
||||
);
|
||||
env::verify(program_id, &journal_words).unwrap_or_else(|_: Infallible| {
|
||||
unreachable!("Infallible error is never constructed")
|
||||
});
|
||||
data
|
||||
} else {
|
||||
pre_account.data.clone()
|
||||
@@ -461,8 +461,7 @@ impl ExecutionState {
|
||||
if let Some(claim) = diff_output.required_claim() {
|
||||
// The invoked program can only claim accounts with default program id.
|
||||
assert_eq!(
|
||||
pre_account.program_owner,
|
||||
DEFAULT_PROGRAM_OWNER,
|
||||
pre_account.program_owner, DEFAULT_PROGRAM_OWNER,
|
||||
"Cannot claim an initialized account {pre_account_id}"
|
||||
);
|
||||
|
||||
|
||||
@@ -885,23 +885,27 @@ pub fn validate_execution(
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Total balance is preserved: within this call's own diffs, every decrease must be
|
||||
// balanced by an equal increase.
|
||||
let Some(total_added) = WrappedBalanceSum::from_balances(post_diff.iter().filter_map(
|
||||
|diff_output| match diff_output.diff().diff_balance {
|
||||
BalanceDiff::Add(amount) => Some(amount),
|
||||
BalanceDiff::Sub(_) => None,
|
||||
},
|
||||
)) else {
|
||||
// 5. Total balance is preserved: within this call's own diffs, every decrease must be balanced
|
||||
// by an equal increase.
|
||||
let Some(total_added) =
|
||||
WrappedBalanceSum::from_balances(post_diff.iter().filter_map(|diff_output| {
|
||||
match diff_output.diff().diff_balance {
|
||||
BalanceDiff::Add(amount) => Some(amount),
|
||||
BalanceDiff::Sub(_) => None,
|
||||
}
|
||||
}))
|
||||
else {
|
||||
return Err(ExecutionValidationError::BalanceSumOverflow);
|
||||
};
|
||||
|
||||
let Some(total_subbed) = WrappedBalanceSum::from_balances(post_diff.iter().filter_map(
|
||||
|diff_output| match diff_output.diff().diff_balance {
|
||||
BalanceDiff::Sub(amount) => Some(amount),
|
||||
BalanceDiff::Add(_) => None,
|
||||
},
|
||||
)) else {
|
||||
let Some(total_subbed) =
|
||||
WrappedBalanceSum::from_balances(post_diff.iter().filter_map(|diff_output| {
|
||||
match diff_output.diff().diff_balance {
|
||||
BalanceDiff::Sub(amount) => Some(amount),
|
||||
BalanceDiff::Add(_) => None,
|
||||
}
|
||||
}))
|
||||
else {
|
||||
return Err(ExecutionValidationError::BalanceSumOverflow);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use lee_core::program::{ChainedCall, ProgramCall, ProgramId, ProgramInput, ProgramOutput, read_lee_call};
|
||||
use lee_core::program::{
|
||||
ChainedCall, ProgramCall, ProgramId, ProgramInput, ProgramOutput, read_lee_call,
|
||||
};
|
||||
|
||||
/// Instruction: (`auth_transfer_id`, `amount`) — both primitive, safe for `risc0_zkvm::serde`.
|
||||
type Instruction = (ProgramId, u128);
|
||||
|
||||
@@ -17,7 +17,9 @@ fn main() {
|
||||
) = match read_lee_call::<Instruction>() {
|
||||
ProgramCall::Execute(input, instruction_words) => (input, instruction_words),
|
||||
ProgramCall::UpdateFromDiff { .. } => {
|
||||
unreachable!("noop program never writes diff_data, so update_from_diff is never dispatched")
|
||||
unreachable!(
|
||||
"noop program never writes diff_data, so update_from_diff is never dispatched"
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
reason = "TODO: Fix later"
|
||||
)]
|
||||
|
||||
pub use amm_core as core;
|
||||
|
||||
use std::convert::Infallible;
|
||||
|
||||
pub use amm_core as core;
|
||||
use lee_core::{
|
||||
account::{Account, AccountDiff, AccountId, BalanceDiff, Data},
|
||||
program::AccountDiffOutput,
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
use std::num::NonZero;
|
||||
|
||||
use amm_core::Instruction;
|
||||
use lee_core::program::{ProgramCall, ProgramInput, ProgramOutput, read_lee_call, write_update_from_diff_output};
|
||||
use lee_core::program::{
|
||||
ProgramCall, ProgramInput, ProgramOutput, read_lee_call, write_update_from_diff_output,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let (
|
||||
|
||||
@@ -30,8 +30,7 @@ fn expected_diff(pre: &AccountWithMetadata, expected_post: &Account) -> AccountD
|
||||
} else {
|
||||
BalanceDiff::Sub(pre.account.balance - expected_post.balance)
|
||||
};
|
||||
let diff_data =
|
||||
(expected_post.data != pre.account.data).then(|| expected_post.data.clone());
|
||||
let diff_data = (expected_post.data != pre.account.data).then(|| expected_post.data.clone());
|
||||
AccountDiff {
|
||||
id: pre.account_id,
|
||||
diff_balance,
|
||||
@@ -3020,7 +3019,13 @@ fn new_definition_lp_asymmetric_amounts() {
|
||||
|
||||
// check the minted LP amount
|
||||
let pool_post = post_states[0].clone();
|
||||
let pool_data: Data = pool_post.diff().diff_data.clone().unwrap().try_into().unwrap();
|
||||
let pool_data: Data = pool_post
|
||||
.diff()
|
||||
.diff_data
|
||||
.clone()
|
||||
.unwrap()
|
||||
.try_into()
|
||||
.unwrap();
|
||||
let pool_def = PoolDefinition::try_from(&pool_data).unwrap();
|
||||
assert_eq!(
|
||||
pool_def.liquidity_pool_supply,
|
||||
@@ -3053,7 +3058,13 @@ fn new_definition_lp_symmetric_amounts() {
|
||||
);
|
||||
|
||||
let pool_post = post_states[0].clone();
|
||||
let pool_data: Data = pool_post.diff().diff_data.clone().unwrap().try_into().unwrap();
|
||||
let pool_data: Data = pool_post
|
||||
.diff()
|
||||
.diff_data
|
||||
.clone()
|
||||
.unwrap()
|
||||
.try_into()
|
||||
.unwrap();
|
||||
let pool_def = PoolDefinition::try_from(&pool_data).unwrap();
|
||||
assert_eq!(pool_def.liquidity_pool_supply, expected_lp);
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use lee_core::{account::AccountWithMetadata, program::{AccountDiffOutput, ChainedCall, ProgramId}};
|
||||
use lee_core::{
|
||||
account::AccountWithMetadata,
|
||||
program::{AccountDiffOutput, ChainedCall, ProgramId},
|
||||
};
|
||||
use token_core::TokenHolding;
|
||||
|
||||
pub fn burn_from_associated_token_account(
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//! The Associated Token Account Program implementation.
|
||||
|
||||
pub use associated_token_account_core as core;
|
||||
|
||||
use lee_core::{
|
||||
account::{AccountDiff, AccountId, BalanceDiff},
|
||||
program::AccountDiffOutput,
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use lee_core::{account::AccountWithMetadata, program::{AccountDiffOutput, ChainedCall, ProgramId}};
|
||||
use lee_core::{
|
||||
account::AccountWithMetadata,
|
||||
program::{AccountDiffOutput, ChainedCall, ProgramId},
|
||||
};
|
||||
use token_core::TokenHolding;
|
||||
|
||||
pub fn transfer_from_associated_token_account(
|
||||
|
||||
@@ -8,8 +8,8 @@ use cross_zone_outbox_core::Instruction as OutboxInstruction;
|
||||
use lee_core::{
|
||||
account::{Account, AccountDiff, AccountId, AccountWithMetadata, BalanceDiff, Data},
|
||||
program::{
|
||||
AccountDiffOutput, ChainedCall, Claim, ProgramCall, ProgramId, ProgramInput,
|
||||
ProgramOutput, read_lee_call, write_update_from_diff_output,
|
||||
AccountDiffOutput, ChainedCall, Claim, ProgramCall, ProgramId, ProgramInput, ProgramOutput,
|
||||
read_lee_call, write_update_from_diff_output,
|
||||
},
|
||||
};
|
||||
use wrapped_token_core::{Instruction as WrappedInstruction, MAX_MINT_AMOUNT};
|
||||
|
||||
@@ -8,8 +8,8 @@ use cross_zone_marker_core::inbox_source_marker_account_id;
|
||||
use lee_core::{
|
||||
account::{Account, AccountDiff, AccountWithMetadata, BalanceDiff, Data},
|
||||
program::{
|
||||
AccountDiffOutput, ChainedCall, Claim, ProgramCall, ProgramId, ProgramInput,
|
||||
ProgramOutput, read_lee_call, write_update_from_diff_output,
|
||||
AccountDiffOutput, ChainedCall, Claim, ProgramCall, ProgramId, ProgramInput, ProgramOutput,
|
||||
read_lee_call, write_update_from_diff_output,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ use cross_zone_outbox_core::Instruction as OutboxInstruction;
|
||||
use lee_core::{
|
||||
account::{Account, AccountDiff, AccountId, AccountWithMetadata, BalanceDiff, Data},
|
||||
program::{
|
||||
AccountDiffOutput, ChainedCall, Claim, ProgramCall, ProgramId, ProgramInput,
|
||||
ProgramOutput, read_lee_call, write_update_from_diff_output,
|
||||
AccountDiffOutput, ChainedCall, Claim, ProgramCall, ProgramId, ProgramInput, ProgramOutput,
|
||||
read_lee_call, write_update_from_diff_output,
|
||||
},
|
||||
};
|
||||
use ping_core::{
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
use std::convert::Infallible;
|
||||
|
||||
use lee_core::account::{Account, Data};
|
||||
|
||||
pub use token_core as core;
|
||||
|
||||
pub mod burn;
|
||||
|
||||
@@ -33,8 +33,7 @@ fn expected_diff(pre: &AccountWithMetadata, expected_post: &Account) -> AccountD
|
||||
} else {
|
||||
BalanceDiff::Sub(pre.account.balance - expected_post.balance)
|
||||
};
|
||||
let diff_data =
|
||||
(expected_post.data != pre.account.data).then(|| expected_post.data.clone());
|
||||
let diff_data = (expected_post.data != pre.account.data).then(|| expected_post.data.clone());
|
||||
AccountDiff {
|
||||
id: pre.account_id,
|
||||
diff_balance,
|
||||
|
||||
@@ -137,6 +137,9 @@ fn main() {
|
||||
.write();
|
||||
}
|
||||
|
||||
fn update_from_diff(_pre_state: Account, diff_data: Data) -> Result<Data, std::convert::Infallible> {
|
||||
fn update_from_diff(
|
||||
_pre_state: Account,
|
||||
diff_data: Data,
|
||||
) -> Result<Data, std::convert::Infallible> {
|
||||
Ok(diff_data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user