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

fix validation in chain write capability #15191

Conversation

jinhoonbang
Copy link
Contributor

@jinhoonbang jinhoonbang commented Nov 11, 2024

fix for validation errors in chain write capability.

  1. change workflow owner validation to be case-insensitive. Previous error was:
{"level":"error","ts":"2024-11-07T19:41:53.857Z","logger":"WorkflowEngine","caller":"workflows/engine.go:788","msg":"error executing step request: WorkflowOwner in the report does not match WorkflowOwner in the request metadata. Report WorkflowOwner: f39fd6e51aad88f6f4ce6ab8827279cfffb92266, request WorkflowOwner: f39Fd6e51aad88F6F4ce6aB8827279cffFb92266","version":"2.18.0@b54ecc5","workflowID":"25c431fe6583ef9f6fa463ecae2642ca92913abfe03ac3df731c18ee49514e1f","stepRef":"write_geth-testnet@1.0.0","workflowExecutionID":"51162356dd82ee2e378832d5ce7da91681ec113c5c32450695a228eb8b7a66b7","sentryEventID":null,"stacktrace":"github.com/smartcontractkit/chainlink/v2/core/services/workflows.(*Engine).workerForStepRequest\n\tgithub.com/smartcontractkit/chainlink/v2/core/services/workflows/engine.go:788\ngithub.com/smartcontractkit/chainlink/v2/core/services/workflows.(*Engine).worker\n\tgithub.com/smartcontractkit/chainlink/v2/core/services/workflows/engine.go:719"}
  1. change workflow name validation to be based on [10]byte. Previous error was:
{"level":"error","ts":"2024-11-07T23:34:12.977Z","logger":"WorkflowEngine","caller":"workflows/engine.go:788","msg":"error executing step request: WorkflowName in the report does not match WorkflowName in the request metadata. Report WorkflowName: 6c2d3133333700000000, request WorkflowName: 6c2d31333337","version":"2.18.0@dfd16fc","workflowID":"c62a5a587bdf7f7eb7c6426a7bdcf2c6a3a9cd03ca014b32f1da17d2774f85a6","stepRef":"write_geth-testnet@1.0.0","workflowExecutionID":"6e3915c5a833cb07fc0dfe9d3745891503c81311ba64558ebaa846964e02d074","sentryEventID":null,"stacktrace":"github.com/smartcontractkit/chainlink/v2/core/services/workflows.(*Engine).workerForStepRequest\n\tgithub.com/smartcontractkit/chainlink/v2/core/services/workflows/engine.go:788\ngithub.com/smartcontractkit/chainlink/v2/core/services/workflows.(*Engine).worker\n\tgithub.com/smartcontractkit/chainlink/v2/core/services/workflows/engine.go:719"}

Copy link
Contributor

I see you updated files related to core. Please run pnpm changeset in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

@jinhoonbang jinhoonbang marked this pull request as ready for review November 11, 2024 21:59
@jinhoonbang jinhoonbang requested review from a team as code owners November 11, 2024 21:59
vreff
vreff previously approved these changes Nov 12, 2024
@@ -217,4 +220,44 @@ func TestWriteTarget(t *testing.T) {
_, err2 := writeTarget.Execute(ctx, req)
require.Error(t, err2)
})

tests := []struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add case-insensitive scenarios?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. case-insensitive scenario is now tested as part of TestWriteTarget/succeeds_with_valid_report

@@ -181,12 +182,18 @@ func evaluate(rawRequest capabilities.CapabilityRequest) (r Request, err error)
return r, fmt.Errorf("WorkflowExecutionID in the report does not match WorkflowExecutionID in the request metadata. Report WorkflowExecutionID: %+v, request WorkflowExecutionID: %+v", reportMetadata.WorkflowExecutionID, rawRequest.Metadata.WorkflowExecutionID)
}

if hex.EncodeToString(reportMetadata.WorkflowOwner[:]) != rawRequest.Metadata.WorkflowOwner {
if !strings.EqualFold(hex.EncodeToString(reportMetadata.WorkflowOwner[:]), rawRequest.Metadata.WorkflowOwner) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add comments in both cases to explain what we're doing and why we need it?

For item 1: do a case sensitive verification of the owner address (so that a check-summed address matches its non-checksummed version).

For item 2: workflowNames are padded in the core node to 10bytes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep added!

@jinhoonbang jinhoonbang requested a review from a team November 14, 2024 16:29
@jinhoonbang jinhoonbang added this pull request to the merge queue Nov 19, 2024
Merged via the queue into develop with commit 570c23f Nov 19, 2024
141 of 142 checks passed
@jinhoonbang jinhoonbang deleted the CM-561-chain-write-capability-workflow-name-and-owner-validation-errors branch November 19, 2024 20:39
cedric-cordenier pushed a commit that referenced this pull request Nov 20, 2024
* fix validation in chain write capability

* add unit tests

* address comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants