Skip to content

Commit d806af3

Browse files
committed
fix staking_amount_in_avax
Signed-off-by: Gyuho Lee <[email protected]>
1 parent 3b9de27 commit d806af3

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

avalanche-ops/src/aws/spec.rs

+15
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ pub struct Spec {
9898
#[serde(skip_serializing_if = "Option::is_none")]
9999
pub prefunded_keys: Option<Vec<key::secp256k1::Info>>,
100100

101+
/// For primary network.
102+
#[serde(default)]
103+
pub staking_amount_in_avax: u64,
104+
101105
/// Represents the configuration for "avalanchego".
102106
/// Set as if run in remote machines.
103107
/// For instance, "config-file" must be the path valid
@@ -395,6 +399,7 @@ pub struct RegionMachineId {
395399
pub struct DefaultSpecOption {
396400
pub log_level: String,
397401
pub network_name: String,
402+
pub staking_amount_in_avax: u64,
398403

399404
pub arch_type: String,
400405
pub os_type: String,
@@ -1071,6 +1076,12 @@ impl Spec {
10711076

10721077
prefunded_keys: Some(prefunded_keys_info),
10731078

1079+
staking_amount_in_avax: if opts.staking_amount_in_avax > 0 {
1080+
opts.staking_amount_in_avax
1081+
} else {
1082+
2000
1083+
},
1084+
10741085
avalanchego_config,
10751086
coreth_chain_config,
10761087
avalanchego_genesis_template,
@@ -1535,6 +1546,8 @@ avalanchego_config:
15351546
consensus-accepted-frontier-gossip-peer-size: 10
15361547
network-compression-type: gzip
15371548
1549+
staking_amount_in_avax: 2000
1550+
15381551
coreth_chain_config:
15391552
coreth-admin-api-enabled: true
15401553
offline-pruning-enabled: false
@@ -1639,6 +1652,8 @@ coreth_chain_config:
16391652

16401653
prefunded_keys: None,
16411654

1655+
staking_amount_in_avax: 2000,
1656+
16421657
avalanchego_config,
16431658
coreth_chain_config: coreth_chain_config::Config::default(),
16441659
avalanchego_genesis_template: None,

avalancheup-aws/src/apply/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -2483,12 +2483,19 @@ cat /tmp/{node_id}.crt
24832483
.checked_add(Duration::from_millis(500 + random_manager::u64() % 100))
24842484
.unwrap();
24852485

2486+
let staking_amount_in_navax = if spec.staking_amount_in_avax > 0 {
2487+
units::cast_avax_to_xp_navax(primitive_types::U256::from(
2488+
spec.staking_amount_in_avax,
2489+
))
2490+
} else {
2491+
primitive_types::U256::from(2 * units::KILO_AVAX)
2492+
};
24862493
handles.push(tokio::spawn(add_primary_network_permissionless_validator(
24872494
Arc::new(random_wait),
24882495
Arc::new(wallet_to_spend.clone()),
24892496
Arc::new(ids::node::Id::from_str(&node.node_id).unwrap()),
24902497
Arc::new(node.proof_of_possession.to_owned()),
2491-
Arc::new(2 * units::KILO_AVAX),
2498+
Arc::new(staking_amount_in_navax.as_u64()),
24922499
Arc::new(spec.primary_network_validate_period_in_days),
24932500
)));
24942501
}

avalancheup-aws/src/default_spec/mod.rs

+11
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,17 @@ pub fn command() -> Command {
339339
.value_parser(["mainnet", "fuji", "custom"])
340340
.default_value("custom"),
341341
)
342+
.arg(
343+
Arg::new("STAKING_AMOUNT_IN_AVAX")
344+
.long("staking-amount-in-avax")
345+
.help(
346+
"Sets the staking amount in P-chain AVAX (not in nAVAX) for primary network validator",
347+
)
348+
.required(false)
349+
.num_args(1)
350+
.value_parser(value_parser!(u64))
351+
.default_value("2000"),
352+
)
342353
.arg(
343354
Arg::new("VOLUME_SIZE_IN_GB")
344355
.long("volume-size-in-gb")

avalancheup-aws/src/main.rs

+3
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ async fn main() -> io::Result<()> {
115115
.get_one::<String>("NETWORK_NAME")
116116
.unwrap_or(&String::new())
117117
.clone(),
118+
staking_amount_in_avax: *sub_matches
119+
.get_one::<u64>("STAKING_AMOUNT_IN_AVAX")
120+
.unwrap_or(&2000),
118121

119122
arch_type: sub_matches
120123
.get_one::<String>("ARCH_TYPE")

0 commit comments

Comments
 (0)