Skip to content

Commit

Permalink
Merge branch 'feat/equivalent-messages' into fix-prev-proof-saving
Browse files Browse the repository at this point in the history
# Conflicts:
#	common/common.go
  • Loading branch information
AdoAdoAdo committed Jan 30, 2025
2 parents 61edf71 + 5ff1ea4 commit dbb9351
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 29 deletions.
28 changes: 0 additions & 28 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +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-vm-v1_2-go/ipc/marshaling"

"github.com/multiversx/mx-chain-go/storage"
)

// IsValidRelayedTxV3 returns true if the provided transaction is a valid transaction of type relayed v3
Expand Down Expand Up @@ -78,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 dbb9351

Please sign in to comment.