Skip to content

Commit

Permalink
fix staking_amount_in_avax
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <[email protected]>
  • Loading branch information
gyuho committed Feb 13, 2024
1 parent 3b9de27 commit d806af3
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
15 changes: 15 additions & 0 deletions avalanche-ops/src/aws/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ pub struct Spec {
#[serde(skip_serializing_if = "Option::is_none")]
pub prefunded_keys: Option<Vec<key::secp256k1::Info>>,

/// For primary network.
#[serde(default)]
pub staking_amount_in_avax: u64,

/// Represents the configuration for "avalanchego".
/// Set as if run in remote machines.
/// For instance, "config-file" must be the path valid
Expand Down Expand Up @@ -395,6 +399,7 @@ pub struct RegionMachineId {
pub struct DefaultSpecOption {
pub log_level: String,
pub network_name: String,
pub staking_amount_in_avax: u64,

pub arch_type: String,
pub os_type: String,
Expand Down Expand Up @@ -1071,6 +1076,12 @@ impl Spec {

prefunded_keys: Some(prefunded_keys_info),

staking_amount_in_avax: if opts.staking_amount_in_avax > 0 {
opts.staking_amount_in_avax
} else {
2000
},

avalanchego_config,
coreth_chain_config,
avalanchego_genesis_template,
Expand Down Expand Up @@ -1535,6 +1546,8 @@ avalanchego_config:
consensus-accepted-frontier-gossip-peer-size: 10
network-compression-type: gzip
staking_amount_in_avax: 2000
coreth_chain_config:
coreth-admin-api-enabled: true
offline-pruning-enabled: false
Expand Down Expand Up @@ -1639,6 +1652,8 @@ coreth_chain_config:

prefunded_keys: None,

staking_amount_in_avax: 2000,

avalanchego_config,
coreth_chain_config: coreth_chain_config::Config::default(),
avalanchego_genesis_template: None,
Expand Down
9 changes: 8 additions & 1 deletion avalancheup-aws/src/apply/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2483,12 +2483,19 @@ cat /tmp/{node_id}.crt
.checked_add(Duration::from_millis(500 + random_manager::u64() % 100))
.unwrap();

let staking_amount_in_navax = if spec.staking_amount_in_avax > 0 {
units::cast_avax_to_xp_navax(primitive_types::U256::from(
spec.staking_amount_in_avax,
))
} else {
primitive_types::U256::from(2 * units::KILO_AVAX)
};
handles.push(tokio::spawn(add_primary_network_permissionless_validator(
Arc::new(random_wait),
Arc::new(wallet_to_spend.clone()),
Arc::new(ids::node::Id::from_str(&node.node_id).unwrap()),
Arc::new(node.proof_of_possession.to_owned()),
Arc::new(2 * units::KILO_AVAX),
Arc::new(staking_amount_in_navax.as_u64()),
Arc::new(spec.primary_network_validate_period_in_days),
)));
}
Expand Down
11 changes: 11 additions & 0 deletions avalancheup-aws/src/default_spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,17 @@ pub fn command() -> Command {
.value_parser(["mainnet", "fuji", "custom"])
.default_value("custom"),
)
.arg(
Arg::new("STAKING_AMOUNT_IN_AVAX")
.long("staking-amount-in-avax")
.help(
"Sets the staking amount in P-chain AVAX (not in nAVAX) for primary network validator",
)
.required(false)
.num_args(1)
.value_parser(value_parser!(u64))
.default_value("2000"),
)
.arg(
Arg::new("VOLUME_SIZE_IN_GB")
.long("volume-size-in-gb")
Expand Down
3 changes: 3 additions & 0 deletions avalancheup-aws/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ async fn main() -> io::Result<()> {
.get_one::<String>("NETWORK_NAME")
.unwrap_or(&String::new())
.clone(),
staking_amount_in_avax: *sub_matches
.get_one::<u64>("STAKING_AMOUNT_IN_AVAX")
.unwrap_or(&2000),

arch_type: sub_matches
.get_one::<String>("ARCH_TYPE")
Expand Down

0 comments on commit d806af3

Please sign in to comment.