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:
Tendermint Core: Consensus and networking
- Byzantine Fault Tolerant (BFT) consensus
- P2P networking
- Block production
Cosmos SDK: Application framework
- Modules (bank, staking, governance)
- State management
- Transaction processing
Validators: Block producers
- Stake tokens
- Participate in consensus
- Earn rewards
Full Nodes: State maintainers
- Store blockchain state
- Serve queries
- Validate blocks
Light Clients: Query-only nodes
- Verify headers
- Query state
- Minimal resource usage
Q2: How does Tendermint consensus work?
Answer:
Tendermint Consensus Algorithm:
Consensus Steps:
Propose: Validator proposes block
- Highest voting power validator proposes
- Block includes transactions from mempool
Prevote: Validators vote on proposal
- Validators check if proposal is valid
- Broadcast prevote if valid
- Need 2/3+ voting power
Precommit: Validators commit to block
- After seeing 2/3+ prevotes
- Broadcast precommit
- Need 2/3+ voting power
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:
Consensus Key: Used for consensus signing
- Signs prevotes/precommits
- Stored in validator node
- Can be rotated
Tendermint Key: Used for block signing
- Signs proposed blocks
- Stored in validator node
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:
- Create Validator Account:
1# Create account
2gaiad keys add validator
3
4# Fund account
5gaiad tx bank send <from> <validator-address> 1000000uatom
- 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
- 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:
- Delegate:
1# Delegate to validator
2gaiad tx staking delegate <validator-address> 1000000uatom --from delegator
Rewards:
- Validators earn block rewards
- Delegators share in rewards
- Validator takes commission
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:
Bank Module: Token management
- Send/receive tokens
- Query balances
- Mint/burn tokens
Staking Module: Validator management
- Create validators
- Delegate/undelegate
- Validator set updates
Governance Module: On-chain governance
- Submit proposals
- Vote on proposals
- Parameter changes
Distribution Module: Reward distribution
- Distribute block rewards
- Handle commissions
- Community pool
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:
Transaction Collection:
- Node collects transactions from mempool
- Validates transactions
- Orders transactions
Block Proposal:
- Proposer creates block
- Includes transactions
- Signs block with consensus key
Consensus:
- Validators vote on block
- Need 2/3+ voting power
- Block is committed
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:
- 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
- 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
- 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})
- 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:
Double Signing:
- Validator signs two different blocks at same height
- Severe penalty (e.g., 5% of stake)
- Validator is jailed
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:
- Install Binary:
1# Download and install
2git clone https://github.com/cosmos/gaia
3cd gaia
4make install
5
6# Verify installation
7gaiad version
- 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
- 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"
- 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
- Bitcoin (Nakamoto) Consensus Interview Questions
Bitcoin consensus algorithm interview questions covering Proof-of-Work (PoW) and … - Byzantine Fault Tolerance (BFT) Consensus Interview Questions
Byzantine Fault Tolerance (BFT) consensus algorithm interview questions covering … - Cardano Interview Questions - Easy
Easy-level Cardano interview questions covering blockchain basics, Plutus, and … - Cardano Interview Questions - Hard
Hard-level Cardano interview questions covering advanced optimization and formal … - Cardano Interview Questions - Medium
Medium-level Cardano interview questions covering advanced Plutus development … - Consensus Algorithms Comparison Interview Questions
Consensus algorithm comparison and general implementation interview questions. … - Cosmos Chain Operations Interview Questions - Hard
Hard-level Cosmos chain operation questions covering advanced algorithms, … - Cosmos Chain Operations Interview Questions - Medium
Medium-level Cosmos chain operation questions covering advanced chain … - Cosmos SDK Interview Questions - Easy
Easy-level Cosmos SDK interview questions covering chain code, SDK basics, and … - Cosmos SDK Interview Questions - Hard
Hard-level Cosmos SDK interview questions covering advanced SDK internals, … - Cosmos SDK Interview Questions - Medium
Medium-level Cosmos SDK interview questions covering advanced module … - Ethereum Proof-of-Stake Consensus Interview Questions
Ethereum Proof-of-Stake consensus algorithm interview questions covering Casper … - Ouroboros (Cardano) Consensus Interview Questions
Ouroboros consensus algorithm interview questions covering Cardano's … - Paxos Consensus Interview Questions
Paxos consensus algorithm interview questions covering the classic distributed … - Polkadot (NPoS) Consensus Interview Questions
Polkadot consensus algorithm interview questions covering Nominated … - Polkadot Interview Questions - Easy
Easy-level Polkadot interview questions covering blockchain basics, Substrate, … - Polkadot Interview Questions - Hard
Hard-level Polkadot interview questions covering advanced optimization and … - Polkadot Interview Questions - Medium
Medium-level Polkadot interview questions covering advanced Substrate … - Solana Interview Questions - Easy
Easy-level Solana interview questions covering blockchain basics, programs, and … - Solana Interview Questions - Hard
Hard-level Solana interview questions covering advanced optimization, security, … - Solana Interview Questions - Medium
Medium-level Solana interview questions covering advanced program development, … - Solana Proof of History Consensus Interview Questions
Solana consensus algorithm interview questions covering Proof of History (PoH) … - Tendermint Consensus Interview Questions
Tendermint consensus algorithm interview questions covering the Byzantine Fault … - Web3 Interview Questions - Easy
Easy-level Web3 interview questions covering blockchain fundamentals, Ethereum, … - Web3 Interview Questions - Hard
Hard-level Web3 interview questions covering MEV, zero-knowledge proofs, … - Web3 Interview Questions - Medium
Medium-level Web3 interview questions covering DeFi, advanced Solidity, …