Skip to Content
Whitepaper v18.3 · Chapter 02 / 17

Network Topology & Dual-Ledger Architecture

← All chapters·Normative EN specification

The four structural problems identified in §1.2, and the architectural decisions required to resolve them simultaneously, demand a network topology that can optimize for contradictory objectives without compromise. This section specifies how the Bond/Aevum dual-ledger topology resolves this constraint through functional segregation (see §1.4 for comparative positioning against existing protocols).

2.1. Functional Segregation: Resolving the Blockchain Trilemma

The classical Blockchain Trilemma posits that a single-layer network can optimize for at most two of three properties: decentralization, security, and scalability. The Bond/Aevum architecture rejects the premise of solving this trilemma within a single chain. Instead, it implements Strict Functional Segregation — splitting the network state into two purpose-built topologies, each optimized for orthogonal objectives:

Property Bond RSC Aevum ESC
Primary Objective Decentralization + Security Scalability + Throughput
Sacrificed Property Scalability (deliberately constrained) Maximal decentralization (validator set is economically gated by D_score — permissionless but capital-intensive)
Consensus Proof of Work (thermodynamic) Proof of Dedication (meritocratic)
Block Time 20 minutes 5 seconds
Block Size 2 MB Dynamic (gas limit)
Throughput ~0.3 TPS peak (~0.1–0.2 TPS typical utilization) ~103–205 TPS (mixed workload, 50%–100% utilization); up to ~388 TPS (simple transfers). See §2.4.1
State Model pUTXO (Programmable UTXO) Account-based (Smart Contract Wallets)
Cryptographic Standard ML-DSA-65 (NIST Level 3) ML-DSA-44 (NIST Level 2)
Primary Use Sovereign settlement, cold storage, FCRC custody Commerce, micropayments, dApps, governance

2.1.1. Epoch Disambiguation

Both networks use "epoch" for a ~7-day recalculation period measured in different block-height units:

Chain Epoch Definition Block Count Duration
Bond RSC 1 Bond epoch 504 Bond blocks 504 × 20 min = ~7 days
Aevum ESC 1 Aevum epoch 120,960 Aevum blocks 120,960 × 5 sec = ~7 days

Scope by epoch type:

  • Bond epochs govern: monetary policy (emission rate), PoW difficulty adjustment, oracle rotation.
  • Aevum epochs govern: AEV emission recalculation, validator D_score measurement, governance proposal windows.
  • Cross-chain sections (e.g., bridge operations) always qualify which chain's epoch applies. Unqualified "epoch" in single-chain sections is resolved by chain context.

2.2. Bond Protocol (RSC) — Sovereign Settlement Layer

The Bond RSC is conceived as a thermodynamic fortress — a network that prioritizes absolute security and maximal decentralization at the deliberate expense of transaction throughput.

2.2.1. Network Parameters

The parameters below are jointly governed by a single invariant: a Bond full node must remain operable on consumer-grade hardware indefinitely. Block time (20 min) allows global low-bandwidth propagation; block size (2 MB) caps annual state growth at ~52.6 GB/year — roughly 9–10 years of history per $20 ~500 GB HDD. Cryptographic choices (SHA3-256, ML-DSA-65) satisfy NIST FIPS 202/204 and carry zero ECC exposure.

Parameter Value
Block Time 20 minutes
Block Size 2 MB
Throughput ~0.1–0.2 TPS
Annual State Growth ~52.6 GB/year (2 MB×26,298 blocks/year, §4.3.2)
Hash Function SHA3-256 (FIPS 202)
Signature Scheme ML-DSA-65 (FIPS 204) — NIST Level 3
State Model Programmable UTXO (pUTXO)

2.2.2. Negative Scalability (State Containment)

The Bond RSC implements Negative Scalability — a deliberate architectural decision to constrain throughput in order to preserve full-node accessibility and decentralization (cf. Gervais et al., 2016; Bitcoin Core blocksize debate, 2015–2017). The design is governed by a hardware-accessibility invariant: a Bond full node must be operable on consumer-grade hardware indefinitely.

At 2 MB blocks every 20 minutes, the concrete resource envelope is:

Resource Requirement Hardware Baseline
Storage ~52.6 GB/year (2 MB×26,298 blocks/year, §4.3.2) $20 ~500 GB HDD stores roughly 9–10 years of history
Bandwidth ~13 KB/s provisioning envelope; ~6–8 KB/s steady-state (§14.8.1) Feasible on residential internet globally
CPU Lightweight (SHA3-256 verify + ML-DSA-65 validate at 0.1–0.2 TPS) Raspberry Pi 4 or equivalent

These parameters are not compromises — they are the direct consequence of treating full-node decentralization as a non-negotiable constraint rather than a tunable trade-off. See §14 for the complete P2P network specification and bandwidth envelope derivation.

2.2.3. Fee Market (Free Lane)

The Bond RSC Free Lane uses a first-price sealed-bid auction — the simplest fee model, chosen for predictability on a low-throughput chain. Fees are denominated in Nob (1 BND = 1,000 Nob, as defined in Section 4.1.1).

Parameter Value Rationale
Fee Denomination Nob (1 BND = 1,000 Nob; 1 Nob ≈ $0.01 at LRP, §4.6.1) Nob is the atomic unit of the Bond RSC (§4.1.1)
Auction Type First-price per-transaction (highest total fee wins inclusion) Simple total-fee auction, not per-byte. At 0.1-0.2 TPS, congestion is rare; when present, priority is clear
Minimum Fee 1 Nob per transaction (~$0.01 at LRP) Anti-spam floor. A settlement transaction costs ~$0.01 at LRP — negligible for high-value Bond RSC use cases, sufficient to prevent zero-cost spam
Fee Recipient 100% to miner of the block No fee split, no burn. Consistent with BND's role as miner-incentivized PoW chain
Systemic Expressway Zero fee (protocol-funded from block reward) Systemic transactions (veto, HTLC resolution, FCRC) pay no Free Lane fee; the Expressway quota gives them priority (§2.3.3), but their inclusion is a local relay and block-construction policy, not a validity condition — a block is never invalidated for what it omits (§2.3.4)

Fee Sizing. At the 1 Nob minimum, a Bond RSC transaction costs ~$0.01 at LRP (§4.6.1). During congestion, users bid higher — a 10 Nob fee (~$0.10 at LRP) provides strong priority in a chain with ~363 transactions per block. For context, Bond RSC is designed for sovereign settlement (large-value transfers, FCRC custody, vesting releases), not micropayments — $0.01–$1.00 fees at LRP are negligible relative to the transaction values Bond is optimized for.

Congestion Dynamics. At 2 MB blocks every 20 minutes with typical transaction sizes of ~5.5 KB (dominated by the ML-DSA-65 signature of 3.3 KB + public key of 1.95 KB transmitted in the Witness field — the wire format was planned for the Engineering Blueprint §1.2.2, which is not part of this repository and carries no normative authority), each block accommodates ~363 transactions. At 0.1-0.2 TPS average (~120-240 transactions per 20-minute window), blocks are typically 33-66% full. Fee competition is moderate in steady state. During congestion spikes (e.g., Quantum Canary event, FCRC mobilization driving on-chain activity), the first-price auction naturally prioritizes high-value settlement transactions over low-priority data anchoring.

No EIP-1559 on Bond. Unlike the Aevum ESC, Bond does not implement base fee adjustment or fee burn. The simplicity of a first-price auction is appropriate for a chain processing ~363 transactions per block. EIP-1559's benefits (fee predictability, spam resistance) are unnecessary at Bond's throughput level.

2.3. Block Partitioning & Quality of Service (QoS)

2.3.1. Dual-Lane Architecture

Each 2 MB Bond block is architecturally partitioned into two lanes:

Lane Capacity Allocation Access Mechanism
Free Lane 1.7 MB (85%) Open market — transactions compete via fee auction (highest bidder) Any valid transaction
Systemic Expressway 300 KB (15%) Reserved exclusively for protocol-critical state transitions Restricted to validated systemic transaction types

2.3.2. Systemic Expressway: Transaction Types and Prioritization

The Expressway admits only transactions with validated cryptographic structure matching protocol-defined systemic functions:

Tier Transaction Type Priority Rationale
0 (Maximum) OP_VETO (FCRC challenge) Highest Defense of the systemic vault — must never be delayed
1 Veto of Social Recovery High Owner defending against unauthorized guardian recovery attempt
2 HTLC Resolution (claim/refund) Medium-High Atomic swap finality — timeout expiry creates irreversible fund loss
3 FCRC Activation (withdrawal) Medium Systemic vault mobilization
4 Other systemic functions Standard Protocol maintenance, Canary refresh, sig_version activation

2.3.3. Internal Prioritization: Subdivision with Spillover + Deadline Tiebreaker

When multiple systemic transactions compete for the 300 KB Expressway capacity, the protocol applies a three-layer prioritization mechanism:

Layer 1 — Sub-Quota Allocation. The 300 KB Expressway is internally subdivided:

Sub-Quota Capacity Reserved For
Vetos (FCRC + Social) 120 KB (40%) Tier 0 + Tier 1 transactions
HTLC Resolutions 100 KB (33%) Tier 2 transactions
Other Systemic 80 KB (27%) Tier 3 + Tier 4 transactions

Layer 2 — Spillover. If a sub-quota is not fully utilized in a block, the unused capacity spills over proportionally to the other sub-quotas. This prevents waste — if no vetos are pending, the 120 KB veto quota is redistributed to HTLC resolutions and other systemic functions. If no systemic transactions of any type are pending, the entire 300 KB Expressway capacity overflows to the Free Lane — miners may fill it with fee-paying transactions. The Expressway reservation is a priority guarantee, not a capacity reservation: systemic transactions always displace Free Lane transactions when present, but unused Expressway space is never wasted.

Layer 3 — Deadline Tiebreaker. Within each sub-quota (or spillover allocation), transactions are ordered by urgency — the transaction with the nearest deadline (timelock expiry, veto window closing) is included first. An HTLC claim expiring in 2 blocks takes priority over one expiring in 200 blocks.

2.3.4. Consensus Rejection Rule

Block validity is a deterministic function of the block alone — its header and committed transaction set — and must never depend on any node's local mempool, which is a per-node, non-consensus view. Accordingly, the Expressway consensus rule enforces only predicates decidable from the block's own transaction set: (i) every transaction a block places in the Expressway lane must carry a valid systemic transaction type (§2.3.2), verifiable from the transaction's own cryptographic structure; (ii) the Expressway sub-quotas and the intra-lane ordering of §2.3.3 (spillover, deadline tiebreaker) must be respected by the transactions the block actually contains, using each transaction's committed timelock/deadline fields; and (iii) a block that relegates a systemic transaction it contains to the Free Lane while Expressway capacity for that transaction's tier remains available is invalid — a determination made entirely from in-block data. A miner cannot reorder or mis-lane the systemic transactions present in its own block without producing an invalid block rejected by all honest nodes.

Enforcing inclusion of systemic transactions that are absent from a block — for example, punishing a miner for leaving Expressway capacity idle while a transaction sits in some node's mempool — is not a consensus criterion: no node can prove from the block itself which transactions were pending, so making validity depend on it would let nodes with differing mempool views disagree on the same block and split the chain. Mempool-derived prioritization is therefore a local relay and block-construction policy only: honest nodes preferentially relay and template systemic transactions into the Expressway, but a block is never invalidated for what it omits. Censorship resistance is preserved through the ordinary liveness argument — a censored transaction is included by the next honest miner — while block validity remains strictly decidable from committed data.

2.4. Aevum Protocol (ESC) — Transactional Execution Layer

The Aevum ESC operates as the high-throughput asynchronous engine for commerce, micropayments, dApp execution, and governance:

Parameter Value
Block Time 5 seconds
Blocks Per Year ~6,311,520
Consensus Proof of Dedication (PoD) — meritocratic weighted validator selection
State Model Account-based (native Account Abstraction, all accounts are Smart Contract Wallets — hereafter SCW)
Signature Scheme ML-DSA-44 (NIST Level 2) — optimized for high-frequency transactional signing
Smart Contract Execution WASM sandbox (Rust-compiled contracts, deterministic execution)
Gas Token AEV (subdivided into Vea: 1 AEV = 1,000 Vea)
Gas Mechanism Adapted EIP-1559 Dual-Fee (base fee recycled + priority fee to validator) with on-chain oracle
Account Model Zero EOAs — all accounts are Smart Contract Wallets with Paymaster support
Block Gas Limit 200,000,000 gas (200M). EIP-1559 target utilization: 50% (100,000,000 gas = 100M target per block)
Maximum Block Size MAX ~12 MB (gas-bounded ceiling at 200M gas) / TYPICAL ~4 MB (at 50% target); dominated by ML-DSA-44 signatures at ~2.4 KB each. Recommended; pending ADR-0005 ratification (R4)

[v18.2 INC-16] Wire format delegation. The binary format of the Aevum block header was planned for the Engineering Blueprint (§1.3.1), which is not part of this repository and carries no normative authority (§1.6); the in-tree byte layout of the header is not pinned by this chapter and remains pending maintainer decision. The fields emission_rate and supply_snapshot are implementation additions that enable light-client verification of monetary policy without full state replay. These fields do not alter the design semantics described in this section — they are deterministically computed state projections included in the header for verification convenience.

2.4.1. Throughput Derivation

The effective throughput of the Aevum ESC is a function of the block gas limit (200M gas), the block time (5 seconds), and the gas cost per UserOperation (UserOp) class. Unlike byte-limited blockchains, Aevum uses a gas-metered model where different operation types consume different gas budgets.

Gas Schedule — Key Operations:

Operation Gas Cost Rationale
ML-DSA-44 signature verification (precompile) 50,000 gas Protocol-level precompile — not interpreted in WASM. Fixed cost, constant-time execution. Dominates per-UserOp cost due to ~2.4 KB signature
SHA3-256 hash (32 bytes input) 30 gas + 6 gas/word Base cost per §2.4.4.4 Group G (authoritative); consistent with FIPS 202 sponge construction
Storage read (cold) 2,100 gas First access to a storage slot in a transaction (EVM SLOAD cold)
Storage read (warm) 100 gas Subsequent access to already-loaded slot
Storage write (new slot) 20,000 gas Creates a new storage slot
Storage write (cold update) 5,000 gas Overwrites an existing slot (cold access)
Storage write (warm) 100 gas Slot already in the warm-set
AEV transfer (base) 21,000 gas Intrinsic cost of a value transfer between accounts
EntryPoint overhead (per UserOp) 30,000 gas AA-singleton EntryPoint: bundle routing, nonce management, Paymaster dispatch
WASM instruction execution 1 gas/instruction High-level approximation; per-opcode costs in §2.4.4.3

These summary figures are illustrative. The authoritative per-opcode and host-function costs are the §2.4.4.3 (opcode) and §2.4.4.4 (host API) tables, which prevail on any discrepancy — specifically: SHA3-256 base = 30 gas + 6/word; storage write = 20,000 (new) / 5,000 (cold update) / 100 (warm); warm storage read = 100 gas. The derived per-UserOp totals below inherit these values.

Derived Gas Costs per UserOperation Class:

UserOp Class Components Total Gas Derivation
Simple P2P transfer EntryPoint (30K) + ML-DSA-44 verify (50K) + nonce check (2.1K) + transfer (21K) ~103,000 gas Minimum viable UserOp
POS payment (spendAllowance via PartFund) EntryPoint (30K) + ML-DSA-44 verify (50K) + SAT validation (50K sig verify + 5K field checks) + nonce (2.1K) + allowance check (4.2K reads) + whitelist lookup (2.1K) + transfer (21K) + Paymaster validateOp (30K) + Paymaster postOp (20K) ~215,000 gas Standard commercial transaction
POS + Geofence (Off-Chain Optimistic) POS payment (215K) + geofence commitment hash (20K) ~235,000 gas Geofence proof verified off-chain by Paymaster; on-chain stores SHA3-256 commitment only. Fraud-proof dispute window: 120 blocks (~10 min)
AMM swap (wBND↔AEV) EntryPoint (30K) + ML-DSA-44 verify (50K) + AMM routing (100K compute + 60K storage) ~240,000 gas Multi-pool routing with price impact calculation
Batch operation (5 transfers) EntryPoint (30K) + ML-DSA-44 verify (50K) + 5× transfer (105K) + nonce (2.1K) ~187,000 gas Amortizes signature cost across multiple operations

Throughput per UserOp Class (Block Gas Limit: 200M, Block Time: 5s):

UserOp Class Gas/UserOp TPS @ 50% Target TPS @ 100% Fill Note
Simple P2P transfer ~103K ~194 TPS ~388 TPS Theoretical maximum for homogeneous simple blocks
POS payment ~215K ~93 TPS ~186 TPS Primary commercial workload
POS + Geofence ~235K ~85 TPS ~170 TPS Geofence-verified workload (off-chain optimistic)
AMM swap ~240K ~83 TPS ~167 TPS DeFi workload
Mixed realistic (60% POS, 20% P2P, 10% AMM, 10% complex) ~195K avg ~103 TPS ~205 TPS Weighted average of production workload. Complex includes geofence-verified (235K) and batch operations (187K)

Utilization Semantics. The EIP-1559 mechanism targets 50% block gas utilization under normal conditions. The "TPS @ 50% Target" column represents sustained throughput when the base fee mechanism is in equilibrium — this is the operational throughput implementers should use for capacity planning. The "TPS @ 100% Fill" column represents the burst ceiling achievable during temporary demand spikes (when base fee escalation temporarily permits full blocks). Both figures are correct under their respective utilization assumptions. Gas cost estimates per UserOp class should be reconciled with the opcode-level gas table (§2.4.4.3) post-testnet benchmarking; until then, both are valid within their stated assumptions.

The derivation above confirms the throughput claims in Section 2.1. Batch operations (amortizing one signature across 5 transfers at 187K gas each) fit ~1,070 batch UserOps in a full 200M-gas block (200M ÷ 187K), yielding ~5,350 effective value transfers per full block (~2,675 at the 50% EIP-1559 target). This is a ~2.7× amortization gain over the simple-transfer ceiling of ~1,940 non-batched P2P transfers per full block (200M ÷ 103K), which is the count for un-amortized transfers, not batch. The realistic mixed workload of ~103 TPS (sustained) to ~205 TPS (burst) exceeds Visa's average per-country throughput (~28 TPS for 60 active countries) while remaining conservative relative to Visa's peak capacity.

Signature Overhead Analysis. ML-DSA-44 signatures (~2.4 KB) are approximately 37× larger than ECDSA signatures (~65 bytes). This is the primary throughput cost of post-quantum security. The 200M block gas limit is calibrated to absorb this overhead while maintaining commercially viable TPS. If future post-quantum signature schemes achieve smaller signatures (e.g., NIST Round 4 candidates), the TPS ceiling increases proportionally without protocol changes — only the precompile gas cost requires recalibration via governance.

Terminology Note: Execution Sovereign Chain (ESC). Aevum is designated as an Execution Sovereign Chain (ESC) — a sovereign execution chain economically anchored to Bond RSC via staking and treasury mechanics. It maintains its own validator set and security guarantees — Bond does not validate Aevum state transitions. This designation replaces the conventional "Layer 2" label to avoid semantic collision with rollup-based L2 architectures (Optimistic, ZK) where the L2 inherits security from RSC via fraud proofs or validity proofs. Aevum does not inherit security from Bond RSC.

Security Model Boundaries:

Property Conventional Rollup L2 Aevum (ESC)
State validation Proofs verified on RSC Own validator set (sovereign PoD consensus)
Reversion via RSC Yes (fraud/validity proof) No — Bond RSC cannot revert Aevum state
Data availability Posted to RSC Own (Aevum validators maintain independent DA)
RSC coupling Security inheritance Economic (BND staking, treasury, wBND bridge mint)
Validator compromise impact Reverted by RSC proofs Not reverted — users bear PoD validator set risk

Users should calibrate trust assumptions accordingly: funds on the Aevum ESC are secured by the PoD validator set alone, not by Bond's PoW thermodynamic security. A compromise of Aevum's PoD consensus cannot be reversed by the Bond RSC.

2.4.2. Gas-to-Vea Pricing Derivation

The gas price (denominated in Vea per gas unit) is determined by the EIP-1559 mechanism. The hardcoded floor establishes the minimum:

gas_price_floor = 1 Vea / 103,000 gas ≈ 9.7×10⁻⁶ Vea/gas (see Appendix 02 for the canonical typeset form)

This calibration ensures that the simplest possible UserOperation (a P2P transfer at ~103K gas) costs exactly 1 Vea at the floor price. The gas costs per operation class at different congestion levels:

UserOp Class Gas At Floor (1× base) Moderate Congestion (5× base) High Congestion (20× base)
Simple P2P ~103K 1 Vea ($0.0001) 5 Vea ($0.0005) 20 Vea ($0.002)
POS payment ~215K ~2 Vea ($0.0002) ~10 Vea ($0.001) ~42 Vea ($0.004)
POS + Geofence ~235K ~2 Vea ($0.0002) ~11 Vea ($0.001) ~46 Vea ($0.005)
AMM swap ~240K ~2 Vea ($0.0002) ~12 Vea ($0.001) ~47 Vea ($0.005)

The Paymaster gas estimation range of 1-100 Vea thus corresponds to: simple transfers at floor price (1 Vea) through complex geofence-verified payments under moderate congestion (~11 Vea), with headroom to 100 Vea for extreme congestion or unusually complex operations. Even at the range ceiling, 100 Vea = $0.01 — two orders of magnitude below a contactless card tap fee.

2.4.3. Smart Contract Execution Environment (WASM VM)

The Aevum ESC executes smart contracts in a sandboxed WebAssembly (WASM) virtual machine. This section specifies the execution model, constraints, and developer interface.

Supported Target. Contracts are authored in Rust (stable toolchain) and compiled to wasm32-unknown-unknown via the Aevum SDK (aevum-sdk). The SDK provides procedural macros for contract entry-point function declaration (the __aevum_call export — distinct from the AA singleton EntryPoint), storage access, cross-contract calls, and ABI generation. No other source languages are supported at mainnet launch; future language support (AssemblyScript, C/C++ via Emscripten) is deferred to post-launch governance proposals.

ABI & Serialization. Contract interfaces are defined via Rust trait declarations annotated with #[aevum::interface]. The SDK generates a CBOR-encoded ABI descriptor published alongside the contract bytecode. All cross-contract calls and external invocations use CBOR serialization for arguments and return values — chosen over Ethereum's ABI encoding for compactness (critical given ML-DSA-44 signature overhead) and self-describing schema.

Storage Model. Each contract maintains an isolated key-value store (256-bit keys, arbitrary-length values) backed by a Merkle Patricia Trie rooted in the account's storage_root. Storage operations are gas-metered, calibrated to EVM equivalents (EIP-2929): reads at 2,100 gas (EVM SLOAD cold; warm access = 100 gas), writes at 20,000 gas for new slots and 5,000 for updates (EVM SSTORE), and deletes produce a 5,000 gas refund to incentivize state cleanup.

Operation Gas Cost
storage_read(key) 2,100 gas
storage_write(key, value) 20,000 gas (new slot) / 5,000 gas (update)
storage_delete(key) 5,000 gas refund

WASM Instruction Metering. All WASM MVP instructions are supported at 1 gas per instruction. Floating-point operations are disabled (non-deterministic across architectures); SIMD extensions are disabled at launch (cross-platform determinism not yet validated); memory.grow costs 10,000 gas base + 1,000 gas per page allocated (see §2.4.4.3 for formal gas table).

Instruction Class Gas Cost
memory.grow 10,000 base + 1,000 per page (see §2.4.4.3)
Floating-point Disabled
SIMD extensions Disabled at launch

Maximum contract memory: 4 MB (64 pages). Maximum contract bytecode size: 512 KB. Maximum cross-contract call depth: 64 frames (host call/call_static chain, including the initial UserOp frame). The WASM-internal function-call-stack depth is a separate, much larger bound (§2.4.4.5) — it is not the 64-frame cap.

Precompiles. The following operations are implemented as host functions, bypassing WASM interpretation for performance:

Precompile Gas Cost Function
ml_dsa44_verify(pk, msg, sig) 50,000 gas ML-DSA-44 signature verification
sha3_256(data) 30 gas + 6 gas/word SHA3-256 hash computation
ema_compute(values, alpha) 10,000 gas On-chain EMA calculation (used by fee oracles, volume tracking)

Composability & Reentrancy. Cross-contract calls use a synchronous call(address, method, args, gas_limit) host function. The execution model follows Checks-Effects-Interactions by convention, enforced by the SDK's #[aevum::nonreentrant] guard macro which sets a per-contract reentrancy flag in transient storage (cleared at transaction end). The VM does not enforce reentrancy protection at the protocol level — contracts that omit the guard are vulnerable, consistent with the sovereignty principle (Axiom 1: developers are responsible for their contract logic). No delegatecall equivalent exists — all calls execute in the callee's context with the callee's storage, eliminating proxy-pattern vulnerabilities.

Determinism. The WASM runtime uses a single-pass AOT compiler (Wasmer Singlepass backend). For a given target architecture, Singlepass is a deterministic function of the input bytecode — every node on the same ISA (e.g. all x86_64 nodes) emits byte-identical native code — but different ISAs (x86_64 vs aarch64) necessarily emit different machine code. Consensus determinism therefore does not rely on cross-architecture native-code identity; it is guaranteed by the architecture-independent gas schedule (§2.4.4.3) and by state_root agreement (§2.4.4.7), both computed from values rather than native instructions. Floating-point is disabled. memory.grow is deterministic (always succeeds up to the 4 MB cap, always fails above). Block timestamps are consensus values, not system clock. Random number generation is not available as a WASM instruction — contracts requiring randomness must consume the block's VRF output (exposed as a host function block_vrf_output()) or use commit-reveal schemes.

Developer Toolchain (Launch-Critical Coordination Dependency). The developer experience is reclassified from an adoption dependency to a launch-critical dependency — platform adoption is a coordination game with multiple equilibria, and the SDK is the commitment device that pushes toward the positive equilibrium. This roadmap appears here (within the WASM VM specification) because SDK delivery is a consensus-layer constraint: mainnet cannot launch without a minimum SDK maturity that guarantees independently deployable dApps. The SDK roadmap and Anchor dApp program are specified here and nowhere else in the corpus — the tables below are the primary statement, not a reproduction of a fuller one. (Earlier drafts cited Appendix 08 (Genesis Bootstrap Protocol) as their authority; that appendix's section map §1–§12 contains no SDK or Anchor material, so the citation is withdrawn rather than repointed.) The schedule below is backward-derived from the January 2028 mainnet target and is the critical-path reference for WASM VM implementors.

Month Deliverable Exit Criteria
10 MV-SDK — contract templates, local testnet CLI, 2 end-to-end tutorials (payment contract, basic token) External developer can deploy and test a contract locally within 1 hour
13 SDK v0.5 — Paymaster integration guide, migration guides (Solidity→Rust), block explorer with contract verification 3 Anchor dApp teams building on testnet (see below)
16 SDK v1.0 — testing framework, audit templates, gas profiling tools, performance benchmarks All 3+ Anchor dApps operational on testnet
18 Mainnet — SDK v1.0 with 2-3 months of testnet usage Launch gate: minimum 3 independently-built dApps operational on testnet

Anchor dApp Program. To bootstrap the ecosystem coordination game, the protocol funds 3-5 reference dApps built internally (from the Ecosystem Reserve allocation):

Anchor dApp Function SDK Coverage
Payment Gateway Merchant POS integration, Paymaster interaction Core SDK + Paymaster
Basic DEX/AMM wBND↔AEV pool, swap interface DeFi primitives, AMM patterns
Identity/Auth Social recovery guardian management, key rotation SCW extension patterns

Anchor dApps serve as SDK beta testers (months 13-17), initial Paymaster merchants (providing real transaction volume at mainnet), and reference implementations for third-party developers. The mainnet launch gate — minimum 3 independently-built dApps on testnet — ensures the ecosystem exists at launch, not in theory.

Topology defined — consensus next. Section 2 specified what each network layer must achieve: Bond RSC optimizes for decentralization and security at the cost of throughput; Aevum ESC optimizes for scalability at the cost of maximal decentralization. Section 3 specifies how each layer enforces those properties at the consensus level — the PoW and PoD mechanisms that make the topology's security guarantees physically and economically binding.



§2.4.4 — WASM VM Formal Specification

Expanded specification (planned, not in this repository). A fuller treatment (deploy-time pipeline, per-opcode gas table with 80+ instructions, host API, state model) was planned for an expanded companion (03-expanded-sections-v18_3.md, §2.4.4); the in-repo per-opcode reference is §2.4.4.3 of this chapter. That companion is not part of this repository and carries no normative authority; this chapter is the authoritative in-repo specification.

Relation to §2.4.3. Section §2.4.3 describes the high-level execution model in prose: supported language, ABI, storage model, determinism. This section (§2.4.4) is the formal specification for implementors — the precise contract between the protocol and the WASM runtime. All references to "§2.4.4.3" throughout the document (including §2.4.1) point to the per-opcode gas table in this section. In case of conflict between §2.4.3 and §2.4.4, §2.4.4 prevails.


§2.4.4.1 — Module Format and Deploy-Time Validation

Set of Permitted WASM Proposals

The Aevum ESC supports exactly the WASM MVP (1.0) set as specified by the W3C WebAssembly Core Specification 1.0. All post-MVP proposals are explicitly disabled at genesis:

WASM Proposal Status Rationale
WASM MVP (1.0) ✅ Enabled Baseline — determinism verified on x86_64 and aarch64
Bulk Memory Operations ❌ Disabled memory.copy and memory.fill have non-uniform cost semantics; deferred until gas calibration
Reference Types ❌ Disabled funcref/externref expand attack surface without benefit to financial contracts
Multi-Value ❌ Disabled Adds validation complexity without precedent in Rust financial contracts
Non-Trapping Float-to-Int ❌ Disabled Floating-point entirely disabled (§2.4.3)
Sign-Extension Ops ✅ Enabled i32.extend8_s etc. — uniform cost, necessary for idiomatic Rust → WASM
SIMD ❌ Disabled Non-deterministic behavior across microarchitectures (Intel vs ARM Neon vs AMD)
Threads/Atomics ❌ Disabled Execution model is single-threaded by determinism invariant
Tail Call ❌ Disabled Gas semantics for TCO unresolved
Exception Handling ❌ Disabled Traps are the only error mechanism — structured exceptions add ambiguous execution paths
GC Proposal ❌ Disabled Non-deterministic garbage collection
Component Model ❌ Disabled Not supported by Wasmer Singlepass

Modules referencing opcodes from disabled proposals are rejected at deploy-time with ValidationError::DisabledProposal. This is verified statically before AOT compilation.

Permitted Sections Structure

A WASM module valid for the Aevum ESC MUST satisfy the following constraints on its binary sections:

WASM Section Permitted Constraints
Type ✅ Maximum 256 function types
Import ✅ Only from the "env" namespace — imports from other modules are rejected
Function ✅ Maximum 1,024 internal functions
Table ✅ Maximum 1 table of type funcref; maximum 1,024 entries
Memory ✅ Exactly 1 linear memory; minimum 1 page, maximum 64 pages (4 MB)
Global ✅ Maximum 64 globals; mutable and immutable globals are permitted
Export ✅ MUST export "__aevum_call" (see §2.4.4.5); other exports are optional
Start ❌ start section prohibited — constructors execute via __aevum_call during the deploy pipeline (§2.4.4.6)
Element ✅ Table initializers with function indices only; maximum 1,024 elements
Code ✅ Function bodies; maximum 512 KB total for all bodies
Data ✅ Memory initialization data; maximum 256 KB total
Custom ❌ All custom sections are stripped before on-chain storage

Maximum module size after custom section stripping: 512 KB.

Import Restrictions (Namespace "env")

The only permitted import namespace is "env". Any import from a different namespace causes immediate rejection. The complete list of symbols available in "env" is defined in §2.4.4.4 (Host API). Imports referencing symbols not listed in §2.4.4.4 cause ValidationError::UnknownImport.

Deploy-Time Validation Pipeline

Bytecode raw (512 KB max)
    │
    ▼
[1] Strip Custom Sections
    │  'name', debug info, and any custom sections stripped
    ▼
[2] Structural Validation (Wasmer wasm-validator)
    │  Binary format verification, index consistency,
    │  well-formed function types
    ▼
[3] Proposal Enforcement
    │  Scan all opcodes; reject if any opcode
    │  belongs to a disabled proposal
    ▼
[4] Import/Export Verification
    │  All imports in namespace "env" and present in §2.4.4.4
    │  Export "__aevum_call" with correct signature present
    ▼
[5] Resource Limit Checks
    │  #types ≤ 256, #functions ≤ 1024, memory ≤ 64 pages,
    │  bytecode total ≤ 512 KB, data ≤ 256 KB
    ▼
[6] Gas Instrumentation (Wasmer gas metering middleware)
    │  Injects gas decrements before each basic block
    │  (not before each instruction — performance optimization)
    ▼
[7] AOT Compilation (Wasmer Singlepass)
    │  Single-pass compilation to native code (x86_64/aarch64)
    │  Node-local cache-integrity tag: SHA3-256(emitted_native_code) → cache_tag
    │  (per-arch, node-local only — NOT a consensus value, never on-chain)
    ▼
[8] Artifact Storage
       Stripped bytecode + code_hash (SHA3-256 of the stripped bytecode)
         stored in the state trie (consensus data)
       Compiled native artifact + cache_tag cached node-locally only

The compiled artifact is cached in node state (not on-chain), identified by (contract_address, code_hash, target_arch). The cache_tag = SHA3-256(emitted_native_code) is a node-local, per-architecture integrity value, used only to detect corruption of the local artifact cache against a fresh recompilation on the same machine. It is never stored on-chain and is never a block-validity criterion. Two failure modes make an on-chain artifact hash unworkable and both are avoided here: a pure hash of (bytecode, target_arch) is independent of the compiler's output and so could never detect compiler non-determinism (vacuous), while a hash of the actual native code necessarily differs between x86_64 and aarch64 and so could not be reproduced by a heterogeneous-ISA validator set (spurious rejection). Genuine execution non-determinism is instead caught by the sole consensus check that already commits post-execution state: any divergence in runtime behavior alters the committed state_root (§2.4.4.7), and a block whose replayed state_root does not match its header is rejected by all honest nodes. Consensus never depends on cache_tag or native-code identity — only on state_root agreement.

Formal-review pending (ADR-0005 counter-sign).


§2.4.4.2 — Gas Instrumentation Model

Instrumentation Strategy: Basic-Block Injection

The "1 gas per instruction" instrumentation described in §2.4.3 is a high-level approximation. The implementation uses basic-block injection — the gas of a basic block (linear sequence without branches) is pre-computed and decremented once before the block starts. This eliminates per-instruction decrement overhead while maintaining semantic equivalence:

// Original WASM code:
local.get 0
local.get 1
i32.add
local.set 2

// After instrumentation (pseudocode):
__gas_decrement(4)   // 4 instructions in the basic block
local.get 0
local.get 1
i32.add
local.set 2

The per-instruction gas count within the block uses the §2.4.4.3 table. The block total is the sum of individual costs. Instrumentation is performed during step [6] of the deploy-time pipeline and is deterministic — given the same bytecode, all nodes produce the same decrement points and the same block totals.

Operand-dependent instructions break the basic block. The static block-sum is valid only for instructions whose cost is fixed at instrumentation time. memory.grow is the sole exception in the permitted MVP + Sign-Extension set: its cost is 10,000 + 1,000 × n, where n is a runtime operand on the stack (§2.4.4.3). It cannot be summed statically, so it is special-cased — it terminates the current basic block. The static base (10,000) is included in the preceding block's pre-sum; the runtime then emits a dynamic decrement of 1,000 × n immediately before the grow executes, reading n from the operand stack and checking OutOfGas against 1,000 × n first. Every other permitted opcode (Groups 1–5 of §2.4.4.3) has statically-known cost, so the block-sum invariant holds elsewhere; host-function (env) calls likewise charge their fixed per-call cost at the call site, outside the WASM block sum.

Available Gas Check

Before each basic-block decrement, the runtime checks:

if current_gas < block_gas_cost {
    return Err(ExecutionError::OutOfGas);
}
current_gas -= block_gas_cost;

An OutOfGas is treated as a trap — it reverts all state changes from the current frame and consumes all gas allotted to the current call frame (the gas_limit forwarded to it by its caller), not merely the failing block's gas. The caller retains its own remaining gas and observes an error return from call() (§2.4.4.5), so it can continue executing; only when the trap occurs in the top-level UserOperation frame is all remaining transaction gas consumed. Gas consumed up to the trap is non-refundable.

Gas determinism invariant: The gas consumed by an execution is completely deterministic given (calldata, state_root, block_context). Two independent executions with the same inputs consume exactly the same gas.


§2.4.4.3 — Per-Instruction Gas Table (Opcode-Level Gas Table)

This is the table referenced in §2.4.1 ("reconciled with the opcode-level gas table (§2.4.4.3) post-testnet benchmarking"). The values below are the genesis specifications. Post-testnet adjustments are published as errata before mainnet and incorporated into the final table.

Group 1 — Control Flow

Instruction Gas Notes
unreachable 1 Produces immediate trap; gas charged before the trap
nop 1 No-op; gas charged
block 1 Start of structured block; only bookkeeping cost
loop 1 Start of structured loop
if 2 Conditional branch — light prediction overhead
else 1 Else arm of if
end 1 End of block/loop/function
br 2 Unconditional branch
br_if 3 Conditional branch — condition evaluation
br_table 3 + N Branch table with N entries; N = number of targets in the vector
return 2 Function return
call 100 Internal function call (see §2.4.4.5 for complete semantics)
call_indirect 300 Indirect call via table — runtime type verification + lookup

Note on call and call_indirect. These are WASM-internal function calls, not cross-contract calls. The base cost of 100/300 gas covers only the call overhead (save/restore frame, bounds-check against the internal function-call-stack limit). The internal stack limit is the WASM-internal bound of §2.4.4.5 (not the 64-frame cross-contract cap of §2.4.4.4 Group E). The gas of the called function body is charged separately during execution of that frame. The total cost of a call is 100 + gas(body).

Group 2 — Variables and Memory

Instruction Gas Notes
local.get 1 Read of local variable
local.set 1 Write to local variable
local.tee 1 Set + push (syntactic sugar; 1 real instruction)
global.get 2 Read of global — mutability verification
global.set 2 Write to global
i32.load 2 Load of 4 bytes from linear memory
i64.load 2 Load of 8 bytes
i32.load8_s / i32.load8_u 2 Load of 1 byte with sign/zero extension
i32.load16_s / i32.load16_u 2 Load of 2 bytes
i64.load8_s / i64.load8_u 2 Load i64 of 1 byte
i64.load16_s / i64.load16_u 2 Load i64 of 2 bytes
i64.load32_s / i64.load32_u 2 Load i64 of 4 bytes
i32.store 3 Store of 4 bytes — write is more expensive than read
i64.store 3 Store of 8 bytes
i32.store8 3 Store of 1 byte
i32.store16 3 Store of 2 bytes
i64.store8 3 Store i64 of 1 byte
i64.store16 3 Store i64 of 2 bytes
i64.store32 3 Store i64 of 4 bytes
memory.size 2 Query current memory size in pages
memory.grow 10,000 Allocation of new page(s) — base cost 10,000 gas + 1,000 gas per page allocated (see formula in §2.4.4.3)

Consistent with §2.4.3. §2.4.3 already gives the memory.grow cost as 10,000 gas base + 1,000 gas per page allocated; this section restates it formally as the per-page metering rule:

gas(memory.grow(n))=10,000+1,000×n

where n is the number of pages being allocated. The 10,000 base is charged statically (§2.4.3, Instrumentation Strategy), so memory.grow(0) costs 10,000 gas; a size query uses memory.size (2 gas).

Group 3 — Constants and Comparisons

Instruction Gas Notes
i32.const 1 Push i32 constant
i64.const 1 Push i64 constant
drop 1 Discard top of stack
select 2 Conditional select without predicate branch overhead
i32.eqz 1 Compare to zero
i32.eq, i32.ne 1 Equality comparison
i32.lt_s, i32.lt_u, i32.gt_s, i32.gt_u 1 Ordered comparison
i32.le_s, i32.le_u, i32.ge_s, i32.ge_u 1 Ordered comparison ≤/≥
i64.eqz, i64.eq, i64.ne 1 i64 comparison
i64.lt_s, i64.lt_u, i64.gt_s, i64.gt_u 1 Ordered i64 comparison
i64.le_s, i64.le_u, i64.ge_s, i64.ge_u 1 Ordered i64 comparison ≤/≥

Group 4 — Integer Arithmetic

Instruction Gas Notes
i32.add, i32.sub 1 Additive operations — 1-cycle latency
i32.mul 1 Integer multiplication — 3-cycle hardware latency but uniform cost for simplicity
i32.div_s, i32.div_u 5 Division — expensive hardware instruction (20-40 cycle latency)
i32.rem_s, i32.rem_u 5 Remainder — same latency as division
i32.and, i32.or, i32.xor 1 Bitwise operations
i32.shl, i32.shr_s, i32.shr_u 1 Shifts
i32.rotl, i32.rotr 1 Rotations
i32.clz, i32.ctz, i32.popcnt 2 Count leading/trailing zeros, population count — can be one instruction or several depending on the ISA
i64.add, i64.sub 1 i64 arithmetic
i64.mul 1 i64 multiplication
i64.div_s, i64.div_u 7 i64 division — 64-bit div is more expensive than 32-bit
i64.rem_s, i64.rem_u 7 i64 remainder
i64.and, i64.or, i64.xor 1 Bitwise i64
i64.shl, i64.shr_s, i64.shr_u 1 Shifts i64
i64.rotl, i64.rotr 1 i64 rotations
i64.clz, i64.ctz, i64.popcnt 2 Count bits i64

Group 5 — Conversions (Float Explicitly Prohibited)

Instruction Gas Status
i32.wrap_i64 1 i64→i32 truncation
i64.extend_i32_s, i64.extend_i32_u 1 i32→i64 extension
i32.extend8_s, i32.extend16_s 1 Sign-extension (enabled via Sign-Extension Ops)
i64.extend8_s, i64.extend16_s, i64.extend32_s 1 Sign-extension i64
f32.*, f64.* ❌ Disabled — immediate trap ValidationError::FloatInstruction
i32.trunc_f32_s etc. ❌ Disabled — float→int conversion
f32.convert_i32_s etc. ❌ Disabled — int→float conversion

Important: Floating-point instructions are rejected at deploy-time during module validation. They never reach execution. Modules containing any f32.* or f64.* instruction are rejected with ValidationError::FloatInstruction.


§2.4.4.4 — Interface Host API (Namespace "env")

The WASM contract accesses protocol state exclusively through functions in the "env" module. These are host functions implemented in Rust in the node runtime — they are not interpreted in WASM, and their gas cost is charged as a fixed cost at call time.

Signature conventions. Pointers are i32 (address in WASM linear memory). Lengths are i32. Hashes are 32 bytes. Aevum addresses are 20 bytes. Error returns: i32 with value -1 on failure (error propagated via OutOfGas or ExecutionError where applicable).

Group A — Block and Transaction Context

Import "env" WASM Signature Gas Semantics
get_block_number () → i64 100 Current block number (Aevum ESC)
get_block_timestamp () → i64 100 Unix block timestamp (seconds); consensus value, not local clock
get_block_gas_limit () → i64 50 Current block gas limit
get_gas_remaining () → i64 10 Gas available before this call; useful for internal estimates
get_caller (ptr: i32) → void 100 Writes 20 bytes: address of the direct caller (SCW that called this contract, or EntryPoint)
get_origin (ptr: i32) → void 100 Writes 20 bytes: address of the SCW that initiated the UserOperation (the UserOp sender)
get_self (ptr: i32) → void 100 Writes 20 bytes: address of this contract
get_value (out_ptr: i32) → void 50 Writes 32 bytes (u256 big-endian): AEV (in Vea) transferred to this contract in this call; zeros if none
block_vrf_output (ptr: i32) → void 200 Writes 32 bytes: current block VRF output for contracts requiring pseudorandomness; not a secure randomness source — use commit-reveal for high-value cases

Group B — Balance and Transfer

Import "env" WASM Signature Gas Semantics
get_balance_self (out_ptr: i32) → void 200 Writes 32 bytes (u256 big-endian): AEV balance of this contract in Vea. Note: u256 in WASM is passed via buffer pointer — the SDK wrapper provides a native U256 type.
get_balance (addr_ptr: i32, out_ptr: i32) → void 2,100 Writes 32 bytes (u256 big-endian) at out_ptr: AEV balance of the specified address (20 bytes at addr_ptr); cold access 2,100 gas, warm 100 gas — tracking via the transaction warm-set
transfer_aev (to_ptr: i32, amount_ptr: i32) → i32 21,000 Transfers value (u256, 32 bytes at amount_ptr) in Vea to the address (20 bytes at to_ptr); returns 0 (success) or -1 (insufficient balance); balance is atomically reduced before any code at the destination executes
get_code_size (addr_ptr: i32) → i32 700 Size of the contract bytecode at addr_ptr; 0 if the account has no code (e.g. an SCW with code_hash = [0;32])
get_code_hash (addr_ptr: i32, out_ptr: i32) → void 700 SHA3-256 of the contract bytecode at addr_ptr; writes 32 bytes at out_ptr

Warm-set tracking. The warm address set is initialized at the start of each UserOperation with: (a) the sender address, (b) the EntryPoint address, (c) the address of the contract called directly by the UserOperation. Each get_balance or any access to a new address adds it to the warm-set. The warm-set is local to the UserOperation — it does not persist between UserOps in the same block.

Group C — Persistent Storage

Import "env" WASM Signature Gas (cold) Gas (warm) Semantics
storage_read (key_ptr: i32, val_ptr: i32) → i32 2,100 100 Reads 32-byte slot identified by 32 bytes at key_ptr; writes value to val_ptr; returns 1 if slot exists, 0 if not (val_ptr filled with zeros)
storage_write (key_ptr: i32, val_ptr: i32) → void 20,000 (new) / 5,000 (update) 100 Writes 32 bytes from val_ptr to slot key_ptr; creates a new slot (20,000 gas) or updates existing (5,000 gas)
storage_delete (key_ptr: i32) → void 5,000 refund — Removes slot; adds 5,000 gas to the UserOperation refund pool (whole pool capped at 20% of total consumed gas — integer gas_used / 5, per EIP-3529; see §2.4.4.5)
storage_has_key (key_ptr: i32) → i32 2,100 100 Returns 1 if slot exists, 0 if not; does not load value

Storage warm-set. Analogous to the address warm-set, storage slots accessed in a UserOperation are added to the storage warm-set. Subsequent accesses to the same (contract, key) within the same UserOperation cost the warm value (100 gas), not cold.

Group D — Transient Storage (Cleared per UserOperation)

Transient storage exists only during UserOperation execution. It is automatically zeroed at the end of the UserOperation (success or revert). Used primarily for reentrancy flags and temporary caches.

Import "env" WASM Signature Gas Semantics
tstore (key_ptr: i32, val_ptr: i32) → void 100 Writes 32 bytes to transient storage; does not persist beyond the UserOperation
tload (key_ptr: i32, val_ptr: i32) → void 100 Reads 32 bytes from transient storage; zeros if not set

Group E — Inter-Contract Calls

Import "env" WASM Signature Gas Base Semantics
call (addr_ptr: i32, method_ptr: i32, method_len: i32, args_ptr: i32, args_len: i32, gas_limit: i64, value_ptr: i32) → i32 700 + callee gas Contract call with state modification; callee receives gas_limit gas from caller; value_ptr points to 32-byte u256 big-endian AEV amount to transfer
call_static (addr_ptr: i32, method_ptr: i32, method_len: i32, args_ptr: i32, args_len: i32, gas_limit: i64) → i32 700 + callee gas Read-only call; callee cannot execute storage_write, transfer_aev, or emit_event; write attempts cause a trap in the callee and revert of the static call
call_return_size () → i32 10 Size in bytes of the last call result (for sizing the read buffer)
call_return_read (offset: i32, buf_ptr: i32, len: i32) → void 3 × len/32 Copies len bytes from the last call result starting at offset to buf_ptr

Call revert semantics. If call() returns an error code, all callee state changes are atomically reverted. The caller state is not affected by the callee revert (unlike Ethereum, where the caller must explicitly check the return). Gas consumed by the callee before the revert is not refunded to the caller — consumed gas = spent gas.

Cross-contract call depth limit: 64 frames. The host call / call_static chain (contract → contract) is capped at 64 frames, including the initial UserOperation frame; a host call attempted at depth 64 traps with CallDepthExceeded. This bound governs only cross-contract host calls. It is independent of the WASM-internal function-call-stack depth — the ordinary in-module function nesting that a compiled Rust contract produces (CBOR deserialization, serde, iterator/collection chains) routinely exceeds 64 nested frames, so applying the 64-frame cap to internal calls would trap idiomatic contracts. The internal call stack is instead governed by the runtime's native call-stack region (a fixed native stack, default 1 MiB — sized so idiomatic Rust→WASM nesting cannot overflow it) together with gas metering; exhausting it traps with StackExhausted, a distinct trap from CallDepthExceeded. The StackExhausted bound MUST be enforced deterministically and identically across all node architectures (x86_64, aarch64) — a native-stack-size guard alone is architecture-sensitive, so the normative bound is defined in terms of a metered WASM-internal frame counter, not raw native stack bytes; the 1 MiB figure is an implementation sizing target, not the consensus bound.

Formal-review pending (ADR-0005 counter-sign).

No delegatecall. Per §2.4.3, there is no delegatecall or equivalent. All code executes in the storage context of its own contract.

Group F — Events (Logs)

Import "env" WASM Signature Gas Semantics
emit_event (topics_ptr: i32, topics_count: i32, data_ptr: i32, data_len: i32) → void 375 + 375 × topics_count + 8 × data_len Emits event with up to 4 topics (each topic = 32 bytes) and arbitrary data; indexable by block explorers and off-chain listeners; not accessible by on-chain contracts

The cost is calibrated to match the Ethereum LOG opcode (375 + 375/topic + 8/byte of data), maintaining predictability for developers familiar with EVM.

Group G — Cryptographic Precompiles

Import "env" WASM Signature Gas Semantics
ml_dsa44_verify (pk_ptr: i32, pk_len: i32, msg_ptr: i32, msg_len: i32, sig_ptr: i32, sig_len: i32) → i32 50,000 Verifies ML-DSA-44 signature; returns 1 (valid) or 0 (invalid); constant-time execution — reveals no information about the key pair
sha3_256 (data_ptr: i32, data_len: i32, out_ptr: i32) → void 30 + 6 × ⌈data_len / 32⌉ Computes SHA3-256 (FIPS 202); writes 32 bytes at out_ptr
ema_compute (values_ptr: i32, count: i32, alpha_numerator: i32, alpha_denominator: i32, out_ptr: i32) → void 10,000 Computes EMA over count i64 values at values_ptr with α = alpha_numerator/alpha_denominator; writes i64 result at out_ptr; used by price oracles and volume tracking
verify_stark_geofence (proof_ptr: i32, proof_len: i32, commitment_ptr: i32) → i32 2,500,000 Verifies STARK geofence proof (§8.4); returns 1 (valid) or 0 (invalid); activated as precompile when post-quantum ZK proofs reach maturity (genesis: not available, verification is off-chain optimistic per §8.4)
verify_stark_shield (proof_ptr: i32, proof_len: i32, pub_inputs_ptr: i32) → i32 2,500,000 Verifies Shielded Pool STARK proof (§15.6); activated in Phase 4 together with the Shielded Pool

Note: verify_stark_geofence and verify_stark_shield are pre-declared but return ExecutionError::PrecompileNotActive until their respective governance phases activate. Contracts can reference these imports from genesis without deploy-time errors — failure occurs only at execution, allowing contracts with conditional verification to be deployed in advance.


§2.4.4.5 — Execution Semantics

Mandatory Contract Entry-Point Function: __aevum_call

Every contract MUST export the __aevum_call function with the following WASM signature:

;; Mandatory signature
(export "__aevum_call" (func $dispatch))

;; Function signature
(func $dispatch
    (param $calldata_ptr i32)
    (param $calldata_len i32)
    (result i32)  ;; 0 = success, >0 = error code
)

The runtime deserializes the calldata field of the UserOperation and passes it as (calldata_ptr, calldata_len) in the module's linear memory (copied into the first calldata_len bytes of linear memory before execution). The contract is responsible for deserializing the calldata using its CBOR ABI (§2.4.3).

Return result. The contract returns an i32 value:

  • 0 — success; state changes are persisted
  • 1..=127 — revert with specific error code; state changes are reverted
  • 128..=255 — reserved for system error codes
  • 256..=i32::MAX — any positive code above the reserved system range is treated as a generic revert; state changes are reverted
  • < 0 — treated as generic revert

Return data (results of read functions, etc.) are returned via emit_event or via call_return_* when called by another contract. There is no "returndata" mechanism directly in __aevum_call — the design favors explicit events over implicit return data.

Execution Lifecycle of a UserOperation

UserOperation arrives at the EntryPoint
    │
    ▼
[1] Phase 1 — Verification (gas budget: verificationGasLimit)
    │   EntryPoint calls wallet.__aevum_call(validateUserOp calldata)
    │   Wallet verifies ML-DSA-44 sig, nonce, gas params
    │   If Paymaster: EntryPoint calls paymaster.__aevum_call(validatePaymaster calldata)
    │   Validation failure → UserOp rejected (no state change; bundler gas is charged)
    ▼
[2] Phase 2 — Execution (gas budget: callGasLimit)
    │   EntryPoint calls wallet.__aevum_call(executeUserOp calldata)
    │   Wallet executes the requested operation(s)
    │   Any revert in Phase 2 → reverts wallet and callee state
    │   EntryPoint persists even after wallet revert (to charge gas)
    ▼
[3] Paymaster postOp (if Paymaster present)
    │   EntryPoint calls paymaster.__aevum_call(postOp calldata)
    │   Paymaster accounts for spent gas, updates rate limits
    ▼
[4] Gas Accounting
        gas_used = (verificationGasLimit - gas_remaining_after_v1)
                 + (callGasLimit - gas_remaining_after_v2)
                 + preVerificationGas
        gas_refund = min(gas_used / 5, gas_from_storage_deletes)  // 20% of CONSUMED gas (EIP-3529)
        gas_charged = gas_used - gas_refund
        // Gas charged is debited from sender or paymaster

Integer-only accounting. All protocol gas accounting is exact integer arithmetic — there are no floating-point literals anywhere in consensus-critical computation. The refund ceiling is gas_used / 5 (integer division, i.e. 20% of the gas actually consumed), matching EIP-3529's consumed-gas basis. Basing the cap on consumed gas — rather than on gas_remaining — closes the refund-farming vector in which a caller over-provisions the gas limit to inflate a remaining-gas ceiling: over-provisioning raises no refund because unspent gas is never consumed.

Warm-set between phases. The address and storage slot warm-set is shared between Phase 1 and Phase 2 within the same UserOperation — slots accessed in validateUserOp are already warm in executeUserOp.

Trap Handling

A trap is an unrecoverable execution state. Causes: unreachable, OutOfGas, CallDepthExceeded (cross-contract host-call chain > 64 frames), StackExhausted (WASM-internal function-call stack overflow), division by zero (i32.div / i64.div with divisor = 0), out-of-bounds memory access, memory.grow beyond 64 pages.

All traps have identical semantics:

  1. Complete revert of all state changes in the current frame and in all descendant callees
  2. Gas consumed up to the trap is irrecoverable — there is no refund for gas from operations that produced the trap
  3. Surfaced to the caller as an error return (no automatic unwinding) — if the trap occurred in a callee, call() returns an error code to the caller; the caller retains its own remaining gas and continues executing. The trap consumes only the gas allotted to the trapping frame (the callee's forwarded gas_limit), not the caller's balance.

A callee trap does not automatically unwind the caller — the caller MUST check the return value of call() and decide whether to revert. (This is consistent with the scoped OutOfGas semantics of §2.4.4.2: only a trap in the top-level UserOperation frame consumes all remaining transaction gas.)

State Isolation Invariant

Each contract call (__aevum_call) executes in an isolated execution frame:

Frame {
    memory: LinearMemory(max 4 MB, initialized to zeros per call),
    operand_stack: OperandStack,   // WASM value stack for THIS frame (holds i32/i64 values, not call frames)
    gas_counter: u64,
    warm_set_addrs: HashSet<Address>,
    warm_set_storage: HashSet<(Address, [u8;32])>,
    revert_journal: Vec<StateChange>,  // for atomic rollback
}

The operand_stack field is the per-frame WASM value stack; it holds computation values, not call frames. Two distinct depth limits apply and must not be conflated: the cross-contract call-frame chain (host call/call_static) is capped at 64 frames (§2.4.4.4 Group E), while the WASM-internal function-call stack within a single frame is governed by the native stack-size guard and gas metering (§2.4.4.3 Group 1 note on call), trapping with StackExhausted.

Linear memory is zeroed at the start of each __aevum_call — it does not persist between calls. Only contract storage (accessed via storage_*) and AEV balances (via transfer_aev) persist between calls. This eliminates the entire class of "dirty memory" bugs where data from a prior execution leaks into the next.


§2.4.4.6 — Contract Deployment

DeployUserOperation

Contract deployment is performed via a DeployUserOperation — a specialized UserOperation with the calldata field containing the WASM bytecode instead of a function call. The sender field is the deployer SCW (which pays the gas).

DeployUserOperation {
    sender: Address,          // SCW that pays the deploy gas
    salt: [u8; 32],           // Salt for deterministic address derivation
    init_code: Vec<u8>,       // WASM bytecode (max 512 KB after strip)
    constructor_args: Vec<u8>, // CBOR calldata for the constructor (may be empty)
    nonce: u64,               // Wire: u64; widened to u256 in the state trie (planned Engineering Blueprint §1.3.2, not in this repository; non-normative)
    callGasLimit: u64,        // Wire: u64 (gas limits ≤ block_gas_limit = 200M << u64.MAX)
    // ... other standard UserOperation fields
}

Deterministic Address Derivation (CREATE2 Equivalent)

The deployed contract address is deterministic and computable before the deploy:

contract_address=SHA3-256("aevum_deploy"∥sender∥salt∥SHA3-256(init_code))[0:20]

The "aevum_deploy" prefix provides domain separation — this address cannot be confused with a user address (which is SHA3-256(ml_dsa44_pubkey)[0:20]). The derivation uses the hash of init_code, not the init_code itself — therefore the address is stable even if init_code is provided in chunks or via IPFS-like reference.

Correction pending (ADR-0005 counter-sign) — OQ-24. The domain-separation claim above does not hold for the layout this section pins. "aevum_deploy" is concatenated unframed — no length prefix, no delimiter — so the 96-byte preimage the contract derivation hashes is itself a valid argument to the user derivation, and user_address("aevum_deploy" ∥ sender ∥ salt ∥ SHA3-256(init_code)) reproduces the contract address byte for byte at zero cost. Recorded as H-01 in docs/audits/workspace-scan-1.md and escalated as ADR-0029 (Proposed, counter-sign required, unsigned); the collision is pinned by the passing regression test user_address_reproduces_a_contract_address_from_the_full_preimage in crates/crypto/address-derive. Which of ADR-0029's options A/B/C closes it is not decided here.

Address collision. If a contract already exists at the derived address, the deploy fails with DeployError::AddressCollision. The deployer MUST use a different salt.

Deploy Pipeline

[1] DeployUserOperation Validation
    │   Same verification pipeline as a normal UserOperation
    │   validateUserOp on the sender SCW
    ▼
[2] WASM module validation (full pipeline from §2.4.4.1)
    │   Failure → DeployError::ModuleValidationFailed (bundle gas consumed)
    ▼
[3] Gas accounting for deploy
    │   deploy_gas = 200 (flat base) + 200 × len(init_code) [code-deposit] + 200 × num_pages_initial
    │   Insufficient gas → OutOfGas (contract is not created)
    ▼
[4] Account creation in state trie
    │   New account at contract_address with:
    │     balance = value (if any AEV was sent in the deploy)
    │     code_hash = SHA3-256(stripped_init_code)
    │     storage_root = empty_trie_root
    │     nonce = 0
    │     code_size = len(stripped_init_code)   // [v18.3 NEW-09] INC-03 field
    ▼
[5] AOT Compilation and caching (§2.4.4.1, steps 6-8)
    ▼
[6] Constructor Execution
    │   If constructor_args is not empty:
    │     Instantiates the module with gas_limit = callGasLimit - deploy_gas_used
    │     Calls __aevum_call(constructor_args_ptr, constructor_args_len)
    │     The constructor can write to storage, transfer initial AEV,
    │     register extensions, etc.
    │   Constructor revert → contract is NOT created; state is reverted
    ▼
[7] Finalization
        contract_address emitted as DeploySuccess event
        ABI descriptor (if present as constructor event) indexed

Deploy gas. The code-deposit term 200 × len(init_code) charges 200 gas per byte of bytecode stored permanently on-chain — matching Ethereum's Gcodedeposit (200 gas per byte of deployed code; this rate derives from the original Ethereum protocol, not EIP-2929). At this rate a maximal 512 KB contract costs ~105M gas to deploy (≈ half a 200M-gas block), a deliberate deterrent against cheap permanent on-chain state bloat. The flat base of 200 gas — distinct from the per-byte code-deposit term — covers fixed deploy bookkeeping; smaller contracts are proportionally cheaper.


§2.4.4.7 — Contract State Model in the State Trie

Account State

Each account on the Aevum ESC (both SCWs and contracts) has the following state in the Merkle Patricia Trie (MPT):

AccountState {
    nonce: u256,          // Anti-replay; incremented by EntryPoint after each UserOp
    balance: u256,        // AEV balance in Vea
    storage_root: [u8;32], // Root of this contract's storage sub-trie
    code_hash: [u8;32],   // SHA3-256 of stripped WASM bytecode; [0;32] for SCWs without additional code
    code_size: u32,       // Bytecode size in bytes
}

State Trie Root in the Block Header

The state_root in the Aevum block header is the MPT root containing all AccountStates after execution of all UserOperations in the block. Hierarchical structure:

Block Header {
    ...
    state_root: SHA3-256(MPT({
        address → AccountState {
            nonce,
            balance,
            storage_root: SHA3-256(sub-MPT({key → value})),
            code_hash,
            code_size
        }
    }))
}

Commitment property. The state_root fully commits the post-block state — any change to any storage slot of any contract alters the state_root. This guarantees that all validators attesting a block agree on the complete state, not just the transaction list.

MPT with SHA3-256

The Aevum ESC uses a Modified Merkle Patricia Trie with SHA3-256 as the internal hash function. Trie nodes are identified by SHA3-256(node_rlp_encoding). The choice of SHA3-256 (instead of Keccak-256 as in Ethereum) ensures Axiom 2 compliance and uniformity with the rest of the cryptographic stack — auditors do not need to track two distinct hash functions.

Difference from Ethereum. Ethereum uses Keccak-256 for its trie (not SHA3-256 — both are Keccak but with different padding: 0x06 for SHA3, 0x01 for Keccak). Tools that assume bit-level compatibility with Ethereum state proofs are not compatible with the Aevum state trie without adaptation.


§2.4.4.8 — Reference Table for Implementers

Dimension Specification Notes
Runtime Wasmer Singlepass (AOT) wasmer crate ≥ 4.0; Singlepass backend only; Cranelift and LLVM disabled
Supported targets x86_64, aarch64 Determinism verified; other targets (riscv64, wasm32) require additional validation
WASM Set MVP 1.0 + Sign-Extension No other proposal at genesis
Float Completely disabled Validation reject at deploy-time
SIMD Disabled
Threads Disabled
Max memory 4 MB (64 pages) memory.grow above 64 pages: trap
Max bytecode 512 KB (stripped) Measured after custom section stripping
Max cross-contract call depth 64 frames Host call/call_static chain; includes the initial UserOp frame
WASM-internal call-stack depth native stack guard + gas Separate, much larger bound; overflow traps StackExhausted (§2.4.4.5)
Max functions 1,024 per module
Max types 256 per module
Max globals 64 per module
Import namespace Only "env"
Required export "__aevum_call" Signature: (i32, i32) → i32
start section Prohibited Use constructor via __aevum_call
Custom section Stripped at deploy Not stored on-chain
Gas: uniform per-instruction ❌ Non-uniform See §2.4.4.3 table
Gas: i32 division 5 i32.div_s / i32.div_u
Gas: i64 division 7 i64.div_s / i64.div_u
Gas: memory.grow(n) 10,000 + 1,000n Consistent with §2.4.3 (base + per-page); dynamically metered on operand n
Gas: call (internal) 100 base + callee gas
Gas: call_indirect 300 base + callee gas
Gas: storage cold 2,100 read / 20,000 write
Gas: storage warm 100 read / 100 write Set via warm-set tracking
Gas: transfer_aev 21,000
Gas: ml_dsa44_verify 50,000 Precompile
Gas: sha3_256 30 + 6/word Precompile
Gas: emit_event 375 + 375/topic + 8/byte
Revert: gas consumed Unrecoverable Trap gas is not refunded
Revert: storage Atomic rollback Revert journal per frame
Linear memory Zeroed per call Does not persist between calls to the same contract
State trie hash SHA3-256 Not Keccak-256 — incompatible with Ethereum proofs
Contract address SHA3-256("aevum_deploy" ‖ sender ‖ salt ‖ SHA3-256(code))[0:20] Deterministic pre-deploy

§2.4.4 cross-references:

  • §2.4.1 promises: "reconciled with the opcode-level gas table (§2.4.4.3) post-testnet benchmarking" → table delivered in §2.4.4.3
  • §2.4.3 gives: "memory.grow costs 10,000 gas base + 1,000 gas per page" → restated verbatim in §2.4.4.3 (10,000 + 1,000n); the two are consistent (no correction implied)
  • §2.4.3 describes: "1 gas per instruction" (uniform) → refined in §2.4.4.3 (differentiated per instruction)
  • §2.4.3 mentions: "synchronous call(address, method, args, gas_limit) host function" → formally specified as call in §2.4.4.4 Group E
  • §8.4 mentions: VERIFY_STARK_GEOFENCE precompile → declared in §2.4.4.4 Group G
  • §15.6.2 mentions: VERIFY_STARK_SHIELD precompile at 0x20 → declared in §2.4.4.4 Group G
  • §3.2.4.1 mentions: "state root hash (Merkle root of Aevum state trie)" → formal structure defined in §2.4.4.7