fix(kms): make the AWS KMS signer support dynamic-fee transactions - #792
Open
renatomaia wants to merge 18 commits into
Open
fix(kms): make the AWS KMS signer support dynamic-fee transactions#792renatomaia wants to merge 18 commits into
renatomaia wants to merge 18 commits into
Conversation
renatomaia
force-pushed
the
fix/awsKmsDynamicFeeSigning
branch
3 times, most recently
from
July 22, 2026 13:04
26060af to
e412f81
Compare
|
Old tests needed to fill in the ARN variable with a valid AWS KMS instance to work. That would cost money and expose secrets, so it is disabled by default. But maybe with the localstack setup it could be enabled or refactored, any thoughts on that? |
renatomaia
force-pushed
the
fix/awsKmsDynamicFeeSigning
branch
3 times, most recently
from
July 23, 2026 22:32
9092af5 to
bae5e92
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the AWS KMS-backed transaction signing path to correctly support EIP-1559 (dynamic-fee) transactions by switching to the appropriate signer family, and adds unit + LocalStack-based integration coverage to prevent regressions.
Changes:
- Use
types.LatestSignerForChainIDfor AWS KMS signing (instead of legacy-onlyNewEIP155Signer). - Add a unit test ensuring dynamic-fee tx signing + sender recovery works.
- Add a LocalStack KMS integration test and wire LocalStack into the integration compose + shard selection.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
internal/config/auth/auth.go |
Switch AWS KMS signing to latest signer; add optional region/endpoint support (currently has a compile issue to fix). |
internal/config/generated.go |
Add generated config key + getter for CARTESI_AUTH_AWS_KMS_ENDPOINT. |
internal/config/generate/Config.toml |
Define the new AWS KMS endpoint config entry for generation. |
internal/kms/signtx_test.go |
Add unit test for signing DynamicFeeTx with AWS KMS factory. |
test/integration/localstack_integration_test.go |
New LocalStack KMS integration suite verifying legacy + dynamic-fee signing end-to-end (currently has a config-setting bug to fix). |
test/compose/compose.integration.yaml |
Add LocalStack service and env wiring for integration-test container. |
Makefile |
Add LocalStack start/stop/restart targets and register an awskms integration shard. |
Files not reviewed (1)
- internal/config/generated.go: Generated file
Comments suppressed due to low confidence (1)
internal/config/auth/auth.go:83
- These
errors.Ischecks referenceconfig.ErrNotDefined, but this file already dot-imports internal/config. After removing the duplicateconfigimport, these references should useErrNotDefineddirectly.
kmsRegion, err := GetAuthAwsKmsRegion()
if !errors.Is(err, config.ErrNotDefined) {
if err != nil {
return nil, err
}
awsOpts = append(awsOpts, aws_cfg.WithRegion(kmsRegion.Value))
}
kmsEndpoint, err := GetAuthAwsKmsEndpoint()
if !errors.Is(err, config.ErrNotDefined) {
if err != nil {
return nil, err
}
awsOpts = append(awsOpts, aws_cfg.WithBaseEndpoint(kmsEndpoint.Value))
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
renatomaia
force-pushed
the
fix/awsKmsDynamicFeeSigning
branch
2 times, most recently
from
July 24, 2026 12:17
432a6f9 to
4d1433c
Compare
renatomaia
force-pushed
the
fix/awsKmsDynamicFeeSigning
branch
from
August 11, 2026 15:28
4d1433c to
1f34938
Compare
mpolitzer
previously approved these changes
Aug 11, 2026
renatomaia
force-pushed
the
fix/awsKmsDynamicFeeSigning
branch
from
August 21, 2026 19:18
1f34938 to
6dff1ae
Compare
renatomaia
force-pushed
the
fix/awsKmsDynamicFeeSigning
branch
3 times, most recently
from
August 26, 2026 23:51
8b7dd6a to
3b8473d
Compare
- Exercises the real 'GetTransactOptsFactory' AWS wiring. - Uses an httptest KMS implementation—no Docker or AWS access. - Tests dynamic-fee and legacy transactions. - Verifies the recovered sender matches the KMS key. - Uses isolated dummy AWS credentials and resets Viper state.
renatomaia
force-pushed
the
fix/awsKmsDynamicFeeSigning
branch
from
August 27, 2026 14:18
3b8473d to
7a2a158
Compare
- Replaced nondeterministic map iteration with an ordered test-case slice. - Replaced s.T().Run with s.Run, ensuring suite assertions target the correct subtest. - Legacy and dynamic-fee cases now run predictably and report failures independently.
… test coverage - Funding transfers now use EIP-1559 `DynamicFeeTx`. - Gas tip and fee caps are derived from the current chain state. - `sendFunds` waits for transaction mining before returning. - Receipt success is asserted, removing the funding race. - Ethereum clients are closed after use.
- LocalStack is now behind the awskms Compose profile. - Its dependency is optional when that profile is inactive. - Compose runners activate the profile only when the selected shards include awskms. - The awskms shard is excluded from the multiprocess topology.
- Replaced `TearDownSuite` cleanup with eagerly registered `t.Cleanup` callbacks. - KMS key deletion now uses a fresh background context with a 10-second timeout. - Viper is fully reset and configuration defaults are restored. - Removed suite fields that existed only for deferred teardown.
Use a dedicated Foundry account to avoid nonce collisions with the node submitter and other integration-test actors.
Removed the custom gateway-only LocalStack healthcheck, allowing the image’s built-in per-service readiness check and start period to apply.
- Hoisted the Ethereum client into SetupSuite and registered cleanup once. - Reused the client for both funding transfers. - Read AWS_REGION from the environment, defaulting to us-east-1. - Enforced the bind.SignerFn address contract with bind.ErrNotAuthorized.
- Removed CARTESI_AUTH_AWS_KMS_REGION and CARTESI_AUTH_AWS_KMS_ENDPOINT. - AWS KMS now uses the SDK’s standard region and endpoint resolution. - Updated tests and LocalStack instructions to use AWS_REGION and AWS_ENDPOINT_URL_KMS. - Documented AWS-provided configuration and the KMS alias risk.
- `assembleSignature` now rejects `r` or `s` components longer than 32 bytes with a descriptive error. - Added regression tests covering overlong `r` and `s`.
- `normalizeR` passthrough, zero-padding trim, and malformed-padding rejection. - High-`s` normalization. - Non-canonical DER `r` and `s` handling through a fake KMS client. - Unrecoverable signature failure. - `From()` identity reporting. - Unauthorized signer rejection, verifying KMS is never called.
- Added the `endtoendtests` build tag to .`golangci.yml`. - Replaced unused `ethtypes.NewEIP155Signer` with the current `ethtypes.LatestSignerForChainID` in tests. - Replaced `reflect.DeepEqual` with `bytes.Equal`. - Recovery now tries both recovery IDs when `Ecrecover` fails. - Added a regression test for that behavior. - Reused one Ethereum client in the surviving manual test and closed it after use. - Replaced deprecated `types.NewTransaction` with `types.NewTx`.
- ERC-20 deposit now creates one transaction-options factory per command. - The factory’s address is reused for confirmation output. - Fresh transaction options are derived from that same factory for approval and deposit. - Existing CLI callers remain compatible through GetTransactOpts.
renatomaia
force-pushed
the
fix/awsKmsDynamicFeeSigning
branch
from
August 28, 2026 01:22
7a2a158 to
275baf3
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The AWS KMS factory is still built with
types.NewEIP155Signer(chainId). That signer is legacy-only. Direct geth bindings can create dynamic-fee transactions whenGasPriceis nil and the chain has a base fee, which is the normal EIP-1559 path. In that case the KMS code hashes and attaches the signature using the wrong signer family.AI Review Findings
This PR also implements some improvements described in review here.
Divergences from Proposed Fixes
CreateAWSTransactOptsFactoryis actually called on Claimer and PRT with a time-bounded context (CARTESI_MAX_STARTUP_TIME).Commit relation to Findings
The table below lists the commits, and column
IDindicates which improvement is introduced.