Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions crates/astria-composer/local.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ ASTRIA_COMPOSER_API_LISTEN_ADDR="0.0.0.0:0"
# Address of the RPC server for the sequencer chain
ASTRIA_COMPOSER_SEQUENCER_URL="http://127.0.0.1:26657"

# A list of execution <chain_id_1>::<rpc_server_1>,<chain_id_2>::<rpc_server_2>.
# Chain IDs are not case sensitive. If an ID is repeated, the last list item is used.
# A list of execution <rollup_name_1>::<rpc_server_1>,<rollup_name_id_2>::<rpc_server_2>.
# Rollup names are not case sensitive, they will be converted to lowercase. If a name is
# repeated, the last list item is used.
ASTRIA_COMPOSER_ROLLUPS="astriachain::ws://127.0.0.1:8545"

# Private key for the sequencer account used for signing transactions
Expand Down
2 changes: 1 addition & 1 deletion crates/astria-composer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct Config {
/// Address of the RPC server for the sequencer chain
pub sequencer_url: String,

/// A list of <chain_id>::<url> pairs
/// A list of <rollup_name>::<url> pairs
pub rollups: String,

/// Private key for the sequencer account used for signing transactions
Expand Down
12 changes: 6 additions & 6 deletions crates/astria-composer/src/searcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ impl Searcher {

/// Spawns all collector on the collector task set.
fn spawn_collectors(&mut self) {
for (chain_id, collector) in self.collectors.drain() {
for (rollup_name, collector) in self.collectors.drain() {
self.collector_tasks
.spawn(chain_id, collector.run_until_stopped());
.spawn(rollup_name, collector.run_until_stopped());
}
}

Expand All @@ -284,7 +284,7 @@ impl Searcher {
let mut statuses = self
.collector_statuses
.iter()
.map(|(chain_id, status)| {
.map(|(rollup_name, status)| {
let mut status = status.clone();
async move {
match status.wait_for(collector::Status::is_connected).await {
Expand All @@ -297,14 +297,14 @@ impl Searcher {
Err(e) => Err(e),
}
}
.map(|fut| (chain_id.clone(), fut))
.map(|fut| (rollup_name.clone(), fut))
})
.collect::<FuturesUnordered<_>>();
while let Some((chain_id, maybe_err)) = statuses.next().await {
while let Some((rollup_name, maybe_err)) = statuses.next().await {
if let Err(e) = maybe_err {
return Err(e).wrap_err_with(|| {
format!(
"collector for chain ID {chain_id} failed while waiting for it to become \
"collector for rollup {rollup_name} failed while waiting for it to become \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"collector for rollup {rollup_name} failed while waiting for it to become \
"collector for rollup `{rollup_name}` failed while waiting for it to become \

I like doing this to have the name stand out a bit more.

ready"
)
});
Expand Down
34 changes: 17 additions & 17 deletions crates/astria-composer/src/searcher/rollup.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Parsing strings of the form `<chain_id>::<url>`
//! Parsing strings of the form `<rollup_name>::<url>`

use std::fmt;

Expand All @@ -7,7 +7,7 @@ use regex::Regex;

#[derive(Debug)]
pub(super) struct Rollup {
chain_id: String,
rollup_name: String,
url: String,
}

Expand All @@ -23,8 +23,8 @@ impl ParseError {
impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad(
"invalid rollup definition, must be `<chainid>::<url>, with <chainid> being \
alphanumeric ascii and -",
"invalid rollup definition, must be `<rollup_name>::<url>, with <rollup_name> being \
lowercase alphanumeric ascii and -",
)
}
}
Expand All @@ -36,7 +36,7 @@ impl Rollup {
static ROLLUP_RE: Lazy<Regex> = Lazy::new(|| {
Regex::new(
r"(?x)
^(?P<chain_id>[[:alnum:]-]+?)
^(?P<rollup_name>[[:alnum:]-]+?)
# lazily match all alphanumeric ascii and dash;
# case insignificant, but we will lowercase later
::
Expand All @@ -53,20 +53,20 @@ impl Rollup {
// Note that this will panic on invalid indices. However, these
// accesses will always be correct because the regex will only
// match when these capture groups match.
let chain_id = caps["chain_id"].to_string().to_lowercase();
let rollup_name = caps["rollup_name"].to_string().to_lowercase();
let url = caps["url"].to_string();
Ok(Self {
chain_id,
rollup_name,
url,
})
}

pub(super) fn into_parts(self) -> (String, String) {
let Self {
chain_id,
rollup_name,
url,
} = self;
(chain_id, url)
(rollup_name, url)
}
}

Expand All @@ -89,15 +89,15 @@ mod tests {
fn parse_single_rollup_valid() {
let rollups = expect_parse_rollups("chain-1::http://some.url");
assert_eq!(rollups.len(), 1, "\nparsed: {rollups:#?}");
assert_eq!(rollups[0].chain_id, "chain-1");
assert_eq!(rollups[0].rollup_name, "chain-1");
assert_eq!(rollups[0].url, "http://some.url");
}

#[test]
fn parse_mixed_case_chain_id_is_lowercased() {
fn parse_mixed_case_rollup_name_is_lowercased() {
let rollups = expect_parse_rollups("ChAiN-1::http://some.url");
assert_eq!(rollups.len(), 1, "\nparsed: {rollups:#?}");
assert_eq!(rollups[0].chain_id, "chain-1");
assert_eq!(rollups[0].rollup_name, "chain-1");
assert_eq!(rollups[0].url, "http://some.url");
}

Expand All @@ -106,17 +106,17 @@ mod tests {
let rollups =
expect_parse_rollups("chain-1::http://some.url,another::ws://ws.domain,last::foo.bar");
assert_eq!(rollups.len(), 3, "\nparsed: {rollups:#?}");
assert_eq!(rollups[0].chain_id, "chain-1");
assert_eq!(rollups[0].rollup_name, "chain-1");
assert_eq!(rollups[0].url, "http://some.url");
assert_eq!(rollups[1].chain_id, "another");
assert_eq!(rollups[1].rollup_name, "another");
assert_eq!(rollups[1].url, "ws://ws.domain");
assert_eq!(rollups[2].chain_id, "last");
assert_eq!(rollups[2].rollup_name, "last");
assert_eq!(rollups[2].url, "foo.bar");
}

#[should_panic]
#[test]
fn parse_with_non_alnum_non_dash_chain_id_fails() {
fn parse_with_non_alnum_non_dash_rollup_name_fails() {
expect_parse_rollups("chain_1::http://some.url");
}

Expand All @@ -129,7 +129,7 @@ mod tests {
#[test]
fn parse_with_triple_colon_is_valid() {
let rollups = expect_parse_rollups("chain-1:::http://some.url");
assert_eq!(rollups[0].chain_id, "chain-1");
assert_eq!(rollups[0].rollup_name, "chain-1");
assert_eq!(rollups[0].url, ":http://some.url");
}
}
44 changes: 22 additions & 22 deletions crates/astria-composer/tests/blackbox/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ async fn tx_from_one_rollup_is_received_by_sequencer() {
.await
.expect("setup guard failed");

let expected_chain_ids = vec![RollupId::from_unhashed_bytes("test1")];
let expected_rollup_ids = vec![RollupId::from_unhashed_bytes("test1")];
let mock_guard =
mount_broadcast_tx_sync_mock(&test_composer.sequencer, expected_chain_ids, vec![0]).await;
mount_broadcast_tx_sync_mock(&test_composer.sequencer, expected_rollup_ids, vec![0]).await;
test_composer.rollup_nodes["test1"]
.push_tx(Transaction::default())
.unwrap();
Expand All @@ -60,12 +60,12 @@ async fn tx_from_two_rollups_are_received_by_sequencer() {
.await
.expect("setup guard failed");

let expected_chain_ids = vec![
let expected_rollup_ids = vec![
RollupId::from_unhashed_bytes("test1"),
RollupId::from_unhashed_bytes("test2"),
];
let test_guard =
mount_broadcast_tx_sync_mock(&test_composer.sequencer, expected_chain_ids, vec![0, 1])
mount_broadcast_tx_sync_mock(&test_composer.sequencer, expected_rollup_ids, vec![0, 1])
.await;
test_composer.rollup_nodes["test1"]
.push_tx(Transaction::default())
Expand All @@ -81,22 +81,22 @@ async fn tx_from_two_rollups_are_received_by_sequencer() {
.await
.expect("mocked sequencer should have received a broadcast messages from composer");

// Validate that the received nonces and chain_ids were unique
// Validate that the received nonces and rollup_ids were unique
let mut received_nonces: Vec<u32> = vec![];
let mut received_chain_ids: Vec<RollupId> = vec![];
let mut received_rollup_ids: Vec<RollupId> = vec![];
for request in test_guard.received_requests().await {
let (chain_id, nonce) = chain_id_nonce_from_request(&request);
let (rollup_id, nonce) = rollup_id_nonce_from_request(&request);
assert!(
!received_nonces.contains(&nonce),
"duplicate nonce received"
);
received_nonces.push(nonce);

assert!(
!received_chain_ids.contains(&chain_id),
"duplicate chain id received"
!received_rollup_ids.contains(&rollup_id),
"duplicate rollup id received"
);
received_chain_ids.push(chain_id);
received_rollup_ids.push(rollup_id);
}
}

Expand Down Expand Up @@ -132,10 +132,10 @@ async fn invalid_nonce_failure_causes_tx_resubmission_under_different_nonce() {
)
.await;

let expected_chain_ids = vec![RollupId::from_unhashed_bytes("test1")];
let expected_rollup_ids = vec![RollupId::from_unhashed_bytes("test1")];
// Expect nonce 1 again so that the resubmitted tx is accepted
let valid_nonce_guard =
mount_broadcast_tx_sync_mock(&test_composer.sequencer, expected_chain_ids, vec![1]).await;
mount_broadcast_tx_sync_mock(&test_composer.sequencer, expected_rollup_ids, vec![1]).await;

// Push a tx to the rollup node so that it is picked up by the composer and submitted with the
// stored nonce of 0, triggering the nonce refetch process
Expand Down Expand Up @@ -183,21 +183,21 @@ async fn single_rollup_tx_payload_integrity() {
}

/// Deserizalizes the bytes contained in a `tx_sync::Request` to a signed sequencer transaction and
/// verifies that the contained sequence action is in the given `expected_chain_ids` and
/// verifies that the contained sequence action is in the given `expected_rollup_ids` and
/// `expected_nonces`.
async fn mount_broadcast_tx_sync_mock(
server: &MockServer,
expected_chain_ids: Vec<RollupId>,
expected_rollup_ids: Vec<RollupId>,
expected_nonces: Vec<u32>,
) -> MockGuard {
let expected_calls = expected_nonces.len().try_into().unwrap();
let matcher = move |request: &Request| {
let (chain_id, nonce) = chain_id_nonce_from_request(request);
let (rollup_id, nonce) = rollup_id_nonce_from_request(request);

let valid_chain_id = expected_chain_ids.contains(&chain_id);
let valid_rollup_id = expected_rollup_ids.contains(&rollup_id);
let valid_nonce = expected_nonces.contains(&nonce);

valid_chain_id && valid_nonce
valid_rollup_id && valid_nonce
};
let jsonrpc_rsp = response::Wrapper::new_with_id(
Id::Num(1),
Expand All @@ -219,15 +219,15 @@ async fn mount_broadcast_tx_sync_mock(
}

/// Deserizalizes the bytes contained in a `tx_sync::Request` to a signed sequencer transaction and
/// verifies that the contained sequence action is for the given `expected_chain_id`. It then
/// verifies that the contained sequence action is for the given `expected_rollup_id`. It then
/// rejects the transaction for an invalid nonce.
async fn mount_broadcast_tx_sync_invalid_nonce_mock(
server: &MockServer,
expected_chain_id: RollupId,
expected_rollup_id: RollupId,
) -> MockGuard {
let matcher = move |request: &Request| {
let (chain_id, _) = chain_id_nonce_from_request(request);
chain_id == expected_chain_id
let (rollup_id, _) = rollup_id_nonce_from_request(request);
rollup_id == expected_rollup_id
};
let jsonrpc_rsp = response::Wrapper::new_with_id(
Id::Num(1),
Expand Down Expand Up @@ -303,7 +303,7 @@ fn signed_tx_from_request(request: &Request) -> SignedTransaction {
signed_tx
}

fn chain_id_nonce_from_request(request: &Request) -> (RollupId, u32) {
fn rollup_id_nonce_from_request(request: &Request) -> (RollupId, u32) {
let signed_tx = signed_tx_from_request(request);

// validate that the transaction's first action is a sequence action
Expand Down
4 changes: 2 additions & 2 deletions crates/astria-conductor/local.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ ASTRIA_CONDUCTOR_CELESTIA_BEARER_TOKEN="<JWT Bearer token>"
# This url is used to read astria blocks from the Data Availability layer
ASTRIA_CONDUCTOR_CELESTIA_NODE_URL="http://127.0.0.1:26659"

# The chain id of the chain that is being read from the astria-sequencer or the
# The rollup name of the chain that is being read from the astria-sequencer or the
# Data Availability layer
ASTRIA_CONDUCTOR_CHAIN_ID="astriachain"
ASTRIA_CONDUCTOR_ROLLUP_NAME="astriachain"

# Execution RPC URL
ASTRIA_CONDUCTOR_EXECUTION_RPC_URL="http://127.0.0.1:50051"
Expand Down
2 changes: 1 addition & 1 deletion crates/astria-conductor/src/conductor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl Conductor {
let signals = spawn_signal_handler();

let rollup_id =
proto::native::sequencer::v1alpha1::RollupId::from_unhashed_bytes(&cfg.chain_id);
proto::native::sequencer::v1alpha1::RollupId::from_unhashed_bytes(&cfg.rollup_name);

// Spawn the executor task.
let (executor_tx, sync_start_block_height) = {
Expand Down
5 changes: 3 additions & 2 deletions crates/astria-conductor/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ pub struct Config {
/// URL of the sequencer cometbft websocket
pub sequencer_url: String,

/// Chain ID that we want to work in
pub chain_id: String,
/// Rollup name which the conductor will derive the astria rollup_id, and
/// celestia namespace from.
pub rollup_name: String,

/// Address of the RPC server for execution
pub execution_rpc_url: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,11 @@ mod test {
#[test]
fn validate_sequencer_blob_last_commit_none_ok() {
let rollup_transactions_root = merkle::Tree::from_leaves([[1, 2, 3], [4, 5, 6]]).root();
let chain_ids_commitment = merkle::Tree::new().root();
let rollup_ids_commitment = merkle::Tree::new().root();

let tree = sequencer_types::cometbft::merkle_tree_from_transactions([
rollup_transactions_root,
chain_ids_commitment,
rollup_ids_commitment,
]);
let data_hash = tree.root();
let rollup_transactions_proof = tree.construct_proof(0).unwrap();
Expand All @@ -385,7 +385,7 @@ mod test {
}

#[tokio::test]
async fn validate_sequencer_blob_with_chain_ids() {
async fn validate_sequencer_blob_with_rollup_ids() {
let test_tx = b"test-tx".to_vec();
let rollup_id = RollupId::from_unhashed_bytes(b"test-chain");
let grouped_txs = BTreeMap::from([(rollup_id, vec![test_tx.clone()])]);
Expand Down
4 changes: 2 additions & 2 deletions crates/astria-conductor/src/data_availability/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ pub(crate) struct SequencerBlockSubset {
}

impl SequencerBlockSubset {
pub(crate) fn from_sequencer_block(block: SequencerBlock, chain_id: RollupId) -> Self {
pub(crate) fn from_sequencer_block(block: SequencerBlock, rollup_id: RollupId) -> Self {
let mut block = block.into_unchecked();
let header = block.header;
let block_hash = header.hash();
let transactions = block
.rollup_transactions
.remove(&chain_id)
.remove(&rollup_id)
.unwrap_or_default();
Self {
block_hash,
Expand Down
6 changes: 3 additions & 3 deletions crates/astria-sequencer-relayer/tests/blackbox/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ fn create_block_response(
Time,
};
let suffix = height.to_string().into_bytes();
let rollup_id = RollupId::from_unhashed_bytes([b"test_chain_id_", &*suffix].concat());
let rollup_id = RollupId::from_unhashed_bytes([b"test_rollup_id_", &*suffix].concat());
let signed_tx = UnsignedTransaction {
nonce: 1,
actions: vec![
Expand All @@ -368,10 +368,10 @@ fn create_block_response(
let action_tree_root =
proto::native::sequencer::v1alpha1::derive_merkle_tree_from_rollup_txs(&rollup_txs).root();

let chain_ids_commitment = merkle::Tree::from_leaves(std::iter::once(rollup_id)).root();
let rollup_ids_commitment = merkle::Tree::from_leaves(std::iter::once(rollup_id)).root();
let data = vec![
action_tree_root.to_vec(),
chain_ids_commitment.to_vec(),
rollup_ids_commitment.to_vec(),
signed_tx.into_raw().encode_to_vec(),
];
let data_hash = Some(Hash::Sha256(simple_hash_from_byte_vectors::<sha2::Sha256>(
Expand Down
2 changes: 1 addition & 1 deletion crates/astria-sequencer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub(crate) struct App {

/// set to `0` when `begin_block` is called, and set to `1` or `2` when
/// `deliver_tx` is called for the first two times.
/// this is a hack to allow the `sequence_actions_commitment` and `chain_ids_commitment`
/// this is a hack to allow the `sequence_actions_commitment` and `rollup_ids_commitment`
/// to pass `deliver_tx`, as they're the first two "tx"s delivered.
///
/// when the app is fully updated to ABCI++, `begin_block`, `deliver_tx`,
Expand Down