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

fix(dot/digest): BABE NextEpochData and NextConfigData should be set on finalization #2339

Merged
merged 123 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from 121 commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
6139712
feat: include substrate docker image
EclesioMeloJunior Jan 31, 2022
8c3fb1d
chore: add substrate docker images
EclesioMeloJunior Feb 2, 2022
c0be6dc
chore: formatting and add depends on yaml key
EclesioMeloJunior Feb 2, 2022
eda4e4a
chore: add datadog stuff again
EclesioMeloJunior Feb 2, 2022
dae59e2
chore: use alice peer id
EclesioMeloJunior Feb 2, 2022
6ccf8fb
chore: split substrate docker compose services into another file
EclesioMeloJunior Feb 2, 2022
1407b3a
chore: enable prometheus external and add datadog
EclesioMeloJunior Feb 2, 2022
0d59fac
Merge branch 'development' into eclesio/substrate-docker-image
EclesioMeloJunior Feb 4, 2022
5108412
chore: keep substrate ports same as gossamer node ports
EclesioMeloJunior Feb 4, 2022
9fa7ffb
chore: expose rpc and ws calls in substrate docker file
EclesioMeloJunior Feb 4, 2022
71a8f5e
chore: use same dns name and p2p id
EclesioMeloJunior Feb 4, 2022
f1fea2d
chore: use same key for both alice gossamer and substrate nodes
EclesioMeloJunior Feb 4, 2022
9b485f6
chore: fix dd golang cmd
EclesioMeloJunior Feb 4, 2022
cff9c8c
Update devnet/README.md
EclesioMeloJunior Feb 7, 2022
262b329
Update devnet/README.md
EclesioMeloJunior Feb 7, 2022
012b4b9
chore: update `substrate_alice` readme info
EclesioMeloJunior Feb 7, 2022
1d158a3
Update devnet/README.md
EclesioMeloJunior Feb 7, 2022
f0689ee
chore: add `/tcp` to expose ports
EclesioMeloJunior Feb 7, 2022
604ce4b
Merge branch 'eclesio/substrate-docker-image' of github.com:ChainSafe…
EclesioMeloJunior Feb 7, 2022
237647a
chore: adjust args and envs
EclesioMeloJunior Feb 7, 2022
ae0429e
chore: pin prometheus version, add read only volume and add trailing …
EclesioMeloJunior Feb 7, 2022
843d361
chore: improve README.md
EclesioMeloJunior Feb 7, 2022
bcb134e
Merge branch 'development' into eclesio/substrate-docker-image
EclesioMeloJunior Feb 7, 2022
579136c
chore: add port 7001 explicitly
EclesioMeloJunior Feb 7, 2022
c49bcf0
chore: remove prometheus `--config.file` flag
EclesioMeloJunior Feb 8, 2022
f03093a
chore: use env to chain
EclesioMeloJunior Feb 8, 2022
25946ca
update substrate_bob.Dockerfile
EclesioMeloJunior Feb 8, 2022
e8c1e9d
Merge branch 'development' into eclesio/substrate-docker-image
EclesioMeloJunior Feb 9, 2022
15f1377
chore: add datadog-agent start to gssmr alice node
EclesioMeloJunior Feb 9, 2022
94c6a87
Merge branch 'eclesio/substrate-docker-image' of github.com:ChainSafe…
EclesioMeloJunior Feb 9, 2022
17fd1f2
chore: add comment about different but same node keys
EclesioMeloJunior Feb 16, 2022
90529c8
chore: IncrementSetID to return the nextSetID
EclesioMeloJunior Feb 16, 2022
a3a0635
chore: digest HandleDigests check !ok first
EclesioMeloJunior Feb 16, 2022
6a55d07
feat: store babe next epoch data only at finalised blocks
EclesioMeloJunior Mar 1, 2022
68377a0
Merge branch 'development' into eclesio/babe-next-epoch
EclesioMeloJunior Mar 1, 2022
993dcf2
Merge branch 'development' into eclesio/babe-next-epoch
EclesioMeloJunior Mar 1, 2022
b251fc0
Merge branch 'eclesio/babe-next-epoch' of github.com:ChainSafe/gossam…
EclesioMeloJunior Mar 1, 2022
aac29ab
feat: include substrate docker image
EclesioMeloJunior Jan 31, 2022
4b68de7
chore: add substrate docker images
EclesioMeloJunior Feb 2, 2022
5cc4bb5
chore: formatting and add depends on yaml key
EclesioMeloJunior Feb 2, 2022
863e410
chore: add datadog stuff again
EclesioMeloJunior Feb 2, 2022
943a047
chore: use alice peer id
EclesioMeloJunior Feb 2, 2022
cb11c99
chore: split substrate docker compose services into another file
EclesioMeloJunior Feb 2, 2022
29bbcff
chore: enable prometheus external and add datadog
EclesioMeloJunior Feb 2, 2022
8d7b8cb
chore: keep substrate ports same as gossamer node ports
EclesioMeloJunior Feb 4, 2022
6e13e85
chore: expose rpc and ws calls in substrate docker file
EclesioMeloJunior Feb 4, 2022
c4a7c07
chore: use same dns name and p2p id
EclesioMeloJunior Feb 4, 2022
a9e2977
chore: use same key for both alice gossamer and substrate nodes
EclesioMeloJunior Feb 4, 2022
c3b530c
chore: fix dd golang cmd
EclesioMeloJunior Feb 4, 2022
ca48211
Update devnet/README.md
EclesioMeloJunior Feb 7, 2022
c7409d2
Update devnet/README.md
EclesioMeloJunior Feb 7, 2022
45a7987
chore: update `substrate_alice` readme info
EclesioMeloJunior Feb 7, 2022
f319ebf
chore: add `/tcp` to expose ports
EclesioMeloJunior Feb 7, 2022
ad9396c
Update devnet/README.md
EclesioMeloJunior Mar 1, 2022
d5433be
chore: adjust args and envs
EclesioMeloJunior Feb 7, 2022
a7163f9
chore: pin prometheus version, add read only volume and add trailing …
EclesioMeloJunior Feb 7, 2022
6a0930d
chore: improve README.md
EclesioMeloJunior Feb 7, 2022
d2e50d3
chore: add port 7001 explicitly
EclesioMeloJunior Feb 7, 2022
0efccc0
chore: add datadog-agent start to gssmr alice node
EclesioMeloJunior Feb 9, 2022
97cd61b
chore: remove prometheus `--config.file` flag
EclesioMeloJunior Feb 8, 2022
c17eeed
chore: use env to chain
EclesioMeloJunior Feb 8, 2022
5a23168
update substrate_bob.Dockerfile
EclesioMeloJunior Feb 8, 2022
630ad29
chore: add comment about different but same node keys
EclesioMeloJunior Feb 16, 2022
624fbb1
chore: IncrementSetID to return the nextSetID
EclesioMeloJunior Feb 16, 2022
d9f8627
chore: digest HandleDigests check !ok first
EclesioMeloJunior Feb 16, 2022
79cb4bf
feat: store babe next epoch data only at finalised blocks
EclesioMeloJunior Mar 1, 2022
799315c
Merge branch 'eclesio/babe-next-epoch' of github.com:ChainSafe/gossam…
EclesioMeloJunior Mar 1, 2022
f728564
chore: resolve conflicts
EclesioMeloJunior Mar 2, 2022
3b9566d
chore: remove unused
EclesioMeloJunior Mar 4, 2022
57bfff4
chore: rename function and change log message
EclesioMeloJunior Mar 4, 2022
de52526
chore: fix babe next epoch data/config while not finalized chain
EclesioMeloJunior Mar 8, 2022
9691a91
chore: allow forks validate blocks using the right epoch data
EclesioMeloJunior Mar 9, 2022
9437e35
Merge branch 'development' into eclesio/babe-next-epoch
EclesioMeloJunior Mar 9, 2022
849c9a8
chore: add exported comments and improve VerifyBlock comment
EclesioMeloJunior Mar 9, 2022
3c78b35
chore: fix lint, removing shadowing
EclesioMeloJunior Mar 9, 2022
409d2eb
chore: promising integration test to cover babe digest handler
EclesioMeloJunior Mar 11, 2022
63bcd2b
chore: integration test added to babe verify block
EclesioMeloJunior Mar 11, 2022
51eb04c
chore: needs improvent at chain finalization
EclesioMeloJunior Mar 11, 2022
2d5f3d1
chore: integration test done!
EclesioMeloJunior Mar 11, 2022
20137f5
chore: fix lint
EclesioMeloJunior Mar 11, 2022
a66e755
Merge branch 'development' into eclesio/babe-next-epoch
EclesioMeloJunior Mar 14, 2022
e6f78e2
chore: addressing comments at digest pkg
EclesioMeloJunior Mar 14, 2022
eece1fe
chore: wrap errors at granpda pkg and fix lll at verify_integration_test
EclesioMeloJunior Mar 14, 2022
8afbded
Merge branch 'development' into eclesio/babe-next-epoch
EclesioMeloJunior Mar 18, 2022
de47880
chore: improve comments
EclesioMeloJunior Mar 18, 2022
83b7328
chore: improving state/epoch tests
EclesioMeloJunior Mar 21, 2022
ada7efd
chore: return wrapped error at `babe digest finalization`
EclesioMeloJunior Mar 23, 2022
8f2b866
chore: improve testing
EclesioMeloJunior Mar 23, 2022
9f824b4
chore: improve exported comment
EclesioMeloJunior Mar 23, 2022
aace7da
chore: improve exported comment
EclesioMeloJunior Mar 23, 2022
5fc2508
chore: improve error decription
EclesioMeloJunior Mar 23, 2022
1764f20
chore: improve error description
EclesioMeloJunior Mar 23, 2022
fc9856f
Merge branch 'eclesio/babe-next-epoch' of github.com:ChainSafe/gossam…
EclesioMeloJunior Mar 23, 2022
ee1de46
chore: reorg `HasConfigData` and `HasEpochData`
EclesioMeloJunior Mar 23, 2022
51e11f8
chore: add two mutexes for protect `nextEpoch` and `nextConfig`
EclesioMeloJunior Mar 23, 2022
63484f9
chore: improve exported comment
EclesioMeloJunior Mar 23, 2022
cd4b675
Merge branch 'development' into eclesio/babe-next-epoch
EclesioMeloJunior Mar 23, 2022
c9e34df
chore: change `GetEpochData` to check in the memory if database doesn…
EclesioMeloJunior Mar 23, 2022
b968c2a
chore: scope specific variables
EclesioMeloJunior Mar 23, 2022
4338cba
unneeded `\n`
EclesioMeloJunior Mar 24, 2022
1e1f99d
chore: fix unit tests
EclesioMeloJunior Mar 24, 2022
dc91c1b
Merge branch 'development' into eclesio/babe-next-epoch
EclesioMeloJunior Mar 24, 2022
8f60c9f
Merge branch 'development' into eclesio/babe-next-epoch
EclesioMeloJunior Mar 24, 2022
6b7e6ec
chore: git add fix exported func name
EclesioMeloJunior Mar 24, 2022
649c224
Merge branch 'eclesio/babe-next-epoch' of github.com:ChainSafe/gossam…
EclesioMeloJunior Mar 24, 2022
cfed2f0
chore: fix tests
EclesioMeloJunior Mar 24, 2022
7621e2f
chore: remove DigestHandler from core pkg
EclesioMeloJunior Mar 25, 2022
e880e8a
Merge branch 'development' into eclesio/babe-next-epoch
EclesioMeloJunior Mar 28, 2022
2ac2752
chore: get current epoch at next epoch data and next config data
EclesioMeloJunior Mar 28, 2022
70a114e
chore: check `err != nil` before check `err is not ErrKeyNotFound`
EclesioMeloJunior Mar 28, 2022
1df169b
chore: rename error var name
EclesioMeloJunior Mar 30, 2022
e02015a
chore: flip babe digest finalization
EclesioMeloJunior Mar 30, 2022
eff747e
chore: improve exported comment
EclesioMeloJunior Mar 30, 2022
1694db0
chore: separate not related conditions
EclesioMeloJunior Mar 30, 2022
9b234c7
chore: remove DigestHandler from `dot/core` pkg
EclesioMeloJunior Mar 30, 2022
5193288
chore: changing `String()` method owner
EclesioMeloJunior Mar 30, 2022
c0665fc
chore: change function name to `persistBABEDigestsForNextEpoch`
EclesioMeloJunior Mar 30, 2022
56a1277
chore: fix typo
EclesioMeloJunior Mar 30, 2022
3715b00
chore: remove `nilnil` lint warn
EclesioMeloJunior Mar 30, 2022
094d32d
chore: remove unused core.DigestHandler mocks
EclesioMeloJunior Mar 30, 2022
054b942
chore: fix
EclesioMeloJunior Mar 30, 2022
42ec9e4
chore: unexport functions
EclesioMeloJunior Mar 31, 2022
5083234
chore: fix integration tests
EclesioMeloJunior Mar 31, 2022
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
3 changes: 0 additions & 3 deletions dot/core/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ var (
// ErrEmptyRuntimeCode is returned when the storage :code is empty
ErrEmptyRuntimeCode = errors.New("new :code is empty")

// ErrNilDigestHandler is returned when the DigestHandler interface is nil
ErrNilDigestHandler = errors.New("cannot have nil DigestHandler")

errNilCodeSubstitutedState = errors.New("cannot have nil CodeSubstitutedStat")
)

Expand Down
5 changes: 0 additions & 5 deletions dot/core/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"path/filepath"
"testing"

"github.com/ChainSafe/gossamer/dot/digest"
"github.com/ChainSafe/gossamer/dot/network"
"github.com/ChainSafe/gossamer/dot/state"
"github.com/ChainSafe/gossamer/internal/log"
Expand All @@ -32,10 +31,6 @@ func NewTestService(t *testing.T, cfg *Config) *Service {
cfg = &Config{}
}

if cfg.DigestHandler == nil {
cfg.DigestHandler = &digest.Handler{} // only for nil check in NewService
}

if cfg.Keystore == nil {
cfg.Keystore = keystore.NewGlobalKeystore()
kp, err := sr25519.GenerateKeypair()
Expand Down
7 changes: 1 addition & 6 deletions dot/core/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/ChainSafe/gossamer/lib/transaction"
)

//go:generate mockgen -destination=mock_core_test.go -package $GOPACKAGE . BlockState,StorageState,TransactionState,Network,EpochState,CodeSubstitutedState,DigestHandler
//go:generate mockgen -destination=mock_core_test.go -package $GOPACKAGE . BlockState,StorageState,TransactionState,Network,EpochState,CodeSubstitutedState

// BlockState interface for block state methods
type BlockState interface {
Expand Down Expand Up @@ -87,8 +87,3 @@ type CodeSubstitutedState interface {
LoadCodeSubstitutedBlockHash() common.Hash
StoreCodeSubstitutedBlockHash(hash common.Hash) error
}

// DigestHandler is the interface for the consensus digest handler
type DigestHandler interface {
HandleDigests(header *types.Header)
}
8 changes: 0 additions & 8 deletions dot/core/messages_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ func TestService_HandleBlockProduced(t *testing.T) {
Keystore: keystore.NewGlobalKeystore(),
}

digestHandler := NewMockDigestHandler(ctrl)
digestHandler.EXPECT().HandleDigests(gomock.AssignableToTypeOf(new(types.Header)))
cfg.DigestHandler = digestHandler

s := NewTestService(t, cfg)
err := s.Start()
require.NoError(t, err)
Expand Down Expand Up @@ -137,9 +133,6 @@ func TestService_HandleTransactionMessage(t *testing.T) {
telemetryMock := NewMockClient(ctrl)
telemetryMock.EXPECT().SendMessage(gomock.Any()).AnyTimes()

digestHandler := NewMockDigestHandler(ctrl)
digestHandler.EXPECT().HandleDigests(gomock.AssignableToTypeOf(new(types.Header)))

net := NewMockNetwork(ctrl)
net.EXPECT().GossipMessage(gomock.AssignableToTypeOf(new(network.TransactionMessage))).AnyTimes()
net.EXPECT().IsSynced().Return(true).AnyTimes()
Expand All @@ -151,7 +144,6 @@ func TestService_HandleTransactionMessage(t *testing.T) {
cfg := &Config{
Keystore: ks,
TransactionState: state.NewTransactionState(telemetryMock),
DigestHandler: digestHandler,
Network: net,
}

Expand Down
37 changes: 1 addition & 36 deletions dot/core/mock_core_test.go

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

10 changes: 0 additions & 10 deletions dot/core/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ type Service struct {
storageState StorageState
transactionState TransactionState
net Network
digestHandler DigestHandler

// map of code substitutions keyed by block hash
codeSubstitute map[common.Hash]string
Expand All @@ -71,7 +70,6 @@ type Config struct {
Network Network
Keystore *keystore.GlobalKeystore
Runtime runtime.Instance
DigestHandler DigestHandler

CodeSubstitutes map[common.Hash]string
CodeSubstitutedState CodeSubstitutedState
Expand All @@ -96,10 +94,6 @@ func NewService(cfg *Config) (*Service, error) {
return nil, ErrNilNetwork
}

if cfg.DigestHandler == nil {
return nil, ErrNilDigestHandler
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
}

if cfg.CodeSubstitutedState == nil {
return nil, errNilCodeSubstitutedState
}
Expand All @@ -121,7 +115,6 @@ func NewService(cfg *Config) (*Service, error) {
blockAddCh: blockAddCh,
codeSubstitute: cfg.CodeSubstitutes,
codeSubstitutedState: cfg.CodeSubstitutedState,
digestHandler: cfg.DigestHandler,
}

return srv, nil
Expand Down Expand Up @@ -218,9 +211,6 @@ func (s *Service) handleBlock(block *types.Block, state *rtstorage.TrieState) er
logger.Debugf("imported block %s and stored state trie with root %s",
block.Header.Hash(), state.MustRoot())

// handle consensus digests
s.digestHandler.HandleDigests(&block.Header)

rt, err := s.blockState.GetRuntime(&block.Header.ParentHash)
if err != nil {
return err
Expand Down
7 changes: 0 additions & 7 deletions dot/core/service_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,6 @@ func TestAnnounceBlock(t *testing.T) {
Network: net,
}

digestHandler := NewMockDigestHandler(ctrl)
digestHandler.EXPECT().HandleDigests(gomock.AssignableToTypeOf(new(types.Header)))
cfg.DigestHandler = digestHandler

s := NewTestService(t, cfg)
err := s.Start()
require.NoError(t, err)
Expand Down Expand Up @@ -583,9 +579,6 @@ func TestService_GetRuntimeVersion(t *testing.T) {
func TestService_HandleSubmittedExtrinsic(t *testing.T) {
cfg := &Config{}
ctrl := gomock.NewController(t)
digestHandler := NewMockDigestHandler(ctrl)
digestHandler.EXPECT().HandleDigests(gomock.AssignableToTypeOf(new(types.Header)))
cfg.DigestHandler = digestHandler

net := NewMockNetwork(ctrl)
net.EXPECT().GossipMessage(gomock.AssignableToTypeOf(new(network.TransactionMessage)))
Expand Down
36 changes: 13 additions & 23 deletions dot/core/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,15 @@ func Test_Service_handleCodeSubstitution(t *testing.T) {

func Test_Service_handleBlock(t *testing.T) {
t.Parallel()

execTest := func(t *testing.T, s *Service, block *types.Block, trieState *rtstorage.TrieState, expErr error) {
err := s.handleBlock(block, trieState)
assert.ErrorIs(t, err, expErr)
if expErr != nil {
assert.EqualError(t, err, expErr.Error())
}
}

t.Run("nil input", func(t *testing.T) {
t.Parallel()
service := &Service{}
Expand Down Expand Up @@ -366,13 +368,10 @@ func Test_Service_handleBlock(t *testing.T) {
mockBlockState := NewMockBlockState(ctrl)
mockBlockState.EXPECT().AddBlock(&block).Return(blocktree.ErrBlockExists)
mockBlockState.EXPECT().GetRuntime(&block.Header.ParentHash).Return(nil, errTestDummyError)
mockDigestHandler := NewMockDigestHandler(ctrl)
mockDigestHandler.EXPECT().HandleDigests(&block.Header)

service := &Service{
storageState: mockStorageState,
blockState: mockBlockState,
digestHandler: mockDigestHandler,
storageState: mockStorageState,
blockState: mockBlockState,
}
execTest(t, service, &block, trieState, errTestDummyError)
})
Expand All @@ -396,13 +395,10 @@ func Test_Service_handleBlock(t *testing.T) {
mockBlockState.EXPECT().GetRuntime(&block.Header.ParentHash).Return(runtimeMock, nil)
mockBlockState.EXPECT().HandleRuntimeChanges(trieState, runtimeMock, block.Header.Hash()).
Return(errTestDummyError)
mockDigestHandler := NewMockDigestHandler(ctrl)
mockDigestHandler.EXPECT().HandleDigests(&block.Header)

service := &Service{
storageState: mockStorageState,
blockState: mockBlockState,
digestHandler: mockDigestHandler,
storageState: mockStorageState,
blockState: mockBlockState,
}
execTest(t, service, &block, trieState, errTestDummyError)
})
Expand All @@ -425,14 +421,11 @@ func Test_Service_handleBlock(t *testing.T) {
mockBlockState.EXPECT().AddBlock(&block).Return(blocktree.ErrBlockExists)
mockBlockState.EXPECT().GetRuntime(&block.Header.ParentHash).Return(runtimeMock, nil)
mockBlockState.EXPECT().HandleRuntimeChanges(trieState, runtimeMock, block.Header.Hash()).Return(nil)
mockDigestHandler := NewMockDigestHandler(ctrl)
mockDigestHandler.EXPECT().HandleDigests(&block.Header)

service := &Service{
storageState: mockStorageState,
blockState: mockBlockState,
digestHandler: mockDigestHandler,
ctx: context.Background(),
storageState: mockStorageState,
blockState: mockBlockState,
ctx: context.Background(),
}
execTest(t, service, &block, trieState, nil)
})
Expand Down Expand Up @@ -488,17 +481,14 @@ func Test_Service_HandleBlockProduced(t *testing.T) {
mockBlockState.EXPECT().AddBlock(&block).Return(blocktree.ErrBlockExists)
mockBlockState.EXPECT().GetRuntime(&block.Header.ParentHash).Return(runtimeMock, nil)
mockBlockState.EXPECT().HandleRuntimeChanges(trieState, runtimeMock, block.Header.Hash()).Return(nil)
mockDigestHandler := NewMockDigestHandler(ctrl)
mockDigestHandler.EXPECT().HandleDigests(&block.Header)
mockNetwork := NewMockNetwork(ctrl)
mockNetwork.EXPECT().GossipMessage(msg)

service := &Service{
storageState: mockStorageState,
blockState: mockBlockState,
digestHandler: mockDigestHandler,
net: mockNetwork,
ctx: context.Background(),
storageState: mockStorageState,
blockState: mockBlockState,
net: mockNetwork,
ctx: context.Background(),
}
execTest(t, service, &block, trieState, nil)
})
Expand Down
Loading