Skip to content

Commit

Permalink
fix: name & test code for multi executor
Browse files Browse the repository at this point in the history
  • Loading branch information
djm07073 committed Jun 10, 2024
1 parent d5b1ea3 commit 844cc67
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 88 deletions.
2 changes: 1 addition & 1 deletion api/opinit/opchild/v1/types.pulsar.go

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

2 changes: 1 addition & 1 deletion contrib/launchtools/steps/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func setOpChildBridgeExecutorAddress(cdc codec.Codec, genesisAppState map[string
error,
) {
opchildState := opchildtypes.GetGenesisStateFromAppState(cdc, genesisAppState)
opchildState.Params.BridgeExecutor = []string{bridgeExecutorAddr}
opchildState.Params.BridgeExecutors = []string{bridgeExecutorAddr}

return opchildState, nil
}
2 changes: 1 addition & 1 deletion proto/opinit/opchild/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ message Params {
];
// the account address of bridge executor who can execute permissioned bridge
// messages.
repeated string bridge_executor = 4 [
repeated string bridge_executors = 4 [
(cosmos_proto.scalar) = "cosmos.AddressString",
(amino.dont_omitempty) = true,
(gogoproto.moretags) = "yaml:\"bridge_executor\""
Expand Down
4 changes: 2 additions & 2 deletions x/opchild/client/cli/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ $ %s add-genesis-validator my-key-name --home=/path/to/home/dir --keyring-backen
}

allEmpty := true
for _, be := range opchildState.Params.BridgeExecutor {
for _, be := range opchildState.Params.BridgeExecutors {
if be != "" {
allEmpty = false
break

Check warning on line 99 in x/opchild/client/cli/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/opchild/client/cli/genesis.go#L95-L99

Added lines #L95 - L99 were not covered by tests
}
}
if allEmpty {
opchildState.Params.BridgeExecutor = []string{addr.String()}
opchildState.Params.BridgeExecutors = []string{addr.String()}

Check warning on line 103 in x/opchild/client/cli/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/opchild/client/cli/genesis.go#L102-L103

Added lines #L102 - L103 were not covered by tests
}

opchildGenStateBz, err := cdc.MarshalJSON(opchildState)
Expand Down
2 changes: 1 addition & 1 deletion x/opchild/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func _createTestInput(

opchildParams := opchildtypes.DefaultParams()
opchildParams.Admin = addrs[0].String()
opchildParams.BridgeExecutor = []string{addrs[0].String()}
opchildParams.BridgeExecutors = []string{addrs[0].String()}
require.NoError(t, opchildKeeper.SetParams(ctx, opchildParams))

// register handlers to msg router
Expand Down
4 changes: 2 additions & 2 deletions x/opchild/keeper/executor_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (k Keeper) RegisterExecutorChangePlan(
k.ExecutorChangePlans[height] = types.ExecutorChangePlan{
ProposalID: proposalID,
Height: height,
NextExecutor: nextExecutors,
NextExecutors: nextExecutors,
NextValidator: validator,
Info: info,
}
Expand All @@ -76,7 +76,7 @@ func (k Keeper) ChangeExecutor(ctx context.Context, plan types.ExecutorChangePla
if err != nil {
return err
}
params.BridgeExecutor = plan.NextExecutor
params.BridgeExecutors = plan.NextExecutors

Check warning on line 79 in x/opchild/keeper/executor_change.go

View check run for this annotation

Codecov / codecov/patch

x/opchild/keeper/executor_change.go#L79

Added line #L79 was not covered by tests
if err := k.SetParams(ctx, params); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions x/opchild/keeper/executor_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func Test_RegisterExecutorChangePlan(t *testing.T) {
l1ProposalID := uint64(rand.Uint64())
height := uint64(rand.Uint64())
nextValAddr := valAddrsStr[0]
nextExecutorAddr := []string{addrsStr[0]}
nextExecutorAddr := []string{addrsStr[0], addrsStr[1]}
consensusPubKey := "l7aqGv+Zjbm0rallfqfqz+3iN31iOmgJCafWV5pGs6o="
moniker := "moniker"
info := "info"
Expand All @@ -44,7 +44,7 @@ func Test_RegisterExecutorChangePlan(t *testing.T) {
require.Equal(t, types.ExecutorChangePlan{
ProposalID: l1ProposalID,
Height: height,
NextExecutor: []string{addrsStr[0]},
NextExecutors: []string{addrsStr[0], addrsStr[1]},
NextValidator: expectedValidator,
Info: info,
}, input.OPChildKeeper.ExecutorChangePlans[height])
Expand Down
2 changes: 1 addition & 1 deletion x/opchild/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (ms MsgServer) checkBridgeExecutorPermission(ctx context.Context, sender st
return err
}

bridgeExecutors, err := ms.BridgeExecutor(ctx)
bridgeExecutors, err := ms.BridgeExecutors(ctx)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion x/opchild/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func Test_MsgServer_UpdateParams(t *testing.T) {
require.NoError(t, err)
params.MaxValidators = 1
params.HistoricalEntries = 1
params.BridgeExecutor = []string{addrs[1].String()}
params.BridgeExecutors = []string{addrs[1].String(), addrs[2].String()}

moduleAddr, err := input.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(types.ModuleName))
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions x/opchild/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (
)

// BridgeExecutor returns params.BridgeExecutor
func (k Keeper) BridgeExecutor(ctx context.Context) ([]sdk.AccAddress, error) {
func (k Keeper) BridgeExecutors(ctx context.Context) ([]sdk.AccAddress, error) {
params, err := k.GetParams(ctx)
if err != nil {
return nil, err
}
var addrs []sdk.AccAddress

for _, be := range params.BridgeExecutor {
for _, be := range params.BridgeExecutors {
addr, err := k.authKeeper.AddressCodec().StringToBytes(be)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion x/opchild/keeper/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func Test_Params(t *testing.T) {
minGasPrices, err := input.OPChildKeeper.MinGasPrices(ctx)
require.NoError(t, err)
require.True(t, minGasPrices.Empty())
bridgeExecutor, err := input.OPChildKeeper.BridgeExecutor(ctx)
bridgeExecutor, err := input.OPChildKeeper.BridgeExecutors(ctx)
require.NoError(t, err)
require.Equal(t, []sdk.AccAddress{addrs[0]}, bridgeExecutor)

Expand Down
6 changes: 3 additions & 3 deletions x/opchild/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ func DefaultParams() Params {
}

// NewParams creates a new Params instance
func NewParams(admin string, bridgeExecutor []string, maxValidators, historicalEntries uint32, minGasPrice sdk.DecCoins, feeWhitelist []string) Params {
func NewParams(admin string, bridgeExecutors []string, maxValidators, historicalEntries uint32, minGasPrice sdk.DecCoins, feeWhitelist []string) Params {
return Params{
Admin: admin,
BridgeExecutor: bridgeExecutor,
BridgeExecutors: bridgeExecutors,
MaxValidators: maxValidators,
HistoricalEntries: historicalEntries,
MinGasPrices: minGasPrice,
Expand All @@ -50,7 +50,7 @@ func (p Params) Validate(ac address.Codec) error {
if _, err := ac.StringToBytes(p.Admin); err != nil {
return err
}
for _, be := range p.BridgeExecutor {
for _, be := range p.BridgeExecutors {
if _, err := ac.StringToBytes(be); err != nil {
return err
}

Check warning on line 56 in x/opchild/types/params.go

View check run for this annotation

Codecov / codecov/patch

x/opchild/types/params.go#L55-L56

Added lines #L55 - L56 were not covered by tests
Expand Down
2 changes: 1 addition & 1 deletion x/opchild/types/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type ExecutorChangePlan struct {
Height uint64

// Next executor addresses
NextExecutor []string
NextExecutors []string

// Next validator
NextValidator Validator
Expand Down
138 changes: 69 additions & 69 deletions x/opchild/types/types.pb.go

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

0 comments on commit 844cc67

Please sign in to comment.