Skip to content

Commit

Permalink
Merge branch 'development' into eclesio/fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
EclesioMeloJunior authored Nov 7, 2024
2 parents 5a80128 + 6a30228 commit 9b69564
Show file tree
Hide file tree
Showing 39 changed files with 2,994 additions and 419 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/dispatch-baremetal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Dispatch workflow to deploy baremetal Gossamer nodes

on:
workflow_dispatch:
inputs:
commit:
description: 'commit'
required: true
nodeType:
description: 'Node type'
required: true
default: 'genesis'
type: choice
options:
- snapshot
- genesis
chain:
description: 'Chain'
required: true
default: 'westend'
type: choice
options:
- paseo
- westend
gossamerStartArgs:
description: 'Arguments'
required: false

jobs:
dispatch:
runs-on: ubuntu-latest
steps:
- name: Get Token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v4
with:
application_id: ${{ vars.APPLICATION_ID }}
application_private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }}

- name: Dispatch Repository Event for ${{ github.event.inputs.chain }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ steps.get_workflow_token.outputs.token }}
repository: Chainsafe/infrastructure-general
event-type: deploy-baremetal-gossamer-${{ github.event.inputs.nodeType }}
client-payload: |
{
"ref": "refs/heads/main",
"inputs": {
"commit": "${{ github.event.inputs.commit }}",
"nodeType": "${{ github.event.inputs.nodeType }}",
"chain": "${{ github.event.inputs.chain }}",
"gossamerStartArgs": "${{ github.event.inputs.gossamerStartArgs }}"
}
}
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const (
// DefaultDiscoveryInterval is the default discovery interval
DefaultDiscoveryInterval = 10 * time.Second
// DefaultMinPeers is the default minimum number of peers
DefaultMinPeers = 0
DefaultMinPeers = 5
// DefaultMaxPeers is the default maximum number of peers
DefaultMaxPeers = 50

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/usage/command-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ These are the flags that can be used with the `gossamer` command
By default, all modules log 'info'.
The global log level can be set with --log global=debug
--max-peers Maximum number of peers to connect to (default 50)
--min-peers Minimum number of peers to connect to (default 0)
--min-peers Minimum number of peers to connect to (default 5)
--name Name of the node
--no-bootstrap Disables network bootstrapping (mdns still enabled)
--no-mdns Disables network mdns discovery
Expand Down
8 changes: 8 additions & 0 deletions dot/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func Test_createRuntimeStorage(t *testing.T) {
stateSrvc, err := builder.createStateService(config)
require.NoError(t, err)

require.NoError(t, stateSrvc.Start())

tests := []struct {
name string
service *state.Service
Expand All @@ -51,6 +53,8 @@ func Test_createRuntimeStorage(t *testing.T) {
assert.NotNil(t, got.PersistentStorage)
})
}

require.NoError(t, stateSrvc.Stop())
}

func Test_createSystemService(t *testing.T) {
Expand All @@ -65,6 +69,8 @@ func Test_createSystemService(t *testing.T) {
stateSrvc, err := builder.createStateService(config)
require.NoError(t, err)

require.NoError(t, stateSrvc.Start())

type args struct {
cfg *types.SystemInfo
service *state.Service
Expand Down Expand Up @@ -96,6 +102,8 @@ func Test_createSystemService(t *testing.T) {
}
})
}

require.NoError(t, stateSrvc.Stop())
}

func Test_newInMemoryDB(t *testing.T) {
Expand Down
6 changes: 1 addition & 5 deletions dot/sync/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,7 @@ func (s *SyncService) waitWorkers() {
}

err = s.network.BlockAnnounceHandshake(bestBlockHeader)
if err != nil {
if errors.Is(err, network.ErrNoPeersConnected) {
continue
}

if err != nil && !errors.Is(err, network.ErrNoPeersConnected) {
logger.Criticalf("waiting workers: %s", err.Error())
break
}
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/ChainSafe/gossamer
require (
github.com/ChainSafe/go-schnorrkel v1.1.0
github.com/OneOfOne/xxhash v1.2.8
github.com/adrg/xdg v0.5.1
github.com/adrg/xdg v0.5.3
github.com/btcsuite/btcd/btcutil v1.1.6
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
github.com/centrifuge/go-substrate-rpc-client/v4 v4.1.0
Expand All @@ -13,7 +13,7 @@ require (
github.com/dgraph-io/ristretto v1.0.0
github.com/disiqueira/gotree v1.0.0
github.com/ethereum/go-ethereum v1.14.11
github.com/fatih/color v1.17.0
github.com/fatih/color v1.18.0
github.com/gammazero/deque v0.2.1
github.com/go-playground/validator/v10 v10.22.1
github.com/google/go-cmp v0.6.0
Expand All @@ -30,7 +30,7 @@ require (
github.com/libp2p/go-libp2p v0.36.2
github.com/libp2p/go-libp2p-kad-dht v0.27.0
github.com/minio/sha256-simd v1.0.1
github.com/multiformats/go-multiaddr v0.13.0
github.com/multiformats/go-multiaddr v0.14.0
github.com/nanobox-io/golang-scribble v0.0.0-20190309225732-aa3e7c118975
github.com/prometheus/client_golang v1.20.5
github.com/prometheus/client_model v0.6.1
Expand Down Expand Up @@ -76,7 +76,7 @@ require (
github.com/flynn/noise v1.1.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.4 // indirect
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand Down Expand Up @@ -207,7 +207,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8
github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q=
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/adrg/xdg v0.5.1 h1:Im8iDbEFARltY09yOJlSGu4Asjk2vF85+3Dyru8uJ0U=
github.com/adrg/xdg v0.5.1/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ=
github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78=
github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand Down Expand Up @@ -140,8 +140,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum/go-ethereum v1.14.11 h1:8nFDCUUE67rPc6AKxFj7JKaOa2W/W1Rse3oS6LvvxEY=
github.com/ethereum/go-ethereum v1.14.11/go.mod h1:+l/fr42Mma+xBnhefL/+z11/hcmJ2egl+ScIVPjhc7E=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/flynn/noise v1.1.0 h1:KjPQoQCEFdZDiP03phOvGi11+SVVhBG2wOWAorLsstg=
github.com/flynn/noise v1.1.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag=
Expand All @@ -153,8 +153,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy+R0LnH8I=
github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s=
github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc=
github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc=
github.com/gammazero/deque v0.2.1 h1:qSdsbG6pgp6nL7A0+K/B7s12mcCY/5l5SIUpMOl+dC0=
github.com/gammazero/deque v0.2.1/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU=
github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps=
Expand Down Expand Up @@ -420,8 +420,8 @@ github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9
github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4=
github.com/multiformats/go-multiaddr v0.1.1/go.mod h1:aMKBKNEYmzmDmxfX88/vz+J5IU55txyt0p4aiWVohjo=
github.com/multiformats/go-multiaddr v0.2.0/go.mod h1:0nO36NvPpyV4QzvTLi/lafl2y95ncPj0vFwVF6k6wJ4=
github.com/multiformats/go-multiaddr v0.13.0 h1:BCBzs61E3AGHcYYTv8dqRH43ZfyrqM8RXVPT8t13tLQ=
github.com/multiformats/go-multiaddr v0.13.0/go.mod h1:sBXrNzucqkFJhvKOiwwLyqamGa/P5EIXNPLovyhQCII=
github.com/multiformats/go-multiaddr v0.14.0 h1:bfrHrJhrRuh/NXH5mCnemjpbGjzRw/b+tJFOD41g2tU=
github.com/multiformats/go-multiaddr v0.14.0/go.mod h1:6EkVAxtznq2yC3QT5CM1UTAwG0GTP3EWAIcjHuzQ+r4=
github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A=
github.com/multiformats/go-multiaddr-dns v0.3.1/go.mod h1:G/245BRQ6FJGmryJCrOuTdB37AMA5AMOVuO6NY3JwTk=
github.com/multiformats/go-multiaddr-fmt v0.1.0 h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E=
Expand Down Expand Up @@ -750,8 +750,8 @@ golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down
2 changes: 1 addition & 1 deletion internal/primitives/core/hash/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (h256 H256) Bytes() []byte {

// String returns string representation of H256
func (h256 H256) String() string {
return fmt.Sprintf("%v", h256.Bytes())
return fmt.Sprintf("%x", h256.Bytes())
}

// Length returns the byte length of H256
Expand Down
16 changes: 15 additions & 1 deletion lib/grandpa/grandpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ type Service struct {
bestFinalCandidate map[uint64]*Vote // map of round number -> best final candidate

// channels for communication with other services
finalisedCh chan *types.FinalisationInfo
finalisedCh chan *types.FinalisationInfo
neighborMsgChan chan neighborData

telemetry Telemetry

neighborTracker *neighborTracker
}

// Config represents a GRANDPA service configuration
Expand Down Expand Up @@ -130,6 +133,8 @@ func NewService(cfg *Config) (*Service, error) {
cfg.Interval = defaultGrandpaInterval
}

neighborMsgChan := make(chan neighborData)

ctx, cancel := context.WithCancel(context.Background())
s := &Service{
ctx: ctx,
Expand All @@ -151,8 +156,11 @@ func NewService(cfg *Config) (*Service, error) {
finalisedCh: finalisedCh,
interval: cfg.Interval,
telemetry: cfg.Telemetry,
neighborMsgChan: neighborMsgChan,
}

s.neighborTracker = newNeighborTracker(s, neighborMsgChan)

if err := s.registerProtocol(); err != nil {
return nil, err
}
Expand All @@ -165,6 +173,8 @@ func NewService(cfg *Config) (*Service, error) {

// Start begins the GRANDPA finality service
func (s *Service) Start() error {
s.neighborTracker.Start()

// if we're not an authority, we don't need to worry about the voting process.
// the grandpa service is only used to verify incoming block justifications
if !s.authority {
Expand All @@ -191,6 +201,9 @@ func (s *Service) Stop() error {
s.cancel()
s.blockState.FreeFinalisedNotifierChannel(s.finalisedCh)

s.neighborTracker.Stop()
close(s.neighborTracker.neighborMsgChan)

if !s.authority {
return nil
}
Expand Down Expand Up @@ -1146,6 +1159,7 @@ func (s *Service) handleCommitMessage(commitMessage *CommitMessage) error {
commitMessage.Vote.Hash, uint(commitMessage.Vote.Number))
if err != nil {
if errors.Is(err, database.ErrNotFound) {
logger.Warnf("Not able to verify, adding commit to tracker")
s.tracker.addCommit(commitMessage)
}

Expand Down
18 changes: 9 additions & 9 deletions lib/grandpa/message_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
)

var (
ErrNeighbourVersionNotSupported = errors.New("neighbour version not supported")
)

// MessageHandler handles GRANDPA consensus messages
type MessageHandler struct {
grandpa *Service
Expand Down Expand Up @@ -63,8 +59,8 @@ func (h *MessageHandler) handleMessage(from peer.ID, m GrandpaMessage) (network.

return nil, nil //nolint:nilnil
case *NeighbourPacketV1:
// we can afford to not retry handling neighbour message, if it errors.
return nil, h.handleNeighbourMessage(msg)
h.handleNeighbourMessage(msg, from)
return nil, nil //nolint:nilnil
case *CatchUpRequest:
return h.handleCatchUpRequest(msg)
case *CatchUpResponse:
Expand All @@ -82,9 +78,13 @@ func (h *MessageHandler) handleMessage(from peer.ID, m GrandpaMessage) (network.
}
}

func (*MessageHandler) handleNeighbourMessage(_ *NeighbourPacketV1) error {
// TODO(#2931)
return nil
func (h *MessageHandler) handleNeighbourMessage(packet *NeighbourPacketV1, from peer.ID) {
logger.Debugf("handling neighbour message from peer %v with set id %v and round %v",
from.ShortString(), packet.SetID, packet.Round)
h.grandpa.neighborMsgChan <- neighborData{
peer: from,
neighborMsg: packet,
}
}

func (h *MessageHandler) handleCatchUpRequest(msg *CatchUpRequest) (*ConsensusMessage, error) {
Expand Down
4 changes: 4 additions & 0 deletions lib/grandpa/message_handler_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ func TestMessageHandler_NeighbourMessage(t *testing.T) {

gs, st := newTestService(t, aliceKeyPair)

gs.neighborTracker.Start()

ctrl := gomock.NewController(t)
telemetryMock := NewMockTelemetry(ctrl)

Expand Down Expand Up @@ -250,6 +252,8 @@ func TestMessageHandler_NeighbourMessage(t *testing.T) {
out, err := h.handleMessage("", NeighbourPacketV1)
require.NoError(t, err)
require.Nil(t, out)

gs.neighborTracker.Stop()
}

func TestMessageHandler_VerifyJustification_InvalidSig(t *testing.T) {
Expand Down
Loading

0 comments on commit 9b69564

Please sign in to comment.