mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-10-14 00:59:21 +00:00
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:
parent
7e3c0b719b
commit
001a472ef9
@ -26,13 +26,13 @@ func (cmad CheckReissuanceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu
|
|||||||
if sdk.MsgTypeURL(msg) == "/planetmintgo.dao.MsgReissueRDDLProposal" {
|
if sdk.MsgTypeURL(msg) == "/planetmintgo.dao.MsgReissueRDDLProposal" {
|
||||||
MsgProposal, ok := msg.(*daotypes.MsgReissueRDDLProposal)
|
MsgProposal, ok := msg.(*daotypes.MsgReissueRDDLProposal)
|
||||||
if ok {
|
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)
|
isValid := cmad.dk.IsValidReissuanceProposal(ctx, MsgProposal)
|
||||||
if !isValid {
|
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")
|
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())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
func (gc GasKVCostDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (_ sdk.Context, err error) {
|
||||||
if !simulate && ctx.BlockHeight() != 0 {
|
if simulate || ctx.BlockHeight() == 0 {
|
||||||
msgs := tx.GetMsgs()
|
return next(ctx, tx, simulate)
|
||||||
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,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
return next(ctx, tx, simulate)
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ distribution-address-inv = "{{ .PlmntConfig.DistributionAddrInv }}"
|
|||||||
distribution-address-dao = "{{ .PlmntConfig.DistributionAddrDAO }}"
|
distribution-address-dao = "{{ .PlmntConfig.DistributionAddrDAO }}"
|
||||||
distribution-address-pop = "{{ .PlmntConfig.DistributionAddrPop }}"
|
distribution-address-pop = "{{ .PlmntConfig.DistributionAddrPop }}"
|
||||||
distribution-offset = {{ .PlmntConfig.DistributionOffset }}
|
distribution-offset = {{ .PlmntConfig.DistributionOffset }}
|
||||||
re-issuance-epochs = {{ .PlmntConfig.ReissuanceEpochs }}
|
reissuance-epochs = {{ .PlmntConfig.ReissuanceEpochs }}
|
||||||
mqtt-domain = "{{ .PlmntConfig.MqttDomain }}"
|
mqtt-domain = "{{ .PlmntConfig.MqttDomain }}"
|
||||||
mqtt-port = {{ .PlmntConfig.MqttPort }}
|
mqtt-port = {{ .PlmntConfig.MqttPort }}
|
||||||
mqtt-user = "{{ .PlmntConfig.MqttUser }}"
|
mqtt-user = "{{ .PlmntConfig.MqttUser }}"
|
||||||
@ -106,10 +106,10 @@ func DefaultConfig() *Config {
|
|||||||
// to wait for confirmations on the reissuance
|
// to wait for confirmations on the reissuance
|
||||||
DistributionOffset: 360,
|
DistributionOffset: 360,
|
||||||
// `ReissuanceEpochs` is a configuration parameter that determines the number of CometBFT epochs
|
// `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
|
// 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
|
// seconds) that need to pass before reissuance 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.
|
// to 17280, which means that reissuance can occur after 1 day (12*60*24) of epochs.
|
||||||
ReissuanceEpochs: 17280,
|
ReissuanceEpochs: 17280,
|
||||||
MqttDomain: "testnet-mqtt.rddl.io",
|
MqttDomain: "testnet-mqtt.rddl.io",
|
||||||
MqttPort: 1885,
|
MqttPort: 1885,
|
||||||
|
@ -239,9 +239,9 @@ func (s *E2ETestSuite) TestReissuance() {
|
|||||||
latestHeight, err = s.network.WaitForHeight(latestHeight + 1)
|
latestHeight, err = s.network.WaitForHeight(latestHeight + 1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// wait + for sending the re-issuance result, i.e.:
|
// wait + for sending the reissuance result, i.e.:
|
||||||
// 0: block 25: initializing RDDL re-issuance broadcast tx succeeded
|
// 0: block 25: initializing RDDL reissuance broadcast tx succeeded
|
||||||
// 1: block 26: sending the re-issuance result broadcast tx succeeded
|
// 1: block 26: sending the reissuance result broadcast tx succeeded
|
||||||
// 2: block 27: confirmation
|
// 2: block 27: confirmation
|
||||||
wait = 2
|
wait = 2
|
||||||
if latestHeight%int64(conf.ReissuanceEpochs+wait) == 0 {
|
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)
|
intValue := strconv.FormatInt(latestHeight-int64(wait), 10)
|
||||||
_, err = clitestutil.ExecTestCLICmd(val.ClientCtx, daocli.CmdGetReissuance(), []string{intValue})
|
_, err = clitestutil.ExecTestCLICmd(val.ClientCtx, daocli.CmdGetReissuance(), []string{intValue})
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -39,7 +39,7 @@ func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper)
|
|||||||
util.SendInitReissuance(ctx, hexProposerAddress, reissuance.GetCommand(), currentBlockHeight,
|
util.SendInitReissuance(ctx, hexProposerAddress, reissuance.GetCommand(), currentBlockHeight,
|
||||||
reissuance.GetFirstIncludedPop(), reissuance.GetLastIncludedPop())
|
reissuance.GetFirstIncludedPop(), reissuance.GetLastIncludedPop())
|
||||||
} else {
|
} else {
|
||||||
util.GetAppLogger().Error(ctx, "error while computing the RDDL re-issuance ", err)
|
util.GetAppLogger().Error(ctx, "error while computing the RDDL reissuance ", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,17 +142,17 @@ func (k Keeper) ComputeReissuanceValue(ctx sdk.Context, startHeight int64, endHe
|
|||||||
popReissuanceString := GetReissuanceAsStringValue(obj.GetHeight())
|
popReissuanceString := GetReissuanceAsStringValue(obj.GetHeight())
|
||||||
amount, err := util.RDDLTokenStringToUint(popReissuanceString)
|
amount, err := util.RDDLTokenStringToUint(popReissuanceString)
|
||||||
if err != nil {
|
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
|
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 {
|
if firstIncludedPop == 0 {
|
||||||
firstIncludedPop = obj.GetHeight()
|
firstIncludedPop = obj.GetHeight()
|
||||||
}
|
}
|
||||||
lastIncludedPop = obj.GetHeight()
|
lastIncludedPop = obj.GetHeight()
|
||||||
overallAmount += amount
|
overallAmount += amount
|
||||||
} else {
|
} 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 {
|
if obj.GetHeight()+2*popEpochs > endHeight {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user