Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(proto): non-nullable proto arrays #2130

Merged
merged 1 commit into from
Oct 10, 2024
Merged
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
8 changes: 4 additions & 4 deletions halo/attest/keeper/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var (
consensusID = netconf.Simnet.Static().OmniConsensusChainIDUint64()
)

func newValSet(id uint64, vals ...*vtypes.Validator) *vtypes.ValidatorSetResponse {
func newValSet(id uint64, vals ...vtypes.Validator) *vtypes.ValidatorSetResponse {
return &vtypes.ValidatorSetResponse{
Id: id,
CreatedHeight: 0,
Expand All @@ -51,8 +51,8 @@ func newValSet(id uint64, vals ...*vtypes.Validator) *vtypes.ValidatorSetRespons
}
}

func newValidator(key crypto.PubKey, power int64) *vtypes.Validator {
return &vtypes.Validator{
func newValidator(key crypto.PubKey, power int64) vtypes.Validator {
return vtypes.Validator{
ConsensusPubkey: key.Bytes(),
Power: power,
}
Expand Down Expand Up @@ -230,7 +230,7 @@ func (b *AggVoteBuilder) Vote() *types.AggVote {
return b.vote
}

func sigsTuples(vals ...*vtypes.Validator) []*types.SigTuple {
func sigsTuples(vals ...vtypes.Validator) []*types.SigTuple {
var sigs []*types.SigTuple
for _, v := range vals {
ethAddr, _ := v.EthereumAddress()
Expand Down
2 changes: 1 addition & 1 deletion halo/attest/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ func toValSet(valset *vtypes.ValidatorSetResponse) keeper.ValSet {
}
}

func expectValSig(id uint64, attID uint64, val *vtypes.Validator, offset uint64) *keeper.Signature {
func expectValSig(id uint64, attID uint64, val vtypes.Validator, offset uint64) *keeper.Signature {
ethAddr, _ := val.EthereumAddress()
paddedSig := pad65(ethAddr.Bytes())

Expand Down
2 changes: 1 addition & 1 deletion halo/attest/keeper/valaddr.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (c *valAddrCache) GetEthAddress(cmtAddr [crypto.AddressSize]byte) (common.A
return ethAddr, ok
}

func (c *valAddrCache) SetAll(vals []*vtypes.Validator) error {
func (c *valAddrCache) SetAll(vals []vtypes.Validator) error {
var ethAddrs = make(map[[crypto.AddressSize]byte]common.Address, len(vals))
for _, val := range vals {
cmtAddr, err := val.CometAddress()
Expand Down
4 changes: 2 additions & 2 deletions halo/attest/voter/voter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,12 +581,12 @@ func setIsVal(t *testing.T, v *voter.Voter, pk k1.PrivKey, isVal bool) {
cmtPubkey, err := k1util.PBPubKeyFromBytes(pk.PubKey().Bytes())
require.NoError(t, err)

vals := []*vtypes.Validator{{
vals := []vtypes.Validator{{
ConsensusPubkey: k1.GenPrivKey().PubKey().Bytes(),
Power: 1,
}}
if isVal {
vals = append(vals, &vtypes.Validator{
vals = append(vals, vtypes.Validator{
ConsensusPubkey: cmtPubkey.GetSecp256K1(),
Power: 1,
})
Expand Down
8 changes: 4 additions & 4 deletions halo/evmslashing/evmslashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func New(ethCl ethclient.Client, sKeeper skeeper.Keeper) (EventProcessor, error)
}

// Prepare returns all omni stake contract EVM event logs from the provided block hash.
func (p EventProcessor) Prepare(ctx context.Context, blockHash common.Hash) ([]*evmenginetypes.EVMEvent, error) {
func (p EventProcessor) Prepare(ctx context.Context, blockHash common.Hash) ([]evmenginetypes.EVMEvent, error) {
logs, err := p.ethCl.FilterLogs(ctx, ethereum.FilterQuery{
BlockHash: &blockHash,
Addresses: p.Addresses(),
Expand All @@ -66,13 +66,13 @@ func (p EventProcessor) Prepare(ctx context.Context, blockHash common.Hash) ([]*
return nil, errors.Wrap(err, "filter logs")
}

resp := make([]*evmenginetypes.EVMEvent, 0, len(logs))
resp := make([]evmenginetypes.EVMEvent, 0, len(logs))
for _, l := range logs {
topics := make([][]byte, 0, len(l.Topics))
for _, t := range l.Topics {
topics = append(topics, t.Bytes())
}
resp = append(resp, &evmenginetypes.EVMEvent{
resp = append(resp, evmenginetypes.EVMEvent{
Address: l.Address.Bytes(),
Topics: topics,
Data: l.Data,
Expand All @@ -92,7 +92,7 @@ func (p EventProcessor) Addresses() []common.Address {

// Deliver processes a omni deposit log event, which must be one of:
// - Unjail.
func (p EventProcessor) Deliver(ctx context.Context, _ common.Hash, elog *evmenginetypes.EVMEvent) error {
func (p EventProcessor) Deliver(ctx context.Context, _ common.Hash, elog evmenginetypes.EVMEvent) error {
ethlog, err := elog.ToEthLog()
if err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions halo/evmstaking/evmstaking.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func New(
}

// Prepare returns all omni stake contract EVM event logs from the provided block hash.
func (p EventProcessor) Prepare(ctx context.Context, blockHash common.Hash) ([]*evmenginetypes.EVMEvent, error) {
func (p EventProcessor) Prepare(ctx context.Context, blockHash common.Hash) ([]evmenginetypes.EVMEvent, error) {
logs, err := p.ethCl.FilterLogs(ctx, ethereum.FilterQuery{
BlockHash: &blockHash,
Addresses: p.Addresses(),
Expand All @@ -81,13 +81,13 @@ func (p EventProcessor) Prepare(ctx context.Context, blockHash common.Hash) ([]*
return nil, errors.Wrap(err, "filter logs")
}

resp := make([]*evmenginetypes.EVMEvent, 0, len(logs))
resp := make([]evmenginetypes.EVMEvent, 0, len(logs))
for _, l := range logs {
topics := make([][]byte, 0, len(l.Topics))
for _, t := range l.Topics {
topics = append(topics, t.Bytes())
}
resp = append(resp, &evmenginetypes.EVMEvent{
resp = append(resp, evmenginetypes.EVMEvent{
Address: l.Address.Bytes(),
Topics: topics,
Data: l.Data,
Expand All @@ -108,7 +108,7 @@ func (p EventProcessor) Addresses() []common.Address {
// Deliver processes a omni deposit log event, which must be one of:
// - CreateValidator
// - Delegate.
func (p EventProcessor) Deliver(ctx context.Context, _ common.Hash, elog *evmenginetypes.EVMEvent) error {
func (p EventProcessor) Deliver(ctx context.Context, _ common.Hash, elog evmenginetypes.EVMEvent) error {
ethlog, err := elog.ToEthLog()
if err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions halo/evmupgrade/evmupgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func New(ethCl ethclient.Client, uKeeper *ukeeper.Keeper) (EventProcessor, error
}

// Prepare returns all omni stake contract EVM event logs from the provided block hash.
func (p EventProcessor) Prepare(ctx context.Context, blockHash common.Hash) ([]*evmenginetypes.EVMEvent, error) {
func (p EventProcessor) Prepare(ctx context.Context, blockHash common.Hash) ([]evmenginetypes.EVMEvent, error) {
logs, err := p.ethCl.FilterLogs(ctx, ethereum.FilterQuery{
BlockHash: &blockHash,
Addresses: p.Addresses(),
Expand All @@ -68,13 +68,13 @@ func (p EventProcessor) Prepare(ctx context.Context, blockHash common.Hash) ([]*
return nil, errors.Wrap(err, "filter logs")
}

resp := make([]*evmenginetypes.EVMEvent, 0, len(logs))
resp := make([]evmenginetypes.EVMEvent, 0, len(logs))
for _, l := range logs {
topics := make([][]byte, 0, len(l.Topics))
for _, t := range l.Topics {
topics = append(topics, t.Bytes())
}
resp = append(resp, &evmenginetypes.EVMEvent{
resp = append(resp, evmenginetypes.EVMEvent{
Address: l.Address.Bytes(),
Topics: topics,
Data: l.Data,
Expand All @@ -95,7 +95,7 @@ func (p EventProcessor) Addresses() []common.Address {
// Deliver processes a upgrade log event, which must be one of:
// - PlanUpgrade.
// - CancelUpgrade.
func (p EventProcessor) Deliver(ctx context.Context, _ common.Hash, elog *evmenginetypes.EVMEvent) error {
func (p EventProcessor) Deliver(ctx context.Context, _ common.Hash, elog evmenginetypes.EVMEvent) error {
ethlog, err := elog.ToEthLog()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions halo/portal/keeper/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ func (k Keeper) Block(ctx context.Context, req *types.BlockRequest) (*types.Bloc
return nil, status.Error(codes.Internal, err.Error())
}

var messages []*types.Msg
var messages []types.Msg
for _, msg := range msgs {
messages = append(messages, &types.Msg{
messages = append(messages, types.Msg{
Id: msg.GetId(),
Type: msg.GetMsgType(),
MsgTypeId: msg.GetMsgTypeId(),
Expand Down
56 changes: 29 additions & 27 deletions halo/portal/types/query.pb.go

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

4 changes: 3 additions & 1 deletion halo/portal/types/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package halo.portal.types;

import "gogoproto/gogo.proto";

option go_package = "halo/portal/types";

// Query defines the gRPC querier service.
Expand All @@ -17,7 +19,7 @@ message BlockRequest {
message BlockResponse {
uint64 id = 1;
uint64 created_height = 2;
repeated Msg msgs = 3;
repeated Msg msgs = 3 [(gogoproto.nullable) = false];
}

message Msg {
Expand Down
8 changes: 4 additions & 4 deletions halo/registry/keeper/logeventproc.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (k Keeper) Addresses() []common.Address {
}

// Prepare returns all omni portal registry contract EVM event logs from the provided block hash.
func (k Keeper) Prepare(ctx context.Context, blockHash common.Hash) ([]*evmenginetypes.EVMEvent, error) {
func (k Keeper) Prepare(ctx context.Context, blockHash common.Hash) ([]evmenginetypes.EVMEvent, error) {
logs, err := k.ethCl.FilterLogs(ctx, ethereum.FilterQuery{
BlockHash: &blockHash,
Addresses: k.Addresses(),
Expand All @@ -44,13 +44,13 @@ func (k Keeper) Prepare(ctx context.Context, blockHash common.Hash) ([]*evmengin
return nil, errors.Wrap(err, "filter logs")
}

resp := make([]*evmenginetypes.EVMEvent, 0, len(logs))
resp := make([]evmenginetypes.EVMEvent, 0, len(logs))
for _, l := range logs {
topics := make([][]byte, 0, len(l.Topics))
for _, t := range l.Topics {
topics = append(topics, t.Bytes())
}
resp = append(resp, &evmenginetypes.EVMEvent{
resp = append(resp, evmenginetypes.EVMEvent{
Address: l.Address.Bytes(),
Topics: topics,
Data: l.Data,
Expand All @@ -61,7 +61,7 @@ func (k Keeper) Prepare(ctx context.Context, blockHash common.Hash) ([]*evmengin
}

// Deliver processes a omni portal registry events.
func (k Keeper) Deliver(ctx context.Context, _ common.Hash, elog *evmenginetypes.EVMEvent) error {
func (k Keeper) Deliver(ctx context.Context, _ common.Hash, elog evmenginetypes.EVMEvent) error {
ethlog, err := elog.ToEthLog()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions halo/registry/keeper/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ func (k Keeper) Network(ctx context.Context, req *types.NetworkRequest) (*types.
return nil, status.Error(codes.Internal, err.Error())
}

portals := make([]*types.Portal, 0, len(network.GetPortals()))
portals := make([]types.Portal, 0, len(network.GetPortals()))
for _, portal := range network.GetPortals() {
portals = append(portals, &types.Portal{
portals = append(portals, types.Portal{
ChainId: portal.GetChainId(),
Address: portal.GetAddress(),
DeployHeight: portal.GetDeployHeight(),
Expand Down
Loading
Loading