Skip to content

Commit

Permalink
query bridge info, smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
quasystaty1 committed Sep 23, 2024
1 parent d8326b0 commit 08f0208
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 0 deletions.
33 changes: 33 additions & 0 deletions charts/deploy.just
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ rollup_multiplier := "1000000000"
# 10 RIA
sequencer_transfer_amount := "10"
sequencer_rpc_url := "http://rpc.sequencer.localdev.me"
sequencer_funded_address:= "astria1qrt4kfc9ggyy548u7rg0d64sgq5c952kzk9tg9"
sequencer_funded_pkey := "934ab488f9e1900f6a08f50605ce1409ca9d95ebdc400dafc2e8a4306419fd52"
sequencer_bridge_address := "astria13ahqz4pjqfmynk9ylrqv4fwe4957x2p0h5782u"
sequencer_bridge_pkey := "dfa7108e38ab71f89f356c72afc38600d5758f11a8c337164713e4471411d2e0"
sequencer_chain_id := "sequencer-test-chain-0"
Expand Down Expand Up @@ -330,11 +332,42 @@ run-smoke-test:
else
sleep 1
fi

done
if (( $CHECKS >= $MAX_CHECKS )); then
echo "Finalization failure"
exit 1
fi
echo "Testing Bridge sudo address change"
astria-cli sequencer bridge-sudo-change {{sequencer_bridge_address}} --private-key={{sequencer_bridge_pkey}} --new-sudo-address={{sequencer_funded_address}} --sequencer-url={{sequencer_rpc_url}} --sequencer.chain-id={{sequencer_chain_id}}
CHECKS=0
while (( $CHECKS < $MAX_CHECKS )); do
CHECKS=$((CHECKS+1))
SUDO_ADDRESS=$(astria-cli sequencer get-bridge-account {{sequencer_bridge_address}} --sequencer-url {{sequencer_rpc_url}} | awk '/Sudo Address/{print $(NF)}')
echo "Check $CHECKS, Sudo address: $SUDO_ADDRESS, Expected: {{sequencer_funded_address}}"
if [ "$SUDO_ADDRESS" == "{{sequencer_funded_address}}" ]; then
echo "Bridge Sudo change success"
break
else
sleep 1
fi
done

echo "Reverting Bridge sudo address"
astria-cli sequencer bridge-sudo-change {{sequencer_bridge_address}} --private-key={{sequencer_funded_pkey}} --new-sudo-address={{sequencer_bridge_address}} --sequencer-url={{sequencer_rpc_url}} --sequencer.chain-id={{sequencer_chain_id}}
CHECKS=0
while (( $CHECKS < $MAX_CHECKS )); do
CHECKS=$((CHECKS+1))
SUDO_ADDRESS=$(astria-cli sequencer get-bridge-account {{sequencer_bridge_address}} --sequencer-url {{sequencer_rpc_url}} | awk '/Sudo Address/{print $(NF)}')
echo "Check $CHECKS, Sudo address: $SUDO_ADDRESS, Expected: {{sequencer_bridge_address}}"
if [ "$SUDO_ADDRESS" == "{{sequencer_bridge_address}}" ]; then
echo "Bridge Sudo change back success"
break
else
sleep 1
fi
done

exit 0

delete-smoke-test:
Expand Down
3 changes: 3 additions & 0 deletions crates/astria-cli/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ impl Cli {
}

/// Commands that can be run
// allow: these are one-shot variants. the size doesn't matter as they are
// passed around only once.
#[allow(clippy::large_enum_variant)]
#[derive(Debug, Subcommand)]
pub(crate) enum Command {
Bridge {
Expand Down
18 changes: 18 additions & 0 deletions crates/astria-cli/src/cli/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use clap::{
};

/// Interact with a Sequencer node
// allow: these are one-shot variants. the size doesn't matter as they are
// passed around only once.
#[allow(clippy::large_enum_variant)]
#[derive(Debug, Subcommand)]
pub(crate) enum Command {
/// Commands for interacting with Sequencer accounts
Expand Down Expand Up @@ -43,6 +46,8 @@ pub(crate) enum Command {
BridgeLock(BridgeLockArgs),
/// Command for changing the bridge account sudo address or withdrawer address
BridgeSudoChange(BridgeSudoChangeArgs),
/// Command for getting bridge account information
GetBridgeAccount(BridgeAccountArgs),
}

#[derive(Debug, Subcommand)]
Expand Down Expand Up @@ -108,6 +113,19 @@ pub(crate) struct BasicAccountArgs {
pub(crate) address: Address,
}

#[derive(Args, Debug)]
pub(crate) struct BridgeAccountArgs {
/// The url of the Sequencer node
#[arg(
long,
env = "SEQUENCER_URL",
default_value = crate::cli::DEFAULT_SEQUENCER_RPC
)]
pub(crate) sequencer_url: String,
/// The address of the Sequencer bridge account
pub(crate) address: Address,
}

#[derive(Args, Debug)]
pub(crate) struct Bech32mAddressArgs {
/// The hex formatted byte part of the bech32m address
Expand Down
3 changes: 3 additions & 0 deletions crates/astria-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ pub async fn run(cli: Cli) -> eyre::Result<()> {
SequencerCommand::BridgeSudoChange(args) => {
sequencer::bridge_sudo_change(&args).await?;
}
SequencerCommand::GetBridgeAccount(args) => {
sequencer::get_bridge_account(&args).await?;
}
},
}
} else {
Expand Down
31 changes: 31 additions & 0 deletions crates/astria-cli/src/commands/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use crate::cli::sequencer::{
BasicAccountArgs,
Bech32mAddressArgs,
BlockHeightGetArgs,
BridgeAccountArgs,
BridgeLockArgs,
BridgeSudoChangeArgs,
FeeAssetChangeArgs,
Expand Down Expand Up @@ -165,6 +166,36 @@ pub(crate) async fn get_block_height(args: &BlockHeightGetArgs) -> eyre::Result<
Ok(())
}

/// Gets bridge account information
///
/// # Arguments
///
/// * `args` - The arguments passed to the command
///
/// # Errors
///
/// * If the http client cannot be created
/// * If the bridge account information cannot be retrieved
pub(crate) async fn get_bridge_account(args: &BridgeAccountArgs) -> eyre::Result<()> {
let sequencer_client = HttpClient::new(args.sequencer_url.as_str())
.wrap_err("failed constructing http sequencer client")?;

let res = sequencer_client
.get_bridge_account_info(args.address)
.await
.wrap_err("failed to get bridge account")?;
let Some(info) = res.info else {
return Err(eyre::eyre!("no bridge account information found"));
};
println!("Bridge Account Information for address: {}", args.address);
println!(" Rollup Id: {}", info.rollup_id);
println!(" Asset: {}", info.asset);
println!(" Sudo Address: {}", info.sudo_address);
println!(" Withdrawer Address {}", info.withdrawer_address);

Ok(())
}

/// Returns a bech32m sequencer address given a prefix and hex-encoded byte slice
pub(crate) fn make_bech32m(args: &Bech32mAddressArgs) -> eyre::Result<()> {
use hex::FromHex as _;
Expand Down

0 comments on commit 08f0208

Please sign in to comment.