Cosmos Chain Operations Interview Questions - Easy

Easy-level Cosmos chain operation interview questions covering chain operations, algorithms, keys, validators, and modules.

Q1: What are the key components of a Cosmos chain?

Answer:

Chain Components:

Key Components:

  1. Tendermint Core: Consensus and networking

    • Byzantine Fault Tolerant (BFT) consensus
    • P2P networking
    • Block production
  2. Cosmos SDK: Application framework

    • Modules (bank, staking, governance)
    • State management
    • Transaction processing
  3. Validators: Block producers

    • Stake tokens
    • Participate in consensus
    • Earn rewards
  4. Full Nodes: State maintainers

    • Store blockchain state
    • Serve queries
    • Validate blocks
  5. Light Clients: Query-only nodes

    • Verify headers
    • Query state
    • Minimal resource usage

Q2: How does Tendermint consensus work?

Answer:

Tendermint Consensus Algorithm:

Consensus Steps:

  1. Propose: Validator proposes block

    • Highest voting power validator proposes
    • Block includes transactions from mempool
  2. Prevote: Validators vote on proposal

    • Validators check if proposal is valid
    • Broadcast prevote if valid
    • Need 2/3+ voting power
  3. Precommit: Validators commit to block

    • After seeing 2/3+ prevotes
    • Broadcast precommit
    • Need 2/3+ voting power
  4. Commit: Block is finalized

    • After seeing 2/3+ precommits
    • Block is committed to chain
    • State is updated

Key Properties:

  • Safety: No two validators commit different blocks
  • Liveness: Chain continues even with 1/3 failures
  • Finality: Blocks are final (no reorgs)

Byzantine Fault Tolerance:

  • Tolerates up to 1/3 Byzantine validators
  • Requires 2/3+ honest validators
  • Ensures consensus safety

Q3: What are validator keys and how are they managed?

Answer:

Validator Key Types:

  1. Consensus Key: Used for consensus signing

    • Signs prevotes/precommits
    • Stored in validator node
    • Can be rotated
  2. Tendermint Key: Used for block signing

    • Signs proposed blocks
    • Stored in validator node
  3. Account Key: Used for transactions

    • Sends transactions
    • Receives rewards
    • Can be different from validator

Key Management:

 1# Generate consensus key
 2gaiad init validator --chain-id mychain
 3
 4# This creates:
 5# ~/.gaia/config/priv_validator_key.json  # Consensus key
 6# ~/.gaia/config/node_key.json           # Node key
 7
 8# View validator address
 9gaiad tendermint show-address
10
11# View validator pubkey
12gaiad tendermint show-validator

Key Security:

  • Hardware Security Modules (HSM): Store keys in hardware
  • Key Rotation: Periodically rotate keys
  • Multi-sig: Use multiple keys for security
  • Backup: Securely backup keys

Key Derivation:

1// Generate Ed25519 key pair
2privKey := ed25519.GenPrivKey()
3pubKey := privKey.PubKey()
4
5// Get address from pubkey
6address := sdk.AccAddress(pubKey.Address())

Q4: How do you become a validator?

Answer:

Validator Setup Process:

  1. Create Validator Account:
1# Create account
2gaiad keys add validator
3
4# Fund account
5gaiad tx bank send <from> <validator-address> 1000000uatom
  1. Initialize Node:
1# Initialize node
2gaiad init my-validator --chain-id cosmoshub-4
3
4# Download genesis
5curl https://raw.githubusercontent.com/cosmos/mainnet/master/genesis.json > ~/.gaia/config/genesis.json
6
7# Set peers
8sed -i 's/persistent_peers = ""/persistent_peers = "..."/' ~/.gaia/config/config.toml
  1. Create Validator:
 1# Create validator transaction
 2gaiad tx staking create-validator \
 3  --amount=1000000uatom \
 4  --pubkey=$(gaiad tendermint show-validator) \
 5  --moniker="My Validator" \
 6  --commission-rate="0.10" \
 7  --commission-max-rate="0.20" \
 8  --commission-max-change-rate="0.01" \
 9  --min-self-delegation="1" \
10  --from=validator \
11  --chain-id=cosmoshub-4

Validator Parameters:

  • Moniker: Validator name
  • Commission Rate: Fee charged to delegators
  • Max Commission: Maximum commission rate
  • Min Self-Delegation: Minimum self-staked amount

Validator Requirements:

  • Minimum stake (varies by chain)
  • Running node 24/7
  • Good network connection
  • Security practices

Q5: How does staking and delegation work?

Answer:

Staking Mechanism:

Delegation Process:

  1. Delegate:
1# Delegate to validator
2gaiad tx staking delegate <validator-address> 1000000uatom --from delegator
  1. Rewards:

    • Validators earn block rewards
    • Delegators share in rewards
    • Validator takes commission
  2. Undelegate:

1# Undelegate (unbonding period applies)
2gaiad tx staking unbond <validator-address> 1000000uatom --from delegator

Unbonding Period:

  • Tokens are locked during unbonding
  • Typically 21 days for Cosmos Hub
  • Prevents validator misbehavior

Redelegation:

1# Move delegation to another validator
2gaiad tx staking redelegate <src-validator> <dst-validator> 1000000uatom --from delegator

Reward Distribution:

  • Block rewards distributed to validators
  • Validators take commission (e.g., 10%)
  • Remaining rewards shared with delegators
  • Proportional to stake

Q6: What are Cosmos SDK modules and how do they work?

Answer:

Module Architecture:

Core Modules:

  1. Bank Module: Token management

    • Send/receive tokens
    • Query balances
    • Mint/burn tokens
  2. Staking Module: Validator management

    • Create validators
    • Delegate/undelegate
    • Validator set updates
  3. Governance Module: On-chain governance

    • Submit proposals
    • Vote on proposals
    • Parameter changes
  4. Distribution Module: Reward distribution

    • Distribute block rewards
    • Handle commissions
    • Community pool
  5. Slashing Module: Penalties

    • Slash for downtime
    • Slash for double-signing
    • Jail validators

Module Interaction:

  • Modules communicate via keepers
  • Each module has its own store
  • Modules can depend on other modules

Q7: How does block production work?

Answer:

Block Production Process:

  1. Transaction Collection:

    • Node collects transactions from mempool
    • Validates transactions
    • Orders transactions
  2. Block Proposal:

    • Proposer creates block
    • Includes transactions
    • Signs block with consensus key
  3. Consensus:

    • Validators vote on block
    • Need 2/3+ voting power
    • Block is committed
  4. State Update:

    • Execute transactions
    • Update state
    • Emit events

Block Structure:

1type Block struct {
2    Header     Header
3    Data       Data      // Transactions
4    Evidence   Evidence  // Proof of misbehavior
5    LastCommit Commit    // Previous block commits
6}

Block Time:

  • Typically 1-6 seconds
  • Configurable per chain
  • Faster than Bitcoin/Ethereum

Block Size:

  • Limited by consensus parameters
  • Typically 1-10 MB
  • Prevents spam attacks

Q8: How do you query chain state?

Answer:

Query Methods:

  1. CLI Queries:
 1# Query account balance
 2gaiad query bank balances <address>
 3
 4# Query validator info
 5gaiad query staking validator <validator-address>
 6
 7# Query governance proposals
 8gaiad query gov proposals
 9
10# Query module parameters
11gaiad query staking params
  1. REST API:
1# Query via REST
2curl http://localhost:1317/cosmos/bank/v1beta1/balances/<address>
3
4# Query validators
5curl http://localhost:1317/cosmos/staking/v1beta1/validators
  1. gRPC:
1// Query via gRPC
2conn, _ := grpc.Dial("localhost:9090", grpc.WithInsecure())
3client := banktypes.NewQueryClient(conn)
4
5resp, err := client.Balance(context.Background(), &banktypes.QueryBalanceRequest{
6    Address: address,
7    Denom:   "uatom",
8})
  1. Tendermint RPC:
1# Query block
2curl http://localhost:26657/block?height=100
3
4# Query transaction
5curl http://localhost:26657/tx?hash=<tx-hash>
6
7# Query account
8curl http://localhost:26657/abci_query?path="/store/acc/key"&data=<address>

Q9: How does slashing work?

Answer:

Slashing Types:

  1. Double Signing:

    • Validator signs two different blocks at same height
    • Severe penalty (e.g., 5% of stake)
    • Validator is jailed
  2. Downtime:

    • Validator misses too many blocks
    • Moderate penalty (e.g., 0.01% of stake)
    • Validator is jailed

Slashing Process:

Slashing Parameters:

  • Slash Fraction Double Sign: Penalty for double signing
  • Slash Fraction Downtime: Penalty for downtime
  • Signed Blocks Window: Blocks to check for downtime
  • Min Signed Per Window: Minimum blocks to sign

Jailing:

  • Validator is jailed after slashing
  • Cannot participate in consensus
  • Must wait for unjail period
  • Can unjail after period expires

Unjailing:

1# Unjail validator
2gaiad tx slashing unjail --from validator

Q10: How do you run a full node?

Answer:

Full Node Setup:

  1. Install Binary:
1# Download and install
2git clone https://github.com/cosmos/gaia
3cd gaia
4make install
5
6# Verify installation
7gaiad version
  1. Initialize Node:
1# Initialize
2gaiad init my-node --chain-id cosmoshub-4
3
4# Download genesis
5curl https://raw.githubusercontent.com/cosmos/mainnet/master/genesis.json > ~/.gaia/config/genesis.json
6
7# Verify genesis
8gaiad validate-genesis
  1. Configure Node:
 1# Edit config.toml
 2nano ~/.gaia/config/config.toml
 3
 4# Set persistent peers
 5persistent_peers = "node1@ip:port,node2@ip:port"
 6
 7# Set seeds
 8seeds = "seed1@ip:port,seed2@ip:port"
 9
10# Enable API
11[api]
12enable = true
13address = "tcp://0.0.0.0:1317"
  1. Start Node:
1# Start node
2gaiad start
3
4# Or as service
5sudo systemctl start gaiad

Node Types:

  • Full Node: Stores all state, can query
  • Archive Node: Stores all historical state
  • Pruned Node: Stores recent state only
  • Validator Node: Full node + validator

Sync Methods:

  • State Sync: Fast sync from snapshot
  • Block Sync: Sync from genesis
  • Fast Sync: Sync recent blocks only

Related Snippets