Skip to content

Commit

Permalink
Merge branch 'next' of github.com:Team-Kujira/core into sdk-50
Browse files Browse the repository at this point in the history
  • Loading branch information
antstalepresh committed Jul 23, 2024
2 parents 0a2dd84 + b2ae775 commit c7f44e7
Show file tree
Hide file tree
Showing 53 changed files with 3,649 additions and 306 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
golang 1.21.3
golang 1.21.8
39 changes: 39 additions & 0 deletions ROSETTA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Enable Rosetta support by modifying `.kujira/config/config.toml` as follows.

```
###############################################################################
### Rosetta Configuration ###
###############################################################################
[rosetta]
# Enable defines if the Rosetta API server should be enabled.
enable = true
# Address defines the Rosetta API server to listen on.
address = ":8080"
# Network defines the name of the blockchain that will be returned by Rosetta.
blockchain = "kujira"
# Network defines the name of the network that will be returned by Rosetta.
network = "kaiyo-1"
# Retries defines the number of retries when connecting to the node before failing.
retries = 3
# Offline defines if Rosetta server should run in offline mode.
offline = false
# EnableDefaultSuggestedFee defines if the server should suggest fee by default.
# If 'construction/medata' is called without gas limit and gas price,
# suggested fee based on gas-to-suggest and denom-to-suggest will be given.
enable-fee-suggestion = false
# GasToSuggest defines gas limit when calculating the fee
gas-to-suggest = 200000
# DenomToSuggest defines the defult denom for fee suggestion.
# Price must be in minimum-gas-prices.
denom-to-suggest = "ukuji"
```
16 changes: 16 additions & 0 deletions UPGRADES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# kujira

**kujira** is a blockchain built using Cosmos SDK and Comet BFT

Please refer to [docs.kujira.app](https://docs.kujira.app/) and join our [Discord](https://t.co/kur923FTZk) for guidance in getting set up.

## Upgrades

- 0 -> v0.4.0
- 01764000 -> v0.5.0
- 03495000 -> v0.6.0
- 04553726 -> v0.6.4 **manual halt-height required**
- 05196234 -> v0.7.1
- 09226200 -> v0.8.4 **tag `v0.8.4-mainnet`**
- 11478516 -> v0.8.7 **manual halt-height required**
- 16610000 -> v0.9.3-1 (note `-1` suffix)
2 changes: 1 addition & 1 deletion app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {

sigGasConsumer := options.SigGasConsumer
if sigGasConsumer == nil {
sigGasConsumer = ante.DefaultSigVerificationGasConsumer
sigGasConsumer = SigVerificationGasConsumer
}

anteDecorators := []sdk.AnteDecorator{
Expand Down
7 changes: 5 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,11 @@ func New(
app.BankKeeper,
app.OracleKeeper,
*app.DenomKeeper,
app.BatchKeeper,
*app.IBCKeeper,
app.CwICAKeeper,
app.ICAControllerKeeper,
app.TransferKeeper,
keys[ibcexported.StoreKey],
), wasmOpts...)

Expand Down Expand Up @@ -733,6 +735,7 @@ func New(
var transferStack ibcporttypes.IBCModule
transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper)
transferStack = cwica.NewIBCMiddleware(transferStack, app.CwICAKeeper, app.IBCKeeper.ChannelKeeper)

// Create Interchain Accounts Stack
// SendPacket, since it is originating from the application to core IBC:
Expand All @@ -743,7 +746,7 @@ func New(

icaControllerStack = cwica.NewIBCModule(app.CwICAKeeper)
icaControllerStack = icacontroller.NewIBCMiddleware(icaControllerStack, app.ICAControllerKeeper)
icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper)
// icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper)

// RecvPacket, message that originates from core IBC and goes down to app, the flow is:
// channel.RecvPacket -> fee.OnRecvPacket -> icaHost.OnRecvPacket
Expand Down Expand Up @@ -1091,7 +1094,7 @@ func New(
BankKeeper: app.BankKeeper,
FeegrantKeeper: app.FeeGrantKeeper,
SignModeHandler: txConfig.SignModeHandler(),
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
SigGasConsumer: SigVerificationGasConsumer,
},
IBCKeeper: app.IBCKeeper,
WasmConfig: &wasmConfig,
Expand Down
56 changes: 56 additions & 0 deletions app/sigverify.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package app

import (
"fmt"

errorsmod "cosmossdk.io/errors"
authn "github.com/Team-Kujira/core/crypto/keys/authn"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256r1"
"github.com/cosmos/cosmos-sdk/crypto/types/multisig"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)

// SigVerificationGasConsumer is the implementation of SignatureVerificationGasConsumer. It consumes gas
// for signature verification based upon the public key type. The cost is fetched from the given params and is matched
// by the concrete type.
func SigVerificationGasConsumer(
meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params,
) error {
pubkey := sig.PubKey
switch pubkey := pubkey.(type) {
case *ed25519.PubKey:
meter.ConsumeGas(params.SigVerifyCostED25519, "ante verify: ed25519")
return errorsmod.Wrap(sdkerrors.ErrInvalidPubKey, "ED25519 public keys are unsupported")

case *secp256k1.PubKey:
meter.ConsumeGas(params.SigVerifyCostSecp256k1, "ante verify: secp256k1")
return nil

case *secp256r1.PubKey:
meter.ConsumeGas(params.SigVerifyCostSecp256r1(), "ante verify: secp256r1")
return nil

case *authn.PubKey:
meter.ConsumeGas(params.SigVerifyCostSecp256r1(), "ante verify: authn")
return nil

case multisig.PubKey:
multisignature, ok := sig.Data.(*signing.MultiSignatureData)
if !ok {
return fmt.Errorf("expected %T, got, %T", &signing.MultiSignatureData{}, sig.Data)
}
err := ante.ConsumeMultisignatureVerificationGas(meter, multisignature, pubkey, params, sig.Sequence)
if err != nil {
return err
}
return nil
default:
return errorsmod.Wrapf(sdkerrors.ErrInvalidPubKey, "unrecognized public key type: %T", pubkey)
}
}
2 changes: 2 additions & 0 deletions cmd/kujirad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"io"
"os"
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/cast"
Expand Down Expand Up @@ -123,6 +124,7 @@ func NewRootCmd() *cobra.Command {
// return tmcfg.DefaultConfig if no custom configuration is required for the application.
func initTendermintConfig() *tmcfg.Config {
cfg := tmcfg.DefaultConfig()
cfg.Consensus.TimeoutCommit = time.Millisecond * 1500

cfg.P2P.Seeds = ""

Expand Down
14 changes: 14 additions & 0 deletions crypto/codec/amino.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package codec

import (
authn "github.com/Team-Kujira/core/crypto/keys/authn"

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

// RegisterCrypto registers all crypto dependency types with the provided Amino
// codec.
func RegisterCrypto(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(authn.PubKey{},
authn.PubKeyName, nil)
}
13 changes: 13 additions & 0 deletions crypto/codec/proto.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package codec

import (
authn "github.com/Team-Kujira/core/crypto/keys/authn"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
)

// RegisterInterfaces registers the sdk.Tx interface.
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
var pk *cryptotypes.PubKey
registry.RegisterImplementations(pk, &authn.PubKey{})
}
82 changes: 82 additions & 0 deletions crypto/keys/authn/authn.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package authn

import (
"bytes"
"fmt"

"github.com/cometbft/cometbft/crypto"

errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/types/address"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/gogoproto/proto"

Check failure on line 14 in crypto/keys/authn/authn.go

View workflow job for this annotation

GitHub Actions / lint

could not import github.com/cosmos/gogoproto/proto (-: # github.com/cosmos/gogoproto/proto
)

const (
keyType = "authn"
PubKeyName = "tendermint/PubKeyAuthn"
)

var (
_ cryptotypes.PubKey = &PubKey{}
_ codec.AminoMarshaler = &PubKey{}
)

// PubKeySize is comprised of 32 bytes for one field element
// (the x-coordinate), plus one byte for the parity of the y-coordinate.
const PubKeySize = 33

// Address returns a Bitcoin style addresses: RIPEMD160(SHA256(pubkey))
func (pubKey *PubKey) Address() crypto.Address {
if len(pubKey.Key) != PubKeySize {
panic("length of pubkey is incorrect")
}

return address.Hash(proto.MessageName(pubKey), pubKey.Key)
}

// Bytes returns the pubkey byte format.
func (pubKey *PubKey) Bytes() []byte {
return pubKey.Key
}

func (pubKey *PubKey) String() string {
return fmt.Sprintf("PubKeyAuthn{%X}", pubKey.Key)
}

func (pubKey *PubKey) Type() string {
return keyType
}

func (pubKey *PubKey) Equals(other cryptotypes.PubKey) bool {
return pubKey.Type() == other.Type() && bytes.Equal(pubKey.Bytes(), other.Bytes())
}

// MarshalAmino overrides Amino binary marshalling.
func (pubKey PubKey) MarshalAmino() ([]byte, error) {
return pubKey.Key, nil
}

// UnmarshalAmino overrides Amino binary marshalling.
func (pubKey *PubKey) UnmarshalAmino(bz []byte) error {
if len(bz) != PubKeySize {
return errorsmod.Wrap(sdkerrors.ErrInvalidPubKey, "invalid pubkey size")
}
pubKey.Key = bz

return nil
}

// MarshalAminoJSON overrides Amino JSON marshalling.
func (pubKey PubKey) MarshalAminoJSON() ([]byte, error) {
// When we marshal to Amino JSON, we don't marshal the "key" field itself,
// just its contents (i.e. the key bytes).
return pubKey.MarshalAmino()
}

// UnmarshalAminoJSON overrides Amino JSON marshalling.
func (pubKey *PubKey) UnmarshalAminoJSON(bz []byte) error {
return pubKey.UnmarshalAmino(bz)
}
Loading

0 comments on commit c7f44e7

Please sign in to comment.