Skip to content

Commit

Permalink
Rename vm to namespace, and clean up some dead code
Browse files Browse the repository at this point in the history
Closes #1023
  • Loading branch information
jbearer committed Mar 7, 2024
1 parent 632a65a commit 09ffe79
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 300 deletions.
130 changes: 0 additions & 130 deletions scripts/espresso_block_scanner.py

This file was deleted.

2 changes: 1 addition & 1 deletion sequencer/api/availability.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
PATH = ["block/:height/namespace/:namespace"]
":height" = "Integer"
":namespace" = "Integer"
DOC = "Get the namespace proof for a set of VM transactions and the NMT root"
DOC = "Get the transactions in a namespace of the given block, along with a proof."

[route.gettimestampwindow]
PATH = [
Expand Down
19 changes: 10 additions & 9 deletions sequencer/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ mod test_helpers {
persistence::{no_storage::NoStorage, SequencerPersistence},
state::BlockMerkleTree,
testing::{wait_for_decide_on_handle, TestConfig},
Transaction, VmId,
Transaction,
};
use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use async_std::task::sleep;
Expand Down Expand Up @@ -215,7 +215,7 @@ mod test_helpers {
setup_logging();
setup_backtrace();

let txn = Transaction::new(VmId(0), vec![1, 2, 3, 4]);
let txn = Transaction::new(Default::default(), vec![1, 2, 3, 4]);

let port = pick_unused_port().expect("No ports free");

Expand Down Expand Up @@ -410,7 +410,7 @@ mod api_tests {
use super::*;
use crate::{
testing::{wait_for_decide_on_handle, TestConfig},
Header, Transaction, VmId,
Header, Transaction,
};
use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use async_std::task::sleep;
Expand Down Expand Up @@ -456,7 +456,7 @@ mod api_tests {
setup_backtrace();

let vid = vid_scheme(5);
let txn = Transaction::new(VmId(0), vec![1, 2, 3, 4]);
let txn = Transaction::new(Default::default(), vec![1, 2, 3, 4]);

// Start query service.
let port = pick_unused_port().expect("No ports free");
Expand Down Expand Up @@ -498,18 +498,19 @@ mod api_tests {
let mut found_txn = false;
let mut found_empty_block = false;
for block_num in 0..=block_height {
let header: Header = client
.get(&format!("availability/header/{block_num}"))
.send()
.await
.unwrap();
let ns_query_res: NamespaceProofQueryData = client
.get(&format!("availability/block/{block_num}/namespace/0"))
.send()
.await
.unwrap();
ns_query_res
.proof
.verify(
&vid,
&ns_query_res.header.payload_commitment,
&ns_query_res.header.ns_table,
)
.verify(&vid, &header.payload_commitment, &header.ns_table)
.unwrap();

found_empty_block = found_empty_block || ns_query_res.transactions.is_empty();
Expand Down
7 changes: 3 additions & 4 deletions sequencer/src/api/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
block::payload::{parse_ns_payload, NamespaceProof},
network,
state::{BlockMerkleTree, FeeAccountProof, ValidatedState},
Header, SeqTypes, Transaction, VmId,
Header, NamespaceId, SeqTypes, Transaction,
};
use async_std::sync::{Arc, RwLock};
use commit::Committable;
Expand All @@ -32,7 +32,6 @@ use tide_disco::{
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct NamespaceProofQueryData {
pub proof: NamespaceProof,
pub header: Header,
pub transactions: Vec<Transaction>,
}

Expand Down Expand Up @@ -80,7 +79,8 @@ where
api.get("getnamespaceproof", move |req, state| {
async move {
let height: usize = req.integer_param("height")?;
let ns_id = VmId(req.integer_param("namespace")?);
let ns_id: u64 = req.integer_param("namespace")?;
let ns_id = NamespaceId::from(ns_id);
let (block, common) = try_join!(
async move {
state
Expand Down Expand Up @@ -129,7 +129,6 @@ where
Ok(NamespaceProofQueryData {
transactions,
proof,
header: block.header().clone(),
})
}
.boxed()
Expand Down
6 changes: 3 additions & 3 deletions sequencer/src/bin/submit-transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ async fn submit_transactions(
let hash = tx.commit();
tracing::info!(
"submitting transaction {hash} for namespace {} of size {}",
tx.vm(),
tx.namespace(),
tx.payload().len()
);
if let Err(err) = client
Expand Down Expand Up @@ -271,13 +271,13 @@ async fn server(port: u16) {
}

fn random_transaction(opt: &Options, rng: &mut ChaChaRng) -> Transaction {
let vm = rng.gen_range(opt.min_namespace..=opt.max_namespace);
let namespace = rng.gen_range(opt.min_namespace..=opt.max_namespace);

let len = rng.gen_range(opt.min_size..=opt.max_size);
let mut payload = vec![0; len];
rng.fill_bytes(&mut payload);

Transaction::new(vm.into(), payload)
Transaction::new(namespace.into(), payload)
}

fn random_seed() -> u64 {
Expand Down
12 changes: 6 additions & 6 deletions sequencer/src/block/entry.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{Deserialize, Serialize};
use crate::VmId;
use crate::NamespaceId;
use core::fmt;
use std::mem::size_of;

Expand Down Expand Up @@ -69,17 +69,17 @@ impl TryFrom<TxTableEntry> for usize {
}
}

impl TryFrom<VmId> for TxTableEntry {
impl TryFrom<NamespaceId> for TxTableEntry {
type Error = <TxTableEntryWord as TryFrom<u64>>::Error;

fn try_from(value: VmId) -> Result<Self, Self::Error> {
TxTableEntryWord::try_from(value.0).map(Self)
fn try_from(value: NamespaceId) -> Result<Self, Self::Error> {
TxTableEntryWord::try_from(u64::from(value)).map(Self)
}
}
impl TryFrom<TxTableEntry> for VmId {
impl TryFrom<TxTableEntry> for NamespaceId {
type Error = <u64 as TryFrom<TxTableEntryWord>>::Error;

fn try_from(value: TxTableEntry) -> Result<Self, Self::Error> {
Ok(Self(From::from(value.0)))
Ok((value.0 as u64).into())
}
}
Loading

0 comments on commit 09ffe79

Please sign in to comment.