-
Notifications
You must be signed in to change notification settings - Fork 10
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
Enable validation of submitted transactions with local state index #693
Merged
j1010001
merged 5 commits into
feature/local-tx-reexecution
from
mpeter/tx-validation-with-local-state
Dec 12, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
26b732b
Enable transaction validation with local state index
m-Peter bda9fd5
Implement a Keystore for handling signing of multiple transactions co…
m-Peter 04fd1d5
Remove hard-coded addresses for FungibleToken & FlowToken contracts
m-Peter 74cb17d
Add auto-expiration for locked account keys and metrics for available…
m-Peter 374f70c
Auto-expire account keys based on the reference block height they wer…
m-Peter 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
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package bootstrap | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/onflow/flow-evm-gateway/config" | ||
"github.com/onflow/flow-evm-gateway/services/requester" | ||
"github.com/onflow/flow-go-sdk/crypto" | ||
"github.com/rs/zerolog" | ||
) | ||
|
||
// createSigner creates the signer based on either a single coa key being | ||
// provided and using a simple in-memory signer, or a Cloud KMS key being | ||
// provided and using a Cloud KMS signer. | ||
func createSigner( | ||
ctx context.Context, | ||
config config.Config, | ||
logger zerolog.Logger, | ||
) (crypto.Signer, error) { | ||
var signer crypto.Signer | ||
var err error | ||
switch { | ||
case config.COAKey != nil: | ||
signer, err = crypto.NewInMemorySigner(config.COAKey, crypto.SHA3_256) | ||
case config.COACloudKMSKey != nil: | ||
signer, err = requester.NewKMSKeySigner( | ||
ctx, | ||
*config.COACloudKMSKey, | ||
logger, | ||
) | ||
default: | ||
return nil, fmt.Errorf("must provide either single COA / Cloud KMS key") | ||
} | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to create a COA signer: %w", err) | ||
} | ||
|
||
return signer, nil | ||
} |
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.
Note: After viewing this comment, I am not entirely sure if we should have one
crypto.Signer
object for each account key, or create one for each account key. Are there any thread-safe concerns here? 🤔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.
A single signer cannot be used across go routines, so we need multiple. One for every account key.
Actually the
crypto.PrivateKey
is not thread safe either! So if multiple account keys have the same private key, you need to create multiple copies ofcrypto.PrivateKey
.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.
Note that we have 2 types of signers, one is the in-memory signer:
crypto.NewInMemorySigner(config.COAKey, crypto.SHA3_256)
requester.NewKMSKeySigner
, which doesn't deal at all withcrypto.PrivateKey
Currently, only option 2. is supposed to be used in production. And I'm not sure if it has any thread-safety concerns, as it uses Cloud KMS for signing.
Option 1. is supposed to be used for local development / testing.