Skip to content

Commit

Permalink
Merge branch 'main' into ENG-1031/forma_migration
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanoroshiba committed Jan 6, 2025
2 parents af7ebd0 + 8be7af8 commit e890e64
Show file tree
Hide file tree
Showing 61 changed files with 712 additions and 373 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ jobs:
if: needs.run_checker.outputs.run_lint_rust == 'true'
steps:
- uses: actions/checkout@v4
- name: Install just
uses: taiki-e/install-action@just
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-09-15
components: rustfmt
- name: run rustfmt
run: cargo +nightly-2024-09-15 fmt --all -- --check
run: just lint rust-fmt

toml:
runs-on: ubuntu-22.04
Expand Down
19 changes: 8 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Install just
uses: taiki-e/install-action@just
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUSTUP_TOOLCHAIN }}
Expand All @@ -230,15 +232,10 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: run pedantic clippy on workspace crates
run: |
cargo clippy --all-targets --all-features \
-- --warn clippy::pedantic --warn clippy::arithmetic-side-effects \
--warn clippy::allow_attributes --warn clippy::allow_attributes_without_reason \
--deny warnings
just lint rust-clippy
- name: run pedantic clippy on tools/protobuf-compiler
run: |
cargo clippy --manifest-path tools/protobuf-compiler/Cargo.toml \
--all-targets --all-features \
-- --warn clippy::pedantic --deny warnings
just lint rust-clippy-tools
custom-lints:
runs-on: buildjet-8vcpu-ubuntu-2204
Expand All @@ -248,6 +245,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Install just
uses: taiki-e/install-action@just
- uses: dtolnay/rust-toolchain@master
with:
# This has to match `rust-toolchain` in the rust-toolchain file of the dylint lints
Expand All @@ -266,17 +265,15 @@ jobs:
run: |
: # list all lint packages here to have clippy explicitly test them
: # uses the same nightly installed above to work around the entry in rust-toolchain.toml
cargo +nightly-2024-09-05 clippy --all-targets --all-features \
-p tracing_debug_field \
-- --warn clippy::pedantic --deny warnings
just lint rust-clippy-custom
- name: run dylint clippy on workspace crates
env:
# set the dylint driver path to the target/ directory so that it's hopefully cached by rust-cache
DYLINT_DRIVER_PATH: ${{ github.workspace }}/target/dylint_drivers/
DYLINT_RUSTFLAGS: "-D warnings"
run: |
mkdir -p "$DYLINT_DRIVER_PATH"
cargo dylint --all --workspace
just lint rust-dylint
test:
if: ${{ always() && !cancelled() }}
Expand Down
3 changes: 2 additions & 1 deletion crates/astria-cli/src/bridge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ impl Command {

#[derive(Debug, Subcommand)]
enum SubCommand {
/// Commands for interacting with Sequencer accounts
/// Collect withdrawals actions
CollectWithdrawals(collect::Command),
/// Submit collected withdrawal actions
SubmitWithdrawals(submit::Command),
}

Expand Down
5 changes: 5 additions & 0 deletions crates/astria-cli/src/bridge/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@ use tracing::{

#[derive(clap::Args, Debug)]
pub(crate) struct Command {
/// Path to the file containing the actions to submit
#[arg(long, short)]
input: PathBuf,
/// Path to the file containing the signing key
#[arg(long)]
signing_key: PathBuf,
/// The address prefix for the sequencer account
#[arg(long, default_value = "astria")]
sequencer_address_prefix: String,
/// The chain ID of the sequencer
#[arg(long)]
sequencer_chain_id: String,
/// The URL of the sequencer rpc
#[arg(long)]
sequencer_url: String,
}
Expand Down
4 changes: 3 additions & 1 deletion crates/astria-cli/src/sequencer/bridge_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ pub(super) struct Command {
/// The amount being locked
#[arg(long)]
amount: u128,
/// The address on the destination chain
#[arg(long)]
destination_chain_address: String,
/// The prefix to construct a bech32m address given the private key.
#[arg(long, default_value = "astria")]
prefix: String,
/// The private key of the account locking the funds
#[arg(long, env = "SEQUENCER_PRIVATE_KEY")]
// TODO: https://github.com/astriaorg/astria/issues/594
// Don't use a plain text private, prefer wrapper like from
// the secrecy crate with specialized `Debug` and `Drop` implementations
// that overwrite the key on drop and don't reveal it when printing.
#[arg(long, env = "SEQUENCER_PRIVATE_KEY")]
private_key: String,
/// The url of the Sequencer node
#[arg(long, env = "SEQUENCER_URL")]
Expand Down
3 changes: 2 additions & 1 deletion crates/astria-cli/src/sequencer/ics20_withdrawal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ pub(super) struct Command {
/// The prefix to construct a bech32m address given the private key
#[arg(long, default_value = "astria")]
prefix: String,
/// The private key of the account withdrawing the funds
#[arg(long, env = "SEQUENCER_PRIVATE_KEY")]
// TODO: https://github.com/astriaorg/astria/issues/594
// Don't use a plain text private, prefer wrapper like from
// the secrecy crate with specialized `Debug` and `Drop` implementations
// that overwrite the key on drop and don't reveal it when printing.
#[arg(long, env = "SEQUENCER_PRIVATE_KEY")]
private_key: String,
/// The url of the Sequencer node
#[arg(long, env = "SEQUENCER_URL")]
Expand Down
3 changes: 2 additions & 1 deletion crates/astria-cli/src/sequencer/init_bridge_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ pub(super) struct Command {
/// The bech32m prefix that will be used for constructing addresses using the private key
#[arg(long, default_value = "astria")]
prefix: String,
/// The private key of the account initializing the bridge account
#[arg(long, env = "SEQUENCER_PRIVATE_KEY")]
// TODO: https://github.com/astriaorg/astria/issues/594
// Don't use a plain text private, prefer wrapper like from
// the secrecy crate with specialized `Debug` and `Drop` implementations
// that overwrite the key on drop and don't reveal it when printing.
#[arg(long, env = "SEQUENCER_PRIVATE_KEY")]
private_key: String,
/// The url of the Sequencer node
#[arg(long, env = "SEQUENCER_URL")]
Expand Down
3 changes: 2 additions & 1 deletion crates/astria-cli/src/sequencer/sudo/fee_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ struct ArgsInner {
/// The bech32m prefix that will be used for constructing addresses using the private key
#[arg(long, default_value = "astria")]
prefix: String,
/// The private key of the sudo account authorizing change
#[arg(long, env = "SEQUENCER_PRIVATE_KEY")]
// TODO: https://github.com/astriaorg/astria/issues/594
// Don't use a plain text private, prefer wrapper like from
// the secrecy crate with specialized `Debug` and `Drop` implementations
// that overwrite the key on drop and don't reveal it when printing.
#[arg(long, env = "SEQUENCER_PRIVATE_KEY")]
private_key: String,
/// The url of the Sequencer node
#[arg(long, env = "SEQUENCER_URL")]
Expand Down
3 changes: 2 additions & 1 deletion crates/astria-cli/src/sequencer/sudo/ibc_relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ struct ArgsInner {
/// The prefix to construct a bech32m address given the private key.
#[arg(long, default_value = "astria")]
prefix: String,
/// The private key of the account authorizing the change
#[arg(long, env = "SEQUENCER_PRIVATE_KEY")]
// TODO: https://github.com/astriaorg/astria/issues/594
// Don't use a plain text private, prefer wrapper like from
// the secrecy crate with specialized `Debug` and `Drop` implementations
// that overwrite the key on drop and don't reveal it when printing.
#[arg(long, env = "SEQUENCER_PRIVATE_KEY")]
private_key: String,
/// The url of the Sequencer node
#[arg(long, env = "SEQUENCER_URL")]
Expand Down
3 changes: 2 additions & 1 deletion crates/astria-cli/src/sequencer/sudo/sudo_address_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ pub(super) struct Command {
/// The bech32m prefix that will be used for constructing addresses using the private key
#[arg(long, default_value = "astria")]
prefix: String,
/// The private key of account authorizing the change
#[arg(long, env = "SEQUENCER_PRIVATE_KEY")]
// TODO: https://github.com/astriaorg/astria/issues/594
// Don't use a plain text private, prefer wrapper like from
// the secrecy crate with specialized `Debug` and `Drop` implementations
// that overwrite the key on drop and don't reveal it when printing.
#[arg(long, env = "SEQUENCER_PRIVATE_KEY")]
private_key: String,
/// The url of the Sequencer node
#[arg(long, env = "SEQUENCER_URL")]
Expand Down
1 change: 1 addition & 0 deletions crates/astria-cli/src/sequencer/threshold/dkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub(super) struct Command {
#[arg(long)]
public_key_package_path: String,

/// The address prefix for the generated address.
#[arg(long, default_value = "astria")]
prefix: String,
}
Expand Down
4 changes: 2 additions & 2 deletions crates/astria-cli/src/sequencer/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ use crate::utils::submit_transaction;

#[derive(clap::Args, Debug)]
pub(super) struct Command {
// The address of the Sequencer account to send amount to
/// The address of the Sequencer account to send amount to
to_address: Address,
// The amount being sent
/// The amount being sent
#[arg(long)]
amount: u128,
/// The bech32m prefix that will be used for constructing addresses using the private key
Expand Down
35 changes: 18 additions & 17 deletions crates/astria-conductor/src/celestia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub(crate) struct Reader {

impl Reader {
pub(crate) async fn run_until_stopped(mut self) -> eyre::Result<ExitReason> {
let ((), executor, sequencer_chain_id) = select!(
let (executor, sequencer_chain_id) = select!(
() = self.shutdown.clone().cancelled_owned() => {
info_span!("conductor::celestia::Reader::run_until_stopped").in_scope(||
info!("received shutdown signal while waiting for Celestia reader task to initialize")
Expand All @@ -169,11 +169,10 @@ impl Reader {
.await
}

// TODO(https://github.com/astriaorg/astria/issues/1879): refactor to not return an empty tuple
#[instrument(skip_all, err)]
async fn initialize(
&mut self,
) -> eyre::Result<((), executor::Handle<StateIsInit>, tendermint::chain::Id)> {
) -> eyre::Result<(executor::Handle<StateIsInit>, tendermint::chain::Id)> {
let executor = self
.executor
.wait_for_init()
Expand Down Expand Up @@ -212,7 +211,7 @@ impl Reader {
get_and_validate_sequencer_chain_id
)?;

Ok(((), executor, sequencer_chain_id))
Ok((executor, sequencer_chain_id))
}
}

Expand Down Expand Up @@ -511,18 +510,20 @@ impl RunningReader {
match self.executor.try_send_firm_block(block) {
Ok(()) => self.advance_reference_celestia_height(celestia_height),
Err(FirmTrySendError::Channel {
source: mpsc::error::TrySendError::Full(block),
}) => {
trace!(
"executor channel is full; rescheduling block fetch until the channel opens up"
);
self.enqueued_block = enqueue_block(self.executor.clone(), block).boxed().fuse();
}

Err(FirmTrySendError::Channel {
source: mpsc::error::TrySendError::Closed(_),
}) => bail!("exiting because executor channel is closed"),

source,
}) => match source {
mpsc::error::TrySendError::Full(block) => {
trace!(
"executor channel is full; rescheduling block fetch until the channel \
opens up"
);
self.enqueued_block =
enqueue_block(self.executor.clone(), block).boxed().fuse();
}
mpsc::error::TrySendError::Closed(_) => {
bail!("exiting because executor channel is closed");
}
},
Err(FirmTrySendError::NotSet) => bail!(
"exiting because executor was configured without firm commitments; this Celestia \
reader should have never been started"
Expand Down Expand Up @@ -658,7 +659,7 @@ impl FetchConvertVerifyAndReconstruct {
#[instrument(skip_all, err)]
async fn enqueue_block(
executor: executor::Handle<StateIsInit>,
block: ReconstructedBlock,
block: Box<ReconstructedBlock>,
) -> Result<u64, FirmSendError> {
let celestia_height = block.celestia_height;
executor.send_firm_block(block).await?;
Expand Down
3 changes: 2 additions & 1 deletion crates/astria-conductor/src/executor/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use super::{
state,
Executor,
Handle,
ReconstructedBlock,
StateNotInit,
};
use crate::{
Expand Down Expand Up @@ -44,7 +45,7 @@ impl Builder {
let mut firm_block_tx = None;
let mut firm_block_rx = None;
if mode.is_with_firm() {
let (tx, rx) = mpsc::channel(16);
let (tx, rx) = mpsc::channel::<Box<ReconstructedBlock>>(16);
firm_block_tx = Some(tx);
firm_block_rx = Some(rx);
}
Expand Down
22 changes: 10 additions & 12 deletions crates/astria-conductor/src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub(crate) enum FirmSendError {
#[error("failed sending blocks to executor")]
Channel {
#[from]
source: mpsc::error::SendError<ReconstructedBlock>,
source: mpsc::error::SendError<Box<ReconstructedBlock>>,
},
}

Expand All @@ -161,7 +161,7 @@ pub(crate) enum FirmTrySendError {
#[error("failed sending blocks to executor")]
Channel {
#[from]
source: mpsc::error::TrySendError<ReconstructedBlock>,
source: mpsc::error::TrySendError<Box<ReconstructedBlock>>,
},
}

Expand Down Expand Up @@ -191,7 +191,7 @@ pub(crate) enum SoftTrySendError {
/// information.
#[derive(Debug, Clone)]
pub(crate) struct Handle<TStateInit = StateNotInit> {
firm_blocks: Option<mpsc::Sender<ReconstructedBlock>>,
firm_blocks: Option<mpsc::Sender<Box<ReconstructedBlock>>>,
soft_blocks: Option<channel::Sender<FilteredSequencerBlock>>,
state: StateReceiver,
_state_init: TStateInit,
Expand Down Expand Up @@ -222,20 +222,18 @@ impl Handle<StateIsInit> {
#[instrument(skip_all, err)]
pub(crate) async fn send_firm_block(
self,
block: ReconstructedBlock,
block: impl Into<Box<ReconstructedBlock>>,
) -> Result<(), FirmSendError> {
let sender = self.firm_blocks.as_ref().ok_or(FirmSendError::NotSet)?;
sender.send(block).await?;
Ok(())
Ok(sender.send(block.into()).await?)
}

pub(crate) fn try_send_firm_block(
&self,
block: ReconstructedBlock,
block: impl Into<Box<ReconstructedBlock>>,
) -> Result<(), FirmTrySendError> {
let sender = self.firm_blocks.as_ref().ok_or(FirmTrySendError::NotSet)?;
sender.try_send(block)?;
Ok(())
Ok(sender.try_send(block.into())?)
}

#[instrument(skip_all, err)]
Expand Down Expand Up @@ -310,7 +308,7 @@ pub(crate) struct Executor {
/// The channel of which this executor receives blocks for executing
/// firm commitments.
/// Only set if `mode` is `FirmOnly` or `SoftAndFirm`.
firm_blocks: Option<mpsc::Receiver<ReconstructedBlock>>,
firm_blocks: Option<mpsc::Receiver<Box<ReconstructedBlock>>>,

/// The channel of which this executor receives blocks for executing
/// soft commitments.
Expand Down Expand Up @@ -584,7 +582,7 @@ impl Executor {
))]
async fn execute_firm(
&mut self,
block: ReconstructedBlock,
block: Box<ReconstructedBlock>,
) -> eyre::Result<Option<StopHeightExceded>> {
if self.is_firm_block_height_exceded(&block) {
return Ok(Some(StopHeightExceded::celestia(
Expand All @@ -595,7 +593,7 @@ impl Executor {
}

let celestia_height = block.celestia_height;
let executable_block = ExecutableBlock::from_reconstructed(block);
let executable_block = ExecutableBlock::from_reconstructed(*block);
let expected_height = self.state.next_expected_firm_sequencer_height();
let block_height = executable_block.height;
let rollup_start_block_height = self.state.rollup_start_block_height();
Expand Down
Loading

0 comments on commit e890e64

Please sign in to comment.