Skip to content

Commit

Permalink
feat: imp noJesterBlocks + bump wormhole
Browse files Browse the repository at this point in the history
  • Loading branch information
boojamya committed Jan 12, 2025
1 parent 1f00eba commit 2eaada9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
28 changes: 26 additions & 2 deletions abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,36 @@ type InjectedDollarVE struct {

// client queryv1connect.QueryServiceClient
func NewExtendVoteHandler(client jester.QueryServiceClient) sdk.ExtendVoteHandler {
// TODO: consider better handling of "noJesterBlocks" logic
// maximum amount of blocks a validator is allowed to submit without a jester response
const maxNoJesterBlocks = uint16(500)
noJesterBlocks := new(uint16)

// Returns custom functionality for the block proposer to execute.
return func(ctx sdk.Context, req *abcitypes.RequestExtendVote) (*abcitypes.ResponseExtendVote, error) {
log := ctx.Logger()

request := connect.NewRequest(&jester.GetVoteExtensionRequest{})
res, err := client.GetVoteExtension(context.Background(), request)
if err != nil {
log.Error("failed to get vote extention from jester", "err", err)
*noJesterBlocks++

log.Error(`failed to get vote extention from Jester. Your node will panic if "MAX-noJesterBlocks" is reached!!!`,
"current-noJesterBlocks", *noJesterBlocks, "MAX-noJesterBlocks", maxNoJesterBlocks,
"err", err,
)

if *noJesterBlocks >= maxNoJesterBlocks {
panic("too many consecutive blocks porposed without jester response")
}

return &abcitypes.ResponseExtendVote{
VoteExtension: nil,
}, nil
}

*noJesterBlocks = 0

bz, err := json.Marshal(res.Msg)
if err != nil {
log.Error("failed to marshal vote extention", "err", err)
Expand Down Expand Up @@ -69,7 +89,7 @@ func NewPrepareProposalHandler() sdk.PrepareProposalHandler {
return &abcitypes.ResponsePrepareProposal{Txs: req.Txs}, nil
}

rawVoteExtension := []byte{}
var rawVoteExtension []byte
highestPowerVal := int64(math.MinInt64)

for _, vote := range req.LocalLastCommit.Votes {
Expand All @@ -79,6 +99,10 @@ func NewPrepareProposalHandler() sdk.PrepareProposalHandler {
}
}

if rawVoteExtension == nil {
return &abcitypes.ResponsePrepareProposal{Txs: req.Txs}, nil
}

var voteExtension jester.GetVoteExtensionResponse
err := json.Unmarshal(rawVoteExtension, &voteExtension)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/noble-assets/forwarding/v2 v2.0.0
github.com/noble-assets/globalfee v1.0.0
github.com/noble-assets/halo/v2 v2.0.1
github.com/noble-assets/wormhole v0.0.0-20241219114800-b834d8c93ab2
github.com/noble-assets/wormhole v1.0.0-alpha.0
github.com/ondoprotocol/usdy-noble/v2 v2.0.0
github.com/spf13/cast v1.7.0
github.com/spf13/cobra v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1090,8 +1090,8 @@ github.com/noble-assets/globalfee v1.0.0 h1:NUNDXd5tdzB5A/O8Em/1g+GU92E4lojH3+3l
github.com/noble-assets/globalfee v1.0.0/go.mod h1:DmNoTJ2LqGP4KpJuz+IEKp/5uf/3hRu3GSNBGhNUZkA=
github.com/noble-assets/halo/v2 v2.0.1 h1:nHAhTnq5dPJGelcLnKzMviXtk9x0DfMnRPv+CPoEvyA=
github.com/noble-assets/halo/v2 v2.0.1/go.mod h1:DY4GCfZ/7S3IEjoJBCCh7HRTxirPBOLMVwkT0N6n3bA=
github.com/noble-assets/wormhole v0.0.0-20241219114800-b834d8c93ab2 h1:eDy2v+ipxsD5bX35oZLmaxj+eyOHH76nZHEr/qGvWQg=
github.com/noble-assets/wormhole v0.0.0-20241219114800-b834d8c93ab2/go.mod h1:OUivFiRSS9o7k4q/5rBBZEwh0hR8kzoDVD7LulOkHx0=
github.com/noble-assets/wormhole v1.0.0-alpha.0 h1:SEZvL0yT/tOFbBxzMVebl/Zaqc9VbuLnd0ER8wNyX40=
github.com/noble-assets/wormhole v1.0.0-alpha.0/go.mod h1:OUivFiRSS9o7k4q/5rBBZEwh0hR8kzoDVD7LulOkHx0=
github.com/nunnatsa/ginkgolinter v0.18.3 h1:WgS7X3zzmni3vwHSBhvSgqrRgUecN6PQUcfB0j1noDw=
github.com/nunnatsa/ginkgolinter v0.18.3/go.mod h1:BE1xyB/PNtXXG1azrvrqJW5eFH0hSRylNzFy8QHPwzs=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down

0 comments on commit 2eaada9

Please sign in to comment.