Skip to content

all: restructure into more comprehensive archtechture#9

Merged
andrepatta merged 33 commits intomainfrom
source-restructure
Apr 14, 2026
Merged

all: restructure into more comprehensive archtechture#9
andrepatta merged 33 commits intomainfrom
source-restructure

Conversation

@andrepatta
Copy link
Copy Markdown
Member

@andrepatta andrepatta commented Apr 12, 2026

Summary

Restructure the Parallax client from go-ethereum's flat package layout into a layered architecture with strict dependency ordering. Rename the main binary from
prlx to parallax. Remove the non-functional light client. Bump version to 2.0.0. Move technical documentation in-repo under docs/.

Why

The codebase inherited go-ethereum's flat package layout — 35 top-level directories with no enforced layering. Any package could import any other, making it
difficult to reason about dependencies, extract components, or maintain clear boundaries between consensus, networking, and application logic.

This restructure models the architecture after Bitcoin Core's libbitcoin_kernel / libbitcoin_node / libbitcoin_wallet separation:

  • Embeddable consensus kernel: kernel/ can be imported independently without pulling in RPC, networking, or wallet code. This enables external tools to
    validate blocks without the full node stack.
  • Clear dependency ordering: each layer only imports from layers below it, enforced by Go's import rules.
  • Discoverability: directory names match Bitcoin Core conventions (validation/, script/, wallet/, primitives/), making the codebase navigable for
    developers familiar with either ecosystem.
  • Reduced coupling: interfaces (StateAccessor, ChainConfigurator, kernel.Engine) replace concrete types at layer boundaries, so internal changes don't
    cascade across the codebase.

What changed

Layered architecture introduced:

  • kernel/ — RPC-free consensus layer: Engine interface, StateAccessor interface, consensus engines (xhash, clique), chain parameters, fork/gas verification.
    Cannot import validation, rpc, p2p, node, or wallet.
  • validation/ — blockchain, state, tx pool (formerly core/, trie/)
  • script/ — PVM execution engine, ABI codec and contract bindings (formerly core/vm/, accounts/abi/)
  • primitives/ — fundamental types and serialization (rlp/, types/). Zero imports from kernel or above — fully Layer 0.
  • policy/ — fee estimation oracle
  • node/ — node lifecycle, full node (fullnode/), mining (miner/), shared config (nodeconfig/), filters, stats, console
  • p2p/ — P2P networking, wire protocol definitions (protocols/), network parameters (netparams/)
  • wallet/ — account management, keystore, hardware wallets, signer (formerly accounts/, signer/)
  • rpc/ — JSON-RPC server, GraphQL transport, typed RPC client
  • support/ — event system, metrics

Kernel layer fully isolated:

  • kernel/ defines StateAccessor interface instead of depending on *state.StateDB — consensus engines use the interface, callers pass the concrete state
  • Engine.FinalizeAndAssemble() takes a types.TrieHasher parameter instead of importing validation/trie internally
  • kernel/ root package has zero imports from validation, p2p, node, rpc, or wallet

Primitives layer decoupled from kernel:

  • primitives/types/ defines a ChainConfigurator interface for signer selection, replacing the direct dependency on *chainparams.ChainConfig
  • MakeSigner, LatestSigner, and Receipts.DeriveFields accept the interface — *ChainConfig satisfies it via 4 new getter methods
  • primitives/types/ now has zero imports from kernel/ — fully Layer 0

Consensus wrapper eliminated:

  • Deleted the consensus/ package entirely — it was a thin wrapper that added APIs() to kernel engines
  • RPC API registration now happens directly in the server layer via type-switch (node/fullnode/backend.go)
  • kernel/consensus/ and kernel/misc/ merged into kernel/ root package

Cross-dependencies resolved:

  • node/fullnode/protocols/p2p/protocols/ (wire protocol definitions belong with p2p)
  • node/fullnode/filters/node/filters/ (shared event filtering)
  • node/fullnode/gasprice/ → deleted (was forwarding shim, callers use policy/fees/ directly)
  • node/fullnode/prlconfig/node/nodeconfig/ (shared node config)

Light client removed:

  • Deleted node/light/ (109 Go files — LES client, server, downloaders, flow control, vflux)
  • Deleted validation/light/ (10 files — light chain, ODR, light tx pool). Moved nodeset.go (trie proof helper used by snap sync) to validation/trie/
  • Deleted tests/fuzzers/les/ and tests/fuzzers/vflux/ (LES fuzzers)
  • Removed all LES/LPS startup flags (--light.serve, --light.maxpeers, --ultralight.*, etc.)
  • Removed LightSync sync mode option and LightClientGPO config defaults
  • Cleaned all LES/LPS references from comments and documentation

Dead packages and files removed:

  • swarm/ (empty, just a README)
  • prlx/ (unused mobile bindings)
  • contracts/ (checkpointoracle was only used by LES)
  • cmd/checkpoint-admin/ (unused)
  • tests/testdata/, tests/evm-benchmarks/ (Ethereum test submodules — incompatible with Parallax block format)
  • Build files: nsis (Windows installer), maven/pod (mobile), travis, deb (Debian packaging)
  • CI configs: appveyor.yml, circle.yml (Parallax uses GitHub Actions)

Binary renamed:

  • cmd/prlx/cmd/parallax/ — main binary is now parallax instead of prlx
  • Updated Makefile targets, build scripts, IPC socket names, metrics prefixes, and all user-facing references

Version bumped to 2.0.0:

  • Major version bump signals breaking changes to all Go module import paths
  • RPC/wire protocol unchanged — nodes remain compatible

Other changes:

  • bootnodes.go and network_params.go moved from kernel/chainparams/ to p2p/netparams/
  • version.go moved from kernel/chainparams/ to the root parallax package
  • prlclient/prlxclient/ merged into rpc/client/ as extended.go
  • Documentation moved from separate parallax-docs repository into docs/
  • All documentation updated to reflect new directory structure, import paths, package names, and binary name
  • README overhauled — Bitcoin Core-style gateway document
  • Community standards added: CODE_OF_CONDUCT.md, SECURITY.md, .github/PULL_REQUEST_TEMPLATE.md
  • Contributing guide updated with architecture section and new package name conventions

Package names updated to match directories using gofmt -r for AST-aware rewriting (e.g., package commonpackage util, all common.Hashutil.Hash).

Complete directory rename map:

Before After
common/ util/
log/ logging/
prldb/ dbstore/
rlp/ primitives/rlp/
core/types/ primitives/types/
core/ validation/
core/vm/ script/
accounts/abi/ script/abi/
params/ kernel/chainparams/
event/ support/event/
metrics/ support/metrics/
accounts/ wallet/
signer/ wallet/signer/
p2p/ p2p/
miner/ node/miner/
prl/ node/fullnode/
prl/prlconfig/ node/nodeconfig/
prl/filters/ node/filters/
prl/protocols/ p2p/protocols/
prlstats/ node/stats/
console/ node/console/
graphql/ rpc/graphql/
prlclient/ rpc/client/
internal/prlapi/ internal/api/
trie/ validation/trie/
consensus/ (deleted, merged into kernel/)
les/ (deleted)
light/ (deleted)
swarm/ (deleted)
contracts/ (deleted)
cmd/prlx/ cmd/parallax/

Final directory structure

  parallax/
  ├── cmd/              — binaries (parallax, clef, pvm, abigen, etc.)
  ├── crypto/           — cryptographic primitives
  ├── dbstore/          — database abstraction (leveldb, memorydb)
  ├── docs/             — technical documentation (published to docs.parallaxprotocol.org)
  ├── internal/         — private utilities (api, debug, jsre, etc.)
  ├── kernel/           — RPC-free consensus layer
  │   ├── chainparams/  — chain configuration, denomination, genesis
  │   ├── clique/       — PoA consensus engine
  │   └── xhash/        — PoW consensus engine
  ├── logging/          — structured logging framework
  ├── node/             — node lifecycle and services
  │   ├── console/      — interactive JavaScript console
  │   ├── filters/      — shared event filtering
  │   ├── fullnode/     — full node protocol handler
  │   ├── miner/        — block mining
  │   ├── nodeconfig/   — shared node configuration
  │   └── stats/        — network statistics reporting
  ├── p2p/              — P2P networking
  │   ├── discover/     — node discovery
  │   ├── enode/        — enode URL handling
  │   ├── enr/          — Ethereum Node Records
  │   ├── netparams/    — bootnodes, network constants
  │   └── protocols/    — wire protocol definitions (prl, snap)
  ├── policy/           — transaction policy
  │   └── fees/         — fee estimation oracle
  ├── primitives/       — fundamental data types
  │   ├── rlp/          — RLP encoding/decoding
  │   └── types/        — block, transaction, receipt types
  ├── rpc/              — RPC layer
  │   ├── client/       — typed RPC client
  │   └── graphql/      — GraphQL transport
  ├── script/           — smart contract execution
  │   ├── abi/          — ABI codec and contract bindings
  │   └── runtime/      — PVM runtime
  ├── support/          — support utilities
  │   ├── event/        — event pub/sub system
  │   └── metrics/      — metrics collection
  ├── tests/            — test vectors and fuzzers
  ├── util/             — common types and utilities (Address, Hash, etc.)
  ├── validation/       — blockchain validation
  │   ├── asm/          — PVM assembly
  │   ├── bloombits/    — bloom indexing
  │   ├── forkid/       — fork identification
  │   ├── rawdb/        — raw database operations
  │   ├── state/        — state management (snapshots, pruning)
  │   └── trie/         — Merkle Patricia trie
  └── wallet/           — account management
      ├── external/     — external signer backend
      ├── keystore/     — encrypted key storage
      ├── scwallet/     — smart card wallets
      ├── signer/       — transaction signing rules
      └── usbwallet/    — USB hardware wallets (Ledger, Trezor)

Test plan

  • go build ./... passes
  • go vet ./... passes
  • golangci-lint run ./... passes (0 issues)
  • make all passes
  • make lint passes
  • go test ./kernel/... — all kernel tests pass
  • go test ./validation/... — all validation tests pass
  • go test ./primitives/... — all primitives tests pass
  • go test ./policy/... — fee oracle tests pass
  • go test ./script/... — PVM tests pass
  • Kernel layer fully isolated: kernel/ root has zero imports from validation, p2p, node, rpc, or wallet
  • Primitives layer fully isolated: primitives/types/ has zero imports from kernel/
  • No circular dependencies between node subpackages
  • Full node startup and block sync
  • eth_gasPrice and eth_estimateSmartFee RPCs work
  • Mining produces blocks

@andrepatta andrepatta changed the title all: source code restructure into more comprehensive directories all: source code restructure into more comprehensive archtechture Apr 13, 2026
@andrepatta andrepatta changed the title all: source code restructure into more comprehensive archtechture all: restructure into more comprehensive archtechture Apr 13, 2026
@andrepatta andrepatta marked this pull request as ready for review April 13, 2026 20:35
@andrepatta andrepatta merged commit df465fe into main Apr 14, 2026
3 of 4 checks passed
@andrepatta andrepatta deleted the source-restructure branch April 14, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant