forked from cerc-io/laconicd
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1949eb514 | ||
|
|
debfb82205 | ||
|
|
3c5cd002e1 | ||
|
|
b5a76a920e |
@@ -34,6 +34,7 @@ import (
|
||||
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
|
||||
_ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects
|
||||
@@ -48,6 +49,7 @@ import (
|
||||
_ "github.com/cosmos/cosmos-sdk/x/crisis" // import for side-effects
|
||||
_ "github.com/cosmos/cosmos-sdk/x/distribution" // import for side-effects
|
||||
_ "github.com/cosmos/cosmos-sdk/x/mint" // import for side-effects
|
||||
_ "github.com/cosmos/cosmos-sdk/x/slashing" // import for side-effects
|
||||
_ "github.com/cosmos/cosmos-sdk/x/staking" // import for side-effects
|
||||
)
|
||||
|
||||
@@ -76,6 +78,7 @@ type LaconicApp struct {
|
||||
AccountKeeper authkeeper.AccountKeeper
|
||||
BankKeeper bankkeeper.Keeper
|
||||
StakingKeeper *stakingkeeper.Keeper
|
||||
SlashingKeeper slashingkeeper.Keeper
|
||||
DistrKeeper distrkeeper.Keeper
|
||||
CrisisKeeper *crisiskeeper.Keeper
|
||||
ConsensusParamsKeeper consensuskeeper.Keeper
|
||||
@@ -142,6 +145,7 @@ func NewLaconicApp(
|
||||
&app.AccountKeeper,
|
||||
&app.BankKeeper,
|
||||
&app.StakingKeeper,
|
||||
&app.SlashingKeeper,
|
||||
&app.DistrKeeper,
|
||||
&app.CrisisKeeper,
|
||||
&app.ConsensusParamsKeeper,
|
||||
|
||||
+5
-2
@@ -6,11 +6,11 @@ modules:
|
||||
# During begin block slashing happens after distr.BeginBlocker so that
|
||||
# there is nothing left over in the validator fee pool, so as to keep the CanWithdrawInvariant invariant.
|
||||
# NOTE: staking module is required if HistoricalEntries param > 0
|
||||
begin_blockers: [distribution, staking]
|
||||
begin_blockers: [distribution, slashing, staking]
|
||||
end_blockers: [crisis, staking, auction, registry]
|
||||
# NOTE: The genutils module must occur after staking so that pools are properly initialized with tokens from genesis accounts.
|
||||
# NOTE: The genutils module must also occur after auth so that it can access the params from auth.
|
||||
init_genesis: [auth, bank, distribution, staking, crisis, genutil, auction, bond, registry, onboarding]
|
||||
init_genesis: [auth, bank, distribution, staking, slashing, crisis, genutil, auction, bond, registry, onboarding]
|
||||
override_store_keys:
|
||||
- module_name: auth
|
||||
kv_store_key: acc
|
||||
@@ -39,6 +39,9 @@ modules:
|
||||
- name: staking
|
||||
config:
|
||||
"@type": cosmos.staking.module.v1.Module
|
||||
- name: slashing
|
||||
config:
|
||||
"@type": cosmos.slashing.module.v1.Module
|
||||
- name: distribution
|
||||
config:
|
||||
"@type": cosmos.distribution.module.v1.Module
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
@@ -221,4 +222,16 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
/* Handle slashing state. */
|
||||
|
||||
// reset start height on signing infos
|
||||
app.SlashingKeeper.IterateValidatorSigningInfos(
|
||||
ctx,
|
||||
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
|
||||
info.StartHeight = 0
|
||||
app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
|
||||
return false
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ require (
|
||||
github.com/agnivade/levenshtein v1.1.1 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
|
||||
github.com/bits-and-blooms/bitset v1.10.0 // indirect
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
|
||||
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
|
||||
|
||||
@@ -227,7 +227,7 @@ type Query {
|
||||
getBondsByIds(ids: [String!]): [Bond]
|
||||
|
||||
# Query bonds.
|
||||
queryBonds(attributes: [KeyValueInput!]): [Bond]
|
||||
queryBonds: [Bond]
|
||||
|
||||
# Query bonds by owner.
|
||||
queryBondsByOwner(ownerAddresses: [String!]): [OwnerBonds]
|
||||
|
||||
+4
-35
@@ -183,7 +183,7 @@ type ComplexityRoot struct {
|
||||
GetStatus func(childComplexity int) int
|
||||
LookupAuthorities func(childComplexity int, names []string) int
|
||||
LookupNames func(childComplexity int, names []string) int
|
||||
QueryBonds func(childComplexity int, attributes []*KeyValueInput) int
|
||||
QueryBonds func(childComplexity int) int
|
||||
QueryBondsByOwner func(childComplexity int, ownerAddresses []string) int
|
||||
QueryRecords func(childComplexity int, attributes []*KeyValueInput, all *bool) int
|
||||
ResolveNames func(childComplexity int, names []string) int
|
||||
@@ -233,7 +233,7 @@ type QueryResolver interface {
|
||||
GetStatus(ctx context.Context) (*Status, error)
|
||||
GetAccounts(ctx context.Context, addresses []string) ([]*Account, error)
|
||||
GetBondsByIds(ctx context.Context, ids []string) ([]*Bond, error)
|
||||
QueryBonds(ctx context.Context, attributes []*KeyValueInput) ([]*Bond, error)
|
||||
QueryBonds(ctx context.Context) ([]*Bond, error)
|
||||
QueryBondsByOwner(ctx context.Context, ownerAddresses []string) ([]*OwnerBonds, error)
|
||||
GetRecordsByIds(ctx context.Context, ids []string) ([]*Record, error)
|
||||
QueryRecords(ctx context.Context, attributes []*KeyValueInput, all *bool) ([]*Record, error)
|
||||
@@ -844,12 +844,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||
break
|
||||
}
|
||||
|
||||
args, err := ec.field_Query_queryBonds_args(context.TODO(), rawArgs)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return e.complexity.Query.QueryBonds(childComplexity, args["attributes"].([]*KeyValueInput)), true
|
||||
return e.complexity.Query.QueryBonds(childComplexity), true
|
||||
|
||||
case "Query.queryBondsByOwner":
|
||||
if e.complexity.Query.QueryBondsByOwner == nil {
|
||||
@@ -1294,21 +1289,6 @@ func (ec *executionContext) field_Query_queryBondsByOwner_args(ctx context.Conte
|
||||
return args, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Query_queryBonds_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
|
||||
var err error
|
||||
args := map[string]interface{}{}
|
||||
var arg0 []*KeyValueInput
|
||||
if tmp, ok := rawArgs["attributes"]; ok {
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("attributes"))
|
||||
arg0, err = ec.unmarshalOKeyValueInput2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐKeyValueInputᚄ(ctx, tmp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
args["attributes"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Query_queryRecords_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
|
||||
var err error
|
||||
args := map[string]interface{}{}
|
||||
@@ -4578,7 +4558,7 @@ func (ec *executionContext) _Query_queryBonds(ctx context.Context, field graphql
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return ec.resolvers.Query().QueryBonds(rctx, fc.Args["attributes"].([]*KeyValueInput))
|
||||
return ec.resolvers.Query().QueryBonds(rctx)
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
@@ -4610,17 +4590,6 @@ func (ec *executionContext) fieldContext_Query_queryBonds(ctx context.Context, f
|
||||
return nil, fmt.Errorf("no field named %q was found under type Bond", field.Name)
|
||||
},
|
||||
}
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
err = ec.Recover(ctx, r)
|
||||
ec.Error(ctx, err)
|
||||
}
|
||||
}()
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
if fc.Args, err = ec.field_Query_queryBonds_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -296,7 +296,7 @@ func (q *queryResolver) GetBond(ctx context.Context, id string) (*Bond, error) {
|
||||
return getGQLBond(bondResp.GetBond())
|
||||
}
|
||||
|
||||
func (q queryResolver) QueryBonds(ctx context.Context, attributes []*KeyValueInput) ([]*Bond, error) {
|
||||
func (q queryResolver) QueryBonds(ctx context.Context) ([]*Bond, error) {
|
||||
bondQueryClient := bondtypes.NewQueryClient(q.ctx)
|
||||
bonds, err := bondQueryClient.Bonds(context.Background(), &bondtypes.QueryBondsRequest{})
|
||||
if err != nil {
|
||||
|
||||
+32
-10
@@ -1,10 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
KEY="alice"
|
||||
CHAINID="laconic_9000-1"
|
||||
MONIKER="localtestnet"
|
||||
KEYRING="test"
|
||||
LOGLEVEL="${LOGLEVEL:-info}"
|
||||
CHAINID=${CHAINID:-"laconic_9000-1"}
|
||||
MONIKER=${MONIKER:-"localtestnet"}
|
||||
KEYRING=${KEYRING:-"test"}
|
||||
DENOM=${DENOM:-"alnt"}
|
||||
STAKING_AMOUNT=${STAKING_AMOUNT:-"1000000000000000"}
|
||||
LOGLEVEL=${LOGLEVEL:-"info"}
|
||||
|
||||
input_genesis_file=${GENESIS_FILE}
|
||||
|
||||
@@ -29,9 +31,9 @@ if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; then
|
||||
laconicd keys add $KEY --keyring-backend $KEYRING
|
||||
|
||||
# Set moniker and chain-id for Ethermint (Moniker can be anything, chain-id must be an integer)
|
||||
laconicd init $MONIKER --chain-id $CHAINID --default-denom alnt
|
||||
laconicd init $MONIKER --chain-id $CHAINID --default-denom $DENOM
|
||||
|
||||
if [ -f ${input_genesis_file} ]; then
|
||||
if [[ -f ${input_genesis_file} ]]; then
|
||||
# Use provided genesis config
|
||||
cp $input_genesis_file $HOME/.laconicd/config/genesis.json
|
||||
fi
|
||||
@@ -65,6 +67,26 @@ if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; then
|
||||
update_genesis '.app_state["onboarding"]["params"]["onboarding_enabled"]=true'
|
||||
fi
|
||||
|
||||
if [[ "$AUTHORITY_AUCTION_ENABLED" == "true" ]]; then
|
||||
echo "Enabling authority auctions."
|
||||
update_genesis '.app_state["registry"]["params"]["authority_auction_enabled"]=true'
|
||||
fi
|
||||
|
||||
if [[ -n $AUTHORITY_AUCTION_COMMITS_DURATION ]]; then
|
||||
echo "Setting authority_auction_commits_duration to $AUTHORITY_AUCTION_COMMITS_DURATION seconds."
|
||||
update_genesis ".app_state[\"registry\"][\"params\"][\"authority_auction_commits_duration\"]=\"${AUTHORITY_AUCTION_COMMITS_DURATION}s\""
|
||||
fi
|
||||
|
||||
if [[ -n $AUTHORITY_AUCTION_REVEALS_DURATION ]]; then
|
||||
echo "Setting authority_auction_reveals_duration to $AUTHORITY_AUCTION_REVEALS_DURATION seconds."
|
||||
update_genesis ".app_state[\"registry\"][\"params\"][\"authority_auction_reveals_duration\"]=\"${AUTHORITY_AUCTION_REVEALS_DURATION}s\""
|
||||
fi
|
||||
|
||||
if [[ -n $AUTHORITY_GRACE_PERIOD ]]; then
|
||||
echo "Setting authority_grace_period to $AUTHORITY_GRACE_PERIOD seconds."
|
||||
update_genesis ".app_state[\"registry\"][\"params\"][\"authority_grace_period\"]=\"${AUTHORITY_GRACE_PERIOD}s\""
|
||||
fi
|
||||
|
||||
# increase block time (?)
|
||||
update_genesis '.consensus["params"]["block"]["time_iota_ms"]="1000"'
|
||||
|
||||
@@ -94,11 +116,11 @@ if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; then
|
||||
|
||||
# Allocate genesis accounts (cosmos formatted addresses)
|
||||
# 10^30 alnt | 10^12 lnt
|
||||
laconicd genesis add-genesis-account $KEY 1000000000000000000000000000000alnt --keyring-backend $KEYRING
|
||||
laconicd genesis add-genesis-account $KEY 1000000000000000000000000000000$DENOM --keyring-backend $KEYRING
|
||||
|
||||
# Sign genesis transaction
|
||||
# 10^24 alnt | 10^6 lnt
|
||||
laconicd genesis gentx $KEY 1000000000000000000000000alnt --keyring-backend $KEYRING --chain-id $CHAINID
|
||||
# 10^15 alnt
|
||||
laconicd genesis gentx $KEY $STAKING_AMOUNT$DENOM --keyring-backend $KEYRING --chain-id $CHAINID
|
||||
|
||||
# Collect genesis tx
|
||||
laconicd genesis collect-gentxs
|
||||
@@ -113,7 +135,7 @@ fi
|
||||
laconicd start \
|
||||
--pruning=nothing \
|
||||
--log_level $LOGLEVEL \
|
||||
--minimum-gas-prices=1alnt \
|
||||
--minimum-gas-prices=1$DENOM \
|
||||
--api.enable \
|
||||
--rpc.laddr="tcp://0.0.0.0:26657" \
|
||||
--gql-server --gql-playground
|
||||
|
||||
Reference in New Issue
Block a user