-
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.
- Loading branch information
1 parent
cd5a2bf
commit 7cd237d
Showing
9 changed files
with
107 additions
and
22 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 | ||
} |
70 changes: 70 additions & 0 deletions
70
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,70 @@ | ||
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) | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
func (s StatementDistribution) processMessage(msg any) error { | ||
|
||
switch msg := msg.(type) { | ||
case statementedistributionmessages.Backed: | ||
// todo | ||
case statementedistributionmessages.Share: | ||
// todo | ||
// case statementedistributionmessages.NetworkBridgeUpdate | ||
// TODO this above case would need to wait | ||
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 | ||
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