Skip to content

Commit 28e05fb

Browse files
authored
Merge branch 'master' into leo/refactor-index-result
2 parents eefea22 + ab06551 commit 28e05fb

File tree

70 files changed

+2067
-914
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2067
-914
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ jobs:
6262
uses: golangci/golangci-lint-action@v6
6363
continue-on-error: true # after installation (what we care about), this step will fail - this line allows workflow to continue
6464
with:
65-
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
66-
version: v1.63
6765
args: "--no-config --disable-all" # set args so that no linters are actually run
6866
- name: Build custom linter binary
6967
if: steps.cache-linter.outputs.cache-hit != 'true'

cmd/access/node_builder/access_node_builder.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ import (
6666
"github.com/onflow/flow-go/engine/common/version"
6767
"github.com/onflow/flow-go/engine/execution/computation"
6868
"github.com/onflow/flow-go/engine/execution/computation/query"
69-
"github.com/onflow/flow-go/fvm"
7069
"github.com/onflow/flow-go/fvm/storage/derived"
7170
"github.com/onflow/flow-go/ledger"
7271
"github.com/onflow/flow-go/ledger/complete/wal"
@@ -183,7 +182,6 @@ type AccessNodeConfig struct {
183182
storeTxResultErrorMessages bool
184183
stopControlEnabled bool
185184
registerDBPruneThreshold uint64
186-
scheduledCallbacksEnabled bool
187185
}
188186

189187
type PublicNetworkConfig struct {
@@ -291,7 +289,6 @@ func DefaultAccessNodeConfig() *AccessNodeConfig {
291289
storeTxResultErrorMessages: false,
292290
stopControlEnabled: false,
293291
registerDBPruneThreshold: 0,
294-
scheduledCallbacksEnabled: fvm.DefaultScheduledCallbacksEnabled,
295292
}
296293
}
297294

@@ -1324,10 +1321,6 @@ func (builder *FlowAccessNodeBuilder) extraFlags() {
13241321
"stop-control-enabled",
13251322
defaultConfig.stopControlEnabled,
13261323
"whether to enable the stop control feature. Default value is false")
1327-
flags.BoolVar(&builder.scheduledCallbacksEnabled,
1328-
"scheduled-callbacks-enabled",
1329-
defaultConfig.scheduledCallbacksEnabled,
1330-
"whether to include scheduled callback transactions in system collections.")
13311324
// ExecutionDataRequester config
13321325
flags.BoolVar(&builder.executionDataSyncEnabled,
13331326
"execution-data-sync-enabled",
@@ -1517,6 +1510,10 @@ func (builder *FlowAccessNodeBuilder) extraFlags() {
15171510
flags.BoolVar(&unusedRetryEnabled, "retry-enabled", false, "[deprecated] whether to enable the retry mechanism at the access node level")
15181511
_ = flags.MarkDeprecated("retry-enabled", "[deprecated] this flag is ignored and will be removed in a future release.")
15191512

1513+
var unusedScheduledCallbacksEnabled bool
1514+
flags.BoolVar(&unusedScheduledCallbacksEnabled, "scheduled-callbacks-enabled", false, "[deprecated] whether to include scheduled callback transactions in system collections.")
1515+
_ = flags.MarkDeprecated("scheduled-callbacks-enabled", "[deprecated] this flag is ignored and will be removed in a future release.")
1516+
15201517
}).ValidateFlags(func() error {
15211518
if builder.supportsObserver && (builder.PublicNetworkConfig.BindAddress == cmd.NotSet || builder.PublicNetworkConfig.BindAddress == "") {
15221519
return errors.New("public-network-address must be set if supports-observer is true")
@@ -2160,7 +2157,6 @@ func (builder *FlowAccessNodeBuilder) Build() (cmd.Node, error) {
21602157
ExecNodeIdentitiesProvider: notNil(builder.ExecNodeIdentitiesProvider),
21612158
TxErrorMessageProvider: notNil(builder.txResultErrorMessageProvider),
21622159
MaxScriptAndArgumentSize: config.BackendConfig.AccessConfig.MaxRequestMsgSize,
2163-
ScheduledCallbacksEnabled: builder.scheduledCallbacksEnabled,
21642160
})
21652161
if err != nil {
21662162
return nil, fmt.Errorf("could not initialize backend: %w", err)

cmd/execution_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (exeConf *ExecutionConfig) SetupFlags(flags *pflag.FlagSet) {
145145
flags.BoolVar(&exeConf.onflowOnlyLNs, "temp-onflow-only-lns", false, "do not use unless required. forces node to only request collections from onflow collection nodes")
146146
flags.BoolVar(&exeConf.enableStorehouse, "enable-storehouse", false, "enable storehouse to store registers on disk, default is false")
147147
flags.BoolVar(&exeConf.enableChecker, "enable-checker", true, "enable checker to check the correctness of the execution result, default is true")
148-
flags.BoolVar(&exeConf.scheduleCallbacksEnabled, "scheduled-callbacks-enabled", fvm.DefaultScheduledCallbacksEnabled, "enable execution of scheduled callbacks")
148+
flags.BoolVar(&exeConf.scheduleCallbacksEnabled, "scheduled-callbacks-enabled", fvm.DefaultScheduledTransactionsEnabled, "[deprecated] enable execution of scheduled transactions")
149149
// deprecated. Retain it to prevent nodes that previously had this configuration from crashing.
150150
var deprecatedEnableNewIngestionEngine bool
151151
flags.BoolVar(&deprecatedEnableNewIngestionEngine, "enable-new-ingestion-engine", true, "enable new ingestion engine, default is true")

cmd/util/cmd/verify_execution_result/cmd.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ import (
1616
)
1717

1818
var (
19-
flagLastK uint64
20-
flagDatadir string
21-
flagChunkDataPackDir string
22-
flagChain string
23-
flagFromTo string
24-
flagWorkerCount uint // number of workers to verify the blocks concurrently
25-
flagStopOnMismatch bool
26-
flagtransactionFeesDisabled bool
27-
flagScheduledCallbacksEnabled bool
19+
flagLastK uint64
20+
flagDatadir string
21+
flagChunkDataPackDir string
22+
flagChain string
23+
flagFromTo string
24+
flagWorkerCount uint // number of workers to verify the blocks concurrently
25+
flagStopOnMismatch bool
26+
flagtransactionFeesDisabled bool
27+
flagScheduledTransactionsEnabled bool
2828
)
2929

3030
// # verify the last 100 sealed blocks
@@ -60,7 +60,7 @@ func init() {
6060

6161
Cmd.Flags().BoolVar(&flagtransactionFeesDisabled, "fees_disabled", false, "disable transaction fees")
6262

63-
Cmd.Flags().BoolVar(&flagScheduledCallbacksEnabled, "scheduled_callbacks_enabled", fvm.DefaultScheduledCallbacksEnabled, "enable scheduled callbacks")
63+
Cmd.Flags().BoolVar(&flagScheduledTransactionsEnabled, "scheduled_callbacks_enabled", fvm.DefaultScheduledTransactionsEnabled, "[deprecated] enable scheduled transactions")
6464
}
6565

6666
func run(*cobra.Command, []string) {
@@ -95,14 +95,14 @@ func run(*cobra.Command, []string) {
9595
}
9696

9797
lg.Info().Msgf("verifying range from %d to %d", from, to)
98-
err = verifier.VerifyRange(lockManager, from, to, chainID, flagDatadir, flagChunkDataPackDir, flagWorkerCount, flagStopOnMismatch, flagtransactionFeesDisabled, flagScheduledCallbacksEnabled)
98+
err = verifier.VerifyRange(lockManager, from, to, chainID, flagDatadir, flagChunkDataPackDir, flagWorkerCount, flagStopOnMismatch, flagtransactionFeesDisabled, flagScheduledTransactionsEnabled)
9999
if err != nil {
100100
lg.Fatal().Err(err).Msgf("could not verify range from %d to %d", from, to)
101101
}
102102
lg.Info().Msgf("finished verified range from %d to %d", from, to)
103103
} else {
104104
lg.Info().Msgf("verifying last %d sealed blocks", flagLastK)
105-
err := verifier.VerifyLastKHeight(lockManager, flagLastK, chainID, flagDatadir, flagChunkDataPackDir, flagWorkerCount, flagStopOnMismatch, flagtransactionFeesDisabled, flagScheduledCallbacksEnabled)
105+
err := verifier.VerifyLastKHeight(lockManager, flagLastK, chainID, flagDatadir, flagChunkDataPackDir, flagWorkerCount, flagStopOnMismatch, flagtransactionFeesDisabled, flagScheduledTransactionsEnabled)
106106
if err != nil {
107107
lg.Fatal().Err(err).Msg("could not verify last k height")
108108
}

cmd/util/ledger/reporters/fungible_token_tracker_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/hex"
55
"fmt"
66
"os"
7-
"strings"
87
"testing"
98

109
"github.com/onflow/cadence"
@@ -170,13 +169,13 @@ func TestFungibleTokenTracker(t *testing.T) {
170169
require.NoError(t, err)
171170

172171
// wrappedToken
173-
require.True(t, strings.Contains(string(data), `{"path":"storage/wrappedToken/vault","address":"8c5303eaa26202d6","balance":105,"type_id":"A.7e60df042a9c0868.FlowToken.Vault"}`))
172+
require.Contains(t, string(data), `{"path":"storage/wrappedToken/vault","address":"8c5303eaa26202d6","balance":105,"type_id":"A.7e60df042a9c0868.FlowToken.Vault"}`)
174173
// flowTokenVaults
175-
require.True(t, strings.Contains(string(data), `{"path":"storage/flowTokenVault","address":"8c5303eaa26202d6","balance":99999999999599895,"type_id":"A.7e60df042a9c0868.FlowToken.Vault"}`))
176-
require.True(t, strings.Contains(string(data), `{"path":"storage/flowTokenVault","address":"9a0766d93b6608b7","balance":100000,"type_id":"A.7e60df042a9c0868.FlowToken.Vault"}`))
177-
require.True(t, strings.Contains(string(data), `{"path":"storage/flowTokenVault","address":"7e60df042a9c0868","balance":100000,"type_id":"A.7e60df042a9c0868.FlowToken.Vault"}`))
178-
require.True(t, strings.Contains(string(data), `{"path":"storage/flowTokenVault","address":"912d5440f7e3769e","balance":100000,"type_id":"A.7e60df042a9c0868.FlowToken.Vault"}`))
179-
require.True(t, strings.Contains(string(data), `{"path":"storage/flowTokenVault","address":"754aed9de6197641","balance":100000,"type_id":"A.7e60df042a9c0868.FlowToken.Vault"}`))
174+
require.Contains(t, string(data), `{"path":"storage/flowTokenVault","address":"8c5303eaa26202d6","balance":99999999999599895,"type_id":"A.7e60df042a9c0868.FlowToken.Vault"}`)
175+
require.Contains(t, string(data), `{"path":"storage/flowTokenVault","address":"9a0766d93b6608b7","balance":100000,"type_id":"A.7e60df042a9c0868.FlowToken.Vault"}`)
176+
require.Contains(t, string(data), `{"path":"storage/flowTokenVault","address":"7e60df042a9c0868","balance":100000,"type_id":"A.7e60df042a9c0868.FlowToken.Vault"}`)
177+
require.Contains(t, string(data), `{"path":"storage/flowTokenVault","address":"912d5440f7e3769e","balance":100000,"type_id":"A.7e60df042a9c0868.FlowToken.Vault"}`)
178+
require.Contains(t, string(data), `{"path":"storage/flowTokenVault","address":"754aed9de6197641","balance":100000,"type_id":"A.7e60df042a9c0868.FlowToken.Vault"}`)
180179

181180
// do not remove this line, see https://github.com/onflow/flow-go/pull/2237
182181
t.Log("success")

cmd/verification_builder.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ type VerificationConfig struct {
5454
blockWorkers uint64 // number of blocks processed in parallel.
5555
chunkWorkers uint64 // number of chunks processed in parallel.
5656

57-
stopAtHeight uint64 // height to stop the node on
58-
scheduledCallbacksEnabled bool // enable execution of scheduled callbacks
57+
stopAtHeight uint64 // height to stop the node on
58+
scheduledTransactionsEnabled bool // enable execution of scheduled transactions
5959
}
6060

6161
type VerificationNodeBuilder struct {
@@ -83,7 +83,7 @@ func (v *VerificationNodeBuilder) LoadFlags() {
8383
flags.Uint64Var(&v.verConf.blockWorkers, "block-workers", blockconsumer.DefaultBlockWorkers, "maximum number of blocks being processed in parallel")
8484
flags.Uint64Var(&v.verConf.chunkWorkers, "chunk-workers", chunkconsumer.DefaultChunkWorkers, "maximum number of execution nodes a chunk data pack request is dispatched to")
8585
flags.Uint64Var(&v.verConf.stopAtHeight, "stop-at-height", 0, "height to stop the node at (0 to disable)")
86-
flags.BoolVar(&v.verConf.scheduledCallbacksEnabled, "scheduled-callbacks-enabled", fvm.DefaultScheduledCallbacksEnabled, "enable execution of scheduled callbacks")
86+
flags.BoolVar(&v.verConf.scheduledTransactionsEnabled, "scheduled-callbacks-enabled", fvm.DefaultScheduledTransactionsEnabled, "enable execution of scheduled transactions")
8787
})
8888
}
8989

@@ -211,7 +211,7 @@ func (v *VerificationNodeBuilder) LoadComponentsAndModules() {
211211
computation.DefaultFVMOptions(
212212
node.RootChainID,
213213
false,
214-
v.verConf.scheduledCallbacksEnabled,
214+
v.verConf.scheduledTransactionsEnabled,
215215
)...,
216216
)
217217
vmCtx := fvm.NewContext(fvmOptions...)

engine/access/rpc/backend/backend.go

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ import (
2525
"github.com/onflow/flow-go/engine/access/rpc/backend/transactions/provider"
2626
"github.com/onflow/flow-go/engine/access/rpc/backend/transactions/status"
2727
txstream "github.com/onflow/flow-go/engine/access/rpc/backend/transactions/stream"
28-
"github.com/onflow/flow-go/engine/access/rpc/backend/transactions/system"
2928
"github.com/onflow/flow-go/engine/access/rpc/connection"
3029
"github.com/onflow/flow-go/engine/access/subscription"
3130
"github.com/onflow/flow-go/engine/access/subscription/tracker"
3231
"github.com/onflow/flow-go/engine/common/rpc"
3332
"github.com/onflow/flow-go/engine/common/version"
3433
accessmodel "github.com/onflow/flow-go/model/access"
34+
"github.com/onflow/flow-go/model/access/systemcollection"
3535
"github.com/onflow/flow-go/model/flow"
3636
"github.com/onflow/flow-go/module"
3737
"github.com/onflow/flow-go/module/counters"
@@ -118,7 +118,6 @@ type Params struct {
118118
VersionControl *version.VersionControl
119119
ExecNodeIdentitiesProvider *rpc.ExecutionNodeIdentitiesProvider
120120
TxErrorMessageProvider error_messages.Provider
121-
ScheduledCallbacksEnabled bool
122121
}
123122

124123
var _ access.API = (*Backend)(nil)
@@ -138,9 +137,9 @@ func New(params Params) (*Backend, error) {
138137
}
139138
}
140139

141-
systemCollection, err := system.DefaultSystemCollection(params.ChainID, params.ScheduledCallbacksEnabled)
140+
systemCollections, err := systemcollection.NewVersioned(params.ChainID.Chain(), systemcollection.Default(params.ChainID))
142141
if err != nil {
143-
return nil, fmt.Errorf("failed to construct system collection: %w", err)
142+
return nil, fmt.Errorf("failed to create system collection set: %w", err)
144143
}
145144

146145
accountsBackend, err := accounts.NewAccountsBackend(
@@ -220,10 +219,9 @@ func New(params Params) (*Backend, error) {
220219
params.EventsIndex,
221220
params.TxResultsIndex,
222221
params.TxErrorMessageProvider,
223-
systemCollection,
222+
systemCollections,
224223
txStatusDeriver,
225224
params.ChainID,
226-
params.ScheduledCallbacksEnabled,
227225
)
228226
execNodeTxProvider := provider.NewENTransactionProvider(
229227
params.Log,
@@ -233,34 +231,32 @@ func New(params Params) (*Backend, error) {
233231
params.Communicator,
234232
params.ExecNodeIdentitiesProvider,
235233
txStatusDeriver,
236-
systemCollection,
234+
systemCollections,
237235
params.ChainID,
238-
params.ScheduledCallbacksEnabled,
239236
)
240237
failoverTxProvider := provider.NewFailoverTransactionProvider(localTxProvider, execNodeTxProvider)
241238

242239
txParams := transactions.Params{
243-
Log: params.Log,
244-
Metrics: params.AccessMetrics,
245-
State: params.State,
246-
ChainID: params.ChainID,
247-
SystemCollection: systemCollection,
248-
StaticCollectionRPCClient: params.CollectionRPC,
249-
HistoricalAccessNodeClients: params.HistoricalAccessNodes,
250-
NodeCommunicator: params.Communicator,
251-
ConnFactory: params.ConnFactory,
252-
NodeProvider: params.ExecNodeIdentitiesProvider,
253-
Blocks: params.Blocks,
254-
Collections: params.Collections,
255-
Transactions: params.Transactions,
256-
TxErrorMessageProvider: params.TxErrorMessageProvider,
257-
ScheduledTransactions: params.ScheduledTransactions,
258-
TxResultCache: txResCache,
259-
TxValidator: txValidator,
260-
TxStatusDeriver: txStatusDeriver,
261-
EventsIndex: params.EventsIndex,
262-
TxResultsIndex: params.TxResultsIndex,
263-
ScheduledTransactionsEnabled: params.ScheduledCallbacksEnabled,
240+
Log: params.Log,
241+
Metrics: params.AccessMetrics,
242+
State: params.State,
243+
ChainID: params.ChainID,
244+
SystemCollections: systemCollections,
245+
StaticCollectionRPCClient: params.CollectionRPC,
246+
HistoricalAccessNodeClients: params.HistoricalAccessNodes,
247+
NodeCommunicator: params.Communicator,
248+
ConnFactory: params.ConnFactory,
249+
NodeProvider: params.ExecNodeIdentitiesProvider,
250+
Blocks: params.Blocks,
251+
Collections: params.Collections,
252+
Transactions: params.Transactions,
253+
TxErrorMessageProvider: params.TxErrorMessageProvider,
254+
ScheduledTransactions: params.ScheduledTransactions,
255+
TxResultCache: txResCache,
256+
TxValidator: txValidator,
257+
TxStatusDeriver: txStatusDeriver,
258+
EventsIndex: params.EventsIndex,
259+
TxResultsIndex: params.TxResultsIndex,
264260
}
265261

266262
switch params.TxResultQueryMode {

engine/access/rpc/backend/backend_test.go

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ func (suite *Suite) TestGetTransactionResultByIndex() {
922922
suite.state.On("Sealed").Return(suite.snapshot, nil).Maybe()
923923

924924
ctx := context.Background()
925-
block := unittest.BlockFixture()
925+
block := unittest.BlockFixture(unittest.Block.WithHeight(1))
926926
blockId := block.ID()
927927
index := uint32(0)
928928

@@ -957,6 +957,12 @@ func (suite *Suite) TestGetTransactionResultByIndex() {
957957
On("GetTransactionResultByIndex", mock.Anything, exeEventReq).
958958
Return(exeEventResp, nil)
959959

960+
suite.execClient.
961+
On("GetEventsForBlockIDs", mock.Anything, mock.Anything).
962+
Return(&execproto.GetEventsForBlockIDsResponse{
963+
Results: []*execproto.GetEventsForBlockIDsResponse_Result{},
964+
}, nil)
965+
960966
suite.Run("TestGetTransactionResultByIndex - happy path", func() {
961967
suite.snapshot.On("Head").Return(block.ToHeader(), nil).Once()
962968
result, err := backend.GetTransactionResultByIndex(ctx, blockId, index, entitiesproto.EventEncodingVersion_JSON_CDC_V0)
@@ -1008,7 +1014,7 @@ func (suite *Suite) TestGetTransactionResultsByBlockID() {
10081014
}
10091015

10101016
exeEventResp := &execproto.GetTransactionResultsResponse{
1011-
TransactionResults: []*execproto.GetTransactionResultResponse{{}},
1017+
TransactionResults: []*execproto.GetTransactionResultResponse{{}, {}},
10121018
EventEncodingVersion: entitiesproto.EventEncodingVersion_CCF_V0,
10131019
}
10141020

@@ -1017,11 +1023,17 @@ func (suite *Suite) TestGetTransactionResultsByBlockID() {
10171023
params := suite.defaultBackendParams()
10181024
// the connection factory should be used to get the execution node client
10191025
params.ConnFactory = suite.setupConnectionFactory()
1020-
params.ScheduledCallbacksEnabled = true
10211026

10221027
backend, err := New(params)
10231028
suite.Require().NoError(err)
10241029

1030+
suite.execClient.
1031+
On("GetEventsForBlockIDs", mock.Anything, mock.Anything).
1032+
Return(&execproto.GetEventsForBlockIDsResponse{
1033+
Results: []*execproto.GetEventsForBlockIDsResponse_Result{},
1034+
}, nil).
1035+
Maybe()
1036+
10251037
suite.execClient.
10261038
On("GetTransactionResultsByBlockID", mock.Anything, exeEventReq).
10271039
Return(exeEventResp, nil)
@@ -1848,7 +1860,7 @@ func (suite *Suite) TestGetTransactionResultByIndexAndBlockIdEventEncodingVersio
18481860
suite.state.On("Sealed").Return(suite.snapshot, nil).Maybe()
18491861

18501862
ctx := context.Background()
1851-
block := unittest.BlockFixture()
1863+
block := unittest.BlockFixture(unittest.Block.WithHeight(1))
18521864
blockId := block.ID()
18531865
index := uint32(0)
18541866

@@ -1872,6 +1884,14 @@ func (suite *Suite) TestGetTransactionResultByIndexAndBlockIdEventEncodingVersio
18721884
backend, err := New(params)
18731885
suite.Require().NoError(err)
18741886

1887+
// Mock GetEventsForBlockIDs for system collection construction
1888+
suite.execClient.
1889+
On("GetEventsForBlockIDs", mock.Anything, mock.Anything).
1890+
Return(&execproto.GetEventsForBlockIDsResponse{
1891+
Results: []*execproto.GetEventsForBlockIDsResponse_Result{},
1892+
}, nil).
1893+
Maybe()
1894+
18751895
exeNodeEventEncodingVersion := entitiesproto.EventEncodingVersion_CCF_V0
18761896
ccfEvents, jsoncdcEvents := generateEncodedEvents(suite.T(), 1)
18771897
eventMessages := convert.EventsToMessages(ccfEvents)
@@ -1909,6 +1929,10 @@ func (suite *Suite) TestGetTransactionResultByIndexAndBlockIdEventEncodingVersio
19091929
suite.Run(fmt.Sprintf("test %s event encoding version for GetTransactionResultsByBlockID", version.String()), func() {
19101930
exeEventResp := &execproto.GetTransactionResultsResponse{
19111931
TransactionResults: []*execproto.GetTransactionResultResponse{
1932+
{
1933+
Events: eventMessages,
1934+
EventEncodingVersion: exeNodeEventEncodingVersion,
1935+
},
19121936
{
19131937
Events: eventMessages,
19141938
EventEncodingVersion: exeNodeEventEncodingVersion,

0 commit comments

Comments
 (0)