How vcity-team/vcitychain works
Purpose and Entry Points
This is a Go implementation of a Polygon Edge–style EVM blockchain node, with pluggable consensus (DPoS/PolyBFT, IBFT, development), P2P networking, transaction execution, synchronization, bridge/root-chain operations, and operator tooling. The primary binary begins at main.go, builds the command hierarchy in command/root/root.go, and starts a node through command/server/server.go and server/server.go.
Node Composition and Lifecycle
server/server.go is the runtime composition boundary: it connects chain configuration, blockchain storage, state execution, consensus, networking, txpool, sync, RPC, and system services. server/config.go defines node-level configuration, while server/system_service.go exposes node management over generated gRPC interfaces in server/proto/system.proto. The CLI is both the node launcher and an operational control plane, including genesis, secrets, peers, status, backup, rollback, and root/sidechain commands.
Chain, Blocks, and Persistent Storage
The canonical chain layer in blockchain/blockchain.go validates, stores, finalizes, and publishes blocks; subscriptions in blockchain/subscription.go let dependent subsystems react to chain events. Storage is abstracted by blockchain/storage/storage.go, with LevelDB production persistence at blockchain/storage/leveldb/leveldb.go and an in-memory implementation for ephemeral/test use. Archive operations provide offline chain data boundaries through archive/backup.go and archive/restore.go.
EVM State Transition Boundary
Transactions and block execution enter the state layer through state/executor.go and state/txn.go. Account/storage state is maintained in an immutable Merkle trie under state/immutable-trie/state.go and state/immutable-trie/trie.go. The execution runtime dispatches EVM bytecode in state/runtime/evm/evm.go, with native protocol behavior isolated as precompiles in state/runtime/precompiled/precompiled.go. This separates consensus block selection from deterministic execution and state-root production.
Transaction Admission and Public APIs
The transaction pool in txpool/txpool.go accepts, validates, orders, and tracks pending transactions; event subscriptions are managed by txpool/event_manager.go. JSON-RPC requests are routed by jsonrpc/dispatcher.go, with Ethereum-compatible methods in jsonrpc/eth_endpoint.go, txpool methods in jsonrpc/txpool_endpoint.go, and bridge/DPoS extensions in jsonrpc/bridge_endpoint.go and jsonrpc/dpos_endpoint.go. RPC queries cross into blockchain, state, txpool, and network abstractions rather than directly owning those stores.
Networking and Synchronization
The libp2p-oriented network server lives in network/server.go, with peer discovery in network/discovery/discovery.go, gossip in network/gossip.go, and gRPC transport support in network/grpc/grpc.go. Consensus and sync traffic use generated protobuf contracts under network/proto/ and consensus-specific proto directories. syncer/syncer.go coordinates peer selection, trusted/canonical tip decisions, block ingestion, and state healing; syncer/service.go is its service-facing boundary.
Consensus, Validators, and Cross-Chain Protocols
Consensus is selected through the common contract in consensus/consensus.go. The active feature-rich DPoS implementation is centered on consensus/dpos/dpos.go and consensus/dpos/consensus_runtime.go; it combines validator/stake state, epoch transitions, governance, BLS signatures, block production, fault handling, rewards, and state-sync/checkpoint logic. Legacy/alternative engines remain in consensus/ibft/ibft.go, consensus/polybft/polybft.go, and consensus/dev/dev.go. Validator cryptography and sets are shared in validators/set.go and bls/signature.go. Root-chain deployment, staking, validator registration, bridge transfers, and checkpoint-related operator workflows are exposed under command/rootchain/rootchain.go and command/bridge/bridge.go, implying integration with external EVM root-chain contracts.
Secrets and Deployment Runtime
Node and validator keys are accessed through a provider abstraction in secrets/secrets.go, with local filesystem, AWS SSM, GCP Secret Manager, and HashiCorp Vault backends at secrets/local/local.go, secrets/awsssm/aws_ssm.go, secrets/gcpssm/gcp_ssm.go, and secrets/hashicorpvault/hashicorp_vault.go. Local containerized operation is supported by docker/local/docker-compose.yml. The docs README is scoped to the separate MkDocs documentation site under docs/, not the node’s primary runtime.
Main entry points: server.go Node server · blockchain.go Blockchain · executor.go State executor · consensus_runtime.go DPoS runtime
Components 21
Entry & Operations
- Node binary
main.go - Command hierarchy
command/root/root.go - Server command
command/server/server.go
Node Runtime
- Node server · Wires the node subsystems and lifecycle.
server/server.go - Node configuration
server/config.go - Transaction pool
txpool/txpool.go - Secrets providers · Supports local, cloud secret-manager, and Vault backends.
secrets/secrets.go
Chain & Execution
- Blockchain · Validates, persists, finalizes, and publishes blocks.
blockchain/blockchain.go - Chain storage · LevelDB and in-memory implementations sit behind this boundary.
blockchain/storage/storage.go - State executor · Executes transactions and produces deterministic state roots.
state/executor.go - Immutable Merkle trie
state/immutable-trie/state.go - EVM runtime
state/runtime/evm/evm.go - Archive backup
archive/backup.go
Networking & Sync
- Network server · Provides peer discovery, gossip, and gRPC transport.
network/server.go - Syncer · Selects peer tips and ingests/heals chain state.
syncer/syncer.go
Consensus & Cross-Chain
- Consensus contract
consensus/consensus.go - DPoS runtime · Coordinates validators, epochs, production, rewards, and checkpoints.
consensus/dpos/consensus_runtime.go - Validator set
validators/set.go - Root-chain operations · Deploys and operates staking, bridge, and checkpoint contracts.
command/rootchain/rootchain.go
Public Services
- System service
server/system_service.go - JSON-RPC dispatcher
jsonrpc/dispatcher.go
Connections 26
- Node binary → Command hierarchy: builds
- Command hierarchy → Server command: launch command
- Server command → Node server: starts
- Node configuration → Node server: configures
- Node server → Blockchain: hosts
- Node server → Transaction pool: hosts
- Node server → Network server: hosts
- Node server → Syncer: hosts
- Node server → Consensus contract: selects
- Node server → JSON-RPC dispatcher: serves
- Node server → System service: serves
- Node server → Secrets providers: loads keys
- Blockchain → Chain storage: persists blocks
- Blockchain → State executor: validates execution
- State executor → Immutable Merkle trie: reads and commits state
- State executor → EVM runtime: dispatches bytecode
- Transaction pool → State executor: prevalidates transactions
- JSON-RPC dispatcher → Blockchain: queries chain
- JSON-RPC dispatcher → Transaction pool: submits and queries txs
- Network server → Syncer: provides peers and transport
- Syncer → Blockchain: ingests canonical blocks
- Consensus contract → DPoS runtime: implemented by
- DPoS runtime → Validator set: uses validator set
- DPoS runtime → Blockchain: finalizes selected blocks
- Root-chain operations → DPoS runtime: operates protocol workflows
- Archive backup → Chain storage: exports chain data