Refactoring and fixes (#272)

* refactor: switch log level for PoP messages

Needs to be the other way around, otherwise we receive up to 720
messages on info level.

* refactor: align spelling in comments and log messages

* fix: config key

Commit fc9e795bd0678746993806ac21c92a675ed7006f changed the reissuance
variable. The config key was forgotten to change.

* refactor: return early to reduce indentation

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
This commit is contained in:
Julian Strobl 2024-01-11 10:39:25 +01:00 committed by GitHub
parent 7e3c0b719b
commit 001a472ef9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 34 deletions

View File

@ -26,13 +26,13 @@ func (cmad CheckReissuanceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu
if sdk.MsgTypeURL(msg) == "/planetmintgo.dao.MsgReissueRDDLProposal" {
MsgProposal, ok := msg.(*daotypes.MsgReissueRDDLProposal)
if ok {
util.GetAppLogger().Debug(ctx, anteHandlerTag+"received re-issuance proposal: "+MsgProposal.String())
util.GetAppLogger().Debug(ctx, anteHandlerTag+"received reissuance proposal: "+MsgProposal.String())
isValid := cmad.dk.IsValidReissuanceProposal(ctx, MsgProposal)
if !isValid {
util.GetAppLogger().Info(ctx, anteHandlerTag+"rejected re-issuance proposal")
util.GetAppLogger().Info(ctx, anteHandlerTag+"rejected reissuance proposal")
return ctx, errorsmod.Wrapf(daotypes.ErrReissuanceProposal, "error during CheckTx or ReCheckTx")
}
util.GetAppLogger().Debug(ctx, anteHandlerTag+"accepted re-issuance proposal: "+MsgProposal.String())
util.GetAppLogger().Debug(ctx, anteHandlerTag+"accepted reissuance proposal: "+MsgProposal.String())
}
}
}

View File

@ -13,26 +13,30 @@ func NewGasKVCostDecorator(sk StakingKeeper) GasKVCostDecorator {
}
func (gc GasKVCostDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (_ sdk.Context, err error) {
if !simulate && ctx.BlockHeight() != 0 {
msgs := tx.GetMsgs()
signers := msgs[0].GetSigners()
signer := signers[0]
valAddr := sdk.ValAddress(signer)
_, found := gc.sk.GetValidator(ctx, valAddr)
if found {
ctx = ctx.WithKVGasConfig(sdk.GasConfig{
HasCost: 0,
DeleteCost: 0,
ReadCostFlat: 0,
ReadCostPerByte: 0,
WriteCostFlat: 0,
WriteCostPerByte: 0,
IterNextCostFlat: 0,
})
}
if simulate || ctx.BlockHeight() == 0 {
return next(ctx, tx, simulate)
}
msgs := tx.GetMsgs()
signers := msgs[0].GetSigners()
signer := signers[0]
valAddr := sdk.ValAddress(signer)
_, found := gc.sk.GetValidator(ctx, valAddr)
if !found {
return next(ctx, tx, simulate)
}
ctx = ctx.WithKVGasConfig(sdk.GasConfig{
HasCost: 0,
DeleteCost: 0,
ReadCostFlat: 0,
ReadCostPerByte: 0,
WriteCostFlat: 0,
WriteCostPerByte: 0,
IterNextCostFlat: 0,
})
return next(ctx, tx, simulate)
}

View File

@ -34,7 +34,7 @@ distribution-address-inv = "{{ .PlmntConfig.DistributionAddrInv }}"
distribution-address-dao = "{{ .PlmntConfig.DistributionAddrDAO }}"
distribution-address-pop = "{{ .PlmntConfig.DistributionAddrPop }}"
distribution-offset = {{ .PlmntConfig.DistributionOffset }}
re-issuance-epochs = {{ .PlmntConfig.ReissuanceEpochs }}
reissuance-epochs = {{ .PlmntConfig.ReissuanceEpochs }}
mqtt-domain = "{{ .PlmntConfig.MqttDomain }}"
mqtt-port = {{ .PlmntConfig.MqttPort }}
mqtt-user = "{{ .PlmntConfig.MqttUser }}"
@ -106,10 +106,10 @@ func DefaultConfig() *Config {
// to wait for confirmations on the reissuance
DistributionOffset: 360,
// `ReissuanceEpochs` is a configuration parameter that determines the number of CometBFT epochs
// required for re-issuance. In the context of Planetmint, re-issuance refers to the process of
// required for reissuance. In the context of Planetmint, reissuance refers to the process of
// issuing new tokens. This configuration parameter specifies the number of epochs (each epoch is 5
// seconds) that need to pass before re-issuance can occur. In this case, `ReissuanceEpochs` is set
// to 17280, which means that re-issuance can occur after 1 day (12*60*24) of epochs.
// seconds) that need to pass before reissuance can occur. In this case, `ReissuanceEpochs` is set
// to 17280, which means that reissuance can occur after 1 day (12*60*24) of epochs.
ReissuanceEpochs: 17280,
MqttDomain: "testnet-mqtt.rddl.io",
MqttPort: 1885,

View File

@ -239,9 +239,9 @@ func (s *E2ETestSuite) TestReissuance() {
latestHeight, err = s.network.WaitForHeight(latestHeight + 1)
s.Require().NoError(err)
// wait + for sending the re-issuance result, i.e.:
// 0: block 25: initializing RDDL re-issuance broadcast tx succeeded
// 1: block 26: sending the re-issuance result broadcast tx succeeded
// wait + for sending the reissuance result, i.e.:
// 0: block 25: initializing RDDL reissuance broadcast tx succeeded
// 1: block 26: sending the reissuance result broadcast tx succeeded
// 2: block 27: confirmation
wait = 2
if latestHeight%int64(conf.ReissuanceEpochs+wait) == 0 {
@ -249,7 +249,7 @@ func (s *E2ETestSuite) TestReissuance() {
}
}
// - because we waited on the re-issuance result, see above
// - because we waited on the reissuance result, see above
intValue := strconv.FormatInt(latestHeight-int64(wait), 10)
_, err = clitestutil.ExecTestCLICmd(val.ClientCtx, daocli.CmdGetReissuance(), []string{intValue})
s.Require().NoError(err)

View File

@ -39,7 +39,7 @@ func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper)
util.SendInitReissuance(ctx, hexProposerAddress, reissuance.GetCommand(), currentBlockHeight,
reissuance.GetFirstIncludedPop(), reissuance.GetLastIncludedPop())
} else {
util.GetAppLogger().Error(ctx, "error while computing the RDDL re-issuance ", err)
util.GetAppLogger().Error(ctx, "error while computing the RDDL reissuance ", err)
}
}

View File

@ -142,17 +142,17 @@ func (k Keeper) ComputeReissuanceValue(ctx sdk.Context, startHeight int64, endHe
popReissuanceString := GetReissuanceAsStringValue(obj.GetHeight())
amount, err := util.RDDLTokenStringToUint(popReissuanceString)
if err != nil {
util.GetAppLogger().Error(ctx, "unable to compute PoP re-issuance value: "+popString)
util.GetAppLogger().Error(ctx, "unable to compute PoP reissuance value: "+popString)
continue
}
util.GetAppLogger().Info(ctx, "PoP is part of the reissuance: "+popString)
util.GetAppLogger().Debug(ctx, "PoP is part of the reissuance: "+popString)
if firstIncludedPop == 0 {
firstIncludedPop = obj.GetHeight()
}
lastIncludedPop = obj.GetHeight()
overallAmount += amount
} else {
util.GetAppLogger().Debug(ctx, "PoP is not part of the reissuance: "+popString)
util.GetAppLogger().Info(ctx, "PoP is not part of the reissuance: "+popString)
if obj.GetHeight()+2*popEpochs > endHeight {
break
}