Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
51b3451
save intermediate header to storage on bootstrap
ssd04 Dec 17, 2025
c61e939
Merge branch 'feat/supernova-async-exec' into fix-meta-bootstrap-sync
ssd04 Dec 18, 2025
187313c
handle last included meta headers
ssd04 Dec 18, 2025
b39f967
Merge branch 'feat/supernova-async-exec' into fix-meta-bootstrap-sync
sstanculeanu Dec 18, 2025
dcfc4ab
fallback to search in storage
ssd04 Dec 19, 2025
880872e
Merge branch 'feat/supernova-async-exec' into fix-meta-bootstrap-sync
ssd04 Dec 19, 2025
5011943
request missing meta headers at bootstrap
ssd04 Dec 19, 2025
3a37ddb
remove unneded log
ssd04 Dec 19, 2025
bd53570
set last self notarized meta in tracker based on shard header
ssd04 Dec 19, 2025
7b59f02
Merge branch 'feat/supernova-async-exec' into fix-meta-bootstrap-sync
ssd04 Dec 19, 2025
1efc550
Merge branch 'feat/supernova-async-exec' into fix-meta-bootstrap-sync
ssd04 Dec 19, 2025
f7a164b
remove debug logs
ssd04 Dec 19, 2025
d197d3e
refactor getting from storage with nonce
ssd04 Dec 22, 2025
54b0c24
refactor epoch start last self notarized headers
ssd04 Dec 22, 2025
cfcbb2d
fix saving shard headers to storage
ssd04 Dec 22, 2025
00da184
fixes + unit tests
ssd04 Dec 22, 2025
ff4caa7
fix process tests
ssd04 Dec 22, 2025
6a43815
remove debug log
ssd04 Dec 22, 2025
ff89aab
Merge branch 'feat/supernova-async-exec' into fix-meta-bootstrap-sync
ssd04 Dec 22, 2025
8206f45
remove commented code
ssd04 Dec 22, 2025
e36c8ee
remove debug log
ssd04 Dec 22, 2025
dc6692d
Merge branch 'feat/supernova-async-exec' into fix-meta-bootstrap-sync
ssd04 Dec 22, 2025
0009304
add nonce check
ssd04 Dec 23, 2025
54fc584
refactor to not sync last executed header for last finished ref meta
ssd04 Dec 24, 2025
f58157e
fixes after review - typos
ssd04 Dec 24, 2025
df9793f
fixes after review - typos
ssd04 Dec 24, 2025
0d50c03
Merge branch 'feat/supernova-async-exec' into fix-meta-bootstrap-sync
ssd04 Dec 24, 2025
761ac1c
fix conflicts after merge
ssd04 Dec 24, 2025
8abf8f7
fix linter issue
ssd04 Dec 24, 2025
61401da
get ref meta header for last self notarized headers
ssd04 Dec 29, 2025
73b2142
fixes after review
ssd04 Dec 29, 2025
8661f6c
remove unused code
ssd04 Dec 29, 2025
dc91177
Merge branch 'feat/supernova-async-exec' into fix-meta-bootstrap-sync
sstanculeanu Dec 29, 2025
6785359
fix request shard id
ssd04 Dec 29, 2025
4f5f4ee
fixes after review
ssd04 Dec 29, 2025
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
4 changes: 2 additions & 2 deletions epochStart/bootstrap/fromLocalStorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/epochStart"
"github.com/multiversx/mx-chain-go/epochStart/bootstrap/disabled"
"github.com/multiversx/mx-chain-go/process"
"github.com/multiversx/mx-chain-go/process/block/bootstrapStorage"
"github.com/multiversx/mx-chain-go/sharding"
"github.com/multiversx/mx-chain-go/sharding/nodesCoordinator"
Expand Down Expand Up @@ -288,8 +289,7 @@ func (e *epochStartBootstrap) getEpochStartMetaFromStorage(storer storage.Storer
return nil, err
}

metaBlock := &block.MetaBlock{}
err = e.coreComponentsHolder.InternalMarshalizer().Unmarshal(metaBlock, epochStartMetaBlock)
metaBlock, err := process.UnmarshalMetaHeader(e.coreComponentsHolder.InternalMarshalizer(), epochStartMetaBlock)
if err != nil {
return nil, err
}
Expand Down
140 changes: 139 additions & 1 deletion epochStart/bootstrap/metaStorageHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ func (msh *metaStorageHandler) SaveDataToStorage(components *ComponentsNeededFor
return err
}

err = msh.saveEpochStartMetaHdrs(components)
if err != nil {
return err
}

msh.saveMiniblocksFromComponents(components)

miniBlocks, err := msh.groupMiniBlocksByShard(components.PendingMiniBlocks)
Expand All @@ -126,10 +131,19 @@ func (msh *metaStorageHandler) SaveDataToStorage(components *ComponentsNeededFor
return err
}

lastSelfNotarizedHeaders, err := msh.getLastSelfNotarizedHeaders(
components.EpochStartMetaBlock,
lastHeader,
components.Headers,
)
if err != nil {
return err
}

bootStrapData := bootstrapStorage.BootstrapData{
LastHeader: lastHeader,
LastCrossNotarizedHeaders: lastCrossNotarizedHeaders,
LastSelfNotarizedHeaders: []bootstrapStorage.BootstrapHeaderInfo{lastHeader},
LastSelfNotarizedHeaders: lastSelfNotarizedHeaders,
ProcessedMiniBlocks: []bootstrapStorage.MiniBlocksInMeta{},
PendingMiniBlocks: miniBlocks,
NodesCoordinatorConfigKey: nodesCoordinatorConfigKey,
Expand Down Expand Up @@ -163,6 +177,130 @@ func (msh *metaStorageHandler) SaveDataToStorage(components *ComponentsNeededFor
return nil
}

func (msh *metaStorageHandler) getLastSelfNotarizedHeaders(
epochStartMeta data.MetaHeaderHandler,
epochStartMetaBootstrapInfo bootstrapStorage.BootstrapHeaderInfo,
syncedHeaders map[string]data.HeaderHandler,
) ([]bootstrapStorage.BootstrapHeaderInfo, error) {
var lastSelfNotarizedHeaders []bootstrapStorage.BootstrapHeaderInfo
if !epochStartMeta.IsHeaderV3() {
return []bootstrapStorage.BootstrapHeaderInfo{
epochStartMetaBootstrapInfo,
}, nil
}

for _, epochStartData := range epochStartMeta.GetEpochStartHandler().GetLastFinalizedHeaderHandlers() {
bootstrapHdrInfo, err := msh.getLastNotarizedBootstrapInfoForEpochStartData(epochStartData, syncedHeaders)
if err != nil {
return nil, err
}

lastSelfNotarizedHeaders = append(lastSelfNotarizedHeaders, bootstrapHdrInfo)
}

bootstrapHdrInfoMeta, err := msh.getLastMetaBootstrapInfo(epochStartMeta, syncedHeaders)
if err != nil {
return nil, err
}

lastSelfNotarizedHeaders = append(lastSelfNotarizedHeaders, bootstrapHdrInfoMeta)

return lastSelfNotarizedHeaders, nil
}

func (msh *metaStorageHandler) getLastMetaBootstrapInfo(
epochStartMeta data.MetaHeaderHandler,
syncedHeaders map[string]data.HeaderHandler,
) (bootstrapStorage.BootstrapHeaderInfo, error) {
lastExecRes, err := common.GetLastBaseExecutionResultHandler(epochStartMeta)
if err != nil {
return bootstrapStorage.BootstrapHeaderInfo{}, err
}

lastExecMetaHeader, ok := syncedHeaders[string(lastExecRes.GetHeaderHash())]
if !ok {
return bootstrapStorage.BootstrapHeaderInfo{}, epochStart.ErrMissingHeader
}

bootstrapHdrInfoMeta := bootstrapStorage.BootstrapHeaderInfo{
ShardId: core.MetachainShardId,
Epoch: lastExecMetaHeader.GetEpoch(),
Nonce: lastExecMetaHeader.GetNonce(),
Hash: lastExecRes.GetHeaderHash(),
}

return bootstrapHdrInfoMeta, nil
}

func fetchPrevHeader(
syncedHeaders map[string]data.HeaderHandler,
header data.HeaderHandler,
) (data.ShardHeaderHandler, error) {
prevHash := header.GetPrevHash()
syncedHeader, ok := syncedHeaders[string(prevHash)]
if !ok {
return nil, epochStart.ErrMissingHeader
}

shardHeader, ok := syncedHeader.(data.ShardHeaderHandler)
if !ok {
return nil, epochStart.ErrWrongTypeAssertion
}

return shardHeader, nil
}
Comment on lines +235 to +251
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated function: The fetchPrevHeader function in metaStorageHandler.go (lines 235-251) is identical to the syncPrevShardHeaderHandler method in process.go (lines 854-871), except the latter also stores the header in syncedHeaders. Consider extracting this into a shared utility function to avoid code duplication and potential maintenance issues.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mainly the similar part is the type assertion, otherwise they are quite different since the other one uses syncOneHeader which needs other things like request, data pool, we can have a function pointer for this call, but it would be very similar with what we already have now


func (msh *metaStorageHandler) getLastNotarizedBootstrapInfoForEpochStartData(
epochStartData data.EpochStartShardDataHandler,
syncedHeaders map[string]data.HeaderHandler,
) (bootstrapStorage.BootstrapHeaderInfo, error) {
shardHeaderHash := epochStartData.GetHeaderHash()
shardHeader, ok := syncedHeaders[string(shardHeaderHash)]
if !ok {
return bootstrapStorage.BootstrapHeaderInfo{}, epochStart.ErrMissingHeader
}

lastReferencedMetaHash, err := getLastReferencedMetaHash(syncedHeaders, fetchPrevHeader, shardHeader)
if err != nil {
return bootstrapStorage.BootstrapHeaderInfo{}, err
}

lastReferencesMetaBlock, ok := syncedHeaders[string(lastReferencedMetaHash)]
if !ok {
return bootstrapStorage.BootstrapHeaderInfo{}, epochStart.ErrMissingHeader
}

bootstrapHdrInfo := bootstrapStorage.BootstrapHeaderInfo{
ShardId: epochStartData.GetShardID(),
Epoch: lastReferencesMetaBlock.GetEpoch(),
Nonce: lastReferencesMetaBlock.GetNonce(),
Hash: lastReferencedMetaHash,
}

return bootstrapHdrInfo, nil
}

func (msh *metaStorageHandler) saveEpochStartMetaHdrs(components *ComponentsNeededForBootstrap) error {
for _, hdr := range components.Headers {
isForCurrentShard := hdr.GetShardID() == msh.shardCoordinator.SelfId()
if !isForCurrentShard {
_, err := msh.saveShardHdrToStorage(hdr)
if err != nil {
return err
}

continue
}

_, err := msh.saveMetaHdrToStorage(hdr)
if err != nil {
return err
}
}

return nil
}

func (msh *metaStorageHandler) saveLastCrossNotarizedHeaders(
meta data.MetaHeaderHandler,
mapHeaders map[string]data.HeaderHandler,
Expand Down
Loading
Loading