-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
statement distribution skeleton (#4169)
Statement Distribution subsystem is responsible for distributing signed statements that we have generated and forwarding statements generated by our peers. This commit just introduces a skeleton for it. - implements the subsystem interface - registers the subsystem with overseer - add the processMessage method with messages to be handled Issue #3583
- Loading branch information
1 parent
a2450fe
commit a6d5321
Showing
9 changed files
with
109 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package messages | ||
|
||
import ( | ||
parachaintypes "github.com/ChainSafe/gossamer/dot/parachain/types" | ||
"github.com/ChainSafe/gossamer/lib/common" | ||
) | ||
|
||
// Backed is a statement distribution message. | ||
// it represents a message indicating that a candidate has received sufficient | ||
// validity votes from the backing group. If backed as a result of a local statement, | ||
// it must be preceded by a `Share` message for that statement to ensure awareness of | ||
// full candidates before the `Backed` notification, even in groups of size 1. | ||
type Backed parachaintypes.CandidateHash | ||
|
||
// Share is a statement distribution message. | ||
// It is a signed statement in the context of | ||
// given relay-parent hash and it should be distributed to other validators. | ||
type Share struct { | ||
RelayParent common.Hash | ||
SignedFullStatementWithPVD parachaintypes.SignedFullStatementWithPVD | ||
} |
71 changes: 71 additions & 0 deletions
71
dot/parachain/statement-distribution/statement_distribution.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package statementdistribution | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/ChainSafe/gossamer/internal/log" | ||
|
||
statementedistributionmessages "github.com/ChainSafe/gossamer/dot/parachain/statement-distribution/messages" | ||
parachaintypes "github.com/ChainSafe/gossamer/dot/parachain/types" | ||
) | ||
|
||
var logger = log.NewFromGlobal(log.AddContext("pkg", "statement-distribution")) | ||
|
||
type StatementDistribution struct { | ||
} | ||
|
||
func (s StatementDistribution) Run(ctx context.Context, overseerToSubSystem <-chan any) { | ||
for { | ||
select { | ||
case msg, ok := <-overseerToSubSystem: | ||
if !ok { | ||
return | ||
} | ||
err := s.processMessage(msg) | ||
if err != nil { | ||
logger.Errorf("processing overseer message: %w", err) | ||
} | ||
case <-ctx.Done(): | ||
if err := ctx.Err(); err != nil { | ||
logger.Errorf("ctx error: %v\n", err) | ||
} | ||
} | ||
} | ||
} | ||
|
||
func (s StatementDistribution) processMessage(msg any) error { | ||
|
||
switch msg := msg.(type) { | ||
case statementedistributionmessages.Backed: | ||
// TODO #4171 | ||
case statementedistributionmessages.Share: | ||
// TODO #4170 | ||
// case statementedistributionmessages.NetworkBridgeUpdate | ||
// TODO #4172 this above case would need to wait until network bridge receiver side is merged | ||
case parachaintypes.ActiveLeavesUpdateSignal: | ||
return s.ProcessActiveLeavesUpdateSignal(msg) | ||
case parachaintypes.BlockFinalizedSignal: | ||
return s.ProcessBlockFinalizedSignal(msg) | ||
|
||
default: | ||
return parachaintypes.ErrUnknownOverseerMessage | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (s StatementDistribution) Name() parachaintypes.SubSystemName { | ||
return parachaintypes.StatementDistribution | ||
} | ||
|
||
func (s StatementDistribution) ProcessActiveLeavesUpdateSignal(signal parachaintypes.ActiveLeavesUpdateSignal) error { | ||
// TODO #4173 | ||
return nil | ||
} | ||
|
||
func (s StatementDistribution) ProcessBlockFinalizedSignal(signal parachaintypes.BlockFinalizedSignal) error { | ||
// nothing to do here | ||
return nil | ||
} | ||
|
||
func (s StatementDistribution) Stop() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters