Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions abci/extend_vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ import (
voteexthandler "github.com/node101-io/pulsar-chain/x/voteexthandler/types"
)

var hardcoded = [32]byte{
0x7a, 0x13, 0x9f, 0x42, 0xd1, 0x8c, 0x5e, 0xa7,
0x2b, 0x6d, 0xf0, 0x91, 0x3c, 0x47, 0xb8, 0x0e,
0x55, 0x1a, 0xcd, 0x72, 0x98, 0x04, 0xe6, 0xaf,
0x39, 0xb2, 0x7c, 0x5d, 0x11, 0x8e, 0xf3, 0x64,
}

// ValidatorInfo represents a validator in the set
type ValidatorInfo struct {
MinaAddress string
Expand Down
4 changes: 2 additions & 2 deletions abci/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ func (h *VoteExtHandler) buildExpectedVoteExtBody(height int64) (voteexthandler.
}

return voteexthandler.Body{
InitialValidatorSetRoot: hardcoded[:],
InitialValidatorSetRoot: voteextkeeper.HardcodedValidatorSetRoot[:],
InitialBlockHeight: height - 2,
InitialStateRoot: initialStateRoot,
NewValidatorSetRoot: hardcoded[:],
NewValidatorSetRoot: voteextkeeper.HardcodedValidatorSetRoot[:],
NewBlockHeight: height - 1,
NewStateRoot: newStateRoot,
}, nil
Expand Down
6 changes: 2 additions & 4 deletions abci/pre_blocker.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package vote_ext

import (
"encoding/hex"
"encoding/json"
"fmt"

Expand Down Expand Up @@ -37,15 +36,14 @@ func (h *VoteExtHandler) PreBlocker() sdk.PreBlocker {
if err := json.Unmarshal(ext, &ve); err != nil {
continue
}

sigHex := hex.EncodeToString(ve.Signature)
idx := fmt.Sprintf("%d/%s", targetHeight, minaAddress)

record := types.VoteExt{
Index: idx,
Height: targetHeight,
ValidatorAddr: ve.MinaAddress,
Signature: sigHex,
Signature: ve.Signature,
Body: &ve.VoteExtBody,
}

err := h.voteextKeeper.SetVoteExt(ctx, record)
Expand Down
2 changes: 1 addition & 1 deletion docs/static/openapi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ require (
github.com/spf13/pflag v1.0.10
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.11.1
go.uber.org/mock v0.6.0
google.golang.org/genproto/googleapis/api v0.0.0-20260217215200-42d3e9bedb6d
google.golang.org/grpc v1.79.1
google.golang.org/protobuf v1.36.11
Expand Down Expand Up @@ -404,7 +405,6 @@ require (
go.opentelemetry.io/otel/sdk/metric v1.40.0 // indirect
go.opentelemetry.io/otel/trace v1.40.0 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.uber.org/mock v0.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.1 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
Expand Down
1 change: 1 addition & 0 deletions proto/pulsarchain/voteexthandler/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ message QueryGetAllVoteExtsRequest {}
// QueryGetAllVoteExtsResponse defines the QueryGetAllVoteExtsResponse message.
message QueryGetAllVoteExtsResponse {
repeated VoteExt vote_exts = 1;
bytes validator_set_root = 2;
}
4 changes: 3 additions & 1 deletion proto/pulsarchain/voteexthandler/v1/vote_ext.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package pulsarchain.voteexthandler.v1;
import "amino/amino.proto";
import "gogoproto/gogo.proto";
import "pulsarchain/voteexthandler/v1/params.proto";
import "pulsarchain/voteexthandler/v1/vote_ext_body.proto";

option go_package = "github.com/node101-io/pulsar-chain/x/voteexthandler/types";

Expand All @@ -12,5 +13,6 @@ message VoteExt {
string index = 1;
uint64 height = 2;
string validator_addr = 3;
string signature = 4;
bytes signature = 4;
Body body = 5;
}
2 changes: 1 addition & 1 deletion x/voteexthandler/keeper/query_get_all_vote_exts.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ func (q queryServer) GetAllVoteExts(ctx context.Context, req *types.QueryGetAllV
return nil, err
}

return &types.QueryGetAllVoteExtsResponse{VoteExts: allVoteExts}, nil
return &types.QueryGetAllVoteExtsResponse{VoteExts: allVoteExts, ValidatorSetRoot: HardcodedValidatorSetRoot[:]}, nil
}
8 changes: 4 additions & 4 deletions x/voteexthandler/keeper/query_get_all_vote_exts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestGetAllVoteExts_SingleVote(t *testing.T) {
ctx := f.ctx
q := keeper.NewQueryServerImpl(f.keeper)

v := types.VoteExt{Index: "v1", Height: 100, ValidatorAddr: "val1", Signature: "sig1"}
v := types.VoteExt{Index: "v1", Height: 100, ValidatorAddr: "val1", Signature: []byte("sig1")}
err := f.keeper.SetVoteExt(ctx, v)
require.NoError(t, err)

Expand All @@ -43,9 +43,9 @@ func TestGetAllVoteExts_MultipleVotes(t *testing.T) {
q := keeper.NewQueryServerImpl(f.keeper)

votes := []types.VoteExt{
{Index: "v1", Height: 100, ValidatorAddr: "val1", Signature: "sig1"},
{Index: "v2", Height: 101, ValidatorAddr: "val2", Signature: "sig2"},
{Index: "v3", Height: 102, ValidatorAddr: "val3", Signature: "sig3"},
{Index: "v1", Height: 100, ValidatorAddr: "val1", Signature: []byte("sig1")},
{Index: "v2", Height: 101, ValidatorAddr: "val2", Signature: []byte("sig2")},
{Index: "v3", Height: 102, ValidatorAddr: "val3", Signature: []byte("sig3")},
}
for _, v := range votes {
err := f.keeper.SetVoteExt(ctx, v)
Expand Down
4 changes: 2 additions & 2 deletions x/voteexthandler/keeper/query_voteexts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func TestVoteextsByHeight_ValidHeight(t *testing.T) {
q := keeper.NewQueryServerImpl(f.keeper)

// Setup votes
v1 := types.VoteExt{Index: "v1", Height: 100, ValidatorAddr: "val1", Signature: "sig1"}
v2 := types.VoteExt{Index: "v2", Height: 100, ValidatorAddr: "val2", Signature: "sig2"}
v1 := types.VoteExt{Index: "v1", Height: 100, ValidatorAddr: "val1", Signature: []byte("sig1")}
v2 := types.VoteExt{Index: "v2", Height: 100, ValidatorAddr: "val2", Signature: []byte("sig2")}
_ = f.keeper.SetVoteExt(ctx, v1)
_ = f.keeper.SetVoteExt(ctx, v2)

Expand Down
7 changes: 7 additions & 0 deletions x/voteexthandler/keeper/vote_ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import (
"github.com/node101-io/pulsar-chain/x/voteexthandler/types"
)

var HardcodedValidatorSetRoot = [32]byte{
0x7a, 0x13, 0x9f, 0x42, 0xd1, 0x8c, 0x5e, 0xa7,
0x2b, 0x6d, 0xf0, 0x91, 0x3c, 0x47, 0xb8, 0x0e,
0x55, 0x1a, 0xcd, 0x72, 0x98, 0x04, 0xe6, 0xaf,
0x39, 0xb2, 0x7c, 0x5d, 0x11, 0x8e, 0xf3, 0x64,
}

// SetVoteExt set a specific voteExt in the store from its index
func (k Keeper) SetVoteExt(ctx context.Context, voteExt types.VoteExt) error {
err := k.VoteExts.Set(ctx, voteExt.Index, voteExt)
Expand Down
2 changes: 1 addition & 1 deletion x/voteexthandler/keeper/vote_ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestSetAndGetVoteExt(t *testing.T) {
Index: "vote1",
Height: 100,
ValidatorAddr: "validator1",
Signature: "sig1",
Signature: []byte("sig1"),
}

err := k.SetVoteExt(ctx, vote)
Expand Down
125 changes: 90 additions & 35 deletions x/voteexthandler/types/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading