Compare commits

..
Author SHA1 Message Date
prathamesh d1949eb514 Remove unused attributes arg from queryBonds GQL API 2024-08-27 14:42:54 +05:30
prathamesh debfb82205 Integrate slashing module in the app (#53)
Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675)

Add `slashing` module for penalizing / jailing offline validators
Reference: https://docs.cosmos.network/main/build/modules/slashing#liveness-tracking

Note: Breaking change, an existing chain cannot be run with the updated binary

Reviewed-on: cerc-io/laconicd#53
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-08-16 06:23:56 +00:00
prathamesh 3c5cd002e1 Add env variables to configure authority auctions in initialization script (#50)
Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675)

Reviewed-on: cerc-io/laconicd#50
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-08-08 07:14:36 +00:00
prathamesh b5a76a920e Update node initialization script (#49)
Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675)

Reviewed-on: cerc-io/laconicd#49
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-08-07 11:25:01 +00:00
nabarunandIshaVenikar f176a5889e Implement GQL query for listing authorities (#48)
Part of [Create a public laconicd testnet](https://www.notion.so/Create-a-public-laconicd-testnet-896a11bdd8094eff8f1b49c0be0ca3b8)

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Reviewed-on: cerc-io/laconicd#48
2024-08-02 09:15:08 +00:00
nabarunandAdw8 5e7d5fc47c Update init script to use existing genesis file (#47)
Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675)

Co-authored-by: Adw8 <adwaitgharpure@gmail.com>
Reviewed-on: cerc-io/laconicd#47
2024-08-01 11:52:47 +00:00
prathameshandzramsay c162396298 Change token denom from photon to lnt and alnt (#46)
Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675)

Co-authored-by: zramsay <zach@bluecollarcoding.ca>
Reviewed-on: cerc-io/laconicd#46
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-07-30 11:05:58 +00:00
18 changed files with 491 additions and 84 deletions
+3
View File
@@ -25,6 +25,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
# Copy over binary from the builder
COPY --from=builder /go/src/git.vdb.to/cerc-io/laconicd/build/laconicd /usr/bin/laconicd
# Copy over init script from builder
COPY --from=builder /go/src/git.vdb.to/cerc-io/laconicd/scripts/init.sh scripts/init.sh
WORKDIR /
# Run laconicd by default
+4
View File
@@ -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
View File
@@ -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
+13
View File
@@ -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
},
)
}
+9 -2
View File
@@ -10,9 +10,11 @@ import (
)
const (
CoinUnit = "photon"
CoinUnit = "lnt"
BaseCoinUnit = "alnt"
LntExponent = 18
DefaultBondDenom = CoinUnit
DefaultBondDenom = BaseCoinUnit
// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address.
Bech32PrefixAccAddr = "laconic"
@@ -41,6 +43,11 @@ func RegisterDenoms() {
if err != nil {
panic(err)
}
err = sdk.RegisterDenom(BaseCoinUnit, math.LegacyNewDecWithPrec(1, LntExponent))
if err != nil {
panic(err)
}
}
func SetAddressPrefixes() {
+1 -1
View File
@@ -98,7 +98,7 @@ func NewRootCmd() *cobra.Command {
// overwrite the minimum gas price from the app configuration
srvCfg := serverconfig.DefaultConfig()
srvCfg.MinGasPrices = "0photon"
srvCfg.MinGasPrices = "0alnt"
// overwrite the block timeout
cmtCfg := cmtcfg.DefaultConfig()
+1
View File
@@ -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
+9 -1
View File
@@ -197,6 +197,11 @@ type AuthorityRecord {
auction: Auction # Authority auction.
}
type Authority {
name: String!
entry: AuthorityRecord!
}
# Name record entry, created at a particular height.
type NameRecordEntry {
id: String! # Target record ID.
@@ -222,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]
@@ -247,6 +252,9 @@ type Query {
# Naming API.
#
# Get authorities list.
getAuthorities(owner: String): [Authority]
# Lookup authority information.
lookupAuthorities(names: [String!]): [AuthorityRecord]!
+327 -35
View File
@@ -87,6 +87,11 @@ type ComplexityRoot struct {
Status func(childComplexity int) int
}
Authority struct {
Entry func(childComplexity int) int
Name func(childComplexity int) int
}
AuthorityRecord struct {
Auction func(childComplexity int) int
BondID func(childComplexity int) int
@@ -169,6 +174,7 @@ type ComplexityRoot struct {
Query struct {
GetAccounts func(childComplexity int, addresses []string) int
GetAuctionsByIds func(childComplexity int, ids []string) int
GetAuthorities func(childComplexity int, owner *string) int
GetBondsByIds func(childComplexity int, ids []string) int
GetParticipantByAddress func(childComplexity int, address string) int
GetParticipantByNitroAddress func(childComplexity int, nitroAddress string) int
@@ -177,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
@@ -227,10 +233,11 @@ 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)
GetAuthorities(ctx context.Context, owner *string) ([]*Authority, error)
LookupAuthorities(ctx context.Context, names []string) ([]*AuthorityRecord, error)
LookupNames(ctx context.Context, names []string) ([]*NameRecord, error)
ResolveNames(ctx context.Context, names []string) ([]*Record, error)
@@ -458,6 +465,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.AuctionBid.Status(childComplexity), true
case "Authority.entry":
if e.complexity.Authority.Entry == nil {
break
}
return e.complexity.Authority.Entry(childComplexity), true
case "Authority.name":
if e.complexity.Authority.Name == nil {
break
}
return e.complexity.Authority.Name(childComplexity), true
case "AuthorityRecord.auction":
if e.complexity.AuthorityRecord.Auction == nil {
break
@@ -720,6 +741,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Query.GetAuctionsByIds(childComplexity, args["ids"].([]string)), true
case "Query.getAuthorities":
if e.complexity.Query.GetAuthorities == nil {
break
}
args, err := ec.field_Query_getAuthorities_args(context.TODO(), rawArgs)
if err != nil {
return 0, false
}
return e.complexity.Query.GetAuthorities(childComplexity, args["owner"].(*string)), true
case "Query.getBondsByIds":
if e.complexity.Query.GetBondsByIds == nil {
break
@@ -811,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 {
@@ -1141,6 +1169,21 @@ func (ec *executionContext) field_Query_getAuctionsByIds_args(ctx context.Contex
return args, nil
}
func (ec *executionContext) field_Query_getAuthorities_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 *string
if tmp, ok := rawArgs["owner"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("owner"))
arg0, err = ec.unmarshalOString2ᚖstring(ctx, tmp)
if err != nil {
return nil, err
}
}
args["owner"] = arg0
return args, nil
}
func (ec *executionContext) field_Query_getBondsByIds_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
@@ -1246,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{}{}
@@ -2674,6 +2702,110 @@ func (ec *executionContext) fieldContext_AuctionBid_bidAmount(ctx context.Contex
return fc, nil
}
func (ec *executionContext) _Authority_name(ctx context.Context, field graphql.CollectedField, obj *Authority) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Authority_name(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Name, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(string)
fc.Result = res
return ec.marshalNString2string(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Authority_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Authority",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Authority_entry(ctx context.Context, field graphql.CollectedField, obj *Authority) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Authority_entry(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Entry, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(*AuthorityRecord)
fc.Result = res
return ec.marshalNAuthorityRecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthorityRecord(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Authority_entry(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Authority",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "ownerAddress":
return ec.fieldContext_AuthorityRecord_ownerAddress(ctx, field)
case "ownerPublicKey":
return ec.fieldContext_AuthorityRecord_ownerPublicKey(ctx, field)
case "height":
return ec.fieldContext_AuthorityRecord_height(ctx, field)
case "status":
return ec.fieldContext_AuthorityRecord_status(ctx, field)
case "bondId":
return ec.fieldContext_AuthorityRecord_bondId(ctx, field)
case "expiryTime":
return ec.fieldContext_AuthorityRecord_expiryTime(ctx, field)
case "auction":
return ec.fieldContext_AuthorityRecord_auction(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type AuthorityRecord", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) _AuthorityRecord_ownerAddress(ctx context.Context, field graphql.CollectedField, obj *AuthorityRecord) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_AuthorityRecord_ownerAddress(ctx, field)
if err != nil {
@@ -4426,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)
@@ -4458,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
}
@@ -4670,6 +4791,64 @@ func (ec *executionContext) fieldContext_Query_queryRecords(ctx context.Context,
return fc, nil
}
func (ec *executionContext) _Query_getAuthorities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Query_getAuthorities(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.Query().GetAuthorities(rctx, fc.Args["owner"].(*string))
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.([]*Authority)
fc.Result = res
return ec.marshalOAuthority2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthority(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Query_getAuthorities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Query",
Field: field,
IsMethod: true,
IsResolver: true,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "name":
return ec.fieldContext_Authority_name(ctx, field)
case "entry":
return ec.fieldContext_Authority_entry(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Authority", 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_getAuthorities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return
}
return fc, nil
}
func (ec *executionContext) _Query_lookupAuthorities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Query_lookupAuthorities(ctx, field)
if err != nil {
@@ -8623,6 +8802,41 @@ func (ec *executionContext) _AuctionBid(ctx context.Context, sel ast.SelectionSe
return out
}
var authorityImplementors = []string{"Authority"}
func (ec *executionContext) _Authority(ctx context.Context, sel ast.SelectionSet, obj *Authority) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, authorityImplementors)
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Authority")
case "name":
out.Values[i] = ec._Authority_name(ctx, field, obj)
if out.Values[i] == graphql.Null {
invalids++
}
case "entry":
out.Values[i] = ec._Authority_entry(ctx, field, obj)
if out.Values[i] == graphql.Null {
invalids++
}
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch()
if invalids > 0 {
return graphql.Null
}
return out
}
var authorityRecordImplementors = []string{"AuthorityRecord"}
func (ec *executionContext) _AuthorityRecord(ctx context.Context, sel ast.SelectionSet, obj *AuthorityRecord) graphql.Marshaler {
@@ -9323,6 +9537,26 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
}
out.Concurrently(i, func() graphql.Marshaler {
return rrm(innerCtx)
})
case "getAuthorities":
field := field
innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Query_getAuthorities(ctx, field)
return res
}
rrm := func(ctx context.Context) graphql.Marshaler {
return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc)
}
out.Concurrently(i, func() graphql.Marshaler {
return rrm(innerCtx)
})
@@ -10169,6 +10403,16 @@ func (ec *executionContext) marshalNAuthorityRecord2ᚕᚖgitᚗvdbᚗtoᚋcerc
return ret
}
func (ec *executionContext) marshalNAuthorityRecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthorityRecord(ctx context.Context, sel ast.SelectionSet, v *AuthorityRecord) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._AuthorityRecord(ctx, sel, v)
}
func (ec *executionContext) marshalNBond2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐBond(ctx context.Context, sel ast.SelectionSet, v *Bond) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
@@ -10956,6 +11200,54 @@ func (ec *executionContext) marshalOAuctionBid2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋl
return ec._AuctionBid(ctx, sel, v)
}
func (ec *executionContext) marshalOAuthority2ᚕᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthority(ctx context.Context, sel ast.SelectionSet, v []*Authority) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalOAuthority2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthority(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
return ret
}
func (ec *executionContext) marshalOAuthority2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthority(ctx context.Context, sel ast.SelectionSet, v *Authority) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._Authority(ctx, sel, v)
}
func (ec *executionContext) marshalOAuthorityRecord2ᚖgitᚗvdbᚗtoᚋcercᚑioᚋlaconicdᚋgqlᚐAuthorityRecord(ctx context.Context, sel ast.SelectionSet, v *AuthorityRecord) graphql.Marshaler {
if v == nil {
return graphql.Null
+5
View File
@@ -52,6 +52,11 @@ type AuctionBid struct {
BidAmount *Coin `json:"bidAmount"`
}
type Authority struct {
Name string `json:"name"`
Entry *AuthorityRecord `json:"entry"`
}
type AuthorityRecord struct {
OwnerAddress string `json:"ownerAddress"`
OwnerPublicKey string `json:"ownerPublicKey"`
+32 -20
View File
@@ -35,6 +35,36 @@ func (r *Resolver) Query() QueryResolver {
type queryResolver struct{ *Resolver }
func (q queryResolver) GetAuthorities(ctx context.Context, owner *string) ([]*Authority, error) {
nsQueryClient := registrytypes.NewQueryClient(q.ctx)
auctionQueryClient := auctiontypes.NewQueryClient(q.ctx)
authoritiesReq := &registrytypes.QueryAuthoritiesRequest{}
if owner != nil {
authoritiesReq.Owner = *owner
}
authoritiesResp, err := nsQueryClient.Authorities(ctx, authoritiesReq)
if err != nil {
return nil, err
}
authorities := make([]*Authority, len(authoritiesResp.GetAuthorities()))
for i, a := range authoritiesResp.Authorities {
entry, err := getAuthorityRecord(*a.Entry, auctionQueryClient)
if err != nil {
return nil, err
}
authorities[i] = &Authority{
Name: a.Name,
Entry: entry,
}
}
return authorities, nil
}
func (q queryResolver) LookupAuthorities(ctx context.Context, names []string) ([]*AuthorityRecord, error) {
nsQueryClient := registrytypes.NewQueryClient(q.ctx)
auctionQueryClient := auctiontypes.NewQueryClient(q.ctx)
@@ -52,29 +82,11 @@ func (q queryResolver) LookupAuthorities(ctx context.Context, names []string) ([
}
nameAuthority := res.GetNameAuthority()
gqlNameAuthorityRecord, err := GetGQLNameAuthorityRecord(&nameAuthority)
gqlNameAuthorityRecord, err := getAuthorityRecord(nameAuthority, auctionQueryClient)
if err != nil {
return nil, err
}
if nameAuthority.AuctionId != "" {
auctionResp, err := auctionQueryClient.GetAuction(context.Background(), &auctiontypes.QueryGetAuctionRequest{Id: nameAuthority.GetAuctionId()})
if err != nil {
return nil, err
}
bidsResp, err := auctionQueryClient.GetBids(context.Background(), &auctiontypes.QueryGetBidsRequest{AuctionId: nameAuthority.GetAuctionId()})
if err != nil {
return nil, err
}
gqlAuctionRecord, err := GetGQLAuction(auctionResp.GetAuction(), bidsResp.GetBids())
if err != nil {
return nil, err
}
gqlNameAuthorityRecord.Auction = gqlAuctionRecord
}
gqlResponse = append(gqlResponse, gqlNameAuthorityRecord)
}
@@ -284,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 {
+27
View File
@@ -303,3 +303,30 @@ func toRPCAttributes(attrs []*KeyValueInput) []*registrytypes.QueryRecordsReques
return kvPairs
}
func getAuthorityRecord(nameAuthority registrytypes.NameAuthority, auctionQueryClient auctiontypes.QueryClient) (*AuthorityRecord, error) {
gqlNameAuthorityRecord, err := GetGQLNameAuthorityRecord(&nameAuthority)
if err != nil {
return nil, err
}
if nameAuthority.AuctionId != "" {
auctionResp, err := auctionQueryClient.GetAuction(context.Background(), &auctiontypes.QueryGetAuctionRequest{Id: nameAuthority.GetAuctionId()})
if err != nil {
return nil, err
}
bidsResp, err := auctionQueryClient.GetBids(context.Background(), &auctiontypes.QueryGetBidsRequest{AuctionId: nameAuthority.GetAuctionId()})
if err != nil {
return nil, err
}
gqlAuctionRecord, err := GetGQLAuction(auctionResp.GetAuction(), bidsResp.GetBids())
if err != nil {
return nil, err
}
gqlNameAuthorityRecord.Auction = gqlAuctionRecord
}
return gqlNameAuthorityRecord, nil
}
+40 -9
View File
@@ -1,10 +1,14 @@
#!/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}
if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; then
# validate dependencies are installed
@@ -27,7 +31,12 @@ 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 photon
laconicd init $MONIKER --chain-id $CHAINID --default-denom $DENOM
if [[ -f ${input_genesis_file} ]]; then
# Use provided genesis config
cp $input_genesis_file $HOME/.laconicd/config/genesis.json
fi
update_genesis() {
jq "$1" $HOME/.laconicd/config/genesis.json > $HOME/.laconicd/config/tmp_genesis.json &&
@@ -58,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"'
@@ -70,7 +99,7 @@ if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; then
else
sed -i 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
fi
# Run this to allow requests from any origin
sed -i 's/cors_allowed_origins.*$/cors_allowed_origins = ["*"]/' $HOME/.laconicd/config/config.toml
@@ -86,10 +115,12 @@ if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; then
fi
# Allocate genesis accounts (cosmos formatted addresses)
laconicd genesis add-genesis-account $KEY 100000000000000000000000000photon --keyring-backend $KEYRING
# 10^30 alnt | 10^12 lnt
laconicd genesis add-genesis-account $KEY 1000000000000000000000000000000$DENOM --keyring-backend $KEYRING
# Sign genesis transaction
laconicd genesis gentx $KEY 1000000000000000000000photon --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
@@ -104,7 +135,7 @@ fi
laconicd start \
--pruning=nothing \
--log_level $LOGLEVEL \
--minimum-gas-prices=0.0001photon \
--minimum-gas-prices=1$DENOM \
--api.enable \
--rpc.laddr="tcp://0.0.0.0:26657" \
--gql-server --gql-playground
@@ -324,7 +324,7 @@ func (kts *KeeperTestSuite) createAuctionAndCommitBid(commitBid bool) (*types.Au
}
// Create funded account(s)
accounts := simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, accCount, math.NewInt(100))
accounts := simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, accCount, math.NewInt(1000000))
params, err := k.GetParams(ctx)
if err != nil {
@@ -49,7 +49,7 @@ func (kts *KeeperTestSuite) createBond() (*bondTypes.Bond, error) {
ctx := kts.SdkCtx
// Create a funded account
kts.accounts = simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, 1, math.NewInt(100000000000))
kts.accounts = simtestutil.AddTestAddrs(kts.BankKeeper, integrationTest.BondDenomProvider{}, ctx, 1, math.NewInt(1000000000000))
bond, err := kts.BondKeeper.CreateBond(ctx, kts.accounts[0], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(1000000000))))
if err != nil {
+7 -6
View File
@@ -13,9 +13,10 @@ import (
var (
DefaultCommitsDuration = 5 * time.Minute
DefaultRevealsDuration = 5 * time.Minute
DefaultCommitFee = sdk.Coin{Amount: sdkmath.NewInt(10), Denom: sdk.DefaultBondDenom}
DefaultRevealFee = sdk.Coin{Amount: sdkmath.NewInt(10), Denom: sdk.DefaultBondDenom}
DefaultMinimumBid = sdk.Coin{Amount: sdkmath.NewInt(1000), Denom: sdk.DefaultBondDenom}
DefaultCommitFee = sdkmath.NewInt(1000) // 10^3 alnt
DefaultRevealFee = sdkmath.NewInt(1000) // 10^3 alnt
DefaultMinimumBid = sdkmath.NewInt(1000000) // 10^6 alnt
)
func NewParams(commitsDuration time.Duration, revealsDuration time.Duration, commitFee sdk.Coin, revealFee sdk.Coin, minimumBid sdk.Coin) Params {
@@ -33,9 +34,9 @@ func DefaultParams() Params {
return Params{
CommitsDuration: DefaultCommitsDuration,
RevealsDuration: DefaultRevealsDuration,
CommitFee: DefaultCommitFee,
RevealFee: DefaultRevealFee,
MinimumBid: DefaultMinimumBid,
CommitFee: sdk.NewCoin(sdk.DefaultBondDenom, DefaultCommitFee),
RevealFee: sdk.NewCoin(sdk.DefaultBondDenom, DefaultRevealFee),
MinimumBid: sdk.NewCoin(sdk.DefaultBondDenom, DefaultMinimumBid),
}
}
+1 -1
View File
@@ -9,7 +9,7 @@ import (
)
// DefaultMaxBondAmountTokens are the default parameter values.
var DefaultMaxBondAmountTokens = sdkmath.NewInt(100000000000)
var DefaultMaxBondAmountTokens = sdkmath.NewInt(1000000000000) // 10^12 alnt
func NewParams(maxBondAmount sdk.Coin) Params {
return Params{MaxBondAmount: maxBondAmount}
+5 -5
View File
@@ -11,21 +11,21 @@ import (
// Default parameter values.
var (
// DefaultRecordRent is the default record rent for 1 time period (see expiry time).
DefaultRecordRent = sdkmath.NewInt(1000000)
DefaultRecordRent = sdkmath.NewInt(1000000) // 10^6 alnt
// DefaultRecordExpiryTime is the default record expiry time (1 year).
DefaultRecordExpiryTime = time.Hour * 24 * 365
DefaultAuthorityRent = sdkmath.NewInt(1000000)
DefaultAuthorityRent = sdkmath.NewInt(1000000) // 10^6 alnt
DefaultAuthorityExpiryTime = time.Hour * 24 * 365
DefaultAuthorityGracePeriod = time.Hour * 24 * 2
DefaultAuthorityAuctionEnabled = false
DefaultCommitsDuration = time.Hour * 24
DefaultRevealsDuration = time.Hour * 24
DefaultCommitFee = sdkmath.NewInt(1000000)
DefaultRevealFee = sdkmath.NewInt(1000000)
DefaultMinimumBid = sdkmath.NewInt(5000000)
DefaultCommitFee = sdkmath.NewInt(1000000) // 10^6 alnt
DefaultRevealFee = sdkmath.NewInt(1000000) // 10^6 alnt
DefaultMinimumBid = sdkmath.NewInt(5000000) // 5 * 10^6 alnt
)
// NewParams creates a new Params instance