Skip to content

chain-v1.0.0 — Stateless Execution (Hyperpaper Full Compliance)

Choose a tag to compare

@twobitapps twobitapps released this 25 Mar 13:35
· 31 commits to main since this release

Release v0.3.0 — Stateless Execution (Hyperpaper Full Compliance)

Changelog

Critical Bug Fixes

  • FFI return code (compositor_verify): Rust FFI returns 1=valid, 0=invalid, -1=error. Previous code checked result != 0 which rejected all valid Groth16 proofs. Fixed to proper 3-way switch.
  • Double gas deduction in nanochain EVM: executeAccountTx deducted gas before calling ApplyMessage, which also deducts gas internally. Sender was charged 2x. Fixed by letting ApplyMessage handle all gas accounting.

Phase 1 — Wire Existing Components

  • 1.1 BeaconProofVerifier wired into FinalizeBeaconBlock (fail-closed proof verification)
  • 1.2 DAPBeaconIntegration wired from consensus into beacon chain (DA-enforced finalization)
  • 1.3 Fullnode block execution on syncexecuteBlockTransactions after InsertBlock builds state trie for RPC queries (eth_getBalance, eth_call, eth_getTransactionReceipt)
  • 1.4 State root verification — computed root compared against header root

Phase 2 — Stateless Execution (Core Innovation)

  • 2.1 Per-tx Verkle witness fields on ProofCarryingTx (TxStateWitness, StateDiff)
  • 2.2 Stateless fast pathverifyAndApplyStateDiff skips EVM when witness is valid
  • 2.3 Block-level StateWitness generation — proposer generates Verkle multiproof after execution
  • 2.4 Non-proposer O(1) validationValidateBlockStateless verifies aggregated proof + witness

Phase 3 — Full O(1) Verification

  • 3.1 Beacon O(1) finalization — single Groth16 CompositionProof pairing check per beacon block
  • 3.2 Fullnode O(1) sync path — witness-based verification replaces full EVM re-execution
  • 3.3 Light client P2P messagesGetStateWitness, GetShardProof, GetCompositionProof with real data handlers

Nanochain Engine Architecture

  • NanochainEngine interface bridges ParallelBlockProducersharding.Nanochain
  • Full pipeline: EVM execution → proof verification → SnarkPack aggregation → witness generation → DA certification → beacon submission
  • Real sharding.Nanochain instances created from server.go with chainConfig, VerkleDB, ProofFabric
  • EnableNanochains=true for ALL memory tiers (was >= 16 CPU cores only)
  • EnableDA=true in DefaultConfig (was false)

Full EVM in Nanochains

  • executeAccountTxEVM uses gethcore.ApplyMessage for contract creation and calls
  • Init code properly executed to produce runtime bytecode (was storing init code directly)
  • Gas accounting, EIP-2929 access lists, snapshot/revert

Patricia-to-Verkle Migration

  • SupportsMigration() returns true (Verkle-native import path)
  • MigrateAccount() accepts MigrationAccount (nonce/balance/code/storage) and inserts into Verkle tree

Compositor Structural Fallback

  • compositor_nocgo.go now performs SHA-256 binary Merkle tree composition and structural verification (was returning ErrCompositorNotReady)
  • IsReady() returns true — graceful degradation without CGO

RPC API

  • hyperspace_sendProofCarryingTransaction — submit PCTs with proofs, witnesses, and state diffs
  • hyperspace_getStateWitness — query account state for Merkle witness construction

Dockerfile

  • Updated for CGO build: CGO_ENABLED=1, -tags compositor,jolt_prover
  • Rust .so libraries copied into runtime image
  • Enables real Groth16/Jolt proof generation and verification

E2E Integration Tests (5 tests, all passing)

  1. TestE2E_TransactionLifecycle — tx → pool → build → execute → witness
  2. TestE2E_ProofCarryingTransaction — PCT → proof verification → aggregation → receipts
  3. TestE2E_StatelessValidation — O(1) block validation via StatelessValidator
  4. TestE2E_NanochainEngineInterface — ProduceAndSubmitBlock, SubmitTransaction, QueueLength
  5. TestE2E_TxStateWitnessRLP — roundtrip encoding with witnesses and state diffs

Files Changed (22 files)

File Change
beacon/beacon_chain.go Wire proof verification + O(1) composition + light client proof serving
cmd/server.go Nanochain engine creation, chainConfig wiring, beacon provider
core/types/proof_carrying_tx.go TxStateWitness, StateDiff, RLP V2, Len()
consensus/narwhaltusk/nanochain_coordinator.go NanochainEngine interface, SubmitProofCarryingTx
consensus/narwhaltusk/types.go EnableDA=true, EnableNanochains=true all tiers
jsonrpc/hyperspace_endpoint.go PCT submission + state witness RPC endpoints
network/encoding.go Light client message encoding/decoding
network/protocol.go Light client P2P message types
network/sync.go Fullnode execution, light client handlers, BeaconBlockProvider
prooffabric/compositor_cgo.go Fix FFI return code, add mutex to verify
prooffabric/compositor_nocgo.go Structural fallback (SHA-256 Merkle tree)
sharding/nanochain.go Full EVM, stateless fast path, witness gen, NanochainEngine impl
sharding/stateless_validator.go O(1) ValidateBlockStateless, proof aggregator