fix: distribution relative to the reissuance epoch (#270)

- reissuance   = 1 day
- distribution = 1 day + 30 min

expectation:
- reissuance:   1 day, 2 day, 3 day, ...
- distribution: 1 day + 30 min, 2 day + 30 min, 3 day + 30 min, ...

without patch:
- reissuance:   1 day, 2 day, 3 day, ...
- distribution: 1 day + 30 min, 2 day + 60 min, 3 day + 90 min, ...

Closes #260

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
This commit is contained in:
Julian Strobl 2024-01-11 10:27:57 +01:00 committed by GitHub
parent 4042968dff
commit 7e3c0b719b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

@ -33,7 +33,7 @@ validator-address = "{{ .PlmntConfig.ValidatorAddress }}"
distribution-address-inv = "{{ .PlmntConfig.DistributionAddrInv }}"
distribution-address-dao = "{{ .PlmntConfig.DistributionAddrDAO }}"
distribution-address-pop = "{{ .PlmntConfig.DistributionAddrPop }}"
distribution-epochs = {{ .PlmntConfig.DistributionEpochs }}
distribution-offset = {{ .PlmntConfig.DistributionOffset }}
re-issuance-epochs = {{ .PlmntConfig.ReissuanceEpochs }}
mqtt-domain = "{{ .PlmntConfig.MqttDomain }}"
mqtt-port = {{ .PlmntConfig.MqttPort }}
@ -64,7 +64,7 @@ type Config struct {
DistributionAddrInv string `json:"distribution-addr-inv" mapstructure:"distribution-addr-inv"`
DistributionAddrDAO string `json:"distribution-addr-dao" mapstructure:"distribution-addr-dao"`
DistributionAddrPop string `json:"distribution-addr-pop" mapstructure:"distribution-addr-pop"`
DistributionEpochs int `json:"distribution-epochs" mapstructure:"distribution-epochs"`
DistributionOffset int `json:"distribution-offset" mapstructure:"distribution-offset"`
ReissuanceEpochs int `json:"reissuance-epochs" mapstructure:"reissuance-epochs"`
MqttDomain string `json:"mqtt-domain" mapstructure:"mqtt-domain"`
MqttPort int `json:"mqtt-port" mapstructure:"mqtt-port"`
@ -102,7 +102,9 @@ func DefaultConfig() *Config {
DistributionAddrInv: "vjTyRN2G42Yq3T5TJBecHj1dF1xdhKF89hKV4HJN3uXxUbaVGVR76hAfVRQqQCovWaEpar7G5qBBprFG",
DistributionAddrDAO: "vjU8eMzU3JbUWZEpVANt2ePJuPWSPixgjiSj2jDMvkVVQQi2DDnZuBRVX4Ygt5YGBf5zvTWCr1ntdqYH",
DistributionAddrPop: "vjTvXCFSReRsZ7grdsAreRR12KuKpDw8idueQJK9Yh1BYS7ggAqgvCxCgwh13KGK6M52y37HUmvr4GdD",
DistributionEpochs: 17640, // CometBFT epochs of 5s equate 1 day (12*60*24) + 30 min (12*30) to wait for confirmations on the re-issuance
// `DistributionOffset` relative to `ReissuanceEpochs`. CometBFT epochs of 5s equate 30 min (12*30)
// 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
// issuing new tokens. This configuration parameter specifies the number of epochs (each epoch is 5

View File

@ -52,6 +52,7 @@ func (s *E2ETestSuite) SetupSuite() {
conf := config.GetConfig()
conf.FeeDenom = "node0token"
// set epochs: make sure to start after initial height of 7
conf.DistributionOffset = 5
conf.ReissuanceEpochs = 25
conf.SetPlanetmintConfig(conf)

View File

@ -60,12 +60,18 @@ func isPopHeight(height int64) bool {
func isReissuanceHeight(height int64) bool {
conf := config.GetConfig()
// e.g. 483840 % 17280 = 0
return height%int64(conf.ReissuanceEpochs) == 0
}
func isDistributionHeight(height int64) bool {
conf := config.GetConfig()
return height%int64(conf.DistributionEpochs) == 0
// e.g. 360 % 17280 = 360
if height <= int64(conf.ReissuanceEpochs) {
return false
}
// e.g. 484200 % 17280 = 360
return height%int64(conf.ReissuanceEpochs) == int64(conf.DistributionOffset)
}
func EndBlocker(ctx sdk.Context, _ abci.RequestEndBlock, k keeper.Keeper) {