From 737a0f6b3374f63dd2845b5f820c0776c6b2dbaa Mon Sep 17 00:00:00 2001 From: keithsue Date: Sun, 11 Aug 2024 23:39:22 +0800 Subject: [PATCH] fix end blocker --- x/btcbridge/abci.go | 5 +++++ x/btcbridge/module.go | 4 +++- x/btcbridge/types/tss.go | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/x/btcbridge/abci.go b/x/btcbridge/abci.go index 6cedfdb8..ab8e5735 100644 --- a/x/btcbridge/abci.go +++ b/x/btcbridge/abci.go @@ -15,6 +15,8 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) { // check if the DKG request expired if !ctx.BlockTime().Before(*req.Expiration) { req.Status = types.DKGRequestStatus_DKG_REQUEST_STATUS_TIMEDOUT + k.SetDKGRequest(ctx, req) + continue } @@ -27,6 +29,8 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) { // check if the DKG completion requests are valid if !types.CheckDKGCompletionRequests(completionRequests) { req.Status = types.DKGRequestStatus_DKG_REQUEST_STATUS_FAILED + k.SetDKGRequest(ctx, req) + continue } @@ -35,5 +39,6 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) { // update status req.Status = types.DKGRequestStatus_DKG_REQUEST_STATUS_COMPLETED + k.SetDKGRequest(ctx, req) } } diff --git a/x/btcbridge/module.go b/x/btcbridge/module.go index ad4eae25..8fa1e897 100644 --- a/x/btcbridge/module.go +++ b/x/btcbridge/module.go @@ -141,6 +141,8 @@ func (AppModule) ConsensusVersion() uint64 { return 1 } func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} // EndBlock contains the logic that is automatically triggered at the end of each block -func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + EndBlocker(ctx, am.keeper) + return []abci.ValidatorUpdate{} } diff --git a/x/btcbridge/types/tss.go b/x/btcbridge/types/tss.go index c0bc344c..5df2d22c 100644 --- a/x/btcbridge/types/tss.go +++ b/x/btcbridge/types/tss.go @@ -2,6 +2,7 @@ package types import ( "crypto/ed25519" + "encoding/binary" "encoding/hex" "reflect" @@ -50,7 +51,8 @@ func VerifySignature(signature string, pubKey []byte, req *DKGCompletionRequest) // GetSigMsgFromDKGCompletionReq gets the msg to be signed from the given DKG completion request func GetSigMsgFromDKGCompletionReq(req *DKGCompletionRequest) []byte { - rawMsg := Int64ToBytes(req.Id) + rawMsg := make([]byte, 8) + binary.BigEndian.PutUint64(rawMsg, req.Id) for _, v := range req.Vaults { rawMsg = append(rawMsg, []byte(v)...)