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

Feat/sovereign mainchain header sync #6558

Merged
merged 141 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
f37a7ef
FEAT: Move incomingHeaderProcessor package from sovereign to node
mariusmihaic Oct 18, 2024
efcd1d5
FEAT: RunTypeComponentsHolder for incoming header processor
mariusmihaic Oct 18, 2024
be649c7
CLN: Interfaces
mariusmihaic Oct 18, 2024
97a9409
CLN: incomingHeaderHandlerFactory_test.go + refactor factory params
mariusmihaic Oct 18, 2024
956b391
FIX: Build
mariusmihaic Oct 18, 2024
678b1ec
FEAT: Create epoch start data cross chain
mariusmihaic Oct 21, 2024
9d34c74
FEAT: receivedGenesisMainChainHeaderWithoutPreGenesis
mariusmihaic Oct 21, 2024
d2ca6b8
FEAT: displayLastCrossChainNotarizedHeader
mariusmihaic Oct 21, 2024
dcedab1
FEAT: displayLastCrossChainNotarizedHeader
mariusmihaic Oct 21, 2024
a54a40c
FEAT: Test displayLastCrossChainNotarizedHeader
mariusmihaic Oct 21, 2024
d3790ca
FEAT: Index pre-genesis incoming header
mariusmihaic Oct 21, 2024
4855cb0
FIX: Tests + cleanup
mariusmihaic Oct 22, 2024
961cb20
CLN: More cleanup + fix tests
mariusmihaic Oct 22, 2024
e83c3d1
FEAT: Save last cross chain notarized headers + bootstrap
mariusmihaic Oct 22, 2024
d096d9c
CLN: General cleanup
mariusmihaic Oct 23, 2024
e4c4cb1
FEAT: Tests + fixes bootStrapSovereignShardProcessor_test.go
mariusmihaic Oct 23, 2024
8e40044
FEAT: Test SaveDataToStorageCheckLastCrossChainNotarizedDataIsSaved
mariusmihaic Oct 23, 2024
afae722
FEAT: TestGetExtendedSharHeaderFromStorage + TestGetExtendedHeaderFro…
mariusmihaic Oct 23, 2024
5254e62
CLN: Remove get extended hdr from storage code
mariusmihaic Oct 23, 2024
83a9722
CLN: Line
mariusmihaic Oct 23, 2024
f597c3e
Merge branch 'MX-15948-bootstrap-cross-chain-header' into MX-15950-ge…
mariusmihaic Oct 23, 2024
6015cca
FEAT: Get extended header from storage
mariusmihaic Oct 23, 2024
2f9c51d
FIX: Import cycle
mariusmihaic Oct 23, 2024
8389d15
Merge branch 'MX-15948-bootstrap-cross-chain-header' into MX-15950-ge…
mariusmihaic Oct 23, 2024
ddb52bd
CLN: Unit tests
mariusmihaic Oct 23, 2024
48246b6
FIX: Race condition failing tests
mariusmihaic Oct 23, 2024
6599e4d
Merge branch 'MX-15948-bootstrap-cross-chain-header' into MX-15950-ge…
mariusmihaic Oct 23, 2024
e668733
FEAT: Start updating mock notifier
mariusmihaic Oct 23, 2024
9cd7ced
logs update in mock notifier
axenteoctavian Oct 24, 2024
db13b46
Merge pull request #6545 from multiversx/MX-15936-move-incoming-heade…
mariusmihaic Oct 24, 2024
6337d02
Merge branch 'feat/sovereign-mainchain-header-sync' into MX-15944-cre…
mariusmihaic Oct 24, 2024
da32bf2
FIX: After review
mariusmihaic Oct 24, 2024
4b813d4
FIX: isGenesisHeaderWithNoPreviousTracking
mariusmihaic Oct 24, 2024
bef4499
Merge pull request #6549 from multiversx/MX-15944-create-epoch-start-…
mariusmihaic Oct 24, 2024
8b242b1
Merge branch 'feat/sovereign-mainchain-header-sync' into MX-15948-boo…
mariusmihaic Oct 24, 2024
6cffdc5
FEAT: Cross header requester meta/extended
mariusmihaic Oct 24, 2024
164e0b3
FEAT: Cross header requester integrated in syncHeadersByHash.go
mariusmihaic Oct 24, 2024
9d1095f
FEAT: createHeadersSyncer in bootStrapProcessor
mariusmihaic Oct 24, 2024
da8af9e
FEAT: Add unit tests
mariusmihaic Oct 24, 2024
1caf0a5
CLN: createCrossHeaderRequester -> createCrossHeaderRequester
mariusmihaic Oct 24, 2024
de11bd5
fix request incoming SCRs
axenteoctavian Oct 24, 2024
7d9e597
FEAT: Test errNilCrossHeaderRequester
mariusmihaic Oct 24, 2024
d7d54b8
grpc enabled flag
axenteoctavian Oct 24, 2024
ae66230
Merge pull request #6557 from multiversx/mock-notifier-logs-update
axenteoctavian Oct 24, 2024
f0c3fb6
FEAT: Ugly modified version on shardStorageBootstrapper.go
mariusmihaic Oct 25, 2024
89ce0ae
FEAT: Add code in sovereignChainShardStorageBootstrapper.go
mariusmihaic Oct 25, 2024
bb91d78
FEAT: First sov bootStrap test for applyCrossNotarizedHeaders
mariusmihaic Oct 25, 2024
1e0b915
FEAT: testCleanupNotarizedStorageForHigherNoncesIfExist + refactor
mariusmihaic Oct 25, 2024
5770a3d
FEAT: Test sov cleanupNotarizedStorage
mariusmihaic Oct 25, 2024
3d1706a
CLN: After self review
mariusmihaic Oct 25, 2024
ae64696
Merge pull request #6561 from multiversx/fix-request-incoming-scrs
axenteoctavian Oct 25, 2024
3b7ebfa
Merge branch 'feat/sovereign-mainchain-header-sync' into MX-15948-boo…
mariusmihaic Oct 28, 2024
b1f754b
FEAT: Easy solution getBlockFinality for extended headers
mariusmihaic Oct 28, 2024
5caafce
FIX: Unit tests
mariusmihaic Oct 28, 2024
1549191
Merge pull request #6552 from multiversx/MX-15948-bootstrap-cross-cha…
mariusmihaic Oct 28, 2024
c026fc5
Merge branch 'feat/sovereign-mainchain-header-sync' into MX-15950-get…
mariusmihaic Oct 28, 2024
aefaae5
Merge pull request #6554 from multiversx/MX-15950-get-extended-header…
mariusmihaic Oct 28, 2024
fb7e571
Merge branch 'feat/sovereign-mainchain-header-sync' into MX-15952-syn…
mariusmihaic Oct 28, 2024
87f00bc
FIX: After review
mariusmihaic Oct 28, 2024
fa6a353
FIX: Linter
mariusmihaic Oct 28, 2024
c32c3b3
FEAT: First version chain sim test incoming header 0 finality
mariusmihaic Oct 29, 2024
dfb32cb
FEAT: Second chain sim test case
mariusmihaic Oct 29, 2024
969aa87
Merge pull request #6559 from multiversx/MX-15952-sync-extended-heade…
mariusmihaic Oct 29, 2024
da1da54
Merge branch 'feat/sovereign-mainchain-header-sync' into MX-15953-cro…
mariusmihaic Oct 29, 2024
22be259
FEAT: Third use case test
mariusmihaic Oct 29, 2024
3e29079
CLN: Lots of cleanup for test case 1 + extended use cases
mariusmihaic Oct 29, 2024
6c46440
CLN: General tests cleanup + utility funcs
mariusmihaic Oct 29, 2024
3a79eb6
CLN: Utility func GetCurrentSovereignHeader
mariusmihaic Oct 29, 2024
aaa4f8d
CLN: sovChainBlockTracer
mariusmihaic Oct 29, 2024
b5decf5
FIX: Typo
mariusmihaic Oct 30, 2024
85a5064
FEAT: Add first version notifierBootstrapper.go
mariusmihaic Oct 30, 2024
55e7569
FEAT: Integrate notifierBootstrapper into sovereignNodeRunner.go
mariusmihaic Oct 30, 2024
f7ab872
FIX: getLastCrossNotarizedHeaders
mariusmihaic Oct 30, 2024
b439c1c
Merge branch 'feat/sovereign-mainchain-header-sync' into MX-15951-upd…
axenteoctavian Oct 30, 2024
d5f3114
CLN: checkNodeState
mariusmihaic Oct 31, 2024
fa21b21
FEAT: First unit tests notifierBootstrapper.go
mariusmihaic Oct 31, 2024
0f972f5
FEAT: Extend unit tests notifier bootstrapper
mariusmihaic Oct 31, 2024
d9d349a
FIX: Unit test + small cleanup
mariusmihaic Oct 31, 2024
5f3f42e
FEAT: Trust mode: createNotifierWSReceiverServicesIfNeeded
mariusmihaic Nov 1, 2024
a54a94c
FEAT: Add info log when notifier is disabled
mariusmihaic Nov 4, 2024
41d7623
fixes after review
axenteoctavian Nov 5, 2024
ebc3fb1
fixes after review 2
axenteoctavian Nov 5, 2024
dbae082
fixes after review 3
axenteoctavian Nov 5, 2024
f4ba6ae
FIX: Do not request incoming headers upon receiving
mariusmihaic Nov 5, 2024
feac147
FEAT: Extend test case 3 for incoming header to not request other hea…
mariusmihaic Nov 5, 2024
bedd104
FIX: Unit test
mariusmihaic Nov 5, 2024
e6c4f53
Merge pull request #6555 from multiversx/MX-15951-update-mock-notifier
axenteoctavian Nov 6, 2024
9018342
FIX: After review
mariusmihaic Nov 6, 2024
fa4053f
Merge branch 'feat/sovereign-mainchain-header-sync' into MX-15953-cro…
mariusmihaic Nov 6, 2024
ab4e1ac
Merge pull request #6562 from multiversx/MX-15953-cross-chain-header-…
mariusmihaic Nov 6, 2024
a8ac19e
Merge branch 'feat/sovereign-mainchain-header-sync' into MX-15959-ext…
mariusmihaic Nov 6, 2024
9e65486
Merge branch 'MX-15959-extended-header-block-finality-to-zero' into M…
mariusmihaic Nov 6, 2024
9537851
Merge branch 'MX-15962-chain-sim-test-incoming-header-finality' into …
mariusmihaic Nov 6, 2024
88c0d33
Merge branch 'MX-15963-disable-notifier-until-synced' into MX-15961-s…
mariusmihaic Nov 6, 2024
47378d2
Merge branch 'MX-15961-sov-node-trust-mode' into MX-15984-fix-request…
mariusmihaic Nov 6, 2024
148a4f4
FIX: Quick and dirty fix resync cross chain mbs
mariusmihaic Nov 7, 2024
1ba8b22
FIX: Delete getBlockFinalityFunc and set variable to 0
mariusmihaic Nov 7, 2024
ff232c0
FIX: Delete getBlockFinalityFunc and set variable to 0
mariusmihaic Nov 7, 2024
db6d194
Merge pull request #6568 from multiversx/MX-15959-extended-header-blo…
mariusmihaic Nov 7, 2024
fbc7ac7
Merge branch 'feat/sovereign-mainchain-header-sync' into MX-15962-cha…
mariusmihaic Nov 7, 2024
49c93d9
Merge pull request #6569 from multiversx/MX-15962-chain-sim-test-inco…
mariusmihaic Nov 7, 2024
3e62c38
Merge branch 'feat/sovereign-mainchain-header-sync' into MX-15963-dis…
mariusmihaic Nov 7, 2024
cc78eb4
FEAT: Stop node on channel if notifier bootstrapper fails
mariusmihaic Nov 7, 2024
deaafbd
Merge pull request #6571 from multiversx/MX-15963-disable-notifier-un…
mariusmihaic Nov 8, 2024
f2e7047
Merge branch 'feat/sovereign-mainchain-header-sync' into MX-15961-sov…
mariusmihaic Nov 8, 2024
5bdc041
FIX: After merge
mariusmihaic Nov 8, 2024
536725b
Merge pull request #6578 from multiversx/MX-15961-sov-node-trust-mode
mariusmihaic Nov 8, 2024
d477412
Merge branch 'feat/sovereign-mainchain-header-sync' into MX-15984-fix…
mariusmihaic Nov 8, 2024
b95eff1
Merge branch 'MX-15984-fix-request-incoming-header' into MX-16008-fix…
mariusmihaic Nov 8, 2024
a9dcce7
Merge pull request #6585 from multiversx/MX-15984-fix-request-incomin…
mariusmihaic Nov 8, 2024
c5f11d7
Merge branch 'feat/sovereign-mainchain-header-sync' into MX-16008-fix…
mariusmihaic Nov 8, 2024
cd563fb
FEAT: Intercepted sovereign block header with mb headers checker
mariusmihaic Nov 8, 2024
6b411cb
FEAT: interceptedShardSovereignHeaderDataFactory.go and integrate it
mariusmihaic Nov 8, 2024
9491d19
FEAT: interceptedMiniBlockSovereignDataFactory.go and integrate it
mariusmihaic Nov 8, 2024
0a7dbad
FIX: Intercepted miniblock check with interface
mariusmihaic Nov 11, 2024
7c52836
FEAT: Unit tests intercepted sov header + mbs
mariusmihaic Nov 11, 2024
97aeea7
FEAT: Unit tests intercepted data factory for sov header + mbs
mariusmihaic Nov 11, 2024
a47a8a3
FIX: Revert RoundsPerEpoch config
mariusmihaic Nov 11, 2024
465e77d
FEAT: Quick solution to not request peer miniblocks on epoch change
mariusmihaic Nov 13, 2024
1fd14c1
CLN: Create and save epoch change mbs
mariusmihaic Nov 13, 2024
e58efe9
FEAT: Unity test sov validator create mbs
mariusmihaic Nov 14, 2024
f5018fb
CLN: General cleanup + extend epoch change test
mariusmihaic Nov 14, 2024
5974d1c
CLN: General cleanup + extend epoch change test
mariusmihaic Nov 14, 2024
86fcc75
Merge pull request #6587 from multiversx/MX-16008-fix-resync-cross-ch…
mariusmihaic Nov 18, 2024
5c55f17
Merge branch 'feat/sovereign-mainchain-header-sync' into MX-16089-opt…
mariusmihaic Nov 18, 2024
4caf94b
FIX: Go imports
mariusmihaic Nov 18, 2024
23c73cd
Merge pull request #6600 from multiversx/MX-16089-optimize-epoch-chan…
mariusmihaic Nov 18, 2024
19d8ad2
FIX: Comment
mariusmihaic Nov 18, 2024
a729faa
Merge pull request #6618 from multiversx/fix-missed-review-comm
mariusmihaic Nov 18, 2024
e2fbfb1
Merge branch 'feat/chain-go-sdk' into merge-feat-sovereign-into-sov-m…
mariusmihaic Nov 18, 2024
af28d99
CLN: Update go mod in mock notifier
mariusmihaic Nov 18, 2024
67d5584
Merge pull request #6619 from multiversx/merge-feat-sovereign-into-so…
mariusmihaic Nov 19, 2024
b923d41
FIX: Quick fix in isHeaderReceivedTooLate blockFinality to 0
mariusmihaic Nov 19, 2024
6c2d5cc
FEAT: Push bunch of changes to check if it works
mariusmihaic Nov 19, 2024
a26cba4
CLN: General cleanup, clean solution clean tracked headers
mariusmihaic Nov 20, 2024
5e680c8
FEAT: Refactor notifier bootstrap to work with confidence threshold t…
mariusmihaic Nov 20, 2024
a4ad7f5
CLN: Logs + test for sov shard tracker
mariusmihaic Nov 20, 2024
dac0d27
FIX: After review
mariusmihaic Nov 25, 2024
624ae44
Merge pull request #6622 from multiversx/MX-16147-fix-sync-process-bl…
mariusmihaic Nov 25, 2024
397fa02
Merge branch 'feat/chain-go-sdk' into merge-feat-sovereign-into-feat-…
mariusmihaic Nov 25, 2024
910d464
Merge pull request #6630 from multiversx/merge-feat-sovereign-into-fe…
mariusmihaic Nov 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
45 changes: 45 additions & 0 deletions process/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,51 @@ func GetMetaHeaderFromStorage(
return hdr, nil
}

// GetExtendedShardHeaderFromStorage gets the extended shard header, which is associated with the given hash, from storage
func GetExtendedShardHeaderFromStorage(
hash []byte,
marshaller marshal.Marshalizer,
storageService dataRetriever.StorageService,
) (*block.ShardHeaderExtended, error) {
buffHdr, err := GetMarshalizedHeaderFromStorage(dataRetriever.ExtendedShardHeadersUnit, hash, marshaller, storageService)
if err != nil {
return nil, err
}

hdr := &block.ShardHeaderExtended{}
err = marshaller.Unmarshal(hdr, buffHdr)
if err != nil {
return nil, ErrUnmarshalWithoutSuccess
}

return hdr, nil
}

// GetExtendedHeaderFromStorageWithNonce method returns an extended block header from storage with a given nonce
func GetExtendedHeaderFromStorageWithNonce(
nonce uint64,
storageService dataRetriever.StorageService,
uint64Converter typeConverters.Uint64ByteSliceConverter,
marshaller marshal.Marshalizer,
) (*block.ShardHeaderExtended, []byte, error) {
hash, err := GetHeaderHashFromStorageWithNonce(
nonce,
storageService,
uint64Converter,
marshaller,
dataRetriever.ExtendedShardHeadersNonceHashDataUnit)
if err != nil {
return nil, nil, err
}

hdr, err := GetExtendedShardHeaderFromStorage(hash, marshaller, storageService)
if err != nil {
return nil, nil, err
}

return hdr, hash, nil
}

// GetMarshalizedHeaderFromStorage gets the marshalized header, which is associated with the given hash, from storage
func GetMarshalizedHeaderFromStorage(
blockUnit dataRetriever.UnitType,
Expand Down
99 changes: 99 additions & 0 deletions process/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2362,3 +2362,102 @@ func TestShardedCacheSearchMethod_ToString(t *testing.T) {
str := process.ShardedCacheSearchMethod(166).ToString()
assert.Equal(t, "unknown method 166", str)
}

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

hash := []byte("hash")
marshaller := &mock.MarshalizerMock{}

t.Run("should work", func(t *testing.T) {
expectedHeader := &block.ShardHeaderExtended{
Header: &block.HeaderV2{
Header: &block.Header{
Nonce: 4,
},
},
}

storageService := &storageStubs.ChainStorerStub{
GetStorerCalled: func(unitType dataRetriever.UnitType) (storage.Storer, error) {
return &storageStubs.StorerStub{
GetCalled: func(key []byte) ([]byte, error) {
if bytes.Equal(key, hash) {
return marshaller.Marshal(expectedHeader)
}

return nil, errors.New("error")
},
}, nil
},
}

header, err := process.GetExtendedShardHeaderFromStorage(hash, marshaller, storageService)
require.Nil(t, err)
require.Equal(t, expectedHeader, header)
})

t.Run("nil storage service, should return error", func(t *testing.T) {
header, err := process.GetExtendedShardHeaderFromStorage(hash, marshaller, nil)
require.Equal(t, process.ErrNilStorage, err)
require.Nil(t, header)
})

t.Run("cannot unmarshal, should return error", func(t *testing.T) {
storageService := &storageStubs.ChainStorerStub{
GetStorerCalled: func(unitType dataRetriever.UnitType) (storage.Storer, error) {
return &storageStubs.StorerStub{
GetCalled: func(key []byte) ([]byte, error) {
return nil, nil
},
}, nil
},
}

header, err := process.GetExtendedShardHeaderFromStorage(hash, marshaller, storageService)
require.Equal(t, process.ErrUnmarshalWithoutSuccess, err)
require.Nil(t, header)
})
}

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

nonce := uint64(1)
hash := []byte("hash")
marshaller := &mock.MarshalizerMock{}
expectedHeader := &block.ShardHeaderExtended{
Header: &block.HeaderV2{
Header: &block.Header{
Nonce: 4,
},
},
}

t.Run("should work", func(t *testing.T) {
storageService, uint64Converter := initDefaultStorageServiceAndConverter(nonce, hash, expectedHeader)
header, headerHash, err := process.GetExtendedHeaderFromStorageWithNonce(
nonce,
storageService,
uint64Converter,
marshaller)

require.Nil(t, err)
require.Equal(t, hash, headerHash)
require.Equal(t, expectedHeader, header)
})

t.Run("cannot unmarshall, should return error", func(t *testing.T) {
marshaller.Fail = true
storageService, uint64Converter := initDefaultStorageServiceAndConverter(nonce, hash, expectedHeader)
header, headerHash, err := process.GetExtendedHeaderFromStorageWithNonce(
nonce,
storageService,
uint64Converter,
marshaller)

require.Equal(t, process.ErrUnmarshalWithoutSuccess, err)
require.Nil(t, headerHash)
require.Nil(t, header)
})
}
Loading