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

chore: sync with upstream #183

Merged
merged 5 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

## [v0.50.10](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.10) - 2024-09-18
## Features

* (crypto/keyring) [#21653](https://github.com/cosmos/cosmos-sdk/pull/21653) New Linux-only backend that adds Linux kernel's `keyctl` support.

## [v0.50.10](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.10) - 2024-09-20

## Features

Expand All @@ -55,7 +59,6 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes

* (runtime) [#21769](https://github.com/cosmos/cosmos-sdk/pull/21769) Fix baseapp options ordering to avoid overwriting options set by modules.
* (types/mempool) [#21494](https://github.com/cosmos/cosmos-sdk/pull/21494) `GetSigners` function in priority nonce mempool returns an slide of the correct length.
* (x/consensus) [#21493](https://github.com/cosmos/cosmos-sdk/pull/21493) Fix regression that prevented to upgrade to > v0.50.7 without consensus version params.
* (baseapp) [#21256](https://github.com/cosmos/cosmos-sdk/pull/21256) Halt height will not commit the block indicated, meaning that if halt-height is set to 10, only blocks until 9 (included) will be committed. This is to go back to the original behavior before a change was introduced in v0.50.0.
* (baseapp) [#21444](https://github.com/cosmos/cosmos-sdk/pull/21444) Follow-up, Return PreBlocker events in FinalizeBlockResponse.
Expand Down
539 changes: 270 additions & 269 deletions api/cosmos/staking/v1beta1/query.pulsar.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions crypto/keyring/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
// https://github.com/KDE/kwallet
// pass This backend uses the pass command line utility to store and retrieve keys:
// https://www.passwordstore.org/
// keyctl This backend leverages the Linux's kernel security key management system
// to store cryptographic keys securely in memory. This is available on Linux only.
// test This backend stores keys insecurely to disk. It does not prompt for a password to
// be unlocked and it should be used only for testing purposes.
// memory Same instance as returned by NewInMemory. This backend uses a transient storage. Keys
Expand Down
19 changes: 1 addition & 18 deletions crypto/keyring/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,23 +143,6 @@ type Exporter interface {
// Option overrides keyring configuration options.
type Option func(options *Options)

// Options define the options of the Keyring.
type Options struct {
// supported signing algorithms for keyring
SupportedAlgos SigningAlgoList
// supported signing algorithms for Ledger
SupportedAlgosLedger SigningAlgoList
// define Ledger Derivation function
LedgerDerivation func() (ledger.SECP256K1, error)
// define Ledger key generation function
LedgerCreateKey func([]byte) types.PubKey
// define Ledger app name
LedgerAppName string
// indicate whether Ledger should skip DER Conversion on signature,
// depending on which format (DER or BER) the Ledger app returns signatures
LedgerSigSkipDERConv bool
}

// NewInMemory creates a transient keyring useful for testing
// purposes and on-the-fly key generation.
// Keybase options can be applied when generating this new Keybase.
Expand All @@ -176,7 +159,7 @@ func NewInMemoryWithKeyring(kr keyring.Keyring, cdc codec.Codec, opts ...Option)
// New creates a new instance of a keyring.
// Keyring options can be applied when generating the new instance.
// Available backends are "os", "file", "kwallet", "memory", "pass", "test".
func New(
func newKeyringGeneric(
appName, backend, rootDir string, userInput io.Reader, cdc codec.Codec, opts ...Option,
) (Keyring, error) {
var (
Expand Down
84 changes: 84 additions & 0 deletions crypto/keyring/keyring_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//go:build linux
// +build linux

package keyring

import (
"fmt"
"io"

"github.com/99designs/keyring"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/ledger"
"github.com/cosmos/cosmos-sdk/crypto/types"
)

// Linux-only backend options.
const BackendKeyctl = "keyctl"

func KeyctlScopeUser(options *Options) { setKeyctlScope(options, "user") }
func KeyctlScopeUserSession(options *Options) { setKeyctlScope(options, "usersession") }
func KeyctlScopeSession(options *Options) { setKeyctlScope(options, "session") }
func KeyctlScopeProcess(options *Options) { setKeyctlScope(options, "process") }
func KeyctlScopeThread(options *Options) { setKeyctlScope(options, "thread") }

// Options define the options of the Keyring.
type Options struct {
// supported signing algorithms for keyring
SupportedAlgos SigningAlgoList
// supported signing algorithms for Ledger
SupportedAlgosLedger SigningAlgoList
// define Ledger Derivation function
LedgerDerivation func() (ledger.SECP256K1, error)
// define Ledger key generation function
LedgerCreateKey func([]byte) types.PubKey
// define Ledger app name
LedgerAppName string
// indicate whether Ledger should skip DER Conversion on signature,
// depending on which format (DER or BER) the Ledger app returns signatures
LedgerSigSkipDERConv bool
// KeyctlScope defines the scope of the keyctl's keyring.
KeyctlScope string
}

func newKeyctlBackendConfig(appName, _ string, _ io.Reader, opts ...Option) keyring.Config {
options := Options{
KeyctlScope: keyctlDefaultScope, // currently "process"
}

for _, optionFn := range opts {
optionFn(&options)
}

return keyring.Config{
AllowedBackends: []keyring.BackendType{keyring.KeyCtlBackend},
ServiceName: appName,
KeyCtlScope: options.KeyctlScope,
}
}

// New creates a new instance of a keyring.
// Keyring options can be applied when generating the new instance.
// Available backends are "os", "file", "kwallet", "memory", "pass", "test", "keyctl".
func New(
appName, backend, rootDir string, userInput io.Reader, cdc codec.Codec, opts ...Option,
) (Keyring, error) {
if backend != BackendKeyctl {
return newKeyringGeneric(appName, backend, rootDir, userInput, cdc, opts...)
}

db, err := keyring.Open(newKeyctlBackendConfig(appName, "", userInput, opts...))
if err != nil {
return nil, fmt.Errorf("couldn't open keyring for %q: %w", appName, err)
}

return newKeystore(db, cdc, backend, opts...), nil
}

func setKeyctlScope(options *Options, scope string) { options.KeyctlScope = scope }

// this is private as it is meant to be here for SDK devs convenience
// as the user does not need to pick any default when he wants to
// initialize keyctl with the default scope.
const keyctlDefaultScope = "process"
51 changes: 51 additions & 0 deletions crypto/keyring/keyring_linux_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//go:build linux
// +build linux

package keyring

import (
"errors"
"io"
"strings"
"testing"

"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/codec"
)

func TestNewKeyctlKeyring(t *testing.T) {
cdc := getCodec()

tests := []struct {
name string
appName string
backend string
dir string
userInput io.Reader
cdc codec.Codec
expectedErr error
}{
{
name: "keyctl backend",
appName: "cosmos",
backend: BackendKeyctl,
dir: t.TempDir(),
userInput: strings.NewReader(""),
cdc: cdc,
expectedErr: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
kr, err := New(tt.appName, tt.backend, tt.dir, tt.userInput, tt.cdc)
if tt.expectedErr == nil {
require.NoError(t, err)
} else {
require.Error(t, err)
require.Nil(t, kr)
require.True(t, errors.Is(err, tt.expectedErr))
}
})
}
}
35 changes: 35 additions & 0 deletions crypto/keyring/keyring_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//go:build !linux
// +build !linux

package keyring

import (
"io"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/ledger"
"github.com/cosmos/cosmos-sdk/crypto/types"
)

// Options define the options of the Keyring.
type Options struct {
// supported signing algorithms for keyring
SupportedAlgos SigningAlgoList
// supported signing algorithms for Ledger
SupportedAlgosLedger SigningAlgoList
// define Ledger Derivation function
LedgerDerivation func() (ledger.SECP256K1, error)
// define Ledger key generation function
LedgerCreateKey func([]byte) types.PubKey
// define Ledger app name
LedgerAppName string
// indicate whether Ledger should skip DER Conversion on signature,
// depending on which format (DER or BER) the Ledger app returns signatures
LedgerSigSkipDERConv bool
}

func New(
appName, backend, rootDir string, userInput io.Reader, cdc codec.Codec, opts ...Option,
) (Keyring, error) {
return newKeyringGeneric(appName, backend, rootDir, userInput, cdc, opts...)
}
4 changes: 2 additions & 2 deletions proto/cosmos/staking/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ message QueryRedelegationsRequest {
string delegator_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// src_validator_addr defines the validator address to redelegate from.
string src_validator_addr = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string src_validator_addr = 2 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"];

// dst_validator_addr defines the validator address to redelegate to.
string dst_validator_addr = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string dst_validator_addr = 3 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"];

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 4;
Expand Down
2 changes: 1 addition & 1 deletion simapp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.23.1

require (
cosmossdk.io/api v0.7.6
cosmossdk.io/client/v2 v2.0.0-beta.4.0.20240918122632-1879050ca719
cosmossdk.io/client/v2 v2.0.0-beta.5
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/core v0.11.1
cosmossdk.io/depinject v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions simapp/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1V
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
cosmossdk.io/api v0.7.6 h1:PC20PcXy1xYKH2KU4RMurVoFjjKkCgYRbVAD4PdqUuY=
cosmossdk.io/api v0.7.6/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38=
cosmossdk.io/client/v2 v2.0.0-beta.4.0.20240918122632-1879050ca719 h1:w57wGtZYx1O24WIaFLMK+ZEjQuZzLFUN3hiYf/+H4mk=
cosmossdk.io/client/v2 v2.0.0-beta.4.0.20240918122632-1879050ca719/go.mod h1:4p0P6o0ro+FizakJUYS9SeM94RNbv0thLmkHRw5o5as=
cosmossdk.io/client/v2 v2.0.0-beta.5 h1:0LVv3nEByn//hFDIrYLs2WvsEU3HodOelh4SDHnA/1I=
cosmossdk.io/client/v2 v2.0.0-beta.5/go.mod h1:4p0P6o0ro+FizakJUYS9SeM94RNbv0thLmkHRw5o5as=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.11.1 h1:h9WfBey7NAiFfIcUhDVNS503I2P2HdZLebJlUIs8LPA=
Expand Down
2 changes: 1 addition & 1 deletion tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ require (
cloud.google.com/go/compute/metadata v0.5.0 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/storage v1.38.0 // indirect
cosmossdk.io/client/v2 v2.0.0-beta.4.0.20240918122632-1879050ca719 // indirect
cosmossdk.io/client/v2 v2.0.0-beta.5 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/x/circuit v0.1.1 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1V
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
cosmossdk.io/api v0.7.6 h1:PC20PcXy1xYKH2KU4RMurVoFjjKkCgYRbVAD4PdqUuY=
cosmossdk.io/api v0.7.6/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38=
cosmossdk.io/client/v2 v2.0.0-beta.4.0.20240918122632-1879050ca719 h1:w57wGtZYx1O24WIaFLMK+ZEjQuZzLFUN3hiYf/+H4mk=
cosmossdk.io/client/v2 v2.0.0-beta.4.0.20240918122632-1879050ca719/go.mod h1:4p0P6o0ro+FizakJUYS9SeM94RNbv0thLmkHRw5o5as=
cosmossdk.io/client/v2 v2.0.0-beta.5 h1:0LVv3nEByn//hFDIrYLs2WvsEU3HodOelh4SDHnA/1I=
cosmossdk.io/client/v2 v2.0.0-beta.5/go.mod h1:4p0P6o0ro+FizakJUYS9SeM94RNbv0thLmkHRw5o5as=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/core v0.11.1 h1:h9WfBey7NAiFfIcUhDVNS503I2P2HdZLebJlUIs8LPA=
Expand Down
2 changes: 1 addition & 1 deletion x/staking/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
PositionalArgs: []*autocliv1.PositionalArgDescriptor{
{ProtoField: "delegator_addr"},
{ProtoField: "src_validator_addr"},
{ProtoField: "dst_validator_addr"},
{ProtoField: "dst_validator_addr", Optional: true},
},
},
{
Expand Down
Loading
Loading