Skip to content

Commit

Permalink
[aptos-cli] Add stake amounts to genesis tooling
Browse files Browse the repository at this point in the history
Now we can set amounts of stake for genesis tooling.  It should
be defaulting to 1.

Closes: aptos-labs#881
  • Loading branch information
gregnazario authored and aptos-bot committed May 10, 2022
1 parent 35cc262 commit 8224594
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion aptos-move/vm-genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ fn create_and_initialize_validators(
consensus_pubkeys.push(MoveValue::vector_u8(v.consensus_pubkey.clone()));
validator_network_addresses.push(MoveValue::vector_u8(v.network_address.clone()));
full_node_network_addresses.push(MoveValue::vector_u8(v.full_node_network_address.clone()));
staking_distribution.push(MoveValue::U64(1));
staking_distribution.push(MoveValue::U64(v.stake_amount));
}
exec_function(
session,
Expand Down Expand Up @@ -365,6 +365,8 @@ pub struct Validator {
pub network_address: Vec<u8>,
/// `NetworkAddress` for the validator's full node
pub full_node_network_address: Vec<u8>,
/// Amount to stake for consensus
pub stake_amount: u64,
}

pub struct TestValidator {
Expand Down Expand Up @@ -399,6 +401,7 @@ impl TestValidator {
operator_auth_key,
network_address,
full_node_network_address,
stake_amount: 1,
};
Self { key, data }
}
Expand Down
1 change: 1 addition & 0 deletions config/management/genesis/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl<S: KVStorage> GenesisBuilder<S> {
operator_auth_key,
network_address,
full_node_network_address,
stake_amount: 1,
})
}
Ok(validators)
Expand Down
3 changes: 3 additions & 0 deletions crates/aptos/src/genesis/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ pub struct ValidatorConfiguration {
pub validator_host: HostAndPort,
/// Host for full node which can be an IP or a DNS name and is optional
pub full_node_host: Option<HostAndPort>,
/// Stake amount for consensus
pub stake_amount: u64,
}

impl From<ValidatorConfiguration> for Validator {
Expand All @@ -87,6 +89,7 @@ impl From<ValidatorConfiguration> for Validator {
full_node_network_address: bcs::to_bytes(&full_node_addresses).unwrap(),
operator_auth_key: auth_key,
auth_key,
stake_amount: config.stake_amount,
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/aptos/src/genesis/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ pub struct SetValidatorConfiguration {
/// Host and port pair for the fullnode e.g. 127.0.0.1:6180
#[clap(long)]
full_node_host: Option<HostAndPort>,
/// Stake amount for stake distribution
#[clap(long, default_value = "1")]
stake_amount: u64,
}

#[async_trait]
Expand All @@ -86,6 +89,7 @@ impl CliCommand<()> for SetValidatorConfiguration {
network_key: network_key.public_key(),
validator_host: self.validator_host,
full_node_host: self.full_node_host,
stake_amount: self.stake_amount,
};

self.git_options
Expand Down

0 comments on commit 8224594

Please sign in to comment.