Skip to content

Commit

Permalink
Merge branch 'main' into spike/noble-usdc
Browse files Browse the repository at this point in the history
* main:
  chore: ibc e2e smoke test (#1284)
  chore(metrics): restrict `metrics` crate usage to `astria-telemetry` (#1192)
  fix(charts)!: sequencer-relayer chart correct startup env var (#1437)
  chore(bridge-withdrawer): Add instrumentation (#1324)
  chore(conductor): Add instrumentation (#1330)
  fix(cli, bridge-withdrawer): dont fail entire block due to bad withdraw event (#1409)
  feat(sequencer, bridge-withdrawer)!: enforce withdrawals consumed (#1391)
  • Loading branch information
steezeburger committed Sep 3, 2024
2 parents eef8c42 + e594015 commit b116aa6
Show file tree
Hide file tree
Showing 87 changed files with 2,582 additions and 1,483 deletions.
239 changes: 175 additions & 64 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ insta = "1.36.1"
itertools = "0.12.1"
itoa = "1.0.10"
jsonrpsee = { version = "0.20" }
metrics = "0.22.1"
once_cell = "1.17.1"
pbjson-types = "0.6"
# Note that when updating the penumbra versions, vendored types in `proto/sequencerapis/astria_vendored` may need to be updated as well.
Expand Down
2 changes: 1 addition & 1 deletion charts/sequencer-relayer/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.11.2
version: 0.12.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
10 changes: 0 additions & 10 deletions charts/sequencer-relayer/files/scripts/start-relayer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ set -o errexit -o nounset -o pipefail

echo "Starting the Astria Sequencer Relayer..."

if ! [ -z ${ASTRIA_SEQUENCER_RELAYER_PRE_SUBMIT_PATH+x} ] && ! [ -f "$ASTRIA_SEQUENCER_RELAYER_PRE_SUBMIT_PATH" ]; then
echo "Pre-submit storage file not found, instantiating with ignore state. Post submit storage file will be created on first submit."
echo "{\"state\": \"ignore\"}" > $ASTRIA_SEQUENCER_RELAYER_PRE_SUBMIT_PATH
fi

if ! [ -z ${ASTRIA_SEQUENCER_RELAYER_POST_SUBMIT_PATH+x} ] && ! [ -f "$ASTRIA_SEQUENCER_RELAYER_POST_SUBMIT_PATH" ]; then
echo "Post-submit storage file does not exist, instantiating with fresh state. Will start relaying from first sequencer block."
echo "{\"state\": \"fresh\"}" > $ASTRIA_SEQUENCER_RELAYER_POST_SUBMIT_PATH
fi

if ! [ -z ${ASTRIA_SEQUENCER_RELAYER_SUBMISSION_STATE_PATH+x} ] && ! [ -f "$ASTRIA_SEQUENCER_RELAYER_SUBMISSION_STATE_PATH" ]; then
echo "Submission state file does not exist, instantiating with fresh state. Will start relaying from first sequencer block."
echo "{\"state\": \"fresh\"}" > $ASTRIA_SEQUENCER_RELAYER_SUBMISSION_STATE_PATH
Expand Down
4 changes: 1 addition & 3 deletions charts/sequencer-relayer/templates/configmaps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
namespace: {{ include "sequencer-relayer.namespace" . }}
data:
ASTRIA_SEQUENCER_RELAYER_LOG: "astria_sequencer_relayer=debug"
ASTRIA_SEQUENCER_RELAYER_SUBMISSION_STATE_PATH: "{{ include "sequencer-relayer.storage.submissionStatePath" . }}"
ASTRIA_SEQUENCER_RELAYER_BLOCK_TIME: "1000"
ASTRIA_SEQUENCER_RELAYER_COMETBFT_ENDPOINT: "{{ .Values.config.relayer.cometbftRpc }}"
ASTRIA_SEQUENCER_RELAYER_SEQUENCER_GRPC_ENDPOINT: "{{ .Values.config.relayer.sequencerGrpc }}"
Expand All @@ -28,10 +29,7 @@ data:
ASTRIA_SEQUENCER_RELAYER_SEQUENCER_CHAIN_ID: "{{ .Values.config.relayer.sequencerChainId }}"
ASTRIA_SEQUENCER_RELAYER_CELESTIA_CHAIN_ID: "{{ .Values.config.relayer.celestiaChainId }}"
{{- if not .Values.global.dev }}
ASTRIA_SEQUENCER_RELAYER_PRE_SUBMIT_PATH: "{{ include "sequencer-relayer.storage.preSubmitPath" . }}"
ASTRIA_SEQUENCER_RELAYER_POST_SUBMIT_PATH: "{{ include "sequencer-relayer.storage.postSubmitPath" . }}"
{{- else }}
ASTRIA_SEQUENCER_RELAYER_SUBMISSION_STATE_PATH: "{{ include "sequencer-relayer.storage.submissionStatePath" . }}"
{{- end }}
---
apiVersion: v1
Expand Down
6 changes: 3 additions & 3 deletions charts/sequencer/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: sequencer-relayer
repository: file://../sequencer-relayer
version: 0.11.2
digest: sha256:76454e176c237a3099be9d76ffd20a1a640cfc3d48c7598c9de8a9332ac802ad
generated: "2024-08-22T13:56:23.979747-07:00"
version: 0.12.0
digest: sha256:e7eaa26032e2e92f8df8eaea11580ad9e464866360d4e5d4c14bae4eec8a090b
generated: "2024-08-30T12:12:47.838866-07:00"
4 changes: 2 additions & 2 deletions charts/sequencer/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.21.0
version: 0.22.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
Expand All @@ -24,7 +24,7 @@ appVersion: "0.16.0"

dependencies:
- name: sequencer-relayer
version: "0.11.2"
version: "0.12.0"
repository: "file://../sequencer-relayer"
condition: sequencer-relayer.enabled

Expand Down
22 changes: 9 additions & 13 deletions crates/astria-bridge-contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ where
pub async fn get_for_block_hash(
&self,
block_hash: H256,
) -> Result<Vec<Action>, GetWithdrawalActionsError> {
) -> Result<Vec<Result<Action, GetWithdrawalActionsError>>, GetWithdrawalActionsError> {
use futures::FutureExt as _;
let get_ics20_logs = if self.configured_for_ics20_withdrawals() {
get_logs::<Ics20WithdrawalFilter, _>(&self.provider, self.contract_address, block_hash)
Expand All @@ -358,15 +358,15 @@ where
// XXX: The calls to `log_to_*_action` rely on only be called if `GetWithdrawalActions`
// is configured for either ics20 or sequencer withdrawals (or both). They would panic
// otherwise.
ics20_logs
Ok(ics20_logs
.into_iter()
.map(|log| self.log_to_ics20_withdrawal_action(log))
.chain(
sequencer_logs
.into_iter()
.map(|log| self.log_to_sequencer_withdrawal_action(log)),
)
.collect()
.collect())
}

fn log_to_ics20_withdrawal_action(
Expand All @@ -378,7 +378,7 @@ where
.ok_or_else(|| GetWithdrawalActionsError::log_without_block_number(&log))?
.as_u64();

let rollup_transaction_hash = log
let rollup_withdrawal_event_id = log
.transaction_hash
.ok_or_else(|| GetWithdrawalActionsError::log_without_transaction_hash(&log))?
.to_string();
Expand All @@ -400,7 +400,7 @@ where
memo: event.memo.clone(),
rollup_block_number,
rollup_return_address: event.sender.to_string(),
rollup_transaction_hash,
rollup_withdrawal_event_id,
})
.map_err(GetWithdrawalActionsError::encode_memo)?;

Expand Down Expand Up @@ -433,20 +433,14 @@ where
.ok_or_else(|| GetWithdrawalActionsError::log_without_block_number(&log))?
.as_u64();

let rollup_transaction_hash = log
let rollup_withdrawal_event_id = log
.transaction_hash
.ok_or_else(|| GetWithdrawalActionsError::log_without_transaction_hash(&log))?
.to_string();

let event = decode_log::<SequencerWithdrawalFilter>(log)
.map_err(GetWithdrawalActionsError::decode_log)?;

let memo = memo_to_json(&memos::v1alpha1::BridgeUnlock {
rollup_block_number,
rollup_transaction_hash,
})
.map_err(GetWithdrawalActionsError::encode_memo)?;

let amount = calculate_amount(&event, self.asset_withdrawal_divisor)
.map_err(GetWithdrawalActionsError::calculate_withdrawal_amount)?;

Expand All @@ -456,7 +450,9 @@ where
let action = astria_core::protocol::transaction::v1alpha1::action::BridgeUnlockAction {
to,
amount,
memo,
rollup_block_number,
rollup_withdrawal_event_id,
memo: String::new(),
fee_asset: self.fee_asset.clone(),
bridge_address: self.bridge_address,
};
Expand Down
1 change: 0 additions & 1 deletion crates/astria-bridge-withdrawer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ ethers = { workspace = true, features = ["ws"] }
hyper = { workspace = true }
humantime = { workspace = true }
ibc-types = { workspace = true }
metrics = { workspace = true }
once_cell = { workspace = true }
pin-project-lite = { workspace = true }
prost = { workspace = true }
Expand Down
4 changes: 4 additions & 0 deletions crates/astria-bridge-withdrawer/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use http::status::StatusCode;
use hyper::server::conn::AddrIncoming;
use serde::Serialize;
use tokio::sync::watch;
use tracing::instrument;

use crate::bridge_withdrawer::StateSnapshot;

Expand Down Expand Up @@ -51,6 +52,7 @@ pub(crate) fn start(socket_addr: SocketAddr, withdrawer_state: WithdrawerState)
}

#[allow(clippy::unused_async)] // Permit because axum handlers must be async
#[instrument(skip_all)]
async fn get_healthz(State(withdrawer_state): State<WithdrawerState>) -> Healthz {
if withdrawer_state.borrow().is_healthy() {
Healthz::Ok
Expand All @@ -66,6 +68,7 @@ async fn get_healthz(State(withdrawer_state): State<WithdrawerState>) -> Healthz
/// + there is a current sequencer height (implying a block from sequencer was received)
/// + there is a current data availability height (implying a height was received from the DA)
#[allow(clippy::unused_async)] // Permit because axum handlers must be async
#[instrument(skip_all)]
async fn get_readyz(State(withdrawer_state): State<WithdrawerState>) -> Readyz {
let is_withdrawer_online = withdrawer_state.borrow().is_ready();
if is_withdrawer_online {
Expand All @@ -76,6 +79,7 @@ async fn get_readyz(State(withdrawer_state): State<WithdrawerState>) -> Readyz {
}

#[allow(clippy::unused_async)] // Permit because axum handlers must be async
#[instrument(skip_all)]
async fn get_status(State(withdrawer_state): State<WithdrawerState>) -> Json<StateSnapshot> {
Json(withdrawer_state.borrow().clone())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ use astria_bridge_contracts::{
GetWithdrawalActions,
GetWithdrawalActionsBuilder,
};
use astria_core::primitive::v1::{
asset,
Address,
use astria_core::{
primitive::v1::{
asset,
Address,
},
protocol::transaction::v1alpha1::Action,
};
use astria_eyre::{
eyre::{
Expand Down Expand Up @@ -38,6 +41,7 @@ use tokio_util::sync::CancellationToken;
use tracing::{
debug,
info,
info_span,
instrument,
warn,
};
Expand Down Expand Up @@ -293,11 +297,13 @@ async fn watch_for_blocks(
bail!("current rollup block missing block number")
};

info!(
block.height = current_rollup_block_height.as_u64(),
block.hash = current_rollup_block.hash.map(tracing::field::display),
"got current block"
);
info_span!("watch_for_blocks").in_scope(|| {
info!(
block.height = current_rollup_block_height.as_u64(),
block.hash = current_rollup_block.hash.map(tracing::field::display),
"got current block"
);
});

// sync any blocks missing between `next_rollup_block_height` and the current latest
// (inclusive).
Expand All @@ -314,7 +320,7 @@ async fn watch_for_blocks(
loop {
select! {
() = shutdown_token.cancelled() => {
info!("block watcher shutting down");
info_span!("watch_for_blocks").in_scope(|| info!("block watcher shutting down"));
return Ok(());
}
block = block_rx.next() => {
Expand Down Expand Up @@ -348,10 +354,21 @@ async fn get_and_forward_block_events(
.number
.ok_or_eyre("block did not contain a rollup height")?
.as_u64();
let actions = actions_fetcher
let actions: Vec<Action> = actions_fetcher
.get_for_block_hash(block_hash)
.await
.wrap_err("failed getting actions for block")?;
.wrap_err("failed getting actions for block")?
.into_iter()
.filter_map(|r| {
r.map_err(|e| {
warn!(
error = %eyre::Report::new(e),
"failed to convert rollup withdrawal event to sequencer action; dropping"
);
})
.ok()
})
.collect();

if actions.is_empty() {
info!(
Expand Down
Loading

0 comments on commit b116aa6

Please sign in to comment.