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

release: prepare release for v1.1.0 #356

Merged
merged 10 commits into from
Nov 13, 2023
2 changes: 1 addition & 1 deletion .github/workflows/gosec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/checkout@v3

- name: Run Gosec Security Scanner
uses: securego/gosec@master
uses: securego/gosec@v2.17.0
with:
# we let the report trigger content trigger a failure using the GitHub Security features.
args: "-no-fail -fmt sarif -out results.sarif ./..."
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## v1.1.0
This release introduces the Pampas upgrade and contains 8 new features.

Features:
* [#316](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/316) feat: add validation with context information
* [#321](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/321) feat: add tool to migrate stores for fastnode
* [#336](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/336) feat: introduce the pampas upgrade
* [#341](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/341) feat: add support for some json rpc queries
* [#353](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/353) feat: distinguish inturn relayer
* [#320](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/320) feat: add MsgRejectMigrateBucket
* [#357](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/357) feat: support Secp256k1 format private keys import
* [#358](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/358) feat: enable Pampas hardfork to testnet

## v1.0.1
This release includes 1 bug fix.

Expand Down
242 changes: 184 additions & 58 deletions api/cosmos/oracle/v1/query.pulsar.go

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@ const (

// Supported EVM json-rpc requests
const (
EthBlockNumber = "eth_blockNumber"
EthGetBlockByNumber = "eth_getBlockByNumber"
EthGetBalance = "eth_getBalance"
EthChainID = "eth_chainId"
NetVersion = "net_version"
EthNetworkID = "eth_networkId"
EthBlockNumber = "eth_blockNumber"
EthGetBlockByNumber = "eth_getBlockByNumber"
EthGetBalance = "eth_getBalance"
EthChainID = "eth_chainId"
NetVersion = "net_version"
EthNetworkID = "eth_networkId"
EthGasPrice = "eth_gasPrice"
EthGetCode = "eth_getCode"
EthEstimateGas = "eth_estimateGas"
EthCall = "eth_call"
EthGetTransactionCount = "eth_getTransactionCount"
EthSendRawTransaction = "eth_sendRawTransaction"
)

// InitChain implements the ABCI interface. It runs the initialization logic
Expand Down
20 changes: 20 additions & 0 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,23 @@ func validateBasicTxMsgs(msgs []sdk.Msg) error {
return nil
}

// validateRuntimeTxMsgs executes basic runtime validator calls for messages.
func validateRuntimeTxMsgs(ctx sdk.Context, msgs []sdk.Msg) error {
if len(msgs) == 0 {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "must contain at least one message")
}

for _, msg := range msgs {
if runtimeMsg, ok := msg.(sdk.MsgWithRuntimeValidation); ok {
if err := runtimeMsg.ValidateRuntime(ctx); err != nil {
return err
}
}
}

return nil
}

// Returns the application's deliverState if app is in runTxModeDeliver,
// prepareProposalState if app is in runTxPrepareProposal, processProposalState
// if app is in runTxProcessProposal, and checkState otherwise.
Expand Down Expand Up @@ -790,6 +807,9 @@ func (app *BaseApp) runTxOnContext(ctx sdk.Context, mode runTxMode, txBytes []by
if err := validateBasicTxMsgs(msgs); err != nil {
return sdk.GasInfo{}, nil, nil, 0, err
}
if err := validateRuntimeTxMsgs(ctx, msgs); err != nil {
return sdk.GasInfo{}, nil, nil, 0, err
}

if app.anteHandler != nil {
var (
Expand Down
24 changes: 24 additions & 0 deletions baseapp/ethrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ func (e *EthQueryRouter) RegisterConstHandler() {
e.AddRoute(EthNetworkID, chainIdHandler)
e.AddRoute(EthChainID, chainIdHandler)
e.AddRoute(NetVersion, chainIdHandler)
e.AddRoute(EthGasPrice, gasPriceHandler)
e.AddRoute(EthGetCode, chainIdHandler) // return dummy result
e.AddRoute(EthEstimateGas, estimateGasHandler) // return dummy result
e.AddRoute(EthCall, chainIdHandler) // return dummy result
e.AddRoute(EthGetTransactionCount, getTransactionCountHandler) // return dummy result
e.AddRoute(EthSendRawTransaction, chainIdHandler) // return dummy result
}

func blockNumberHandler(ctx sdk.Context, req cmtrpctypes.RPCRequest) (abci.ResponseEthQuery, error) {
Expand All @@ -72,6 +78,24 @@ func blockNumberHandler(ctx sdk.Context, req cmtrpctypes.RPCRequest) (abci.Respo
return res, nil
}

func gasPriceHandler(ctx sdk.Context, req cmtrpctypes.RPCRequest) (abci.ResponseEthQuery, error) {
var res abci.ResponseEthQuery
res.Response = big.NewInt(5e9).Bytes()
return res, nil
}

func estimateGasHandler(ctx sdk.Context, req cmtrpctypes.RPCRequest) (abci.ResponseEthQuery, error) {
var res abci.ResponseEthQuery
res.Response = big.NewInt(21000).Bytes()
return res, nil
}

func getTransactionCountHandler(ctx sdk.Context, req cmtrpctypes.RPCRequest) (abci.ResponseEthQuery, error) {
var res abci.ResponseEthQuery
res.Response = big.NewInt(1).Bytes()
return res, nil
}

func chainIdHandler(ctx sdk.Context, req cmtrpctypes.RPCRequest) (abci.ResponseEthQuery, error) {
var res abci.ResponseEthQuery
eip155ChainID, err := sdk.ParseChainID(ctx.ChainID())
Expand Down
6 changes: 6 additions & 0 deletions baseapp/msg_service_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ func (msr *MsgServiceRouter) RegisterService(sd *grpc.ServiceDesc, handler inter
return nil, err
}

if runtimeReq, ok := req.(sdk.MsgWithRuntimeValidation); ok {
if err := runtimeReq.ValidateRuntime(ctx); err != nil {
return nil, err
}
}

if msr.circuitBreaker != nil {
msgURL := sdk.MsgTypeURL(req)

Expand Down
67 changes: 55 additions & 12 deletions client/keys/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,82 @@ package keys

import (
"bufio"
"encoding/hex"
"fmt"
"os"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/input"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keys/eth/ethsecp256k1"
)

const (
flagSecp256k1PrivateKey = "secp256k1-private-key"
)

// ImportKeyCommand imports private keys from a keyfile.
func ImportKeyCommand() *cobra.Command {
return &cobra.Command{
Use: "import <name> <keyfile>",
cmd := &cobra.Command{
Use: "import <name> <keyfile>/<privateKey>",
Short: "Import private keys into the local keybase",
Long: "Import a ASCII armored private key into the local keybase.",
Long: "Import a ASCII armored/Secp256k1 private key into the local keybase.",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
buf := bufio.NewReader(clientCtx.Input)

bz, err := os.ReadFile(args[1])
if err != nil {
return err
}
isSecp256k1, _ := cmd.Flags().GetBool(flagSecp256k1PrivateKey)

passphrase, err := input.GetPassword("Enter passphrase to decrypt your key:", buf)
if err != nil {
return err
if !isSecp256k1 {
return importASCIIArmored(clientCtx, args)
}

return clientCtx.Keyring.ImportPrivKey(args[0], string(bz), passphrase)
return importSecp256k1(clientCtx, args)
},
}

cmd.Flags().Bool(flagSecp256k1PrivateKey, false, "import Secp256k1 format private key")

return cmd
}

func importASCIIArmored(clientCtx client.Context, args []string) error {
buf := bufio.NewReader(clientCtx.Input)

bz, err := os.ReadFile(args[1])
if err != nil {
return err
}

passphrase, err := input.GetPassword("Enter passphrase to decrypt your key:", buf)
if err != nil {
return err
}

return clientCtx.Keyring.ImportPrivKey(args[0], string(bz), passphrase)
}

func importSecp256k1(clientCtx client.Context, args []string) error {
keyName := args[0]
keyBytes, err := hex.DecodeString(args[1])
if err != nil {
return err
}
if len(keyBytes) != 32 {
return fmt.Errorf("len of keybytes is not equal to 32")
}
var keyBytesArray [32]byte
copy(keyBytesArray[:], keyBytes[:32])
privKey := hd.EthSecp256k1.Generate()(keyBytesArray[:]).(*ethsecp256k1.PrivKey)

_, err = clientCtx.Keyring.WriteLocalKey(keyName, privKey)
if err != nil {
return err
}
return nil
}
8 changes: 8 additions & 0 deletions crypto/keyring/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ type Importer interface {

// ImportPubKey imports ASCII armored public keys.
ImportPubKey(uid string, armor string) error

// WriteLocalKey persists a private key object into storage.
WriteLocalKey(name string, privKey types.PrivKey) (*Record, error)
}

// Migrator is implemented by key stores and enables migration of keys from amino to proto
Expand Down Expand Up @@ -757,6 +760,11 @@ func newRealPrompt(dir string, buf io.Reader) func(string) (string, error) {
}
}

// WriteLocalKey persists a local key to the keyring.
func (ks keystore) WriteLocalKey(name string, privKey types.PrivKey) (*Record, error) {
return ks.writeLocalKey(name, privKey)
}

func (ks keystore) writeLocalKey(name string, privKey types.PrivKey) (*Record, error) {
k, err := NewLocalRecord(name, privKey, privKey.PubKey())
if err != nil {
Expand Down
21 changes: 12 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ require (
github.com/tidwall/btree v1.6.0
github.com/wealdtech/go-eth2-util v1.6.3
github.com/willf/bitset v1.1.3
golang.org/x/crypto v0.9.0
golang.org/x/crypto v0.14.0
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc
golang.org/x/text v0.9.0
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1
google.golang.org/grpc v1.56.1
google.golang.org/protobuf v1.30.0
golang.org/x/text v0.13.0
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98
google.golang.org/grpc v1.58.3
google.golang.org/protobuf v1.31.0
gotest.tools/v3 v3.4.0
pgregory.net/rapid v0.5.5
sigs.k8s.io/yaml v1.3.0
Expand Down Expand Up @@ -154,9 +154,11 @@ require (
github.com/zondax/hid v0.9.1 // indirect
github.com/zondax/ledger-go v0.14.1 // indirect
go.etcd.io/bbolt v1.3.7 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand All @@ -170,7 +172,7 @@ replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.23.0

github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.3
github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v1.1.0
github.com/cometbft/cometbft-db => github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1
github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1

Expand All @@ -183,6 +185,7 @@ replace (
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1
// replace broken goleveldb
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/wercker/journalhook => github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117
)

retract (
Expand Down
Loading
Loading