Skip to content

qkc/slave 05: add MasterConn protocol layer - #37

Open
iteyelmp wants to merge 99 commits into
goshard/basefrom
slave-05
Open

qkc/slave 05: add MasterConn protocol layer#37
iteyelmp wants to merge 99 commits into
goshard/basefrom
slave-05

Conversation

@iteyelmp

@iteyelmp iteyelmp commented Jul 13, 2026

Copy link
Copy Markdown

Add MasterConn: the slave-side master↔slave connection layer

Introduces MasterConn, the slave-side TCP connection to the cluster master, built on the existing BaseConn.

This PR establishes protocol compatibility, opcode registration, request dispatch, and handler delegation. Cluster business logic remains out of scope.

Scope

  • 12-byte ClusterMetadata framing over TCP.
  • Master↔Slave opcode / serializer / handler registration, including DESTROY_CLUSTER_PEER_CONNECTION_COMMAND.
  • Outbound RPC helpers:
    • SendAddMinorBlockHeader
    • SendAddMinorBlockHeaderList
  • Handler delegation through:
    • SlaveConnHandler (communication and topology orchestration);
    • MasterHandler (business RPC handling).

Not in Scope

  • Cluster business logic (shards, miner, chain state).
  • PeerConn and peer-to-peer communication infrastructure.
  • Dispatcher and routing components.

Reviewer Notes

Handler boundary

MasterConn owns protocol framing, opcode dispatch, and connection-level behavior.

PING always replies with PONG. When PingRequest.RootTip is present, it additionally delegates shard creation/update through SlaveConnHandler.

This matches Python's MasterConnection.handle_ping, where PING serves both as the initial handshake and as the trigger for shard creation/update.

All other master-driven operations are delegated through handler interfaces.

CREATE / DESTROY semantics

CREATE is a normal request/response RPC.

DESTROY is the sole non-RPC opcode.

Its serializer carries a placeholder ResponseOpCode = 0 only because the generic serializer registration requires one. The value is ignored for non-RPC opcodes and never appears on the wire.

Full Codex 5.6 review completed.

@iteyelmp
iteyelmp changed the base branch from goshard/base to slave-04 July 16, 2026 09:47
@iteyelmp
iteyelmp changed the base branch from slave-04 to slave-04-1 August 28, 2026 03:55
@iteyelmp
iteyelmp changed the base branch from slave-04-1 to goshard/base September 4, 2026 02:31
mc.BaseConn = conn.NewBaseConn(conn.Config{
Transport: conn.NewTCPTransport(cfg.Conn, readFrame, wire.WriteFrame),
Serializers: map[byte]*conn.OpSerializer{
// §1 Cluster initialisation

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this labeled “Cluster initialisation” when it also includes runtime operations such as ADD_ROOT_BLOCK, GET_ACCOUNT_DATA, and ADD_TRANSACTION?

}

func (mc *MasterConn) handleAddRootBlock(req any) (any, error) {
return mc.handler.AddRootBlock(req.(*wire.AddRootBlockRequest))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Python calls create_shards(req.root_block) after ADD_ROOT_BLOCK, but this path only delegates AddRootBlock. Shards activated after startup will never be created or receive PeerConns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants