Skip to content

Commit

Permalink
fix(cli)!: refactor yaml serialization to match format in rollup's va…
Browse files Browse the repository at this point in the history
…lues.yaml (#707)

## Summary
Refactors the cli to serialize the rollup config as yaml to match what
is expected in the rollup chart's values.yaml.

## Background
Genesis accounts weren't getting funded in RaaS because the shape of
values.yaml changed.

## Changes
- changed generated yaml shape

## Testing
- updated unit and integration tests

## Breaking Changelist
The api of the cli did not change
  • Loading branch information
steezeburger authored Jan 23, 2024
1 parent c0d1373 commit b4b9474
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/astria-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "astria-cli"
version = "0.2.2"
version = "0.3.0"
edition = "2021"
rust-version = "1.73"

Expand Down
1 change: 0 additions & 1 deletion crates/astria-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ cargo build --release
--log-level DEBUG \
--rollup.name steezechain \
--rollup.network-id 42 \
--rollup.skip-empty-blocks \
--rollup.genesis-accounts 0xaC21B97d35Bf75A7dAb16f35b111a50e78A72F30:100000000000000000000

# edit config
Expand Down
2 changes: 1 addition & 1 deletion crates/astria-cli/src/cli/rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use color_eyre::eyre;
use serde::Serialize;

const DEFAULT_ROLLUP_CHART_PATH: &str =
"https://astriaorg.github.io/dev-cluster/astria-evm-rollup-0.7.4.tgz";
"https://github.com/astriaorg/dev-cluster/releases/download/astria-evm-rollup-0.8.6/astria-evm-rollup-0.8.6.tgz";
const DEFAULT_SEQUENCER_WS: &str = "wss://rpc.sequencer.dusk-2.devnet.astria.org/websocket";
const DEFAULT_LOG_LEVEL: &str = "debug";
const DEFAULT_NETWORK_ID: u64 = 1337;
Expand Down
60 changes: 43 additions & 17 deletions crates/astria-cli/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ impl TryFrom<&ConfigCreateArgs> for RollupDeploymentConfig {
name: args.name.clone(),
chain_id,
network_id: args.network_id.to_string(),
genesis_accounts,
genesis: GenesisConfig {
alloc: genesis_accounts,
},
},
sequencer: SequencerConfig {
initial_block_height: sequencer_initial_block_height.to_string(),
Expand All @@ -200,13 +202,25 @@ pub struct RollupConfig {
chain_id: String,
// NOTE - String here because yaml will serialize large ints w/ scientific notation
network_id: String,
genesis_accounts: Vec<GenesisAccount>,
genesis: GenesisConfig,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GenesisConfig {
alloc: Vec<GenesisAccount>,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct GenesisAccount {
address: String,
value: GenesisAccountValue,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct GenesisAccountValue {
// NOTE - string because yaml will serialize large ints w/ scientific notation
balance: String,
}
Expand All @@ -215,7 +229,9 @@ impl From<GenesisAccountArg> for GenesisAccount {
fn from(arg: GenesisAccountArg) -> Self {
Self {
address: arg.address,
balance: arg.balance.to_string(),
value: GenesisAccountValue {
balance: arg.balance.to_string(),
},
}
}
}
Expand Down Expand Up @@ -274,16 +290,22 @@ mod tests {
name: "rollup1".to_string(),
chain_id: "chain1".to_string(),
network_id: "1".to_string(),
genesis_accounts: vec![
GenesisAccount {
address: "0xA5TR14".to_string(),
balance: "1000000000000000000".to_string(),
},
GenesisAccount {
address: "0x420XYZ69".to_string(),
balance: "420".to_string(),
},
],
genesis: GenesisConfig {
alloc: vec![
GenesisAccount {
address: "0xA5TR14".to_string(),
value: GenesisAccountValue {
balance: "1000000000000000000".to_string(),
},
},
GenesisAccount {
address: "0x420XYZ69".to_string(),
value: GenesisAccountValue {
balance: "420".to_string(),
},
},
],
},
},
sequencer: SequencerConfig {
initial_block_height: "127689000000".to_string(),
Expand Down Expand Up @@ -341,10 +363,14 @@ mod tests {
name: "rollup2".to_string(),
chain_id: "rollup2-chain".to_string(), // Derived from name
network_id: "2211011801".to_string(),
genesis_accounts: vec![GenesisAccount {
address: "0xA5TR14".to_string(),
balance: "10000".to_string(),
}],
genesis: GenesisConfig {
alloc: vec![GenesisAccount {
address: "0xA5TR14".to_string(),
value: GenesisAccountValue {
balance: "10000".to_string(),
},
}],
},
},
sequencer: SequencerConfig {
initial_block_height: "1".to_string(), // Default value
Expand Down

0 comments on commit b4b9474

Please sign in to comment.