Skip to content

Commit

Permalink
Merge branch 'master' into illia-malachyn/6845-unify-subscription-and…
Browse files Browse the repository at this point in the history
…-message-id
  • Loading branch information
illia-malachyn authored Jan 21, 2025
2 parents 99da716 + a3c2cea commit fe70a58
Show file tree
Hide file tree
Showing 82 changed files with 1,022 additions and 761 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.54
version: v1.63
args: -v
working-directory: ${{ matrix.dir }}
# https://github.com/golangci/golangci-lint-action/issues/244
Expand Down
3 changes: 2 additions & 1 deletion cmd/access/node_builder/access_node_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import (
"github.com/onflow/flow-go/engine/common/stop"
synceng "github.com/onflow/flow-go/engine/common/synchronization"
"github.com/onflow/flow-go/engine/common/version"
"github.com/onflow/flow-go/engine/execution/computation"
"github.com/onflow/flow-go/engine/execution/computation/query"
"github.com/onflow/flow-go/fvm/storage/derived"
"github.com/onflow/flow-go/ledger"
Expand Down Expand Up @@ -991,7 +992,7 @@ func (builder *FlowAccessNodeBuilder) BuildExecutionSyncComponents() *FlowAccess
builder.Logger,
metrics.NewExecutionCollector(builder.Tracer),
builder.RootChainID,
query.NewProtocolStateWrapper(builder.State),
computation.NewProtocolStateWrapper(builder.State),
builder.Storage.Headers,
builder.ExecutionIndexerCore.RegisterValue,
builder.scriptExecutorConfig,
Expand Down
12 changes: 6 additions & 6 deletions cmd/execution_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (exeNode *ExecutionNode) LoadExecutionMetrics(node *NodeConfig) error {
// the root block as executed block
var height uint64
var blockID flow.Identifier
err := node.DB.View(procedure.GetHighestExecutedBlock(&height, &blockID))
err := node.DB.View(procedure.GetLastExecutedBlock(&height, &blockID))
if err != nil {
// database has not been bootstrapped yet
if errors.Is(err, storageerr.ErrNotFound) {
Expand Down Expand Up @@ -551,7 +551,7 @@ func (exeNode *ExecutionNode) LoadProviderEngine(
collector,
node.Tracer,
node.Me,
node.State,
computation.NewProtocolStateWrapper(node.State),
vmCtx,
ledgerViewCommitter,
executionDataProvider,
Expand Down Expand Up @@ -590,7 +590,7 @@ func (exeNode *ExecutionNode) LoadProviderEngine(

// Get latest executed block and a view at that block
ctx := context.Background()
height, blockID, err := exeNode.executionState.GetHighestExecutedBlockID(ctx)
height, blockID, err := exeNode.executionState.GetLastExecutedBlockID(ctx)
if err != nil {
return nil, fmt.Errorf(
"cannot get the latest executed block id at height %v: %w",
Expand Down Expand Up @@ -762,12 +762,12 @@ func (exeNode *ExecutionNode) LoadExecutionState(
exeNode.exeConf.enableStorehouse,
)

height, _, err := exeNode.executionState.GetHighestExecutedBlockID(context.Background())
height, _, err := exeNode.executionState.GetLastExecutedBlockID(context.Background())
if err != nil {
return nil, fmt.Errorf("could not get highest executed block: %w", err)
return nil, fmt.Errorf("could not get last executed block: %w", err)
}

log.Info().Msgf("execution state highest executed block height: %v", height)
log.Info().Msgf("execution state last executed block height: %v", height)
exeNode.collector.ExecutionLastExecutedBlockHeight(height)

return &module.NoopReadyDoneAware{}, nil
Expand Down
3 changes: 2 additions & 1 deletion cmd/observer/node_builder/observer_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import (
"github.com/onflow/flow-go/engine/common/stop"
synceng "github.com/onflow/flow-go/engine/common/synchronization"
"github.com/onflow/flow-go/engine/common/version"
"github.com/onflow/flow-go/engine/execution/computation"
"github.com/onflow/flow-go/engine/execution/computation/query"
"github.com/onflow/flow-go/fvm/storage/derived"
"github.com/onflow/flow-go/ledger"
Expand Down Expand Up @@ -1454,7 +1455,7 @@ func (builder *ObserverServiceBuilder) BuildExecutionSyncComponents() *ObserverS
builder.Logger,
metrics.NewExecutionCollector(builder.Tracer),
builder.RootChainID,
query.NewProtocolStateWrapper(builder.State),
computation.NewProtocolStateWrapper(builder.State),
builder.Storage.Headers,
builder.ExecutionIndexerCore.RegisterValue,
builder.scriptExecutorConfig,
Expand Down
10 changes: 5 additions & 5 deletions cmd/util/cmd/common/node_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ func ReadFullPartnerNodeInfos(log zerolog.Logger, partnerWeightsPath, partnerNod
}
err = ValidateNetworkPubKey(partner.NetworkPubKey)
if err != nil {
return nil, fmt.Errorf(fmt.Sprintf("invalid network public key: %s", partner.NetworkPubKey))
return nil, fmt.Errorf("invalid network public key: %s", partner.NetworkPubKey)
}
err = ValidateStakingPubKey(partner.StakingPubKey)
if err != nil {
return nil, fmt.Errorf(fmt.Sprintf("invalid staking public key: %s", partner.StakingPubKey))
return nil, fmt.Errorf("invalid staking public key: %s", partner.StakingPubKey)
}

weight := weights[partner.NodeID]
if valid := ValidateWeight(weight); !valid {
return nil, fmt.Errorf(fmt.Sprintf("invalid partner weight %v: %d", partner.NodeID, weight))
return nil, fmt.Errorf("invalid partner weight %v: %d", partner.NodeID, weight)
}

if weight != flow.DefaultInitialWeight {
Expand Down Expand Up @@ -143,12 +143,12 @@ func ReadFullInternalNodeInfos(log zerolog.Logger, internalNodePrivInfoDir, inte
// validate every single internal node
err := ValidateNodeID(internal.NodeID)
if err != nil {
return nil, fmt.Errorf(fmt.Sprintf("invalid internal node ID: %s", internal.NodeID))
return nil, fmt.Errorf("invalid internal node ID: %s", internal.NodeID)
}
weight := weights[internal.Address]

if valid := ValidateWeight(weight); !valid {
return nil, fmt.Errorf(fmt.Sprintf("invalid partner weight %v: %d", internal.NodeID, weight))
return nil, fmt.Errorf("invalid partner weight %v: %d", internal.NodeID, weight)
}
if weight != flow.DefaultInitialWeight {
log.Warn().Msgf("internal node (id=%x) has non-default weight (%d != %d)", internal.NodeID, weight, flow.DefaultInitialWeight)
Expand Down
2 changes: 1 addition & 1 deletion cmd/util/cmd/find-inconsistent-result/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func findLastExecutedAndSealedHeight(state protocol.State, db *badger.DB) (uint6

var blockID flow.Identifier
var lastExecuted uint64
err = db.View(procedure.GetHighestExecutedBlock(&lastExecuted, &blockID))
err = db.View(procedure.GetLastExecutedBlock(&lastExecuted, &blockID))
if err != nil {
return 0, err
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/util/cmd/verify_execution_result/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var (
// # verify the last 100 sealed blocks
// ./util verify_execution_result --chain flow-testnet --datadir /var/flow/data/protocol --chunk_data_pack_dir /var/flow/data/chunk_data_pack --lastk 100
// # verify the blocks from height 2000 to 3000
// ./util verify_execution_result --chain flow-testnet --datadir /var/flow/data/protocol --chunk_data_pack_dir /var/flow/data/chunk_data_pack --from_to 2000-3000
// ./util verify_execution_result --chain flow-testnet --datadir /var/flow/data/protocol --chunk_data_pack_dir /var/flow/data/chunk_data_pack --from_to 2000_3000
var Cmd = &cobra.Command{
Use: "verify-execution-result",
Short: "verify block execution by verifying all chunks in the result",
Expand All @@ -47,7 +47,7 @@ func init() {
"last k sealed blocks to verify")

Cmd.Flags().StringVar(&flagFromTo, "from_to", "",
"the height range to verify blocks (inclusive), i.e, 1-1000, 1000-2000, 2000-3000, etc.")
"the height range to verify blocks (inclusive), i.e, 1_1000, 1000_2000, 2000_3000, etc.")

Cmd.Flags().UintVar(&flagWorkerCount, "worker_count", 1,
"number of workers to use for verification, default is 1")
Expand Down Expand Up @@ -93,9 +93,9 @@ func run(*cobra.Command, []string) {
}

func parseFromTo(fromTo string) (from, to uint64, err error) {
parts := strings.Split(fromTo, "-")
parts := strings.Split(fromTo, "_")
if len(parts) != 2 {
return 0, 0, fmt.Errorf("invalid format: expected 'from-to', got '%s'", fromTo)
return 0, 0, fmt.Errorf("invalid format: expected 'from_to', got '%s'", fromTo)
}

from, err = strconv.ParseUint(strings.TrimSpace(parts[0]), 10, 64)
Expand Down
12 changes: 6 additions & 6 deletions engine/access/rpc/backend/backend_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func (b *backendTransactions) getTransactionResultsByBlockIDFromExecutionNode(
)
if err != nil {
if IsInsufficientExecutionReceipts(err) {
return nil, status.Errorf(codes.NotFound, err.Error())
return nil, status.Error(codes.NotFound, err.Error())
}
return nil, rpc.ConvertError(err, "failed to retrieve result from any execution node", codes.Internal)
}
Expand Down Expand Up @@ -574,7 +574,7 @@ func (b *backendTransactions) getTransactionResultByIndexFromExecutionNode(
)
if err != nil {
if IsInsufficientExecutionReceipts(err) {
return nil, status.Errorf(codes.NotFound, err.Error())
return nil, status.Error(codes.NotFound, err.Error())
}
return nil, rpc.ConvertError(err, "failed to retrieve result from any execution node", codes.Internal)
}
Expand Down Expand Up @@ -762,7 +762,7 @@ func (b *backendTransactions) getTransactionResultFromExecutionNode(
if err != nil {
// if no execution receipt were found, return a NotFound GRPC error
if IsInsufficientExecutionReceipts(err) {
return nil, status.Errorf(codes.NotFound, err.Error())
return nil, status.Error(codes.NotFound, err.Error())
}
return nil, err
}
Expand Down Expand Up @@ -1002,7 +1002,7 @@ func (b *backendTransactions) LookupErrorMessageByTransactionID(
)
if err != nil {
if IsInsufficientExecutionReceipts(err) {
return "", status.Errorf(codes.NotFound, err.Error())
return "", status.Error(codes.NotFound, err.Error())
}
return "", rpc.ConvertError(err, "failed to select execution nodes", codes.Internal)
}
Expand Down Expand Up @@ -1057,7 +1057,7 @@ func (b *backendTransactions) LookupErrorMessageByIndex(
)
if err != nil {
if IsInsufficientExecutionReceipts(err) {
return "", status.Errorf(codes.NotFound, err.Error())
return "", status.Error(codes.NotFound, err.Error())
}
return "", rpc.ConvertError(err, "failed to select execution nodes", codes.Internal)
}
Expand Down Expand Up @@ -1117,7 +1117,7 @@ func (b *backendTransactions) LookupErrorMessagesByBlockID(
)
if err != nil {
if IsInsufficientExecutionReceipts(err) {
return nil, status.Errorf(codes.NotFound, err.Error())
return nil, status.Error(codes.NotFound, err.Error())
}
return nil, rpc.ConvertError(err, "failed to select execution nodes", codes.Internal)
}
Expand Down
10 changes: 2 additions & 8 deletions engine/access/rpc/backend/script_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/onflow/flow-go/engine/access/index"
"github.com/onflow/flow-go/engine/common/version"
"github.com/onflow/flow-go/engine/execution/computation/query"
"github.com/onflow/flow-go/engine/execution/computation/query/mock"
"github.com/onflow/flow-go/engine/execution/testutil"
"github.com/onflow/flow-go/fvm"
"github.com/onflow/flow-go/fvm/storage/derived"
Expand Down Expand Up @@ -109,12 +108,7 @@ func (s *ScriptExecutorSuite) SetupTest() {
s.headers = newBlockHeadersStorage(blockchain)
s.height = blockchain[0].Header.Height

entropyProvider := testutil.EntropyProviderFixture(nil)
entropyBlock := mock.NewEntropyProviderPerBlock(s.T())
entropyBlock.
On("AtBlockID", testifyMock.AnythingOfType("flow.Identifier")).
Return(entropyProvider).
Maybe()
protocolState := testutil.ProtocolStateWithSourceFixture(nil)

s.snapshot = snapshot.NewSnapshotTree(nil)
s.vm = fvm.NewVirtualMachine()
Expand Down Expand Up @@ -153,7 +147,7 @@ func (s *ScriptExecutorSuite) SetupTest() {
s.log,
metrics.NewNoopCollector(),
s.chain.ChainID(),
entropyBlock,
protocolState,
s.headers,
indexerCore.RegisterValue,
query.NewDefaultConfig(),
Expand Down
Loading

0 comments on commit fe70a58

Please sign in to comment.