-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(IC-1579): TLA instrumentation for
merge_neuron
(#2341)
Adds a TLA model of `merge_neurons` and links it to the code. Since the only Rust integration tests that test merge_neuron are proptests, which generate a ton of traces, introduced a limit to check only some prefix (currently, first 30) of the state pairs from the collected traces. Also made the Apalache checks a bit more parallel, by using channels to signal completion as soon as a single thread is available instead of waiting for the batch. --------- Co-authored-by: IDX GitHub Automation <infra+github-automation@dfinity.org>
- Loading branch information
Showing
12 changed files
with
659 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
use lazy_static::lazy_static; | ||
use tla_instrumentation::{Label, TlaConstantAssignment, ToTla, Update, VarAssignment}; | ||
|
||
use super::common::default_account; | ||
use super::{extract_common_constants, post_process_trace}; | ||
|
||
pub fn claim_neuron_desc() -> Update { | ||
const PID: &str = "Claim_Neuron"; | ||
let default_locals = VarAssignment::new() | ||
.add("account", default_account()) | ||
.add("neuron_id", 0_u64.to_tla_value()); | ||
lazy_static! { | ||
pub static ref CLAIM_NEURON_DESC: Update = { | ||
const PID: &str = "Claim_Neuron"; | ||
let default_locals = VarAssignment::new() | ||
.add("account", default_account()) | ||
.add("neuron_id", 0_u64.to_tla_value()); | ||
|
||
Update { | ||
default_start_locals: default_locals.clone(), | ||
default_end_locals: default_locals, | ||
start_label: Label::new("ClaimNeuron1"), | ||
end_label: Label::new("Done"), | ||
process_id: PID.to_string(), | ||
canister_name: "governance".to_string(), | ||
post_process: |trace| { | ||
let constants = TlaConstantAssignment { | ||
constants: extract_common_constants(PID, trace).into_iter().collect(), | ||
}; | ||
post_process_trace(trace); | ||
constants | ||
}, | ||
} | ||
Update { | ||
default_start_locals: default_locals.clone(), | ||
default_end_locals: default_locals, | ||
start_label: Label::new("ClaimNeuron1"), | ||
end_label: Label::new("Done"), | ||
process_id: PID.to_string(), | ||
canister_name: "governance".to_string(), | ||
post_process: |trace| { | ||
let constants = TlaConstantAssignment { | ||
constants: extract_common_constants(PID, trace).into_iter().collect(), | ||
}; | ||
post_process_trace(trace); | ||
constants | ||
}, | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use super::{account_to_tla, extract_common_constants, post_process_trace}; | ||
use crate::governance::governance_minting_account; | ||
use lazy_static::lazy_static; | ||
use tla_instrumentation::{Label, TlaConstantAssignment, ToTla, Update, VarAssignment}; | ||
|
||
const PID: &str = "Merge_Neurons"; | ||
lazy_static! { | ||
pub static ref MERGE_NEURONS_DESC: Update = { | ||
let default_locals = VarAssignment::new() | ||
.add("source_neuron_id", 0_u64.to_tla_value()) | ||
.add("target_neuron_id", 0_u64.to_tla_value()) | ||
.add("fees_amount", 0_u64.to_tla_value()) | ||
.add("amount_to_target", 0_u64.to_tla_value()); | ||
Update { | ||
default_start_locals: default_locals.clone(), | ||
default_end_locals: default_locals, | ||
start_label: Label::new("MergeNeurons_Start"), | ||
end_label: Label::new("Done"), | ||
process_id: PID.to_string(), | ||
canister_name: "governance".to_string(), | ||
post_process: |trace| { | ||
let mut constants = TlaConstantAssignment { | ||
constants: extract_common_constants(PID, trace).into_iter().collect(), | ||
}; | ||
post_process_trace(trace); | ||
constants.constants.insert( | ||
"Minting_Account_Id".to_string(), | ||
account_to_tla(governance_minting_account()), | ||
); | ||
constants | ||
}, | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.