Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dot/core/mocks_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dot/core/service_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package core
import (
"context"
"fmt"
parachaintypes "github.com/ChainSafe/gossamer/dot/parachain/types"
"math/big"
"os"
"testing"
Expand All @@ -17,7 +18,6 @@ import (
"github.com/ChainSafe/gossamer/dot/state"
"github.com/ChainSafe/gossamer/dot/sync"
"github.com/ChainSafe/gossamer/dot/types"
"github.com/ChainSafe/gossamer/lib/babe/inherents"
"github.com/ChainSafe/gossamer/lib/common"
"github.com/ChainSafe/gossamer/lib/keystore"
"github.com/ChainSafe/gossamer/lib/runtime"
Expand Down Expand Up @@ -720,7 +720,7 @@ func buildTestBlockWithoutExtrinsics(t *testing.T, instance runtime.Instance,
err = inherentData.SetInherent(types.Babeslot, uint64(1))
require.NoError(t, err)

parachainInherent := inherents.ParachainInherentData{
parachainInherent := parachaintypes.InherentData{
ParentHeader: *parentHeader,
}

Expand Down
64 changes: 32 additions & 32 deletions dot/mock_node_builder_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dot/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type nodeBuilderIface interface {
verifier *babe.VerificationManager, cs *core.Service, net *network.Service,
telemetryMailer Telemetry) (*dotsync.Service, error)
createBABEService(config *cfg.Config, st *state.Service, ks KeyStore, cs *core.Service,
telemetryMailer Telemetry) (service *babe.Service, err error)
telemetryMailer Telemetry, om babe.OverseerMessenger) (service *babe.Service, err error)
createSystemService(cfg *types.SystemInfo, stateSrvc *state.Service) (*system.Service, error)
createRPCService(params rpcServiceSettings) (*rpc.HTTPServer, error)
}
Expand Down Expand Up @@ -393,7 +393,7 @@ func newNode(config *cfg.Config,
}
nodeSrvcs = append(nodeSrvcs, phs)

bp, err := builder.createBABEService(config, stateSrvc, ks.Babe, coreSrvc, telemetryMailer)
bp, err := builder.createBABEService(config, stateSrvc, ks.Babe, coreSrvc, telemetryMailer, phs)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion dot/node_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func TestNewNode(t *testing.T) {
gomock.AssignableToTypeOf(&telemetry.Mailer{})).
Return(&dotsync.Service{}, nil)
m.EXPECT().createBABEService(initConfig, gomock.AssignableToTypeOf(&state.Service{}), ks.Babe,
&core.Service{}, gomock.AssignableToTypeOf(&telemetry.Mailer{})).
&core.Service{}, gomock.AssignableToTypeOf(&telemetry.Mailer{}), gomock.AssignableToTypeOf(&parachain.Service{})).
Return(&babe.Service{}, nil)
m.EXPECT().createSystemService(systemInfo, gomock.AssignableToTypeOf(&state.Service{})).
DoAndReturn(func(cfg *types.SystemInfo, stateSrvc *state.Service) (*system.Service, error) {
Expand Down
42 changes: 5 additions & 37 deletions dot/parachain/inherent.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,16 @@ var logger = log.NewFromGlobal(log.AddContext("pkg", "parachain"))

var errResponseChannelClosed = fmt.Errorf("response channel is closed")

// InherentData represents parachains inherent-data passed into the runtime by a block author
type InherentData struct {
// Bitfields represents signed bitfields by validators about availability.
Bitfields []parachaintypes.UncheckedSignedAvailabilityBitfield `scale:"1"`
// BackedCandidates represents backed candidates for inclusion in the block.
BackedCandidates []parachaintypes.BackedCandidate `scale:"2"`
// Disputes represents sets of dispute votes for inclusion.
Disputes []parachaintypes.DisputeStatementSet `scale:"3"`
// ParentHeader represents the parent block header. Used for checking state proofs.
ParentHeader types.Header `scale:"4"`
}

type blockState interface {
GetHeader(common.Hash) (*types.Header, error)
}

// ProvideInherentData creates the inherent data for the parachain block authoring process
// and returns it as a types.InherentData object with the parachain inherent data.
func ProvideInherentData(
blockState blockState,
overseerCh chan<- any,
relayParent common.Hash,
) (*types.InherentData, error) {
parachainInherentData, err := createInherentData(blockState, overseerCh, relayParent)
if err != nil {
return nil, fmt.Errorf("creating parachain inherent data: %w", err)
}

inherentData := types.NewInherentData()
err = inherentData.SetInherent(types.Parachn0, parachainInherentData)
if err != nil {
return nil, fmt.Errorf("setting parachain inherent data: %w", err)
}

return inherentData, nil
}

func createInherentData(
// CreateInherentData fetches the necessary data for the parachain inherent and returns it as an InherentData object.
func CreateInherentData(
blockState blockState,
overseerCh chan<- any,
relayParent common.Hash,
) (*InherentData, error) {
) (*parachaintypes.InherentData, error) {
var (
provisionerInherent *provisioner.ProvisionerInherentData
provErr error
Expand All @@ -85,15 +53,15 @@ func createInherentData(

if provErr != nil {
logger.Errorf("getting provisioner inherent data: %s\n", provErr)
return &InherentData{ParentHeader: *parentHeader}, provErr
return &parachaintypes.InherentData{ParentHeader: *parentHeader}, nil
}

uncheckBitfields := make([]parachaintypes.UncheckedSignedAvailabilityBitfield, 0, len(provisionerInherent.Bitfields))
for _, bitfield := range provisionerInherent.Bitfields {
uncheckBitfields = append(uncheckBitfields, parachaintypes.UncheckedSignedAvailabilityBitfield(bitfield))
}

return &InherentData{
return &parachaintypes.InherentData{
Bitfields: uncheckBitfields,
BackedCandidates: provisionerInherent.BackedCandidates,
Disputes: provisionerInherent.Disputes,
Expand Down
4 changes: 4 additions & 0 deletions dot/parachain/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ func (Service) Stop() error {
return nil
}

func (s Service) OverseerChannel() chan<- any {
return s.overseer.GetSubsystemToOverseerChannel()
}

// Network is the interface required by parachain service for the network
type Network interface {
GossipMessage(msg network.NotificationsMessage)
Expand Down
13 changes: 13 additions & 0 deletions dot/parachain/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"math"
"sort"

"github.com/ChainSafe/gossamer/dot/types"
"github.com/ChainSafe/gossamer/lib/common"
"github.com/ChainSafe/gossamer/lib/crypto"
"github.com/ChainSafe/gossamer/lib/crypto/sr25519"
Expand Down Expand Up @@ -1167,3 +1168,15 @@ type WaitForActivation struct {
RelayParent common.Hash
ResponseCh chan error
}

// InherentData represents parachains inherent-data passed into the runtime by a block author
type InherentData struct {
// Bitfields represents signed bitfields by validators about availability.
Bitfields []UncheckedSignedAvailabilityBitfield `scale:"1"`
// BackedCandidates represents backed candidates for inclusion in the block.
BackedCandidates []BackedCandidate `scale:"2"`
// Disputes represents sets of dispute votes for inclusion.
Disputes []DisputeStatementSet `scale:"3"`
// ParentHeader represents the parent block header. Used for checking state proofs.
ParentHeader types.Header `scale:"4"`
}
Loading
Loading