Gauss Docs
  • 🌐Getting Started
    • Welcome to Gauss
    • Whitepaper
      • Blockchain Providers Need to Do Better
        • Solving a Lack of Token Adoption
          • An Evolving Space With Untapped Potential
        • Security & Reliability
          • Curation & Vetting
            • Important Note For Brands
        • Token Creation
      • WHY BUILD WITH GAUSS?
      • Use Cases
        • Use Cases (Chart)
      • Roadmap
      • Technical Background and Blockchain Development
        • Why Another Blockchain?
        • Gauss 1.0: Built With Efficiency and a Strong Infrastructure to Launch Rapidly
        • Gauss 2.0: Added Functionality For a Better User Experiance
          • Noble Swap 2.0
          • NFTs in Gauss 2.0
          • Token Development Kit (TDK)
          • Gaming DAO
          • Omnipool
      • Token Economics
        • Gang Token Economics: Designed to Ensure Trust and Transparency
        • Token Locking Schedule
        • Reflections: Rewarding the Gauss Community
        • Charitable Allocations: Grants, Scholarships, & Financial Assistance
      • The Gauss Team
      • Important Definitions
      • DISCLAIMER
        • PURCHASER WARNING
        • PROMINENT STATEMENTS
        • FUTURE STATEMENTS
        • VALUE RISKS
        • NOT A SECURITY
    • How To Connect
      • Create Metamask Wallet
    • Links
  • ⚡Launching with Gauss
    • Benefits of Building with Gauss
      • Fostering an Environment for Success
      • Gauss Growth Grant Program
      • Gauss Liquidity Program
      • Ecosystem Integrity Fund
      • Client Referral Program
    • A Guide to Curation
      • Core Principles and Curation Guidelines
      • Curation Stages and Processing Fees
    • Building on Gauss
  • 🖥️Gauss Ecosystem
    • Gauss Chain
      • Polygon-Edge Overview
      • Architecture
      • Consensus
      • Client Modules
        • Blockchain
        • Minimal
        • Networking
        • State
        • TxPool
        • JSON RPC
        • Consensus
        • Storage
        • Types
        • Syncer
        • Sealer
        • Other Modules
      • Polygon-Edge Performance Reports
      • For Developers
        • Operate a Node
          • Local Install
          • Genesis Contract
          • Server Config
          • CLI Commands
          • Key Management
        • Run a Validator
          • Validator FAQ
        • Smart Contract Deployment Permissioning
        • Deploying Contracts
          • Remix
          • Truffle
          • Hardhat
          • Replit
    • Gauss Explorer
      • Features
      • Navigating the Explorer
        • Menus
        • Blocks
        • Transactions
      • Verifying a Smart Contract
        • Hardhat Plugin
        • Sourcify Plugin
        • OpenZeppelin Plugin
      • Interacting With Smart Contracts
      • Exporting Transactions
      • FAQ
      • For Developers
        • Gauss Explorer Dependencies
        • Deployment Guide
          • Smart Contract Verification
          • Cleaning an instance from the previous deployment
          • ENV Variables
          • Testing
        • APIs
          • Requests & Limits
          • GraphQL
          • ETH RPC
    • Noble Swap
      • Liquidity Boost Program
    • Tokens
    • Gauss NFTs
      • Ferro Cards
      • F.E.R.R.E.T. NFTs
    • Contests & Giveaways
    • Gauss Faucet
      • For Developers
    • Address List
  • 💡Additional Resources
    • Partnerships & Affiliates
    • Discord Channel
    • Contact Us
    • Learning Materials
      • Web3 Glossary
    • Media Kit
Powered by GitBook
On this page
  • Overview​
  • Startup Magic​
  1. Gauss Ecosystem
  2. Gauss Chain
  3. Client Modules

Minimal

PreviousBlockchainNextNetworking

Last updated 2 years ago

Overview

As mentioned before, Polygon Edge is a set of different modules, all connected to each other. The Blockchain is connected to the State, or for example, Synchronization, which pipes new blocks into the Blockchain.

Minimal is the cornerstone for these inter-connected modules. It acts as a central hub for all the services that run on the Polygon Edge.

Startup Magic

Among other things, Minimal is responsible for:

  • Setting up data directories

  • Creating a keystore for libp2p communication

  • Creating storage

  • Setting up consensus

  • Setting up the blockchain object with GRPC, JSON RPC, and Synchronization

func NewServer(logger hclog.Logger, config *Config) (*Server, error) {
    m := &Server{
        logger: logger,
        config: config,
        chain:      config.Chain,
        grpcServer: grpc.NewServer(),
    }

    m.logger.Info("Data dir", "path", config.DataDir)

    // Generate all the paths in the dataDir
    if err := setupDataDir(config.DataDir, dirPaths); err != nil {
        return nil, fmt.Errorf("failed to create data directories: %v", err)
    }

    // Get the private key for the node
    keystore := keystore.NewLocalKeystore(filepath.Join(config.DataDir, "keystore"))
    key, err := keystore.Get()
    if err != nil {
        return nil, fmt.Errorf("failed to read private key: %v", err)
    }
    m.key = key

    storage, err := leveldb.NewLevelDBStorage(filepath.Join(config.DataDir, "blockchain"), logger)
    if err != nil {
        return nil, err
    }
    m.storage = storage

    // Setup consensus
    if err := m.setupConsensus(); err != nil {
        return nil, err
    }

    stateStorage, err := itrie.NewLevelDBStorage(filepath.Join(m.config.DataDir, "trie"), logger)
    if err != nil {
        return nil, err
    }

    st := itrie.NewState(stateStorage)
    m.state = st

    executor := state.NewExecutor(config.Chain.Params, st)
    executor.SetRuntime(precompiled.NewPrecompiled())
    executor.SetRuntime(evm.NewEVM())

    // Blockchain object
    m.blockchain, err = blockchain.NewBlockchain(logger, storage, config.Chain, m.consensus, executor)
    if err != nil {
        return nil, err
    }

    executor.GetHash = m.blockchain.GetHashHelper

    // Setup sealer
    sealerConfig := &sealer.Config{
        Coinbase: crypto.PubKeyToAddress(&m.key.PublicKey),
    }
    m.Sealer = sealer.NewSealer(sealerConfig, logger, m.blockchain, m.consensus, executor)
    m.Sealer.SetEnabled(m.config.Seal)

    // Setup the libp2p server
    if err := m.setupLibP2P(); err != nil {
        return nil, err
    }

    // Setup the GRPC server
    if err := m.setupGRPC(); err != nil {
        return nil, err
    }

    // Setup jsonrpc
    if err := m.setupJSONRPC(); err != nil {
        return nil, err
    }

    // Setup the syncer protocol
    m.syncer = protocol.NewSyncer(logger, m.blockchain)
    m.syncer.Register(m.libp2pServer.GetGRPCServer())
    m.syncer.Start()

    // Register the libp2p GRPC endpoints
    proto.RegisterHandshakeServer(m.libp2pServer.GetGRPCServer(), &handshakeService{s: m})

    m.libp2pServer.Serve()
    return m, nil
}
🖥️
​
​