Skip to content

Commit

Permalink
feat(dot/parachain/backing): handle statement message coming from o…
Browse files Browse the repository at this point in the history
…verseer (#3532)

- Implemented functionality to handle a statement message coming to the candidate backing subsystem
    - StatementMessage represents a validator's assessment of a specific candidate.
    - on receiving a statement message, we import a statement into the statement table and dispatch `Backed` notifications and misbehaviours as a result of importing a statement.
    - if the statement is seconded, the committed candidate receipt will be fetched from the statement table. Attesting data will be generated and stored to retry validation with other backing validators if a validator does not provide a PoV.
    - if the statement is valid, the validator index will be stored in existing attesting data.
    It will be checked whether the backing job is already running with the current validator. If not, the backing job will be started.
    - and then validation work will be kicked off.
    
    
 - added some overseer messages for  other subsystems as well, such as provisioner, candidate validation, and statement distribution in `dot/parachain/types/overseer_messages.go`
- implemented `Misbehaviour` enum using the interface (#3601)
- removed duplicate parachain types from `lib/babe/inherents` (#3668)
- implemented ExecutorParams varying datatype slice (partially implements #3544)
  • Loading branch information
axaysagathiya authored and kishansagathiya committed Jan 24, 2024
1 parent 001220e commit 8cceba9
Show file tree
Hide file tree
Showing 32 changed files with 2,921 additions and 392 deletions.
6 changes: 2 additions & 4 deletions dot/parachain/availability-store/availability_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,10 @@ func uint32ToBytes(value uint32) []byte {

// Run runs the availability store subsystem
func (av *AvailabilityStoreSubsystem) Run(ctx context.Context, OverseerToSubsystem chan any,
SubsystemToOverseer chan any) error {
SubsystemToOverseer chan any) {

av.wg.Add(1)
go av.processMessages()

return nil
}

// Name returns the name of the availability store subsystem
Expand Down Expand Up @@ -361,7 +359,7 @@ func (av *AvailabilityStoreSubsystem) handleStoreChunk(msg StoreChunk) error {
}

func (av *AvailabilityStoreSubsystem) handleStoreAvailableData(msg StoreAvailableData) error {
err := av.availabilityStore.storeAvailableData(msg.CandidateHash, msg.AvailableData)
err := av.availabilityStore.storeAvailableData(msg.CandidateHash.Value, msg.AvailableData)
if err != nil {
msg.Sender <- err
return fmt.Errorf("store available data: %w", err)
Expand Down
8 changes: 5 additions & 3 deletions dot/parachain/availability-store/availability_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,12 @@ func TestAvailabilityStore_handleStoreAvailableData(t *testing.T) {
asSub := AvailabilityStoreSubsystem{
availabilityStore: *as,
}
msgSenderChan := make(chan any)
msgSenderChan := make(chan error)
msg := StoreAvailableData{
CandidateHash: common.Hash{0x01},
NValidators: 0,
CandidateHash: parachaintypes.CandidateHash{
Value: common.Hash{0x01},
},
NumValidators: 0,
AvailableData: AvailableData{},
ExpectedErasureRoot: common.Hash{},
Sender: msgSenderChan,
Expand Down
16 changes: 11 additions & 5 deletions dot/parachain/availability-store/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,19 @@ type StoreChunk struct {
Sender chan any
}

// StoreAvailableData store an `AvailableData` in the AV store
// StoreAvailableData computes and checks the erasure root of `AvailableData`
// before storing its chunks in the AV store.
type StoreAvailableData struct {
CandidateHash common.Hash
NValidators uint32
AvailableData AvailableData
// A hash of the candidate this `ASMStoreAvailableData` belongs to.
CandidateHash parachaintypes.CandidateHash
// The number of validators in the session.
NumValidators uint32
// The `AvailableData` itself.
AvailableData AvailableData
// Erasure root we expect to get after chunking.
ExpectedErasureRoot common.Hash
Sender chan any
// channel to send result to.
Sender chan error
}

// AvailableData is the data we keep available for each candidate included in the relay chain
Expand Down
Loading

0 comments on commit 8cceba9

Please sign in to comment.