Skip to content

Commit

Permalink
Merge pull request #6 from anton-rs/rf/feat/no-std-compat
Browse files Browse the repository at this point in the history
feat: workflow to validate no_std compatibility
  • Loading branch information
refcell authored Sep 4, 2024
2 parents f31070b + 508bedd commit 2384dbd
Show file tree
Hide file tree
Showing 17 changed files with 1,547 additions and 1,312 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/no_std.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: no_std

on:
push:
branches: [main]
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
check-no-std:
name: check no_std ${{ matrix.features }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
crate: ["superchain", "superchain-primitives", "superchain-registry"]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: riscv32imac-unknown-none-elf
- run: cargo check --target riscv32imac-unknown-none-elf --no-default-features -p ${{ matrix.crate }}
63 changes: 10 additions & 53 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,19 @@ superchain-registry = { path = "crates/registry", version = "0.3.3", default-fea
superchain-primitives = { path = "crates/primitives", version = "0.3.3", default-features = false }

# Alloy
alloy-sol-types = { version = "0.8.0", default-features = false }
alloy-primitives = { version = "0.8.0", default-features = false }
alloy-sol-types = { version = "0.8", default-features = false }
alloy-primitives = { version = "0.8", default-features = false }
alloy-genesis = { version = "0.3", default-features = false }
alloy-consensus = { version = "0.3", default-features = false }
alloy-eips = { version = "0.3", default-features = false }

# Serialization
toml = { version = "0.8.14" }
basic-toml = "0.1.9"
serde_repr = "0.1"
serde = { version = "1.0.203", default-features = false, features = ["derive", "alloc"] }
serde_json = { version = "1.0.66", default-features = false, features = ["raw_value"] }

# Misc
lazy_static = "1.4.0"
lazy_static = { version = "1.4.0", features = ["spin_no_std"] }
hashbrown = { version = "0.14.3", features = ["serde"] }
anyhow = { version = "1.0.86", default-features = false }
1 change: 1 addition & 0 deletions crates/primitives/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use core::fmt::Display;
/// Block identifier.
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "PascalCase"))]
pub struct BlockID {
/// Block hash
pub hash: B256,
Expand Down
11 changes: 10 additions & 1 deletion crates/primitives/src/chain_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,39 @@ pub struct HardForkConfiguration {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ChainConfig {
/// Chain name (e.g. "Base")
#[cfg_attr(feature = "serde", serde(rename = "Name"))]
pub name: String,
/// Chain ID
#[cfg_attr(feature = "serde", serde(rename = "l2_chain_id"))]
pub chain_id: u64,
/// L1 chain ID
#[cfg_attr(feature = "serde", serde(skip))]
pub l1_chain_id: u64,
/// Chain public RPC endpoint
#[cfg_attr(feature = "serde", serde(rename = "PublicRPC"))]
pub public_rpc: String,
/// Chain sequencer RPC endpoint
#[cfg_attr(feature = "serde", serde(rename = "SequencerRPC"))]
pub sequencer_rpc: String,
/// Chain explorer HTTP endpoint
#[cfg_attr(feature = "serde", serde(rename = "Explorer"))]
pub explorer: String,
/// Level of integration with the superchain.
#[cfg_attr(feature = "serde", serde(rename = "SuperchainLevel"))]
pub superchain_level: SuperchainLevel,
/// Time of opt-in to the Superchain.
/// If superchain_time is set, hardforks times after superchain_time
/// will be inherited from the superchain-wide config.
#[cfg_attr(feature = "serde", serde(rename = "SuperchainTime"))]
pub superchain_time: Option<u64>,
/// Chain-specific batch inbox address
#[cfg_attr(feature = "serde", serde(rename = "batch_inbox_address"))]
pub batch_inbox_addr: Address,
/// Chain-specific genesis information
pub genesis: ChainGenesis,
/// Superchain is a simple string to identify the superchain.
/// This is implied by directory structure, and not encoded in the config file itself.
#[cfg_attr(feature = "serde", serde(skip))]
#[cfg_attr(feature = "serde", serde(rename = "Superchain"))]
pub superchain: String,
/// Chain is a simple string to identify the chain, within its superchain context.
/// This matches the resource filename, it is not encoded in the config file itself.
Expand All @@ -77,6 +85,7 @@ pub struct ChainConfig {
/// Optional AltDA feature
pub alt_da: Option<AltDAConfig>,
/// Addresses
#[cfg_attr(feature = "serde", serde(rename = "Addresses"))]
pub addresses: Option<AddressList>,
}

Expand Down
3 changes: 3 additions & 0 deletions crates/primitives/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ use alloy_primitives::Bytes;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ChainGenesis {
/// L1 genesis block
#[cfg_attr(feature = "serde", serde(rename = "L1"))]
pub l1: BlockID,
/// L2 genesis block
#[cfg_attr(feature = "serde", serde(rename = "L2"))]
pub l2: BlockID,
/// Timestamp of the L2 genesis block
pub l2_time: u64,
/// Extra data for the genesis block
#[cfg_attr(feature = "serde", serde(rename = "ExtraData"))]
pub extra_data: Option<Bytes>,
/// Optional System configuration
pub system_config: Option<SystemConfig>,
Expand Down
7 changes: 7 additions & 0 deletions crates/primitives/src/superchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ pub struct Superchain {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SuperchainConfig {
/// Superchain name (e.g. "Mainnet")
#[cfg_attr(feature = "serde", serde(rename = "Name"))]
pub name: String,
/// Superchain L1 anchor information
#[cfg_attr(feature = "serde", serde(rename = "L1"))]
pub l1: SuperchainL1Info,
/// Optional addresses for the superchain-wide default protocol versions contract.
#[cfg_attr(feature = "serde", serde(rename = "ProtocolVersionsAddr"))]
pub protocol_versions_addr: Option<Address>,
/// Optional address for the superchain-wide default superchain config contract.
#[cfg_attr(feature = "serde", serde(rename = "SuperchainConfigAddr"))]
pub superchain_config_addr: Option<Address>,
/// Hardfork Configuration. These values may be overridden by individual chains.
#[cfg_attr(feature = "serde", serde(flatten))]
Expand All @@ -40,10 +44,13 @@ pub struct SuperchainConfig {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SuperchainL1Info {
/// L1 chain ID
#[cfg_attr(feature = "serde", serde(rename = "ChainID"))]
pub chain_id: u64,
/// L1 chain public RPC endpoint
#[cfg_attr(feature = "serde", serde(rename = "PublicRPC"))]
pub public_rpc: String,
/// L1 chain explorer RPC endpoint
#[cfg_attr(feature = "serde", serde(rename = "Explorer"))]
pub explorer: String,
}

Expand Down
1 change: 1 addition & 0 deletions crates/primitives/src/system_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub const CONFIG_UPDATE_EVENT_VERSION_0: B256 = B256::ZERO;
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct SystemConfig {
/// Batcher address
#[cfg_attr(feature = "serde", serde(rename = "batcherAddr"))]
pub batcher_address: Address,
/// Fee overhead value
pub overhead: U256,
Expand Down
6 changes: 3 additions & 3 deletions crates/registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ lazy_static.workspace = true
hashbrown.workspace = true

# Workspace Dependencies
superchain-primitives = { workspace = true, features = ["serde"] }
superchain-primitives = { workspace = true, default-features = false, features = ["serde"] }

# Serialization
serde.workspace = true
toml.workspace = true
serde_json.workspace = true

[dev-dependencies]
alloy-primitives.workspace = true

[features]
default = ["std"]
std = ["superchain-primitives/std"]
std = ["superchain-primitives/std", "serde_json/std"]
Loading

0 comments on commit 2384dbd

Please sign in to comment.