-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Allow flat interpolation #13601
Merged
Merged
Allow flat interpolation #13601
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d226d76
Allow flat interpolation
cedric-cordenier 31a8e13
Update common
cedric-cordenier a2bc5d5
Merge branch 'develop' into allow-flat-interpolation
cedric-cordenier d79fc23
Merge branch 'develop' into allow-flat-interpolation
cedric-cordenier 1b87d12
Merge branch 'develop' into allow-flat-interpolation
cedric-cordenier 1f096fb
Merge branch 'develop' into allow-flat-interpolation
cedric-cordenier e44b5d8
Merge branch 'develop' into allow-flat-interpolation
cedric-cordenier 7441699
Fix tests after rebase
cedric-cordenier a31c988
Merge branch 'develop' into allow-flat-interpolation
cedric-cordenier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"chainlink": minor | ||
--- | ||
|
||
#internal Allow outputs to be passed directly to the inputs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,9 +74,9 @@ func Test_RemoteTargetCapability_TransmissionSchedules(t *testing.T) { | |
responseTest := func(t *testing.T, responseCh <-chan commoncap.CapabilityResponse, responseError error) { | ||
require.NoError(t, responseError) | ||
response := <-responseCh | ||
responseValue, err := response.Value.Unwrap() | ||
mp, err := response.Value.Unwrap() | ||
require.NoError(t, err) | ||
assert.Equal(t, "aValue1", responseValue.(string)) | ||
assert.Equal(t, "aValue1", mp.(map[string]any)["response"].(string)) | ||
} | ||
|
||
transmissionSchedule, err := values.NewMap(map[string]any{ | ||
|
@@ -106,9 +106,9 @@ func Test_RemoteTargetCapability_DonTopologies(t *testing.T) { | |
responseTest := func(t *testing.T, responseCh <-chan commoncap.CapabilityResponse, responseError error) { | ||
require.NoError(t, responseError) | ||
response := <-responseCh | ||
responseValue, err := response.Value.Unwrap() | ||
mp, err := response.Value.Unwrap() | ||
require.NoError(t, err) | ||
assert.Equal(t, "aValue1", responseValue.(string)) | ||
assert.Equal(t, "aValue1", mp.(map[string]any)["response"].(string)) | ||
} | ||
|
||
transmissionSchedule, err := values.NewMap(map[string]any{ | ||
|
@@ -409,8 +409,12 @@ func (t TestCapability) Execute(ctx context.Context, request commoncap.Capabilit | |
|
||
value := request.Inputs.Underlying["executeValue1"] | ||
|
||
response, err := values.NewMap(map[string]any{"response": value}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bolekk This is where we create the response value |
||
if err != nil { | ||
return nil, err | ||
} | ||
ch <- commoncap.CapabilityResponse{ | ||
Value: value, | ||
Value: response, | ||
} | ||
|
||
return ch, nil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -483,8 +483,9 @@ targets: | |
` | ||
) | ||
|
||
func mockAction() (*mockCapability, values.Value) { | ||
outputs := values.NewString("output") | ||
func mockAction(t *testing.T) (*mockCapability, values.Value) { | ||
outputs, err := values.NewMap(map[string]any{"output": "foo"}) | ||
require.NoError(t, err) | ||
return newMockCapability( | ||
capabilities.MustNewCapabilityInfo( | ||
"[email protected]", | ||
|
@@ -510,7 +511,7 @@ func TestEngine_MultiStepDependencies(t *testing.T) { | |
require.NoError(t, reg.Add(ctx, mockConsensus())) | ||
require.NoError(t, reg.Add(ctx, mockTarget())) | ||
|
||
action, out := mockAction() | ||
action, out := mockAction(t) | ||
require.NoError(t, reg.Add(ctx, action)) | ||
|
||
eng, hooks := newTestEngine(t, reg, multiStepWorkflow) | ||
|
@@ -557,7 +558,7 @@ func TestEngine_ResumesPendingExecutions(t *testing.T) { | |
require.NoError(t, reg.Add(ctx, mockConsensus())) | ||
require.NoError(t, reg.Add(ctx, mockTarget())) | ||
|
||
action, _ := mockAction() | ||
action, _ := mockAction(t) | ||
require.NoError(t, reg.Add(ctx, action)) | ||
|
||
dbstore := store.NewDBStore(pgtest.NewSqlxDB(t), clockwork.NewFakeClock()) | ||
|
@@ -610,7 +611,7 @@ func TestEngine_TimesOutOldExecutions(t *testing.T) { | |
require.NoError(t, reg.Add(ctx, mockConsensus())) | ||
require.NoError(t, reg.Add(ctx, mockTarget())) | ||
|
||
action, _ := mockAction() | ||
action, _ := mockAction(t) | ||
require.NoError(t, reg.Add(ctx, action)) | ||
|
||
clock := clockwork.NewFakeClock() | ||
|
@@ -791,3 +792,91 @@ func TestEngine_GetsNodeInfoDuringInitialization(t *testing.T) { | |
|
||
assert.Equal(t, node, eng.localNode) | ||
} | ||
|
||
const passthroughInterpolationWorkflow = ` | ||
triggers: | ||
- id: "[email protected]" | ||
config: | ||
feedIds: | ||
- "0x1111111111111111111100000000000000000000000000000000000000000000" | ||
- "0x2222222222222222222200000000000000000000000000000000000000000000" | ||
- "0x3333333333333333333300000000000000000000000000000000000000000000" | ||
|
||
consensus: | ||
- id: "[email protected]" | ||
ref: "evm_median" | ||
inputs: | ||
observations: | ||
- "$(trigger.outputs)" | ||
config: | ||
aggregation_method: "data_feeds_2_0" | ||
aggregation_config: | ||
"0x1111111111111111111100000000000000000000000000000000000000000000": | ||
deviation: "0.001" | ||
heartbeat: 3600 | ||
"0x2222222222222222222200000000000000000000000000000000000000000000": | ||
deviation: "0.001" | ||
heartbeat: 3600 | ||
"0x3333333333333333333300000000000000000000000000000000000000000000": | ||
deviation: "0.001" | ||
heartbeat: 3600 | ||
encoder: "EVM" | ||
encoder_config: | ||
abi: "mercury_reports bytes[]" | ||
|
||
targets: | ||
- id: "[email protected]" | ||
inputs: "$(evm_median.outputs)" | ||
config: | ||
address: "0x54e220867af6683aE6DcBF535B4f952cB5116510" | ||
params: ["$(report)"] | ||
abi: "receive(report bytes)" | ||
` | ||
|
||
func TestEngine_PassthroughInterpolation(t *testing.T) { | ||
ctx := testutils.Context(t) | ||
reg := coreCap.NewRegistry(logger.TestLogger(t)) | ||
|
||
trigger, _ := mockTrigger(t) | ||
|
||
require.NoError(t, reg.Add(ctx, trigger)) | ||
require.NoError(t, reg.Add(ctx, mockConsensus())) | ||
writeID := "[email protected]" | ||
target := newMockCapability( | ||
capabilities.MustNewCapabilityInfo( | ||
writeID, | ||
capabilities.CapabilityTypeTarget, | ||
"a write capability targeting ethereum sepolia testnet", | ||
), | ||
func(req capabilities.CapabilityRequest) (capabilities.CapabilityResponse, error) { | ||
return capabilities.CapabilityResponse{ | ||
Value: req.Inputs, | ||
}, nil | ||
}, | ||
) | ||
require.NoError(t, reg.Add(ctx, target)) | ||
|
||
eng, testHooks := newTestEngine( | ||
t, | ||
reg, | ||
passthroughInterpolationWorkflow, | ||
) | ||
|
||
servicetest.Run(t, eng) | ||
|
||
eid := getExecutionId(t, eng, testHooks) | ||
|
||
state, err := eng.executionStates.Get(ctx, eid) | ||
require.NoError(t, err) | ||
|
||
assert.Equal(t, state.Status, store.StatusCompleted) | ||
|
||
// There is passthrough interpolation between the consensus and target steps, | ||
// so the input of one should be the output of the other, exactly. | ||
gotInputs, err := values.Unwrap(state.Steps[writeID].Inputs) | ||
require.NoError(t, err) | ||
|
||
gotOutputs, err := values.Unwrap(state.Steps["evm_median"].Outputs.Value) | ||
require.NoError(t, err) | ||
assert.Equal(t, gotInputs, gotOutputs) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,7 +214,7 @@ targets: | |
}, | ||
}, | ||
{ | ||
name: "non-trigger step with no dependent refs", | ||
name: "invalid refs", | ||
yaml: ` | ||
triggers: | ||
- id: "[email protected]" | ||
|
@@ -241,7 +241,7 @@ targets: | |
inputs: | ||
consensus_output: $(a-consensus.outputs) | ||
`, | ||
errMsg: "all non-trigger steps must have a dependent ref", | ||
errMsg: "invalid refs", | ||
}, | ||
{ | ||
name: "duplicate edge declarations", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get it. Where do we create this nested "response" key in the map? Is it now a requirement for every capability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tagged you where we add the response key.
The only requirement this PR introduces is for capabilities to return a map, not just any value. I think this is preferable because a) all capabilities so far return a map anyway, and b) it's symmetric with the inputs we expect