How nibiruchain/nibiru works
Main Components
• Consensus Layer – Tendermint Core: Highlight Tendermint as the underlying consensus engine. This layer is responsible for the blockchain’s distributed consensus and network communication.
– EVM Module: Supporting Ethereum Virtual Machine operations. Include components such as the EVM state database, JSON-RPC endpoints (found in eth/rpc and related directories), and precompiled contracts (from the evm/precompile folder).
– WASM Module: Governing CosmWasm smart contract execution (the “wasmext” package and associated client interfaces).
– Devgas Module: For sharing contract execution fees with smart contract developers.
– Epochs, Inflation, Oracle, and Other 'x' Modules: From the “x” directory including modules such as epochs, inflation, oracle, tokenfactory, and common utilities.
– Other Core Components: Things like upgrade management, genesis configuration (from folders like app/upgrades and proto directories) and keepers that manage state (as seen in app/keepers and similar folders).
• RPC/API Gateway: This layer exposes both Cosmos-SDK JSON-RPC and Ethereum-compatible JSON-RPC endpoints. This becomes the bridge between external clients and the core.
• CLI & Node Management: Mark the “nibid” CLI inside the cmd folder as an entry point for operators and developers (with connections to underlying modules and configuration files).
Relationships and Data Flow
• Data flows from the API Gateway to the Nibiru Chain Application.
• Inside the application, indicate module interactions: for instance, the EVM module’s dependency on the common module for shared utilities, or the interdependencies between modules (like oracle updating asset prices which might affect inflation control).
• How the consensus engine (Tendermint Core) feeds finalized blocks to the application and how state transitions are managed via the keepers.
Architectural Patterns and Design Principles
• Layered Architecture: Clearly separate the networking/consensus layer (Tendermint) from the business logic (Cosmos-SDK application modules) and the external API interfaces.
Relevant Technologies and Tools
• Technologies: Golang for the core, Docker for containerization (referenced by Dockerfile, docker-compose, etc.), protobufs (in the proto folder) for message encoding, and testing frameworks integrated via Makefiles and CI/CD workflows (observed in the .github/workflows/ directories).
• Frameworks & Libraries: Cosmos-SDK, Tendermint, and Ethereum’s geth libraries (in the eth directory) for EVM support.
Additional Suggestions
• Technology choices: Add labels like “Golang”, “Docker”, “Protobuf”, “Cosmos-SDK”, “Tendermint”, “JSON-RPC”, etc., to clarify the technologies used at each layer.
Happy diagramming!