Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(lib/sync): introduce fullsync strategy #4114

Open
wants to merge 83 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
01b7bec
feat: implement in-memory-trie iterator and prefixed iterator
EclesioMeloJunior Jul 5, 2024
d3004f9
chore: adjustment to fn replacement
EclesioMeloJunior Jul 5, 2024
1bb4eda
chore: add license and fix test
EclesioMeloJunior Jul 5, 2024
ef53a1f
chore: fix lint issues
EclesioMeloJunior Jul 5, 2024
396b873
feat: remove usage of `sorted keys`
EclesioMeloJunior Jul 5, 2024
53288b3
chore: remove unneeded logger
EclesioMeloJunior Jul 6, 2024
c8da583
wip sync
EclesioMeloJunior Jul 7, 2024
a591076
chore: strategies does not report or block peers
EclesioMeloJunior Jul 25, 2024
e9d1bcc
wip: fullsync strategy working, need to polish the libsync servic
EclesioMeloJunior Jul 29, 2024
93aca34
Merge branch 'development' into eclesio/sync-strategy
EclesioMeloJunior Jul 29, 2024
41dde9d
chore: bring sync status
EclesioMeloJunior Jul 29, 2024
88b7d3b
chore: removing panics
EclesioMeloJunior Jul 29, 2024
996baaa
chore: removing unneeded code
EclesioMeloJunior Jul 29, 2024
c1e43c8
chore: add test `TestFullSyncIsFinished`
EclesioMeloJunior Aug 6, 2024
9622544
chore: use yaml file for test data
EclesioMeloJunior Aug 6, 2024
316214a
chore: remove old sync package
EclesioMeloJunior Aug 6, 2024
1aa68d4
Merge branch 'development' into eclesio/sync-strategy
EclesioMeloJunior Aug 7, 2024
959769c
chore: create `unready_blocks.go`
EclesioMeloJunior Aug 7, 2024
b950cda
chore: fix lint
EclesioMeloJunior Aug 7, 2024
8479f23
chore: ignore forks when ancestor is behind highest finalized block
EclesioMeloJunior Aug 7, 2024
124aca8
Merge branch 'eclesio/sync-strategy' of github.com:ChainSafe/gossamer…
EclesioMeloJunior Aug 7, 2024
ec88b94
chore: small updts
EclesioMeloJunior Aug 7, 2024
f291705
chore: listening for stop channel on `runSyncEngine`
EclesioMeloJunior Aug 12, 2024
66f8412
chore: address comments
EclesioMeloJunior Aug 23, 2024
e73bf16
Merge branch 'development' into eclesio/sync-strategy
EclesioMeloJunior Aug 26, 2024
a3fc14e
chore: resolve lll warn
EclesioMeloJunior Aug 26, 2024
0ff9ec9
chore: make license
EclesioMeloJunior Aug 26, 2024
f59e7f2
chore: solve invalid block number type while encoding block request m…
EclesioMeloJunior Aug 27, 2024
2acf762
chore: update the ci to use `lib/sync`
EclesioMeloJunior Aug 27, 2024
eb0ca27
chore: simplify the message construction to use just uint32
EclesioMeloJunior Aug 27, 2024
1d4295f
chore: re-add sync block response handler
EclesioMeloJunior Aug 28, 2024
2048a9e
chore: implement `HighestBlock` and `IsSynced`
EclesioMeloJunior Aug 28, 2024
3467611
Merge branch 'development' into eclesio/sync-strategy
EclesioMeloJunior Aug 28, 2024
625f00e
chore: fix lint warns
EclesioMeloJunior Aug 28, 2024
e533c36
Merge branch 'eclesio/sync-strategy' of github.com:ChainSafe/gossamer…
EclesioMeloJunior Aug 28, 2024
f4615e4
chore: remove unneeded code
EclesioMeloJunior Aug 28, 2024
43eef82
chore: remove unneeded comment
EclesioMeloJunior Aug 29, 2024
c22065f
chore: introduce concurrency and perpetual tip sync chase
EclesioMeloJunior Aug 30, 2024
2f0b3a0
while reporting, create a node in peerset
EclesioMeloJunior Aug 31, 2024
31b9252
Merge branch 'development' into eclesio/sync-strategy
P1sar Sep 4, 2024
d339546
Merge branch 'development' into eclesio/sync-strategy
EclesioMeloJunior Sep 9, 2024
195a9be
chore: propagate block announce
EclesioMeloJunior Sep 10, 2024
ec384c7
wip: remove wrong mtx Lock, remove neighbors message
EclesioMeloJunior Sep 12, 2024
a54572f
chore: remove unneeded log level
EclesioMeloJunior Sep 12, 2024
8546176
chore: if ahead of target dont ask for more blocks
EclesioMeloJunior Sep 13, 2024
8f63325
chore: remove unneeded goto
EclesioMeloJunior Sep 13, 2024
1f48f65
chore: adjust on block announce
EclesioMeloJunior Sep 13, 2024
399eb9b
chore: rollback integration tests to use /dot/sync
EclesioMeloJunior Sep 13, 2024
e554d3f
chore: rollback changes on core pkg
EclesioMeloJunior Sep 13, 2024
f233d05
chore: TODO(#2931)
EclesioMeloJunior Sep 13, 2024
330444c
chore: fix `removeIrrelevantFragments` out of bounds panic
EclesioMeloJunior Sep 13, 2024
2eda142
Merge branch 'development' into eclesio/sync-strategy
EclesioMeloJunior Sep 13, 2024
b3434ec
add license
EclesioMeloJunior Sep 13, 2024
1b94210
chore: solve mocks mismatch and full block importer
EclesioMeloJunior Sep 13, 2024
d905e7d
chore: use snake case on testing names
EclesioMeloJunior Sep 13, 2024
8f86d9b
chore: TestBuildRequestMessage
EclesioMeloJunior Sep 13, 2024
ed6c755
chore: fix sync test
EclesioMeloJunior Sep 13, 2024
9dff75a
chore: address comments and lint
EclesioMeloJunior Sep 17, 2024
c8dcb15
Merge branch 'development' into eclesio/sync-strategy
EclesioMeloJunior Sep 17, 2024
cc71723
chore: use `GossipSuccessValue` to good block announced received
EclesioMeloJunior Sep 17, 2024
6e38bdc
Merge branch 'eclesio/sync-strategy' of github.com:ChainSafe/gossamer…
EclesioMeloJunior Sep 17, 2024
1422414
improve test suite
EclesioMeloJunior Sep 19, 2024
2c11956
chore: remove target calculation using mean
EclesioMeloJunior Sep 19, 2024
b6a0b9d
chore: resolve lll
EclesioMeloJunior Sep 19, 2024
d3920d1
Update dot/sync/peer_view.go
EclesioMeloJunior Sep 19, 2024
793295c
Update dot/sync/fullsync_handle_block.go
EclesioMeloJunior Sep 19, 2024
b3e6bf4
chore: fix `TestHandleBlockAnnounceMessage`
EclesioMeloJunior Sep 19, 2024
04540d1
chore: fix `TestFullSyncIsFinished`
EclesioMeloJunior Sep 19, 2024
7f08a97
Merge branch 'development' into eclesio/sync-strategy
EclesioMeloJunior Sep 23, 2024
3263911
chore: resolve all conflicts
EclesioMeloJunior Sep 23, 2024
2ad6b37
chore: rename `IsFinished -> Process` and add named returns
EclesioMeloJunior Sep 23, 2024
75a30cd
chore: fix small lint err
EclesioMeloJunior Sep 23, 2024
dff8a08
chore: fix `TestService_CreateBlockResponse`
EclesioMeloJunior Sep 23, 2024
50c4594
chore: fix test `TestFullSyncNextActions`
EclesioMeloJunior Sep 23, 2024
ee3380b
chore: fix test `TestCreateNotificationsMessageHandler_BlockAnnounceH…
EclesioMeloJunior Sep 23, 2024
51e281c
chore: solve discovery test problem
EclesioMeloJunior Sep 23, 2024
f68623d
chore: fix `TestFullSyncBlockAnnounce`
EclesioMeloJunior Sep 23, 2024
c7fc7b3
chore: `TestFullSyncBlockAnnounce`
EclesioMeloJunior Sep 24, 2024
fc201d2
chore: remove unneeded file
EclesioMeloJunior Sep 24, 2024
2f4a242
Merge branch 'development' into eclesio/sync-strategy
EclesioMeloJunior Sep 25, 2024
6da0e74
chore: fix deepsource
EclesioMeloJunior Sep 25, 2024
a8b7889
Merge branch 'eclesio/sync-strategy' of github.com:ChainSafe/gossamer…
EclesioMeloJunior Sep 25, 2024
2f5c469
chore: define min peers to 1
EclesioMeloJunior Sep 25, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
github.com/ChainSafe/gossamer/dot/state,
github.com/ChainSafe/gossamer/dot/digest,
github.com/ChainSafe/gossamer/dot/network,
github.com/ChainSafe/gossamer/dot/sync,
github.com/ChainSafe/gossamer/lib/sync,
github.com/ChainSafe/gossamer/lib/babe,
github.com/ChainSafe/gossamer/lib/grandpa,
]
Expand Down
60 changes: 0 additions & 60 deletions dot/core/service_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/ChainSafe/gossamer/dot/network"
"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"
Expand Down Expand Up @@ -210,65 +209,6 @@ func TestHandleChainReorg_NoReorg(t *testing.T) {
require.NoError(t, err)
}

func TestHandleChainReorg_WithReorg_Trans(t *testing.T) {
t.Skip() // TODO: tx fails to validate in handleChainReorg() with "Invalid transaction" (#1026)
s := NewTestService(t, nil)
bs := s.blockState

parent, err := bs.BestBlockHeader()
require.NoError(t, err)

bestBlockHash := s.blockState.BestBlockHash()
rt, err := s.blockState.GetRuntime(bestBlockHash)
require.NoError(t, err)

block1 := sync.BuildBlock(t, rt, parent, nil)
bs.StoreRuntime(block1.Header.Hash(), rt)
err = bs.AddBlock(block1)
require.NoError(t, err)

block2 := sync.BuildBlock(t, rt, &block1.Header, nil)
bs.StoreRuntime(block2.Header.Hash(), rt)
err = bs.AddBlock(block2)
require.NoError(t, err)

block3 := sync.BuildBlock(t, rt, &block2.Header, nil)
bs.StoreRuntime(block3.Header.Hash(), rt)
err = bs.AddBlock(block3)
require.NoError(t, err)

block4 := sync.BuildBlock(t, rt, &block3.Header, nil)
bs.StoreRuntime(block4.Header.Hash(), rt)
err = bs.AddBlock(block4)
require.NoError(t, err)

block5 := sync.BuildBlock(t, rt, &block4.Header, nil)
bs.StoreRuntime(block5.Header.Hash(), rt)
err = bs.AddBlock(block5)
require.NoError(t, err)

block31 := sync.BuildBlock(t, rt, &block2.Header, nil)
bs.StoreRuntime(block31.Header.Hash(), rt)
err = bs.AddBlock(block31)
require.NoError(t, err)

nonce := uint64(0)

// Add extrinsic to block `block41`
ext := createExtrinsic(t, rt, bs.(*state.BlockState).GenesisHash(), nonce)

block41 := sync.BuildBlock(t, rt, &block31.Header, ext)
bs.StoreRuntime(block41.Header.Hash(), rt)
err = bs.AddBlock(block41)
require.NoError(t, err)

err = s.handleChainReorg(block41.Header.Hash(), block5.Header.Hash())
require.NoError(t, err)

pending := s.transactionState.(*state.TransactionState).Pending()
require.Equal(t, 1, len(pending))
}

func TestHandleChainReorg_WithReorg_NoTransactions(t *testing.T) {
s := NewTestService(t, nil)
const height = 5
Expand Down
5 changes: 2 additions & 3 deletions dot/mock_node_builder_test.go

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

28 changes: 14 additions & 14 deletions dot/network/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ func TestAscendingBlockRequest(t *testing.T) {
three := uint32(3)
maxResponseSize := uint32(messages.MaxBlocksInResponse)
cases := map[string]struct {
startNumber, targetNumber uint
startNumber, targetNumber uint32
expectedBlockRequestMessage []*messages.BlockRequestMessage
expectedTotalOfBlocksRequested uint32
}{
Expand All @@ -446,7 +446,7 @@ func TestAscendingBlockRequest(t *testing.T) {
expectedBlockRequestMessage: []*messages.BlockRequestMessage{
{
RequestedData: messages.BootstrapRequestData,
StartingBlock: *variadic.MustNewUint32OrHash(uint32(10)),
StartingBlock: *variadic.Uint32OrHashFrom(uint32(10)),
Direction: messages.Ascending,
Max: &one,
},
Expand All @@ -461,7 +461,7 @@ func TestAscendingBlockRequest(t *testing.T) {
expectedBlockRequestMessage: []*messages.BlockRequestMessage{
{
RequestedData: messages.BootstrapRequestData,
StartingBlock: *variadic.MustNewUint32OrHash(uint32(1)),
StartingBlock: *variadic.Uint32OrHashFrom(uint32(1)),
Direction: messages.Ascending,
Max: &maxResponseSize,
},
Expand All @@ -475,63 +475,62 @@ func TestAscendingBlockRequest(t *testing.T) {
expectedBlockRequestMessage: []*messages.BlockRequestMessage{
{
RequestedData: messages.BootstrapRequestData,
StartingBlock: *variadic.MustNewUint32OrHash(uint32(1)),
StartingBlock: *variadic.Uint32OrHashFrom(uint32(1)),
Direction: messages.Ascending,
Max: &maxResponseSize,
},
{
RequestedData: messages.BootstrapRequestData,
StartingBlock: *variadic.MustNewUint32OrHash(uint32(129)),
StartingBlock: *variadic.Uint32OrHashFrom(uint32(129)),
Direction: messages.Ascending,
Max: &maxResponseSize,
},
{
RequestedData: messages.BootstrapRequestData,
StartingBlock: *variadic.MustNewUint32OrHash(uint32(257)),
StartingBlock: *variadic.Uint32OrHashFrom(uint32(257)),
Direction: messages.Ascending,
Max: &maxResponseSize,
},
{
RequestedData: messages.BootstrapRequestData,
StartingBlock: *variadic.MustNewUint32OrHash(uint32(385)),
StartingBlock: *variadic.Uint32OrHashFrom(uint32(385)),
Direction: messages.Ascending,
Max: &maxResponseSize,
},
},
},

"requesting_4_chunks_of_128_plus_3_blocks": {
startNumber: 1,
targetNumber: (128 * 4) + 3,
expectedTotalOfBlocksRequested: 515,
expectedBlockRequestMessage: []*messages.BlockRequestMessage{
{
RequestedData: messages.BootstrapRequestData,
StartingBlock: *variadic.MustNewUint32OrHash(uint32(1)),
StartingBlock: *variadic.Uint32OrHashFrom(uint32(1)),
Direction: messages.Ascending,
Max: &maxResponseSize,
},
{
RequestedData: messages.BootstrapRequestData,
StartingBlock: *variadic.MustNewUint32OrHash(uint32(129)),
StartingBlock: *variadic.Uint32OrHashFrom(uint32(129)),
Direction: messages.Ascending,
Max: &maxResponseSize,
},
{
RequestedData: messages.BootstrapRequestData,
StartingBlock: *variadic.MustNewUint32OrHash(uint32(257)),
StartingBlock: *variadic.Uint32OrHashFrom(uint32(257)),
Direction: messages.Ascending,
Max: &maxResponseSize,
},
{
RequestedData: messages.BootstrapRequestData,
StartingBlock: *variadic.MustNewUint32OrHash(uint32(385)),
StartingBlock: *variadic.Uint32OrHashFrom(uint32(385)),
Direction: messages.Ascending,
Max: &maxResponseSize,
},
{
RequestedData: messages.BootstrapRequestData,
StartingBlock: *variadic.MustNewUint32OrHash(uint32(513)),
StartingBlock: *variadic.Uint32OrHashFrom(uint32(513)),
Direction: messages.Ascending,
Max: &three,
},
Expand All @@ -543,7 +542,8 @@ func TestAscendingBlockRequest(t *testing.T) {
tt := tt

t.Run(tname, func(t *testing.T) {
requests := messages.NewAscendingBlockRequests(tt.startNumber, tt.targetNumber, messages.BootstrapRequestData)
requests := messages.NewAscendingBlockRequests(tt.startNumber, tt.targetNumber,
messages.BootstrapRequestData)
require.Equal(t, tt.expectedBlockRequestMessage, requests)

acc := uint32(0)
Expand Down
17 changes: 11 additions & 6 deletions dot/network/messages/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func NewBlockRequest(startingBlock variadic.Uint32OrHash, amount uint32,
}
}

func NewAscendingBlockRequests(startNumber, targetNumber uint, requestedData byte) []*BlockRequestMessage {
func NewAscendingBlockRequests(startNumber, targetNumber uint32, requestedData byte) []*BlockRequestMessage {
if startNumber > targetNumber {
return []*BlockRequestMessage{}
}
Expand All @@ -82,7 +82,7 @@ func NewAscendingBlockRequests(startNumber, targetNumber uint, requestedData byt
// start and end block are the same, just request 1 block
if diff == 0 {
return []*BlockRequestMessage{
NewBlockRequest(*variadic.MustNewUint32OrHash(uint32(startNumber)), 1, requestedData, Ascending),
NewBlockRequest(*variadic.Uint32OrHashFrom(startNumber), 1, requestedData, Ascending),
}
}

Expand All @@ -99,22 +99,27 @@ func NewAscendingBlockRequests(startNumber, targetNumber uint, requestedData byt
}

reqs := make([]*BlockRequestMessage, numRequests)
for i := uint(0); i < numRequests; i++ {
for i := uint32(0); i < numRequests; i++ {
max := uint32(MaxBlocksInResponse)

lastIteration := numRequests - 1
if i == lastIteration && missingBlocks != 0 {
max = uint32(missingBlocks)
max = missingBlocks
}

start := variadic.MustNewUint32OrHash(startNumber)
start := variadic.Uint32OrHashFrom(startNumber)
reqs[i] = NewBlockRequest(*start, max, requestedData, Ascending)
startNumber += uint(max)
startNumber += max
}

return reqs
}

// RequestField returns true the field passed as argument exists in the request data
func (bm *BlockRequestMessage) RequestField(field byte) bool {
return (bm.RequestedData & field) == field
}

// String formats a BlockRequestMessage as a string
func (bm *BlockRequestMessage) String() string {
max := uint32(0)
Expand Down
12 changes: 12 additions & 0 deletions dot/network/mock_syncer_test.go

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

1 change: 1 addition & 0 deletions dot/network/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ func (s *Service) processMessage(msg peerset.Message) {
return
}
logger.Debugf("connection dropped successfully for peer %s", peerID)
s.syncer.OnConnectionClosed(peerID)
}
}

Expand Down
2 changes: 2 additions & 0 deletions dot/network/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type Syncer interface {

// CreateBlockResponse is called upon receipt of a BlockRequestMessage to create the response
CreateBlockResponse(peer.ID, *messages.BlockRequestMessage) (*messages.BlockResponseMessage, error)

OnConnectionClosed(peer.ID)
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
}

// TransactionHandler is the interface used by the transactions sub-protocol
Expand Down
7 changes: 3 additions & 4 deletions dot/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/ChainSafe/gossamer/dot/rpc"
"github.com/ChainSafe/gossamer/dot/state"
"github.com/ChainSafe/gossamer/dot/state/pruner"
dotsync "github.com/ChainSafe/gossamer/dot/sync"
"github.com/ChainSafe/gossamer/dot/system"
"github.com/ChainSafe/gossamer/dot/telemetry"
"github.com/ChainSafe/gossamer/dot/types"
Expand Down Expand Up @@ -64,7 +63,7 @@ type nodeBuilderIface interface {
net *network.Service, telemetryMailer Telemetry) (*grandpa.Service, error)
newSyncService(config *cfg.Config, st *state.Service, finalityGadget BlockJustificationVerifier,
verifier *babe.VerificationManager, cs *core.Service, net *network.Service,
telemetryMailer Telemetry) (*dotsync.Service, error)
telemetryMailer Telemetry) (network.Syncer, error)
createBABEService(config *cfg.Config, st *state.Service, ks KeyStore, cs *core.Service,
telemetryMailer Telemetry) (service *babe.Service, err error)
createSystemService(cfg *types.SystemInfo, stateSrvc *state.Service) (*system.Service, error)
Expand Down Expand Up @@ -382,7 +381,7 @@ func newNode(config *cfg.Config,
networkSrvc.SetSyncer(syncer)
networkSrvc.SetTransactionHandler(coreSrvc)
}
nodeSrvcs = append(nodeSrvcs, syncer)
nodeSrvcs = append(nodeSrvcs, syncer.(service))

bp, err := builder.createBABEService(config, stateSrvc, ks.Babe, coreSrvc, telemetryMailer)
if err != nil {
Expand All @@ -402,7 +401,7 @@ func newNode(config *cfg.Config,
blockProducer: bp,
system: sysSrvc,
blockFinality: fg,
syncer: syncer,
syncer: syncer.(rpc.SyncAPI),
}
rpcSrvc, err = builder.createRPCService(cRPCParams)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions dot/node_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
digest "github.com/ChainSafe/gossamer/dot/digest"
network "github.com/ChainSafe/gossamer/dot/network"
"github.com/ChainSafe/gossamer/dot/state"
dotsync "github.com/ChainSafe/gossamer/dot/sync"
"github.com/ChainSafe/gossamer/dot/sync"
system "github.com/ChainSafe/gossamer/dot/system"
"github.com/ChainSafe/gossamer/dot/telemetry"
"github.com/ChainSafe/gossamer/dot/types"
Expand Down Expand Up @@ -139,7 +139,7 @@ func TestNewNode(t *testing.T) {
m.EXPECT().newSyncService(initConfig, gomock.AssignableToTypeOf(&state.Service{}), &grandpa.Service{},
&babe.VerificationManager{}, &core.Service{}, gomock.AssignableToTypeOf(&network.Service{}),
gomock.AssignableToTypeOf(&telemetry.Mailer{})).
Return(&dotsync.Service{}, nil)
Return(&sync.SyncService{}, nil)
m.EXPECT().createBABEService(initConfig, gomock.AssignableToTypeOf(&state.Service{}), ks.Babe,
&core.Service{}, gomock.AssignableToTypeOf(&telemetry.Mailer{})).
Return(&babe.Service{}, nil)
Expand Down
5 changes: 5 additions & 0 deletions dot/peerset/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ const (
// GoodTransactionReason is the reason for used for good transaction.
GoodTransactionReason = "Good Transaction"

// NotRelevantBlockAnnounce when peer sends us a not relevant block
NotRelevantBlockAnnounceValue Reputation = -(1 << 2)
// BadTransactionReason when transaction import was not performed.
NotRelevantBlockAnnounceReason = "Not Relevant Block Announce"

// BadTransactionValue used when transaction import was not performed.
BadTransactionValue Reputation = -(1 << 12)
// BadTransactionReason when transaction import was not performed.
Expand Down
3 changes: 2 additions & 1 deletion dot/peerset/peerstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ func (ps *PeersState) addReputation(peerID peer.ID, change ReputationChange) (

node, has := ps.nodes[peerID]
if !has {
return 0, fmt.Errorf("%w: for peer id %s", ErrPeerDoesNotExist, peerID)
ps.insertPeer(0, peerID)
node = ps.nodes[peerID]
}

newReputation = node.addReputation(change.Value)
Expand Down
12 changes: 12 additions & 0 deletions dot/rpc/modules/mock_syncer_test.go

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

Loading
Loading