Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/runtime/client: Fail SubmitTx early for unsupported runtimes #4204

Merged
merged 1 commit into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changelog/4202.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
go/runtime/client: Fail SubmitTx early for unsupported runtimes

Make sure that the runtime is actually among the supported runtimes as
otherwise we will not be able to actually get any results back.
6 changes: 6 additions & 0 deletions go/runtime/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ func (c *runtimeClient) submitTx(ctx context.Context, request *api.SubmitTxReque
return nil, fmt.Errorf("client: cannot submit transaction, p2p disabled")
}

// Make sure that the runtime is actually among the supported runtimes for this node as
// otherwise we will not be able to actually get any results back.
if _, err := c.common.runtimeRegistry.GetRuntime(request.RuntimeID); err != nil {
kostko marked this conversation as resolved.
Show resolved Hide resolved
return nil, fmt.Errorf("client: cannot resolve runtime: %w", err)
}

// Make sure consensus is synced.
select {
case <-c.common.consensus.Synced():
Expand Down
9 changes: 9 additions & 0 deletions go/runtime/client/tests/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func testFailSubmitTransaction(
c api.RuntimeClient,
input string,
) {
// Failures during CheckTx.
resp, err := c.SubmitTxMeta(ctx, &api.SubmitTxRequest{Data: mock.CheckTxFailInput, RuntimeID: runtimeID})
require.NoError(t, err, "SubmitTxMeta")
require.EqualValues(t, &protocol.Error{
Expand All @@ -90,6 +91,14 @@ func testFailSubmitTransaction(

_, err = c.SubmitTx(ctx, &api.SubmitTxRequest{Data: mock.CheckTxFailInput, RuntimeID: runtimeID})
require.Error(t, err, "SubmitTx should fail check tx")

// Failures for unsupported runtimes.
var unsupportedRuntimeID common.Namespace
err = unsupportedRuntimeID.UnmarshalHex("0000000000000000BADF00BADF00BADF00BADF00BADF00BADF00BADF00BADF00")
require.NoError(t, err, "UnmarshalHex")

_, err = c.SubmitTx(ctx, &api.SubmitTxRequest{Data: []byte("irrelevant"), RuntimeID: unsupportedRuntimeID})
require.Error(t, err, "SubmitTx should fail for unsupported runtime")
}

func testQuery(
Expand Down