Skip to content

Commit

Permalink
update verifable keys
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangchiqing committed Nov 23, 2024
1 parent 3a4f495 commit 60a37c1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fvm/evm/handler/blockHashList.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package handler
import (
"encoding/binary"
"fmt"
"strings"

gethCommon "github.com/onflow/go-ethereum/common"

Expand All @@ -26,6 +27,14 @@ const (
heightEncodingSize
)

func IsBlockHashListBucketKeyFormat(id flow.RegisterID) bool {
return strings.HasPrefix(id.Key, "BlockHashListBucket")
}

func IsBlockHashListMetaKey(id flow.RegisterID) bool {
return id.Key == blockHashListMetaKey
}

// BlockHashList stores the last `capacity` number of block hashes
//
// Under the hood it breaks the list of hashes into
Expand Down
14 changes: 14 additions & 0 deletions fvm/evm/offchain/utils/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/onflow/flow-go/fvm/environment"
"github.com/onflow/flow-go/fvm/evm"
"github.com/onflow/flow-go/fvm/evm/events"
"github.com/onflow/flow-go/fvm/evm/handler"
"github.com/onflow/flow-go/fvm/evm/offchain/blocks"
evmStorage "github.com/onflow/flow-go/fvm/evm/offchain/storage"
"github.com/onflow/flow-go/fvm/evm/offchain/sync"
Expand Down Expand Up @@ -98,6 +99,10 @@ func OffchainReplayBackwardCompatibilityTest(
continue
}

if !verifiableKeys(regID) {
continue
}

// when iterating backwards, duplicated register updates are stale updates,
// so skipping them
if _, ok := expectedUpdates[regID]; !ok {
Expand Down Expand Up @@ -152,7 +157,12 @@ func OffchainReplayBackwardCompatibilityTest(
return err
}

if !verifiableKeys(k) {
continue
}

actualUpdates[k] = v

}

err = verifyRegisterUpdates(expectedUpdates, actualUpdates)
Expand All @@ -166,6 +176,10 @@ func OffchainReplayBackwardCompatibilityTest(
return nil
}

func verifiableKeys(key flow.RegisterID) bool {
return handler.IsBlockHashListBucketKeyFormat(key) || handler.IsBlockHashListMetaKey(key)
}

func parseEVMEvents(evts flow.EventsList) (*events.BlockEventPayload, []events.TransactionEventPayload, error) {
var blockEvent *events.BlockEventPayload
txEvents := make([]events.TransactionEventPayload, 0)
Expand Down

0 comments on commit 60a37c1

Please sign in to comment.