Skip to content

Commit 8917d70

Browse files
authored
feat: add testnet init xtask command (#1632)
* feat: add testnet init xtask command * fix tests * fix lint * fix: registry program test
1 parent 09182ad commit 8917d70

File tree

13 files changed

+694
-73
lines changed

13 files changed

+694
-73
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

program-libs/batched-merkle-tree/src/initialize_address_tree.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,23 @@ impl InitAddressTreeAccountsInstructionData {
7070
close_threshold: None,
7171
}
7272
}
73+
74+
pub fn testnet_default() -> Self {
75+
Self {
76+
index: 0,
77+
program_owner: None,
78+
forester: None,
79+
bloom_filter_num_iters: 3,
80+
input_queue_batch_size: 2000,
81+
input_queue_zkp_batch_size: DEFAULT_ZKP_BATCH_SIZE,
82+
height: 40,
83+
root_history_capacity: 20,
84+
bloom_filter_capacity: 20_000 * 8,
85+
network_fee: Some(5000),
86+
rollover_threshold: Some(95),
87+
close_threshold: None,
88+
}
89+
}
7390
}
7491

7592
impl Default for InitAddressTreeAccountsInstructionData {

program-libs/batched-merkle-tree/src/initialize_state_tree.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,26 @@ impl InitStateTreeAccountsInstructionData {
8686
close_threshold: None,
8787
}
8888
}
89+
90+
pub fn testnet_default() -> Self {
91+
Self {
92+
index: 0,
93+
program_owner: None,
94+
forester: None,
95+
additional_bytes: DEFAULT_CPI_CONTEXT_ACCOUNT_SIZE,
96+
bloom_filter_num_iters: 3,
97+
input_queue_batch_size: 2000,
98+
output_queue_batch_size: 2000,
99+
input_queue_zkp_batch_size: DEFAULT_ZKP_BATCH_SIZE,
100+
output_queue_zkp_batch_size: DEFAULT_ZKP_BATCH_SIZE,
101+
height: DEFAULT_BATCH_STATE_TREE_HEIGHT,
102+
root_history_capacity: 20,
103+
bloom_filter_capacity: 20_000 * 8,
104+
network_fee: Some(5000),
105+
rollover_threshold: Some(95),
106+
close_threshold: None,
107+
}
108+
}
89109
}
90110

91111
impl Default for InitStateTreeAccountsInstructionData {

program-tests/registry-test/tests/tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,7 @@ async fn test_initialize_protocol_config() {
521521
0,
522522
)
523523
.await;
524-
let expected_error_code = RegistryError::InvalidNetworkFee as u32 + 6000;
525-
assert_rpc_error(result, 2, expected_error_code).unwrap();
524+
assert_rpc_error(result, 3, RegistryError::InvalidNetworkFee.into()).unwrap();
526525
}
527526
}
528527

program-tests/system-test/tests/test.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#![cfg(feature = "test-sbf")]
22

3-
use account_compression::errors::AccountCompressionErrorCode;
3+
use account_compression::{
4+
errors::AccountCompressionErrorCode, AddressMerkleTreeConfig, AddressQueueConfig,
5+
NullifierQueueConfig, StateMerkleTreeConfig,
6+
};
47
use anchor_lang::{AnchorSerialize, InstructionData, ToAccountMetas};
58
use light_batched_merkle_tree::{
69
errors::BatchedMerkleTreeError,
@@ -151,7 +154,7 @@ async fn invoke_failing_test() {
151154
}
152155
}
153156
for mut num_addresses in 0..=2 {
154-
for j in 0..6 {
157+
for (j, option) in options.iter().enumerate() {
155158
// there is no combined circuit instantiation for 8 inputs and addresses
156159
if j == 5 {
157160
num_addresses = 0;
@@ -162,7 +165,7 @@ async fn invoke_failing_test() {
162165
&mut test_indexer,
163166
&payer,
164167
&env,
165-
options[j],
168+
*option,
166169
0,
167170
num_addresses,
168171
num_outputs,
@@ -1678,8 +1681,13 @@ async fn regenerate_accounts() {
16781681
protocol_config,
16791682
true,
16801683
skip_register_programs,
1684+
false,
1685+
StateMerkleTreeConfig::default(),
1686+
NullifierQueueConfig::default(),
1687+
AddressMerkleTreeConfig::default(),
1688+
AddressQueueConfig::default(),
16811689
InitStateTreeAccountsInstructionData::test_default(),
1682-
InitAddressTreeAccountsInstructionData::test_default(),
1690+
Some(InitAddressTreeAccountsInstructionData::test_default()),
16831691
)
16841692
.await;
16851693
let keypairs = EnvAccountKeypairs::for_regenerate_accounts();
@@ -2121,16 +2129,12 @@ async fn batch_invoke_test() {
21212129
let input_compressed_accounts = vec![
21222130
compressed_account_with_context_1.compressed_account,
21232131
compressed_account_with_context_2.compressed_account,
2124-
]
2125-
.iter()
2126-
.cloned()
2127-
.collect::<Vec<_>>();
2132+
];
21282133

2129-
let merkle_context = [
2134+
let merkle_context = vec![
21302135
compressed_account_with_context_1.merkle_context,
21312136
compressed_account_with_context_2.merkle_context,
2132-
]
2133-
.to_vec();
2137+
];
21342138
let output_compressed_accounts = vec![
21352139
CompressedAccount {
21362140
lamports: 0,

programs/registry/Cargo.toml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,16 @@ no-entrypoint = []
1515
no-idl = []
1616
no-log-ix-name = []
1717
cpi = ["no-entrypoint"]
18-
custom-heap = ["light-heap"]
19-
mem-profiling = []
20-
default = ["custom-heap", "mem-profiling"]
18+
default = []
2119
test-sbf = []
2220
bench-sbf = []
2321
sdk = []
2422

2523
[dependencies]
2624
aligned-sized = { workspace = true }
27-
anchor-lang = { workspace = true , features = ["init-if-needed"]}
28-
light-heap = { workspace = true, optional = true }
29-
account-compression = { workspace = true }
30-
light-system-program = { workspace = true , features = ["cpi"] }
25+
anchor-lang = { workspace = true, features = ["init-if-needed"] }
26+
account-compression = { workspace = true }
27+
light-system-program = { workspace = true, features = ["cpi"] }
3128
solana-security-txt = "1.1.0"
3229
light-merkle-tree-metadata = { workspace = true }
3330
light-batched-merkle-tree = { workspace = true }

programs/registry/src/protocol_config/state.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,29 @@ impl Default for ProtocolConfig {
7070
}
7171
}
7272

73+
impl ProtocolConfig {
74+
pub fn testnet_default() -> Self {
75+
Self {
76+
genesis_slot: 0,
77+
min_weight: 1,
78+
slot_length: 60,
79+
registration_phase_length: 100,
80+
active_phase_length: 1000,
81+
report_work_phase_length: 100,
82+
network_fee: 5000,
83+
cpi_context_size: 20 * 1024 + 8,
84+
finalize_counter_limit: 100,
85+
place_holder: Pubkey::default(),
86+
place_holder_a: 0,
87+
place_holder_b: 0,
88+
place_holder_c: 0,
89+
place_holder_d: 0,
90+
place_holder_e: 0,
91+
place_holder_f: 0,
92+
}
93+
}
94+
}
95+
7396
#[derive(Debug, Default, Clone, PartialEq, Eq)]
7497
pub enum EpochState {
7598
Registration,

0 commit comments

Comments
 (0)