How blv-labs/whitelist-wallet works
Project Type & Purpose
• This is a blockchain protocol implementation (the reference implementation for the Terra protocol) which serves as a node daemon (terrad) for interacting with the blockchain network.
• It includes a variety of modules for handling accounts, governance, staking, market functions, oracle updates, treasury, upgrade mechanisms, and smart contracts (through WASM integrations).
Top-Level Architectural Layers/Components
• Client / CLI: The “cmd/terrad” directory defines the entry point for the node and includes commands for initialization, key management, querying, transaction submission, and other chain operations.
• Application Layer: The “app” directory holds the main Terra application logic (app.go, modules.go, encoding, and upgrade support). This layer aggregates the various modules and governs the chain’s state transitions.
• Modules: These are the core components implementing blockchain functionalities:
• Custom modules in “custom/” (e.g., auth, bank, gov, distribution, staking, wasm, etc.)
• Standard modules often found under “x/” (e.g., market, oracle, treasury, vesting, etc.)
• Each module contains its own keeper, types, and simulation tests for state management.
• Consensus & Networking:
• Integration with Tendermint (as per the README for launching “terrad start” and the various configuration files for P2P/RPC ports).
• Configuration files and Docker scripts (such as Dockerfile, docker-compose.yml, and scripts) support deployment, monitoring, and scalability.
• Proto Definitions: The “proto” directory holds protocol buffer files that define the APIs and data structures used in inter-module and network communications.
• Testing and Simulation: Unit test files, simulation test scripts (present in directories like “app/sim_test.go”, “contrib/localnet”, “tests”, “scripts”) demonstrate how components interact during network operations.
• Build/Deployment & DevOps: Files including Makefile, Docker-related files, GitHub workflows, and CI configuration indicate the build, linting, release, test, and deployment pipelines.
Relationships & Data Flow
• The terrad binary (from “cmd/terrad”) launches the application. It initializes the blockchain’s state (via “app/app.go”) and then registers various modules.
• Modules interact with each other through well-defined interfaces (keepers, routers) and data flow through transactions and queries.
• Consensus is handled by Tendermint. Show how state transitions trigger consensus rounds and then update the state maintained in the application.
• RPC and REST interfaces (exposed on ports like 26657 for RPC, 1317 for LCD) that serve as external communication channels to interact with your node.
• The Docker and compose configurations demonstrate how container orchestration and deployment integrate with the blockchain node.
Design Patterns & Technologies
• Modular architecture: The clear separation of blockchain modules (accounts, banking, staking, governance) follows a typical Cosmos SDK pattern.
• Client-Server model: The terrad CLI communicates with the node’s local daemons.
• Protobuf/gRPC communication: The “proto” directory and generated code (e.g., in “custom/auth/tx”, “x/dyncomm”, etc.) underline the usage of protocol buffers to ensure robust data serialization across modules.
• DevOps Pipelines: CI/CD workflows and Docker configurations facilitate automated testing, linting, and deployment.
Putting It All Together
– Attach the CLI and API endpoints to the node to represent external interactions.
– Inside the node, compartmentalize the Application Layer into individual modules (list them explicitly: auth, bank, governance, market, oracle, treasury, staking, wasm, etc.).
– Show the Tendermint component on the side to illustrate consensus operations.
– Optionally, include a section for “Build & Deployment” showing Docker, CI/CD pipelines, and scripts that help in building, testing, and deploying the node.
– Make sure to use directional flow symbols to represent the sequence from transaction submission, module processing, block formation, and network consensus.