Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sequencer)!: exclusively use Borsh encoding for stored data (ENG-768) #1492

Merged
merged 17 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions crates/astria-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ server = ["dep:tonic"]
test-utils = []
base64-serde = ["dep:base64-serde"]
brotli = ["dep:brotli"]
# When enabled, this adds constructors for some types that skip the normal constructor validity
# checks. It supports the case where the inputs are already deemed valid, e.g. having read them from
# local storage.
unchecked-constructors = []
Fraser999 marked this conversation as resolved.
Show resolved Hide resolved

[dev-dependencies]
astria-core = { path = ".", features = ["serde"] }
Expand Down
1 change: 1 addition & 0 deletions crates/astria-core/src/primitive/v1/asset/denom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ impl TracePrefixed {

/// This should only be used where the inputs have been provided by a trusted entity, e.g. read
/// from our own state store.
#[cfg(feature = "unchecked-constructors")]
#[doc(hidden)]
#[must_use]
pub fn unchecked_from_parts<I: IntoIterator<Item = (String, String)>>(
Fraser999 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
2 changes: 2 additions & 0 deletions crates/astria-core/src/primitive/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ impl Address<Bech32m> {

/// This should only be used where the inputs have been provided by a trusted entity, e.g. read
/// from our own state store.
#[cfg(feature = "unchecked-constructors")]
#[doc(hidden)]
#[must_use]
pub fn unchecked_from_parts(bytes: [u8; ADDRESS_LEN], prefix: &str) -> Self {
Expand Down Expand Up @@ -889,6 +890,7 @@ mod tests {
let _ = address.into_raw();
}

#[cfg(feature = "unchecked-constructors")]
#[test]
fn address_to_unchecked_roundtrip() {
let bytes = [42u8; ADDRESS_LEN];
Expand Down
3 changes: 3 additions & 0 deletions crates/astria-core/src/sequencerblock/v1alpha1/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ impl RollupTransactions {

/// This should only be used where `parts` has been provided by a trusted entity, e.g. read from
/// our own state store.
#[cfg(feature = "unchecked-constructors")]
#[doc(hidden)]
#[must_use]
pub fn unchecked_from_parts(parts: RollupTransactionsParts) -> Self {
Expand Down Expand Up @@ -502,6 +503,7 @@ impl SequencerBlockHeader {

/// This should only be used where `parts` has been provided by a trusted entity, e.g. read from
/// our own state store.
#[cfg(feature = "unchecked-constructors")]
#[doc(hidden)]
#[must_use]
pub fn unchecked_from_parts(parts: SequencerBlockHeaderParts) -> Self {
Expand Down Expand Up @@ -969,6 +971,7 @@ impl SequencerBlock {

/// This should only be used where `parts` has been provided by a trusted entity, e.g. read from
/// our own state store.
#[cfg(feature = "unchecked-constructors")]
#[doc(hidden)]
#[must_use]
pub fn unchecked_from_parts(parts: SequencerBlockParts) -> Self {
Expand Down
6 changes: 5 additions & 1 deletion crates/astria-sequencer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ name = "astria-sequencer"
benchmark = ["divan"]

[dependencies]
astria-core = { path = "../astria-core", features = ["server", "serde"] }
astria-core = { path = "../astria-core", features = [
"server",
"serde",
"unchecked-constructors",
] }
astria-build-info = { path = "../astria-build-info", features = ["runtime"] }

# The "anyhow" feature is only included because it is necessary for the implementation of
Expand Down