-
Notifications
You must be signed in to change notification settings - Fork 693
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
node: add amazon kms and benchmark signers (old) #4148
node: add amazon kms and benchmark signers (old) #4148
Conversation
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.
Excited about trying this one 👏🏻
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.
For the record, as discussed privately, I think metrics should be produced all the time and not limited to when testing/benchmarking.
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.
Other reviewers may have a different perspective on how this code relies on context.Context
but aside from that I think this is ready for broader review.
guardianSignerUri := args[0] | ||
wormchainAddress := args[1] | ||
if !strings.HasPrefix(wormchainAddress, "wormhole") || strings.HasPrefix(wormchainAddress, "wormholeval") { | ||
return errors.New("must provide a bech32 address that has 'wormhole' prefix") | ||
} | ||
|
||
guardianSigner, err := guardiansigner.NewGuardianSignerFromUri(guardianSignerUri, *unsafeDevnetMode) | ||
guardianSigner, err := guardiansigner.NewGuardianSignerFromUri(ctx, guardianSignerUri, *unsafeDevnetMode) |
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.
Context shouldn't be passed to constructors but to calls, such as Sign
and Verify
by the callers.
- https://go.dev/blog/context-and-structs#prefer-contexts-passed-as-arguments
- https://go.dev/blog/context-and-structs#storing-context-in-structs-leads-to-confusion
That said, I think we can keep this as is and simply add comments explaining why this is a special case, i.e. you need a context for calling AWS KMS during signer initialization.
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.
Alternatively, the initialization may not ask for a parent Context and simply manage its own, e.g. a Context.WithTimeout(timeout)
should suffice.
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 think the suggestion for managing its own context is good. But I'm on the fence about it, so I'm going to defer this to a broader review for the time being.
Amazon KMS Guardian Signer
This PR adds an Amazon AWS KMS Guardian signer, allowing observations to be signed using KMS! The new signer can be used by specifying the ARN of the KMS key to use, through the
--guardianSignerUri
commandline argument, as follows:--guardianSignerUri=amazonkms://<ARN>
NOTE For the best possible performance, it is recommended that the Guardian be run from an EC2 instance that is in the same region as the KMS key.
The KMS key's spec should be
ECC_SECG_P256K1
, and should be enabled for signing. In order for the Guardian to authenticate against the KMS service, one of two options are available:~/.aws/credentials
file. (example here).