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

[WriteTarget] Add input field that combines reports and signatures #13350

Merged
merged 2 commits into from
May 29, 2024
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
13 changes: 11 additions & 2 deletions core/capabilities/targets/write_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ var (
_ capabilities.ActionCapability = &EvmWrite{}
)

const defaultGasLimit = 200000
const (
defaultGasLimit = 200000
signedReportField = "signed_report"
)

type EvmWrite struct {
chain legacyevm.Chain
Expand Down Expand Up @@ -97,11 +100,16 @@ func (cap *EvmWrite) Execute(ctx context.Context, request capabilities.Capabilit
return nil, err
}

signedReport, ok := request.Inputs.Underlying[signedReportField]
if !ok {
return nil, fmt.Errorf("missing required field %s", signedReportField)
}

var inputs struct {
Report []byte
Signatures [][]byte
}
if err = request.Inputs.UnwrapTo(&inputs); err != nil {
if err = signedReport.UnwrapTo(&inputs); err != nil {
return nil, err
}

Expand All @@ -119,6 +127,7 @@ func (cap *EvmWrite) Execute(ctx context.Context, request capabilities.Capabilit
}()
return callback, nil
}
cap.lggr.Debugw("WriteTarget non-empty report - attempting to push to txmgr", "request", request, "report", inputs.Report, "signatures", inputs.Signatures)

// TODO: validate encoded report is prefixed with workflowID and executionID that match the request meta

Expand Down
15 changes: 8 additions & 7 deletions core/capabilities/targets/write_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ func TestEvmWrite(t *testing.T) {
require.NoError(t, err)

inputs, err := values.NewMap(map[string]any{
"report": []byte{1, 2, 3},
"signatures": [][]byte{},
"signed_report": map[string]any{
"report": []byte{1, 2, 3},
"signatures": [][]byte{},
},
})
require.NoError(t, err)

Expand Down Expand Up @@ -106,14 +108,13 @@ func TestEvmWrite_EmptyReport(t *testing.T) {
capability := targets.NewEvmWrite(chain, logger.TestLogger(t))
ctx := testutils.Context(t)

config, err := values.NewMap(map[string]any{
"abi": "receive(report bytes)",
"params": []any{"$(report)"},
})
config, err := values.NewMap(map[string]any{})
require.NoError(t, err)

inputs, err := values.NewMap(map[string]any{
"report": nil,
"signed_report": map[string]any{
"report": nil,
},
})
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion core/scripts/keystone/config_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"DeltaCertifiedCommitRequestMillis": 1000,
"DeltaStageMillis": 30000,
"MaxRoundsPerEpoch": 10,
"TransmissionSchedule": [1, 1, 1, 1],
"TransmissionSchedule": [4],

"MaxDurationQueryMillis": 1000,
"MaxDurationObservationMillis": 1000,
Expand Down
Loading