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 sync on meta #6755

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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