Skip to content

Commit

Permalink
Add warp sync provider
Browse files Browse the repository at this point in the history
  • Loading branch information
dimartiro committed Sep 18, 2024
1 parent f1e3ad3 commit 153c5ef
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 608 deletions.
27 changes: 16 additions & 11 deletions dot/state/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,18 @@ var (
// BlockState contains the historical block data of the blockchain, including block headers and bodies.
// It wraps the blocktree (which contains unfinalised blocks) and the database (which contains finalised blocks).
type BlockState struct {
bt *blocktree.BlockTree
baseState *BaseState
dbPath string
db BlockStateDatabase
lock sync.RWMutex
genesisHash common.Hash
lastFinalised common.Hash
lastRound uint64
lastSetID uint64
unfinalisedBlocks *hashToBlockMap
tries *Tries
bt *blocktree.BlockTree
baseState *BaseState
dbPath string
db BlockStateDatabase
lock sync.RWMutex
genesisHash common.Hash
lastFinalised common.Hash
lastRound uint64
lastSetID uint64
unfinalisedBlocks *hashToBlockMap
tries *Tries
authoritiesChanges types.AuthoritySetChange

// State variables
pausedLock sync.RWMutex
Expand Down Expand Up @@ -960,3 +961,7 @@ func (bs *BlockState) StoreRuntime(hash common.Hash, rt runtime.Instance) {
func (bs *BlockState) GetNonFinalisedBlocks() []common.Hash {
return bs.bt.GetAllBlocks()
}

func (bs *BlockState) GetAuthoritesChanges() types.AuthoritySetChange {
return bs.authoritiesChanges
}
36 changes: 36 additions & 0 deletions dot/types/grandpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,39 @@ type GrandpaEquivocationProof struct {
SetID uint64
Equivocation GrandpaEquivocationEnum
}

type AuthoritySetChangeEvent struct {
SetID uint64
Number uint
}

type AuthoritySetChange struct {
//changes maps block numbers to set ids
changesAt []uint
changes map[uint]uint64
}

func NewAuthoritySetChange() *AuthoritySetChange {
return &AuthoritySetChange{
changesAt: make([]uint, 0),
changes: make(map[uint]uint64),
}
}

func (asc *AuthoritySetChange) Insert(setID uint64, number uint) {
asc.changesAt = append(asc.changesAt, number)
asc.changes[number] = setID
}

func (asc *AuthoritySetChange) From(blockNumber uint) []AuthoritySetChangeEvent {
changes := make([]AuthoritySetChangeEvent, 0)
for _, blockNumber := range asc.changesAt {
changes = append(changes,
AuthoritySetChangeEvent{
setID: asc.changes[blockNumber],

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/digest)

unknown field setID in struct literal of type AuthoritySetChangeEvent

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / linting

unknown field setID in struct literal of type AuthoritySetChangeEvent

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / linting

unknown field setID in struct literal of type AuthoritySetChangeEvent

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / linting

unknown field setID in struct literal of type AuthoritySetChangeEvent

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/lib/babe)

unknown field setID in struct literal of type AuthoritySetChangeEvent

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / zombienet-tests

unknown field setID in struct literal of type AuthoritySetChangeEvent

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/rpc)

unknown field setID in struct literal of type AuthoritySetChangeEvent

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/network)

unknown field setID in struct literal of type AuthoritySetChangeEvent

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/lib/grandpa)

unknown field setID in struct literal of type AuthoritySetChangeEvent

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/rpc/modules)

unknown field setID in struct literal of type AuthoritySetChangeEvent

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/core)

unknown field setID in struct literal of type AuthoritySetChangeEvent

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / unit-tests

unknown field setID in struct literal of type AuthoritySetChangeEvent

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/state)

unknown field setID in struct literal of type AuthoritySetChangeEvent

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/sync)

unknown field setID in struct literal of type AuthoritySetChangeEvent

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot)

unknown field setID in struct literal of type AuthoritySetChangeEvent

Check failure on line 313 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/rpc/subscription)

unknown field setID in struct literal of type AuthoritySetChangeEvent
number: blockNumber,

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/digest)

unknown field number in struct literal of type AuthoritySetChangeEvent

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / linting

unknown field number in struct literal of type AuthoritySetChangeEvent) (typecheck)

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / linting

unknown field number in struct literal of type AuthoritySetChangeEvent) (typecheck)

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / linting

unknown field number in struct literal of type AuthoritySetChangeEvent) (typecheck)

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/lib/babe)

unknown field number in struct literal of type AuthoritySetChangeEvent

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / zombienet-tests

unknown field number in struct literal of type AuthoritySetChangeEvent

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/rpc)

unknown field number in struct literal of type AuthoritySetChangeEvent

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/network)

unknown field number in struct literal of type AuthoritySetChangeEvent

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/lib/grandpa)

unknown field number in struct literal of type AuthoritySetChangeEvent

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/rpc/modules)

unknown field number in struct literal of type AuthoritySetChangeEvent

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/core)

unknown field number in struct literal of type AuthoritySetChangeEvent

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / unit-tests

unknown field number in struct literal of type AuthoritySetChangeEvent

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/state)

unknown field number in struct literal of type AuthoritySetChangeEvent

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/sync)

unknown field number in struct literal of type AuthoritySetChangeEvent

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot)

unknown field number in struct literal of type AuthoritySetChangeEvent

Check failure on line 314 in dot/types/grandpa.go

View workflow job for this annotation

GitHub Actions / integration-tests (github.com/ChainSafe/gossamer/dot/rpc/subscription)

unknown field number in struct literal of type AuthoritySetChangeEvent
},
)
}
return changes
}
Loading

0 comments on commit 153c5ef

Please sign in to comment.