Skip to content

Commit

Permalink
Merge pull request #6755 from multiversx/fix_meta_sync
Browse files Browse the repository at this point in the history
fix sync on meta
  • Loading branch information
AdoAdoAdo authored Jan 30, 2025
2 parents 212798e + 01ab2bb commit 5ff1ea4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 28 deletions.
27 changes: 0 additions & 27 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/data"
"github.com/multiversx/mx-chain-go/storage"
"github.com/multiversx/mx-chain-vm-v1_2-go/ipc/marshaling"
)

// IsValidRelayedTxV3 returns true if the provided transaction is a valid transaction of type relayed v3
Expand Down Expand Up @@ -77,28 +75,3 @@ func VerifyProofAgainstHeader(proof data.HeaderProofHandler, header data.HeaderH

return nil
}

// GetHeader tries to get the header from pool first and if not found, searches for it through storer
func GetHeader(
headerHash []byte,
headersPool HeadersPool,
headersStorer storage.Storer,
marshaller marshaling.Marshalizer,
) (data.HeaderHandler, error) {
header, err := headersPool.GetHeaderByHash(headerHash)
if err == nil {
return header, nil
}

headerBytes, err := headersStorer.SearchFirst(headerHash)
if err != nil {
return nil, err
}

err = marshaller.Unmarshal(header, headerBytes)
if err != nil {
return nil, err
}

return header, nil
}
2 changes: 1 addition & 1 deletion process/block/metablock.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ func (mp *metaProcessor) checkProofsForShardData(header *block.MetaBlock) error

prevProof := shardData.GetPreviousProof()
headersPool := mp.dataPool.Headers()
prevHeader, err := common.GetHeader(prevProof.GetHeaderHash(), headersPool, shardHeadersStorer, mp.marshalizer)
prevHeader, err := process.GetHeader(prevProof.GetHeaderHash(), headersPool, shardHeadersStorer, mp.marshalizer, prevProof.GetHeaderShardId())
if err != nil {
return err
}
Expand Down
23 changes: 23 additions & 0 deletions process/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import (
"github.com/multiversx/mx-chain-core-go/data/typeConverters"
"github.com/multiversx/mx-chain-core-go/hashing"
"github.com/multiversx/mx-chain-core-go/marshal"
"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/dataRetriever"
"github.com/multiversx/mx-chain-go/state"
"github.com/multiversx/mx-chain-go/storage"
logger "github.com/multiversx/mx-chain-logger-go"
vmcommon "github.com/multiversx/mx-chain-vm-common-go"
)
Expand Down Expand Up @@ -774,6 +776,27 @@ func GetSortedStorageUpdates(account *vmcommon.OutputAccount) []*vmcommon.Storag
return storageUpdates
}

// GetHeader tries to get the header from pool first and if not found, searches for it through storer
func GetHeader(
headerHash []byte,
headersPool common.HeadersPool,
headersStorer storage.Storer,
marshaller marshal.Marshalizer,
shardID uint32,
) (data.HeaderHandler, error) {
header, err := headersPool.GetHeaderByHash(headerHash)
if err == nil {
return header, nil
}

headerBytes, err := headersStorer.SearchFirst(headerHash)
if err != nil {
return nil, err
}

return UnmarshalHeader(shardID, marshaller, headerBytes)
}

// UnmarshalHeader unmarshalls a block header
func UnmarshalHeader(shardId uint32, marshalizer marshal.Marshalizer, headerBuffer []byte) (data.HeaderHandler, error) {
if shardId == core.MetachainShardId {
Expand Down

0 comments on commit 5ff1ea4

Please sign in to comment.