added SendRDDLReissuanceResult sending by the proposer after the consensus over the ReissuanceProposal

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel 2023-10-05 17:49:59 +02:00
parent 8f76199214
commit f69c978911
No known key found for this signature in database
3 changed files with 46 additions and 21 deletions

40
util/issue_commands.go Normal file
View File

@ -0,0 +1,40 @@
package util
import (
"fmt"
"os/exec"
"strconv"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func InitRDDLReissuanceProcess(ctx sdk.Context, proposerAddress string, blk_height int64) error {
tx_unsigned, err := GetUnsignedReissuanceTransaction()
//blk_height := 0 //get_last_PoPBlockHeight() // TODO: to be read form the upcoming PoP-store
// Construct the command
cmd := exec.Command("planetmint-god", "tx", "dao", "reissue-rddl-proposal", hexProposerAddress, tx_unsigned, strconv.FormatInt(blk_height, 10))
// Start the command in a non-blocking way
err = cmd.Start()
if err != nil {
fmt.Printf("Error starting command: %s\n", err)
} else {
fmt.Println("Command started in background")
}
return err
}
func SendRDDLReissuanceResult(ctx sdk.Context, proposerAddress string, txID string, blk_height uint64) error {
// Construct the command
cmd := exec.Command("planetmint-god", "tx", "dao", "reissue-rddl-result", hexProposerAddress, txID, strconv.FormatInt(blk_height, 10))
// Start the command in a non-blocking way
err := cmd.Start()
if err != nil {
fmt.Printf("Error starting command: %s\n", err)
} else {
fmt.Println("Command started in background")
}
return err
}

View File

@ -3,8 +3,6 @@ package dao
import (
"encoding/hex"
"fmt"
"os/exec"
"strconv"
"github.com/planetmint/planetmint-go/config"
"github.com/planetmint/planetmint-go/util"
@ -19,34 +17,18 @@ func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper)
proposerAddress := req.Header.GetProposerAddress()
// Check if node is block proposer
if isPoPHeight(req.Header.GetHeight()) && util.IsValidatorBlockProposer(ctx, proposerAddress) {
// TODO: implement PoP trigger
fmt.Println("TODO: implement PoP trigger")
err := initRDDLReissuanceProcess(ctx, proposerAddress, req.Header.GetHeight())
hexProposerAddress := hex.EncodeToString(proposerAddress)
err := util.InitRDDLReissuanceProcess(ctx, hexProposerAddress, req.Header.GetHeight())
if err != nil {
logger.Error("error while issuing RDDL", err)
}
}
}
func initRDDLReissuanceProcess(ctx sdk.Context, proposerAddress []byte, blk_height int64) error {
tx_unsigned, err := util.GetUnsignedReissuanceTransaction()
//blk_height := 0 //get_last_PoPBlockHeight() // TODO: to be read form the upcoming PoP-store
hexProposerAddress := hex.EncodeToString(proposerAddress)
// Construct the command
cmd := exec.Command("planetmint-god", "tx", "dao", "reissue-rddl-proposal", hexProposerAddress, tx_unsigned, strconv.FormatInt(blk_height, 10))
// Start the command in a non-blocking way
err = cmd.Start()
if err != nil {
fmt.Printf("Error starting command: %s\n", err)
} else {
fmt.Println("Command started in background")
}
return err
}
func isPoPHeight(height int64) bool {
cfg := config.GetConfig()
return height%int64(cfg.PoPEpochs) == 0

View File

@ -15,7 +15,10 @@ func (k msgServer) ReissueRDDLProposal(goCtx context.Context, msg *types.MsgReis
if valid_result && msg.Proposer == validator_identity {
// 1. sign tx
// 2. broadcast tx
txID := "asdlkufzaoisdfpoajf"
// 3. notarize result by notarizing the liquid tx-id
util.SendRDDLReissuanceResult(ctx, msg.GetProposer(), txID, msg.GetBlockheight())
}
var reissuance types.Reissuance