Skip to content

Commit

Permalink
Merge pull request #276 from celestiaorg/release/v0.46.x-celestia-qgb
Browse files Browse the repository at this point in the history
feat: merge the QGB v0.46.x branch to the default one
  • Loading branch information
rach-id authored Sep 19, 2022
2 parents 98c7ba6 + 70700b8 commit 482d898
Show file tree
Hide file tree
Showing 59 changed files with 1,816 additions and 911 deletions.
6 changes: 5 additions & 1 deletion client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const (
// failures due to state changes that might occur between the tx simulation
// and the actual run.
DefaultGasAdjustment = 1.0
DefaultGasLimit = 200000
DefaultGasLimit = 210000
GasFlagAuto = "auto"

// DefaultKeyringBackend
Expand Down Expand Up @@ -83,6 +83,10 @@ const (
// Tendermint logging flags
FlagLogLevel = "log_level"
FlagLogFormat = "log_format"

// QGB related flags
FlagOrchestratorAddress = "orchestrator-address"
FlagEthereumAddress = "ethereum-address"
)

// LineBreak can be included in a command list to provide a blank line
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/cosmos/gogoproto v1.4.2
github.com/cosmos/iavl v0.19.0
github.com/cosmos/ledger-cosmos-go v0.11.1
github.com/ethereum/go-ethereum v1.10.17
github.com/gogo/gateway v1.1.0
github.com/gogo/protobuf v1.3.2
github.com/golang/mock v1.6.0
Expand Down Expand Up @@ -72,6 +73,7 @@ require (
github.com/aws/aws-sdk-go v1.40.45 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/btcsuite/btcd/btcec/v2 v2.1.2 // indirect
github.com/celestiaorg/go-leopard v0.1.0 // indirect
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 // indirect
github.com/celestiaorg/nmt v0.10.0 // indirect
Expand All @@ -84,6 +86,7 @@ require (
github.com/creachadair/taskgroup v0.3.2 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13P
github.com/btcsuite/btcd v0.21.0-beta.0.20201114000516-e9c7a5ac6401/go.mod h1:Sv4JPQ3/M+teHz9Bo5jBpkNcP0x6r7rdihlNL/7tTAs=
github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c=
github.com/btcsuite/btcd v0.22.1/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y=
github.com/btcsuite/btcd/btcec/v2 v2.1.2 h1:YoYoC9J0jwfukodSBMzZYUVQ8PTiYg4BnOWiJVzTmLs=
github.com/btcsuite/btcd/btcec/v2 v2.1.2/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
Expand Down Expand Up @@ -266,7 +267,9 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M=
Expand Down Expand Up @@ -314,6 +317,7 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum/go-ethereum v1.10.17 h1:XEcumY+qSr1cZQaWsQs5Kck3FHB0V2RiMHPdTBJ+oT8=
github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0=
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0=
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A=
Expand Down
6 changes: 6 additions & 0 deletions proto/cosmos/staking/v1beta1/staking.proto
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ message Validator {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
// The orchestrator field is a celes1... string (i.e. sdk.AccAddress) that
// references the key that is being delegated to
string orchestrator = 12;
// This is a hex encoded 0x Ethereum public key that will be used by this
// validator on Ethereum
string eth_address = 13;
}

// BondStatus is the status of a validator.
Expand Down
10 changes: 9 additions & 1 deletion proto/cosmos/staking/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ message MsgCreateValidator {
string validator_address = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"];
google.protobuf.Any pubkey = 6 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey"];
cosmos.base.v1beta1.Coin value = 7 [(gogoproto.nullable) = false];
// The orchestrator field is a celes1... string (i.e. sdk.AccAddress) that
// references the key that is being delegated to
string orchestrator = 8;
// This is a hex encoded 0x Ethereum public key that will be used by this
// validator on Ethereum
string eth_address = 9;
}

// MsgCreateValidatorResponse defines the Msg/CreateValidator response type.
Expand All @@ -85,6 +91,8 @@ message MsgEditValidator {
[(cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec"];
string min_self_delegation = 4
[(cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"];
string orchestrator = 5;
string eth_address = 6;
}

// MsgEditValidatorResponse defines the Msg/EditValidator response type.
Expand Down Expand Up @@ -153,7 +161,7 @@ message MsgCancelUnbondingDelegation{

string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// amount is always less than or equal to unbonding delegation entry balance
// amount is always less than or equal to unbonding delegation entry balance
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
// creation_height is the height which the unbonding took place.
int64 creation_height = 4;
Expand Down
2 changes: 1 addition & 1 deletion simapp/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

// SimAppChainID hardcoded chainID for simulation
const (
DefaultGenTxGas = 10000000
DefaultGenTxGas = 2600000 // An increase is needed when adding checks to staking/msg_server.go
SimAppChainID = "simulation-app"
)

Expand Down
10 changes: 9 additions & 1 deletion simapp/simd/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"bufio"
"encoding/json"
"fmt"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"io/ioutil"
"net"
"os"
Expand Down Expand Up @@ -288,14 +289,21 @@ func initTestnetFiles(
genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins.Sort()})
genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0))

orchAddress := sdk.AccAddress(valPubKeys[i].Address())

ethAddress, err := teststaking.RandomEthAddress()
if err != nil {
return err
}

valTokens := sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction)
createValMsg, err := stakingtypes.NewMsgCreateValidator(
sdk.ValAddress(addr),
valPubKeys[i],
sdk.NewCoin(sdk.DefaultBondDenom, valTokens),
stakingtypes.NewDescription(nodeDirName, "", "", "", ""),
stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()),
sdk.OneInt(),
sdk.OneInt(), orchAddress, *ethAddress,
)
if err != nil {
return err
Expand Down
44 changes: 32 additions & 12 deletions testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package network
import (
"bufio"
"context"
"crypto/ecdsa"
"encoding/json"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/crypto"
"net/http"
"net/url"
"os"
Expand All @@ -15,6 +17,7 @@ import (
"testing"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
tmrand "github.com/tendermint/tendermint/libs/rand"
Expand Down Expand Up @@ -167,6 +170,11 @@ type (
api *api.Server
grpc *grpc.Server
grpcWeb *http.Server

EthPrivateKey *ecdsa.PrivateKey
EthereumAddr common.Address

OrchestratorAddr sdk.AccAddress
}
)

Expand Down Expand Up @@ -399,13 +407,22 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
return nil, err
}

ethPrivateKey, err := crypto.GenerateKey()
if err != nil {
return nil, err
}
orchEthPublicKey := ethPrivateKey.Public().(*ecdsa.PublicKey)
ethAddr := crypto.PubkeyToAddress(*orchEthPublicKey)

createValMsg, err := stakingtypes.NewMsgCreateValidator(
sdk.ValAddress(addr),
valPubKeys[i],
sdk.NewCoin(cfg.BondDenom, cfg.BondedTokens),
stakingtypes.NewDescription(nodeDirName, "", "", "", ""),
stakingtypes.NewCommissionRates(commission, sdk.OneDec(), sdk.OneDec()),
sdk.OneInt(),
addr,
ethAddr,
)
if err != nil {
return nil, err
Expand Down Expand Up @@ -462,18 +479,21 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
WithAccountRetriever(cfg.AccountRetriever)

network.Validators[i] = &Validator{
AppConfig: appCfg,
ClientCtx: clientCtx,
Ctx: ctx,
Dir: filepath.Join(network.BaseDir, nodeDirName),
NodeID: nodeID,
PubKey: pubKey,
Moniker: nodeDirName,
RPCAddress: tmCfg.RPC.ListenAddress,
P2PAddress: tmCfg.P2P.ListenAddress,
APIAddress: apiAddr,
Address: addr,
ValAddress: sdk.ValAddress(addr),
AppConfig: appCfg,
ClientCtx: clientCtx,
Ctx: ctx,
Dir: filepath.Join(network.BaseDir, nodeDirName),
NodeID: nodeID,
PubKey: pubKey,
Moniker: nodeDirName,
RPCAddress: tmCfg.RPC.ListenAddress,
P2PAddress: tmCfg.P2P.ListenAddress,
APIAddress: apiAddr,
Address: addr,
ValAddress: sdk.ValAddress(addr),
EthPrivateKey: ethPrivateKey,
EthereumAddr: ethAddr,
OrchestratorAddr: addr,
}
}

Expand Down
3 changes: 3 additions & 0 deletions x/auth/client/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxsCmdByEvents() {
name string
args []string
expectEmpty bool
expectError string
}{
{
"fee event happy case",
Expand All @@ -653,6 +654,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxsCmdByEvents() {
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
false,
"",
},
{
"no matching fee event",
Expand All @@ -662,6 +664,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxsCmdByEvents() {
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
true,
"",
},
}

Expand Down
6 changes: 5 additions & 1 deletion x/auth/migrations/v043/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v043_test

import (
"fmt"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"testing"
"time"

Expand Down Expand Up @@ -652,6 +653,9 @@ func createValidator(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers i
pks := simapp.CreateTestPubKeys(1)
cdc := simapp.MakeTestEncodingConfig().Codec

ethAddr, err := teststaking.RandomEthAddress()
require.NoError(t, err)

app.StakingKeeper = stakingkeeper.NewKeeper(
cdc,
app.GetKey(stakingtypes.StoreKey),
Expand All @@ -660,7 +664,7 @@ func createValidator(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers i
app.GetSubspace(stakingtypes.ModuleName),
)

val1, err := stakingtypes.NewValidator(valAddrs[0], pks[0], stakingtypes.Description{})
val1, err := stakingtypes.NewValidator(valAddrs[0], pks[0], stakingtypes.Description{}, sdk.AccAddress(pks[0].Address()), *ethAddr)
require.NoError(t, err)

app.StakingKeeper.SetValidator(ctx, val1)
Expand Down
4 changes: 3 additions & 1 deletion x/distribution/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ func TestVerifyProposerRewardAssignement(t *testing.T) {
validators[i].addr = sdk.ValAddress(addrs[i])
validators[i].pubkey = ed25519.GenPrivKey().PubKey()
validators[i].votes = make([]abci.VoteInfo, totalValidators)
tstaking.CreateValidatorWithValPower(validators[i].addr, validators[i].pubkey, power, true)
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.CreateValidatorWithValPower(validators[i].addr, validators[i].pubkey, power, sdk.AccAddress(validators[i].addr), *randomEthAddress, true)
}
app.EndBlock(abci.RequestEndBlock{})
require.NotEmpty(t, app.Commit())
Expand Down
24 changes: 18 additions & 6 deletions x/distribution/keeper/allocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) {
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

addrs := simapp.AddTestAddrs(app, ctx, 3, sdk.NewInt(1234))
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
valAddrs := simapp.ConvertAddrsToValAddrs(addrs)
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)

// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidator(sdk.ValAddress(addrs[0]), valConsPk1, sdk.NewInt(100), true)
tstaking.CreateValidator(sdk.ValAddress(addrs[0]), valConsPk1, sdk.NewInt(100), sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)
val := app.StakingKeeper.Validator(ctx, valAddrs[0])

// allocate tokens
Expand All @@ -53,16 +55,20 @@ func TestAllocateTokensToManyValidators(t *testing.T) {
app.DistrKeeper.SetFeePool(ctx, disttypes.InitialFeePool())

addrs := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1234))
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
valAddrs := simapp.ConvertAddrsToValAddrs(addrs)
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)

// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true)
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)

// create second validator with 0% commission
randomEthAddress2, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDec(0), sdk.NewDec(0), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[1], valConsPk2, sdk.NewInt(100), true)
tstaking.CreateValidator(valAddrs[1], valConsPk2, sdk.NewInt(100), sdk.AccAddress(valConsPk2.Address()), *randomEthAddress2, true)

abciValA := abci.Validator{
Address: valConsPk1.Address(),
Expand Down Expand Up @@ -131,16 +137,22 @@ func TestAllocateTokensTruncation(t *testing.T) {
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)

// create validator with 10% commission
randomEthAddress, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(110), true)
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(110), sdk.AccAddress(valConsPk1.Address()), *randomEthAddress, true)

// create second validator with 10% commission
randomEthAddress2, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[1], valConsPk2, sdk.NewInt(100), true)
tstaking.CreateValidator(valAddrs[1], valConsPk2, sdk.NewInt(100), sdk.AccAddress(valConsPk2.Address()), *randomEthAddress2, true)

// create third validator with 10% commission
randomEthAddress3, err := teststaking.RandomEthAddress()
require.NoError(t, err)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[2], valConsPk3, sdk.NewInt(100), true)
tstaking.CreateValidator(valAddrs[2], valConsPk3, sdk.NewInt(100), sdk.AccAddress(valConsPk3.Address()), *randomEthAddress3, true)

abciValA := abci.Validator{
Address: valConsPk1.Address(),
Expand Down
Loading

0 comments on commit 482d898

Please sign in to comment.