-
Notifications
You must be signed in to change notification settings - Fork 117
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
[CORE-538] Upgrade to Cosmos 0.50.1 and CometBFT 0.38 #867
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ee5487e
[CORE-538] Update to Comsos 0.50.1
lcwik cd7a783
Update cosmovisor version.
lcwik cbcd03c
Fix simulation since NewContext doesn't pass through the chainId whil…
lcwik f23cd65
Swap to AppGenesisFromFile as per Cosmos upgrade guide https://docs.c…
lcwik 76ec8d1
Remove TODO since blocktime makes sense to do in BeginBlocker since i…
lcwik b4dd0dd
Re-order imports
lcwik 68d242c
Fix typo
lcwik fff691f
Address Taehoon's PR comments.
lcwik 8c1a3f3
Resolve/update minor TODOs.
lcwik 9656edc
Address Roy's comments.
lcwik bdd0719
Update message types, improve testapp logging/debugging for app hash …
lcwik 4078041
Rebase updates that required changes including ICA message and contro…
lcwik 208f41b
Address Taehoon's comments wrt to message types.
lcwik 0328e71
Fix lint
lcwik 81d7da8
Skip upgrade test till upgrade handler has been updated for 4.0.0
lcwik 069ee8f
Fix data race in test code
lcwik 61fbda5
Increase timeout since some suites of tests are taking longer then th…
lcwik 47ecfd6
Remove the ICA controller and drop ICA from simulation
lcwik 857a768
Update protocol/app/module/interface_registry.go
lcwik 131a772
Address Taehoon's comments.
lcwik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
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
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 |
---|---|---|
@@ -1,31 +1,34 @@ | ||
package ante | ||
|
||
import ( | ||
errorsmod "cosmossdk.io/errors" | ||
"fmt" | ||
|
||
gometrics "github.com/armon/go-metrics" | ||
errorsmod "cosmossdk.io/errors" | ||
txsigning "cosmossdk.io/x/tx/signing" | ||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
"github.com/cosmos/cosmos-sdk/telemetry" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
sdkante "github.com/cosmos/cosmos-sdk/x/auth/ante" | ||
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" | ||
"github.com/dydxprotocol/v4-chain/protocol/lib/metrics" | ||
gometrics "github.com/hashicorp/go-metrics" | ||
"google.golang.org/protobuf/types/known/anypb" | ||
) | ||
|
||
// Verify all signatures for a tx and return an error if any are invalid. Note, | ||
// SigVerificationDecorator verifies all signatures for a tx and return an error if any are invalid. Note, | ||
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. This was updated with the copy from Cosmo 0.50 with the SkipSequenceValidation changes ported over. |
||
// the SigVerificationDecorator will not check signatures on ReCheck. | ||
// | ||
// CONTRACT: Pubkeys are set in context for all signers before this decorator runs | ||
// CONTRACT: Tx must implement SigVerifiableTx interface | ||
type SigVerificationDecorator struct { | ||
ak sdkante.AccountKeeper | ||
signModeHandler authsigning.SignModeHandler | ||
signModeHandler *txsigning.HandlerMap | ||
} | ||
|
||
func NewSigVerificationDecorator( | ||
ak sdkante.AccountKeeper, | ||
signModeHandler authsigning.SignModeHandler, | ||
signModeHandler *txsigning.HandlerMap, | ||
) SigVerificationDecorator { | ||
return SigVerificationDecorator{ | ||
ak: ak, | ||
|
@@ -39,7 +42,7 @@ func (svd SigVerificationDecorator) AnteHandle( | |
simulate bool, | ||
next sdk.AnteHandler, | ||
) (newCtx sdk.Context, err error) { | ||
sigTx, ok := tx.(authsigning.SigVerifiableTx) | ||
sigTx, ok := tx.(authsigning.Tx) | ||
if !ok { | ||
return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") | ||
} | ||
|
@@ -51,14 +54,17 @@ func (svd SigVerificationDecorator) AnteHandle( | |
return ctx, err | ||
} | ||
|
||
signerAddrs := sigTx.GetSigners() | ||
signers, err := sigTx.GetSigners() | ||
if err != nil { | ||
return ctx, err | ||
} | ||
|
||
// check that signer length and signature length are the same | ||
if len(sigs) != len(signerAddrs) { | ||
if len(sigs) != len(signers) { | ||
err := errorsmod.Wrapf( | ||
sdkerrors.ErrUnauthorized, | ||
"invalid number of signer; expected: %d, got %d", | ||
len(signerAddrs), | ||
len(signers), | ||
len(sigs), | ||
) | ||
return ctx, err | ||
|
@@ -69,7 +75,7 @@ func (svd SigVerificationDecorator) AnteHandle( | |
skipSequenceValidation := ShouldSkipSequenceValidation(tx.GetMsgs()) | ||
|
||
for i, sig := range sigs { | ||
acc, err := sdkante.GetSignerAcc(ctx, svd.ak, signerAddrs[i]) | ||
acc, err := sdkante.GetSignerAcc(ctx, svd.ak, signers[i]) | ||
if err != nil { | ||
return ctx, err | ||
} | ||
|
@@ -109,23 +115,32 @@ func (svd SigVerificationDecorator) AnteHandle( | |
if !genesis { | ||
accNum = acc.GetAccountNumber() | ||
} | ||
signerData := authsigning.SignerData{ | ||
Address: acc.GetAddress().String(), | ||
ChainID: chainID, | ||
AccountNumber: accNum, | ||
Sequence: acc.GetSequence(), | ||
PubKey: pubKey, | ||
} | ||
|
||
// no need to verify signatures on recheck tx | ||
if !simulate && !ctx.IsReCheckTx() { | ||
err := authsigning.VerifySignature(pubKey, signerData, sig.Data, svd.signModeHandler, tx) | ||
anyPk, _ := codectypes.NewAnyWithValue(pubKey) | ||
|
||
signerData := txsigning.SignerData{ | ||
Address: acc.GetAddress().String(), | ||
ChainID: chainID, | ||
AccountNumber: accNum, | ||
Sequence: acc.GetSequence(), | ||
PubKey: &anypb.Any{ | ||
TypeUrl: anyPk.TypeUrl, | ||
Value: anyPk.Value, | ||
}, | ||
} | ||
adaptableTx, ok := tx.(authsigning.V2AdaptableTx) | ||
if !ok { | ||
return ctx, fmt.Errorf("expected tx to implement V2AdaptableTx, got %T", tx) | ||
} | ||
txData := adaptableTx.GetSigningTxData() | ||
err = authsigning.VerifySignature(ctx, pubKey, signerData, sig.Data, svd.signModeHandler, txData) | ||
if err != nil { | ||
var errMsg string | ||
if sdkante.OnlyLegacyAminoSigners(sig.Data) { | ||
// If all signers are using SIGN_MODE_LEGACY_AMINO, we rely on VerifySignature to | ||
// check account sequence number, and therefore communicate sequence number as a | ||
// potential cause of error. | ||
// If all signers are using SIGN_MODE_LEGACY_AMINO, we rely on VerifySignature to check account sequence number, | ||
// and therefore communicate sequence number as a potential cause of error. | ||
errMsg = fmt.Sprintf( | ||
"signature verification failed; please verify account number (%d), sequence (%d)"+ | ||
" and chain-id (%s)", | ||
|
@@ -135,9 +150,10 @@ func (svd SigVerificationDecorator) AnteHandle( | |
) | ||
} else { | ||
errMsg = fmt.Sprintf( | ||
"signature verification failed; please verify account number (%d) and chain-id (%s)", | ||
"signature verification failed; please verify account number (%d) and chain-id (%s): (%s)", | ||
accNum, | ||
chainID, | ||
err.Error(), | ||
) | ||
} | ||
return ctx, errorsmod.Wrap(sdkerrors.ErrUnauthorized, errMsg) | ||
|
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 understand that we are specifying the sender should be
sender.owner
inCustomGetSigner
here.Should we remove this option, given that
sender
is not a valid signer (i.e. it's not an address string)?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.
The cosmos SDK was meant to support these recursively but didn't do it quite right since
sender
is supposed to go into that message and then useowner
to find the appropriate address string. I filed cosmos/cosmos-sdk#18722 and they have fixed this but it won't be available till a future Cosmos SDK release.I'd like to leave this for now and once able we can remove the
CustomGetSigners
implementation.