Skip to content
Blockchain Association of Cameroon
BAC-L1-COSMOS-102Cosmos SDKIntermediate

Go II — concurrency, contexts, testing

A node is a concurrent program. Goroutines, channels and cancellation contexts: the toolkit that keeps that concurrency from becoming a trap.

Level
L1Blockchain developer
Duration
4 h
Track
Cosmos SDK
Maintainer
Cosmos Lead Architect

Learning objectives

  • 01Coordinate goroutines through channels and contexts
  • 02Shut down a concurrent service cleanly
  • 03Detect a data race with tooling

Guided lab

Write a cancellable concurrent block collector and test it under the race detector.

Independent lab

Deliberately introduce a race, have the tooling catch it, then fix it.

Security angle

A data race inside a node produces divergent state between validators — that is, a fork.

Assessment

Concurrent service tested with a clean race-detector run.