Skip to content

Commit 9407a95

Browse files
authored
Merge pull request #7890 from onflow/peter/sc-api-system-tx-id
[Access] Update Access API endpoints to support schedule callbacks MVP
2 parents dada498 + 8bfa2df commit 9407a95

File tree

38 files changed

+1729
-296
lines changed

38 files changed

+1729
-296
lines changed

access/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ type TransactionsAPI interface {
5757
GetTransactionResultByIndex(ctx context.Context, blockID flow.Identifier, index uint32, encodingVersion entities.EventEncodingVersion) (*accessmodel.TransactionResult, error)
5858
GetTransactionResultsByBlockID(ctx context.Context, blockID flow.Identifier, encodingVersion entities.EventEncodingVersion) ([]*accessmodel.TransactionResult, error)
5959

60-
GetSystemTransaction(ctx context.Context, blockID flow.Identifier) (*flow.TransactionBody, error)
61-
GetSystemTransactionResult(ctx context.Context, blockID flow.Identifier, encodingVersion entities.EventEncodingVersion) (*accessmodel.TransactionResult, error)
60+
GetSystemTransaction(ctx context.Context, txID flow.Identifier, blockID flow.Identifier) (*flow.TransactionBody, error)
61+
GetSystemTransactionResult(ctx context.Context, txID flow.Identifier, blockID flow.Identifier, encodingVersion entities.EventEncodingVersion) (*accessmodel.TransactionResult, error)
6262
}
6363

6464
type TransactionStreamAPI interface {

access/mock/api.go

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/access/node_builder/access_node_builder.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import (
6565
"github.com/onflow/flow-go/engine/common/version"
6666
"github.com/onflow/flow-go/engine/execution/computation"
6767
"github.com/onflow/flow-go/engine/execution/computation/query"
68+
"github.com/onflow/flow-go/fvm"
6869
"github.com/onflow/flow-go/fvm/storage/derived"
6970
"github.com/onflow/flow-go/ledger"
7071
"github.com/onflow/flow-go/ledger/complete/wal"
@@ -183,6 +184,7 @@ type AccessNodeConfig struct {
183184
storeTxResultErrorMessages bool
184185
stopControlEnabled bool
185186
registerDBPruneThreshold uint64
187+
scheduledCallbacksEnabled bool
186188
}
187189

188190
type PublicNetworkConfig struct {
@@ -292,6 +294,7 @@ func DefaultAccessNodeConfig() *AccessNodeConfig {
292294
storeTxResultErrorMessages: false,
293295
stopControlEnabled: false,
294296
registerDBPruneThreshold: 0,
297+
scheduledCallbacksEnabled: fvm.DefaultScheduledCallbacksEnabled,
295298
}
296299
}
297300

@@ -1321,6 +1324,10 @@ func (builder *FlowAccessNodeBuilder) extraFlags() {
13211324
"stop-control-enabled",
13221325
defaultConfig.stopControlEnabled,
13231326
"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.")
13241331
// ExecutionDataRequester config
13251332
flags.BoolVar(&builder.executionDataSyncEnabled,
13261333
"execution-data-sync-enabled",
@@ -2149,6 +2156,7 @@ func (builder *FlowAccessNodeBuilder) Build() (cmd.Node, error) {
21492156
ExecNodeIdentitiesProvider: notNil(builder.ExecNodeIdentitiesProvider),
21502157
TxErrorMessageProvider: notNil(builder.txResultErrorMessageProvider),
21512158
MaxScriptAndArgumentSize: config.BackendConfig.AccessConfig.MaxRequestMsgSize,
2159+
ScheduledCallbacksEnabled: builder.scheduledCallbacksEnabled,
21522160
})
21532161
if err != nil {
21542162
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
@@ -144,7 +144,7 @@ func (exeConf *ExecutionConfig) SetupFlags(flags *pflag.FlagSet) {
144144
flags.BoolVar(&exeConf.onflowOnlyLNs, "temp-onflow-only-lns", false, "do not use unless required. forces node to only request collections from onflow collection nodes")
145145
flags.BoolVar(&exeConf.enableStorehouse, "enable-storehouse", false, "enable storehouse to store registers on disk, default is false")
146146
flags.BoolVar(&exeConf.enableChecker, "enable-checker", true, "enable checker to check the correctness of the execution result, default is true")
147-
flags.BoolVar(&exeConf.scheduleCallbacksEnabled, "scheduled-callbacks-enabled", false, "enable execution of scheduled callbacks")
147+
flags.BoolVar(&exeConf.scheduleCallbacksEnabled, "scheduled-callbacks-enabled", fvm.DefaultScheduledCallbacksEnabled, "enable execution of scheduled callbacks")
148148
// deprecated. Retain it to prevent nodes that previously had this configuration from crashing.
149149
var deprecatedEnableNewIngestionEngine bool
150150
flags.BoolVar(&deprecatedEnableNewIngestionEngine, "enable-new-ingestion-engine", true, "enable new ingestion engine, default is true")

cmd/util/cmd/run-script/cmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,15 @@ func (*api) GetTransactionResultsByBlockID(
342342
func (*api) GetSystemTransaction(
343343
_ context.Context,
344344
_ flow.Identifier,
345+
_ flow.Identifier,
345346
) (*flow.TransactionBody, error) {
346347
return nil, errors.New("unimplemented")
347348
}
348349

349350
func (*api) GetSystemTransactionResult(
350351
_ context.Context,
351352
_ flow.Identifier,
353+
_ flow.Identifier,
352354
_ entities.EventEncodingVersion,
353355
) (*accessmodel.TransactionResult, error) {
354356
return nil, errors.New("unimplemented")

cmd/verification_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (v *VerificationNodeBuilder) LoadFlags() {
8484
flags.Uint64Var(&v.verConf.blockWorkers, "block-workers", blockconsumer.DefaultBlockWorkers, "maximum number of blocks being processed in parallel")
8585
flags.Uint64Var(&v.verConf.chunkWorkers, "chunk-workers", chunkconsumer.DefaultChunkWorkers, "maximum number of execution nodes a chunk data pack request is dispatched to")
8686
flags.Uint64Var(&v.verConf.stopAtHeight, "stop-at-height", 0, "height to stop the node at (0 to disable)")
87-
flags.BoolVar(&v.verConf.scheduledCallbacksEnabled, "scheduled-callbacks-enabled", false, "enable execution of scheduled callbacks")
87+
flags.BoolVar(&v.verConf.scheduledCallbacksEnabled, "scheduled-callbacks-enabled", fvm.DefaultScheduledCallbacksEnabled, "enable execution of scheduled callbacks")
8888
})
8989
}
9090

engine/access/rpc/backend/backend.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ type Params struct {
118118
VersionControl *version.VersionControl
119119
ExecNodeIdentitiesProvider *rpc.ExecutionNodeIdentitiesProvider
120120
TxErrorMessageProvider error_messages.Provider
121+
ScheduledCallbacksEnabled bool
121122
}
122123

123124
var _ access.API = (*Backend)(nil)
@@ -223,6 +224,8 @@ func New(params Params) (*Backend, error) {
223224
params.TxErrorMessageProvider,
224225
systemTxID,
225226
txStatusDeriver,
227+
params.ChainID,
228+
params.ScheduledCallbacksEnabled,
226229
)
227230
execNodeTxProvider := provider.NewENTransactionProvider(
228231
params.Log,
@@ -233,7 +236,8 @@ func New(params Params) (*Backend, error) {
233236
params.ExecNodeIdentitiesProvider,
234237
txStatusDeriver,
235238
systemTxID,
236-
systemTx,
239+
params.ChainID,
240+
params.ScheduledCallbacksEnabled,
237241
)
238242
failoverTxProvider := provider.NewFailoverTransactionProvider(localTxProvider, execNodeTxProvider)
239243

@@ -242,7 +246,6 @@ func New(params Params) (*Backend, error) {
242246
Metrics: params.AccessMetrics,
243247
State: params.State,
244248
ChainID: params.ChainID,
245-
SystemTx: systemTx,
246249
SystemTxID: systemTxID,
247250
StaticCollectionRPCClient: params.CollectionRPC,
248251
HistoricalAccessNodeClients: params.HistoricalAccessNodes,
@@ -259,6 +262,7 @@ func New(params Params) (*Backend, error) {
259262
TxStatusDeriver: txStatusDeriver,
260263
EventsIndex: params.EventsIndex,
261264
TxResultsIndex: params.TxResultsIndex,
265+
ScheduledCallbacksEnabled: params.ScheduledCallbacksEnabled,
262266
}
263267

264268
switch params.TxResultQueryMode {

engine/access/rpc/backend/backend_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestHandler(t *testing.T) {
104104
}
105105

106106
func (suite *Suite) SetupTest() {
107-
suite.log = zerolog.New(zerolog.NewConsoleWriter())
107+
suite.log = unittest.Logger()
108108
suite.state = new(protocol.State)
109109
suite.snapshot = new(protocol.Snapshot)
110110
header := unittest.BlockHeaderFixture()
@@ -969,7 +969,7 @@ func (suite *Suite) TestGetTransactionResultByIndex() {
969969
suite.snapshot.On("Head").Return(nil, err).Once()
970970

971971
// mock signaler context expect an error
972-
signCtxErr := irrecoverable.NewExceptionf("failed to lookup sealed header: %w", err)
972+
signCtxErr := fmt.Errorf("failed to derive transaction status: %w", irrecoverable.NewExceptionf("failed to lookup sealed header: %w", err))
973973
signalerCtx := irrecoverable.WithSignalerContext(context.Background(),
974974
irrecoverable.NewMockSignalerContextExpectError(suite.T(), context.Background(), signCtxErr))
975975

@@ -1004,14 +1004,16 @@ func (suite *Suite) TestGetTransactionResultsByBlockID() {
10041004
}
10051005

10061006
exeEventResp := &execproto.GetTransactionResultsResponse{
1007-
TransactionResults: []*execproto.GetTransactionResultResponse{{}},
1007+
TransactionResults: []*execproto.GetTransactionResultResponse{{}},
1008+
EventEncodingVersion: entitiesproto.EventEncodingVersion_CCF_V0,
10081009
}
10091010

10101011
suite.fixedExecutionNodeIDs = fixedENIDs.NodeIDs()
10111012

10121013
params := suite.defaultBackendParams()
10131014
// the connection factory should be used to get the execution node client
10141015
params.ConnFactory = suite.setupConnectionFactory()
1016+
params.ScheduledCallbacksEnabled = true
10151017

10161018
backend, err := New(params)
10171019
suite.Require().NoError(err)
@@ -1036,7 +1038,7 @@ func (suite *Suite) TestGetTransactionResultsByBlockID() {
10361038
suite.snapshot.On("Head").Return(nil, err).Once()
10371039

10381040
// mock signaler context expect an error
1039-
signCtxErr := irrecoverable.NewExceptionf("failed to lookup sealed header: %w", err)
1041+
signCtxErr := fmt.Errorf("failed to derive transaction status: %w", irrecoverable.NewExceptionf("failed to lookup sealed header: %w", err))
10401042
signalerCtx := irrecoverable.WithSignalerContext(context.Background(),
10411043
irrecoverable.NewMockSignalerContextExpectError(suite.T(), context.Background(), signCtxErr))
10421044

0 commit comments

Comments
 (0)