mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-11-24 14:35:47 +00:00
Initializing rootDir of dao and machine keeper with the homePath of the validators key material
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
parent
65134b4a0b
commit
27a94d485f
@ -549,6 +549,7 @@ func New(
|
||||
keys[machinemoduletypes.MemStoreKey],
|
||||
app.GetSubspace(machinemoduletypes.ModuleName),
|
||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
homePath,
|
||||
)
|
||||
machineModule := machinemodule.NewAppModule(appCodec, app.MachineKeeper, app.AccountKeeper, app.BankKeeper)
|
||||
|
||||
@ -576,6 +577,7 @@ func New(
|
||||
app.AccountKeeper,
|
||||
app.MachineKeeper,
|
||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
homePath,
|
||||
)
|
||||
daoModule := daomodule.NewAppModule(appCodec, app.DaoKeeper, app.AccountKeeper, app.BankKeeper)
|
||||
|
||||
|
||||
@ -72,6 +72,7 @@ func DaoKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
|
||||
nil,
|
||||
nil,
|
||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
"",
|
||||
)
|
||||
|
||||
// Initialize params
|
||||
|
||||
@ -61,6 +61,7 @@ func MachineKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
|
||||
memStoreKey,
|
||||
paramsSubspace,
|
||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
"",
|
||||
)
|
||||
|
||||
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
|
||||
cometcfg "github.com/cometbft/cometbft/config"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/planetmint/planetmint-go/config"
|
||||
)
|
||||
|
||||
type Key struct {
|
||||
@ -24,11 +23,9 @@ type KeyFile struct {
|
||||
PrivKey Key `json:"priv-key"`
|
||||
}
|
||||
|
||||
func GetValidatorCometBFTIdentity(ctx sdk.Context) (string, bool) {
|
||||
conf := config.GetConfig()
|
||||
|
||||
func GetValidatorCometBFTIdentity(ctx sdk.Context, rootDir string) (string, bool) {
|
||||
cfg := cometcfg.DefaultConfig()
|
||||
jsonFilePath := filepath.Join(conf.ConfigRootDir, cfg.PrivValidatorKey)
|
||||
jsonFilePath := filepath.Join(rootDir, cfg.PrivValidatorKey)
|
||||
|
||||
jsonFile, err := os.Open(jsonFilePath)
|
||||
if err != nil {
|
||||
@ -50,8 +47,8 @@ func GetValidatorCometBFTIdentity(ctx sdk.Context) (string, bool) {
|
||||
return strings.ToLower(keyFile.Address), true
|
||||
}
|
||||
|
||||
func IsValidatorBlockProposer(ctx sdk.Context, proposerAddress []byte) bool {
|
||||
validatorIdentity, validResult := GetValidatorCometBFTIdentity(ctx)
|
||||
func IsValidatorBlockProposer(ctx sdk.Context, proposerAddress []byte, rootDir string) bool {
|
||||
validatorIdentity, validResult := GetValidatorCometBFTIdentity(ctx, rootDir)
|
||||
if !validResult {
|
||||
return false
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper)
|
||||
|
||||
// Check if node is block proposer
|
||||
// take the following actions only once, that's why we filter for the Block Proposer
|
||||
if !util.IsValidatorBlockProposer(ctx, proposerAddress) {
|
||||
if !util.IsValidatorBlockProposer(ctx, proposerAddress, k.RootDir) {
|
||||
return
|
||||
}
|
||||
currentBlockHeight := req.Header.GetHeight()
|
||||
|
||||
@ -29,6 +29,7 @@ type (
|
||||
accountKeeper types.AccountKeeper
|
||||
machineKeeper types.MachineKeeper
|
||||
authority string
|
||||
RootDir string
|
||||
}
|
||||
)
|
||||
|
||||
@ -46,6 +47,7 @@ func NewKeeper(
|
||||
accountKeeper types.AccountKeeper,
|
||||
machineKeeper types.MachineKeeper,
|
||||
authority string,
|
||||
rootDir string,
|
||||
) *Keeper {
|
||||
// set KeyTable if it has not already been set
|
||||
if !ps.HasKeyTable() {
|
||||
@ -66,6 +68,7 @@ func NewKeeper(
|
||||
accountKeeper: accountKeeper,
|
||||
machineKeeper: machineKeeper,
|
||||
authority: authority,
|
||||
RootDir: rootDir,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ func (k msgServer) DistributionRequest(goCtx context.Context, msg *types.MsgDist
|
||||
util.GetAppLogger().Info(ctx, distributionRequestTag+"storing distribution: "+msg.GetDistribution().String())
|
||||
k.StoreDistributionOrder(ctx, *msg.GetDistribution())
|
||||
|
||||
validatorIdentity, validResult := util.GetValidatorCometBFTIdentity(ctx)
|
||||
validatorIdentity, validResult := util.GetValidatorCometBFTIdentity(ctx, k.RootDir)
|
||||
if !validResult || msg.Distribution.GetProposer() != validatorIdentity {
|
||||
util.GetAppLogger().Info(ctx, distributionRequestTag+"Not the proposer. valid result: %t proposer: %s validator identity: %s", validResult, msg.Distribution.GetProposer(), validatorIdentity)
|
||||
return &types.MsgDistributionRequestResponse{}, nil
|
||||
|
||||
@ -19,7 +19,7 @@ func (k msgServer) InitPop(goCtx context.Context, msg *types.MsgInitPop) (*types
|
||||
|
||||
k.StoreChallenge(ctx, challenge)
|
||||
|
||||
validatorIdentity, validResult := util.GetValidatorCometBFTIdentity(ctx)
|
||||
validatorIdentity, validResult := util.GetValidatorCometBFTIdentity(ctx, k.RootDir)
|
||||
if validResult && msg.Initiator == validatorIdentity {
|
||||
go util.SendMqttPopInitMessagesToServer(ctx, challenge)
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ func (k msgServer) CreateRedeemClaim(goCtx context.Context, msg *types.MsgCreate
|
||||
redeemClaim,
|
||||
)
|
||||
|
||||
if util.IsValidatorBlockProposer(ctx, ctx.BlockHeader().ProposerAddress) {
|
||||
if util.IsValidatorBlockProposer(ctx, ctx.BlockHeader().ProposerAddress, k.RootDir) {
|
||||
util.GetAppLogger().Info(ctx, fmt.Sprintf("Issuing RDDL claim: %s/%d", msg.Beneficiary, id))
|
||||
txID, err := util.DistributeAsset(msg.Beneficiary, util.UintValueToRDDLTokenString(msg.Amount), params.ReissuanceAsset)
|
||||
if err != nil {
|
||||
|
||||
@ -23,7 +23,7 @@ func (k msgServer) ReissueRDDLProposal(goCtx context.Context, msg *types.MsgReis
|
||||
reissuance.LastIncludedPop = msg.GetLastIncludedPop()
|
||||
k.StoreReissuance(ctx, reissuance)
|
||||
|
||||
validatorIdentity, validResult := util.GetValidatorCometBFTIdentity(ctx)
|
||||
validatorIdentity, validResult := util.GetValidatorCometBFTIdentity(ctx, k.RootDir)
|
||||
if !validResult || msg.Proposer != validatorIdentity {
|
||||
util.GetAppLogger().Info(ctx, reissueTag+"Not the proposer. valid result: %t proposer: %s validator identity: %s", validResult, msg.Proposer, validatorIdentity)
|
||||
return &types.MsgReissueRDDLProposalResponse{}, nil
|
||||
|
||||
@ -22,6 +22,7 @@ type (
|
||||
memKey storetypes.StoreKey
|
||||
paramstore paramtypes.Subspace
|
||||
authority string
|
||||
rootDir string
|
||||
}
|
||||
)
|
||||
|
||||
@ -36,6 +37,7 @@ func NewKeeper(
|
||||
memKey storetypes.StoreKey,
|
||||
ps paramtypes.Subspace,
|
||||
authority string,
|
||||
rootDir string,
|
||||
) *Keeper {
|
||||
// set KeyTable if it has not already been set
|
||||
if !ps.HasKeyTable() {
|
||||
@ -53,6 +55,7 @@ func NewKeeper(
|
||||
memKey: memKey,
|
||||
paramstore: ps,
|
||||
authority: authority,
|
||||
rootDir: rootDir,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ func (k msgServer) AttestMachine(goCtx context.Context, msg *types.MsgAttestMach
|
||||
return nil, types.ErrMachineTypeUndefined
|
||||
}
|
||||
|
||||
if util.IsValidatorBlockProposer(ctx, ctx.BlockHeader().ProposerAddress) {
|
||||
if util.IsValidatorBlockProposer(ctx, ctx.BlockHeader().ProposerAddress, k.rootDir) {
|
||||
util.GetAppLogger().Info(ctx, "Issuing Machine NFT: "+msg.Machine.String())
|
||||
err := k.issueMachineNFT(goCtx, msg.Machine)
|
||||
if err != nil {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user