Merge remote-tracking branch 'origin/develop' into rigel/fee-distribution

This commit is contained in:
rigelrozanski
2018-10-09 20:19:22 -04:00
32 changed files with 791 additions and 238 deletions
+1 -1
View File
@@ -162,7 +162,6 @@ func GaiaAppGenTxNF(cdc *codec.Codec, pk crypto.PubKey, addr sdk.AccAddress, nam
// Create the core parameters for genesis initialization for gaia
// note that the pubkey input is this machines pubkey
func GaiaAppGenState(cdc *codec.Codec, appGenTxs []json.RawMessage) (genesisState GenesisState, err error) {
if len(appGenTxs) == 0 {
err = errors.New("must provide at least genesis transaction")
return
@@ -198,6 +197,7 @@ func GaiaAppGenState(cdc *codec.Codec, appGenTxs []json.RawMessage) (genesisStat
DistrData: distr.DefaultGenesisState(),
GovData: gov.DefaultGenesisState(),
}
return
}
+76
View File
@@ -0,0 +1,76 @@
package app
import (
"encoding/json"
"errors"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/stake"
tmtypes "github.com/tendermint/tendermint/types"
)
// NewTestGaiaAppGenState creates the core parameters for a test genesis
// initialization given a set of genesis txs, TM validators and their respective
// operating addresses.
func NewTestGaiaAppGenState(
cdc *codec.Codec, appGenTxs []json.RawMessage, tmVals []tmtypes.GenesisValidator, valOperAddrs []sdk.ValAddress,
) (GenesisState, error) {
switch {
case len(appGenTxs) == 0:
return GenesisState{}, errors.New("must provide at least genesis transaction")
case len(tmVals) != len(valOperAddrs):
return GenesisState{}, errors.New("number of TM validators does not match number of operator addresses")
}
// start with the default staking genesis state
stakeData := stake.DefaultGenesisState()
// get genesis account information
genAccs := make([]GenesisAccount, len(appGenTxs))
for i, appGenTx := range appGenTxs {
var genTx GaiaGenTx
if err := cdc.UnmarshalJSON(appGenTx, &genTx); err != nil {
return GenesisState{}, err
}
stakeData.Pool.LooseTokens = stakeData.Pool.LooseTokens.Add(sdk.NewDecFromInt(freeFermionsAcc))
// create the genesis account for the given genesis tx
genAccs[i] = genesisAccountFromGenTx(genTx)
}
for i, tmVal := range tmVals {
var issuedDelShares sdk.Dec
// increase total supply by validator's power
power := sdk.NewInt(tmVal.Power)
stakeData.Pool.LooseTokens = stakeData.Pool.LooseTokens.Add(sdk.NewDecFromInt(power))
// add the validator
desc := stake.NewDescription(tmVal.Name, "", "", "")
validator := stake.NewValidator(valOperAddrs[i], tmVal.PubKey, desc)
validator, stakeData.Pool, issuedDelShares = validator.AddTokensFromDel(stakeData.Pool, power)
stakeData.Validators = append(stakeData.Validators, validator)
// create the self-delegation from the issuedDelShares
selfDel := stake.Delegation{
DelegatorAddr: sdk.AccAddress(validator.OperatorAddr),
ValidatorAddr: validator.OperatorAddr,
Shares: issuedDelShares,
Height: 0,
}
stakeData.Bonds = append(stakeData.Bonds, selfDel)
}
return GenesisState{
Accounts: genAccs,
StakeData: stakeData,
GovData: gov.DefaultGenesisState(),
}, nil
}
+7 -1
View File
@@ -138,11 +138,17 @@ func runPubKeyCmd(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
consenusPub, err := sdk.Bech32ifyConsPub(pubKey)
if err != nil {
return err
}
fmt.Println("Address:", pubKey.Address())
fmt.Printf("Hex: %X\n", pubkeyBytes)
fmt.Println("JSON (base64):", string(pubKeyJSONBytes))
fmt.Println("Bech32 Acc:", accPub)
fmt.Println("Bech32 Val:", valPub)
fmt.Println("Bech32 Validator Operator:", valPub)
fmt.Println("Bech32 Validator Consensus:", consenusPub)
return nil
}