Skip to content

Commit

Permalink
rename getChainList
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Jun 26, 2024
1 parent 994020a commit 54dd10c
Show file tree
Hide file tree
Showing 28 changed files with 44 additions and 44 deletions.
8 changes: 4 additions & 4 deletions testutil/keeper/authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ func MockCheckAuthorization(m *mock.Mock, msg sdk.Msg, authorizationResult error
m.On("CheckAuthorization", mock.Anything, msg).Return(authorizationResult).Once()
}

// MockGetChainList mocks the GetChainList method of the authority keeper.
// MockGetChainList mocks the GetAdditionalChainList method of the authority keeper.
func MockGetChainList(m *mock.Mock, chainList []chains.Chain) {
m.On("GetChainList", mock.Anything).Return(chainList).Once()
m.On("GetAdditionalChainList", mock.Anything).Return(chainList).Once()
}

// MockGetChainListEmpty mocks the GetChainList method of the authority keeper.
// MockGetChainListEmpty mocks the GetAdditionalChainList method of the authority keeper.
func MockGetChainListEmpty(m *mock.Mock) {
m.On("GetChainList", mock.Anything).Return([]chains.Chain{})
m.On("GetAdditionalChainList", mock.Anything).Return([]chains.Chain{})
}

func SetAdminPolicies(ctx sdk.Context, ak *keeper.Keeper) string {
Expand Down
6 changes: 3 additions & 3 deletions testutil/keeper/mocks/crosschain/authority.go

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

6 changes: 3 additions & 3 deletions testutil/keeper/mocks/fungible/authority.go

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

6 changes: 3 additions & 3 deletions testutil/keeper/mocks/lightclient/authority.go

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

6 changes: 3 additions & 3 deletions testutil/keeper/mocks/observer/authority.go

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

4 changes: 2 additions & 2 deletions x/authority/keeper/chain_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ func (k Keeper) GetChainInfo(ctx sdk.Context) (val types.ChainInfo, found bool)
return val, true
}

// GetChainList returns the list of chains in chain info object
// GetAdditionalChainList returns the list of chains in chain info object
// returns empty list if no chains are present
func (k Keeper) GetChainList(ctx sdk.Context) (list []chains.Chain) {
func (k Keeper) GetAdditionalChainList(ctx sdk.Context) (list []chains.Chain) {
chainInfo, found := k.GetChainInfo(ctx)
if !found {
return
Expand Down
4 changes: 2 additions & 2 deletions x/authority/keeper/chain_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ func TestKeeper_GetChainList(t *testing.T) {
k, ctx := keepertest.AuthorityKeeper(t)

// Empty list
list := k.GetChainList(ctx)
list := k.GetAdditionalChainList(ctx)
require.Empty(t, list)

// Set chain info
chainInfo := sample.ChainInfo(42)
k.SetChainInfo(ctx, chainInfo)

// Check list
list = k.GetChainList(ctx)
list = k.GetAdditionalChainList(ctx)
require.Equal(t, chainInfo.Chains, list)
}
2 changes: 1 addition & 1 deletion x/crosschain/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (k Keeper) IterateAndUpdateCctxGasPrice(
return 0, gasPriceIncreaseFlags
}

additionalChains := k.GetAuthorityKeeper().GetChainList(ctx)
additionalChains := k.GetAuthorityKeeper().GetAdditionalChainList(ctx)

cctxCount := 0

Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/cctx_gateway_observers.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (c CCTXGatewayObservers) InitiateOutbound(
noEthereumTxEvent := false
if chains.IsZetaChain(
config.CCTX.InboundParams.SenderChainId,
c.crosschainKeeper.GetAuthorityKeeper().GetChainList(ctx),
c.crosschainKeeper.GetAuthorityKeeper().GetAdditionalChainList(ctx),
) {
noEthereumTxEvent = true
}
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/cctx_orchestrator_validate_outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (k Keeper) validateFailedOutboundObservers(ctx sdk.Context, cctx *types.Cro
// if the cctx is of coin type cmd or the sender chain is zeta chain, then we do not revert, the cctx is aborted
cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed
cctx.SetAbort("Outbound failed")
} else if chains.IsZetaChain(cctx.InboundParams.SenderChainId, k.GetAuthorityKeeper().GetChainList(ctx)) {
} else if chains.IsZetaChain(cctx.InboundParams.SenderChainId, k.GetAuthorityKeeper().GetAdditionalChainList(ctx)) {
switch cctx.InboundParams.CoinType {
// Try revert if the coin-type is ZETA
case coin.CoinType_Zeta:
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/evm_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (k Keeper) HandleEVMDeposit(ctx sdk.Context, cctx *types.CrossChainTx) (boo
to = parsedAddress
}

from, err := chains.DecodeAddressFromChainID(inboundSenderChainID, inboundSender, k.GetAuthorityKeeper().GetChainList(ctx))
from, err := chains.DecodeAddressFromChainID(inboundSenderChainID, inboundSender, k.GetAuthorityKeeper().GetAdditionalChainList(ctx))
if err != nil {
return false, fmt.Errorf("HandleEVMDeposit: unable to decode address: %s", err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/evm_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func (k Keeper) ProcessZetaSentEvent(
func (k Keeper) ValidateZrc20WithdrawEvent(ctx sdk.Context, event *zrc20.ZRC20Withdrawal, chainID int64) error {
// The event was parsed; that means the user has deposited tokens to the contract.

if chains.IsBitcoinChain(chainID, k.GetAuthorityKeeper().GetChainList(ctx)) {
if chains.IsBitcoinChain(chainID, k.GetAuthorityKeeper().GetAdditionalChainList(ctx)) {
if event.Value.Cmp(big.NewInt(constant.BTCWithdrawalDustAmount)) < 0 {
return errorsmod.Wrapf(
types.ErrInvalidWithdrawalAmount,
Expand Down
4 changes: 2 additions & 2 deletions x/crosschain/keeper/grpc_query_cctx_rate_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (k Keeper) RateLimiterInput(
// if a cctx is an outgoing cctx that orginates from ZetaChain
// reverted incoming cctx has an external `SenderChainId` and should not be counted
isCCTXOutgoing := func(cctx *types.CrossChainTx) bool {
return chains.IsZetaChain(cctx.InboundParams.SenderChainId, k.GetAuthorityKeeper().GetChainList(ctx))
return chains.IsZetaChain(cctx.InboundParams.SenderChainId, k.GetAuthorityKeeper().GetAdditionalChainList(ctx))
}

// it is a past cctx if its nonce < `nonceLow`,
Expand Down Expand Up @@ -272,7 +272,7 @@ func (k Keeper) ListPendingCctxWithinRateLimit(
// if a cctx is outgoing from ZetaChain
// reverted incoming cctx has an external `SenderChainId` and should not be counted
isCCTXOutgoing := func(cctx *types.CrossChainTx) bool {
return chains.IsZetaChain(cctx.InboundParams.SenderChainId, k.GetAuthorityKeeper().GetChainList(ctx))
return chains.IsZetaChain(cctx.InboundParams.SenderChainId, k.GetAuthorityKeeper().GetAdditionalChainList(ctx))
}

// query pending nonces for each foreign chain and get the lowest height of the pending cctxs
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/grpc_query_zeta_conversion_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (k Keeper) ConvertGasToZeta(
request *types.QueryConvertGasToZetaRequest,
) (*types.QueryConvertGasToZetaResponse, error) {
ctx := sdk.UnwrapSDKContext(context)
chain := chains.GetChainFromChainID(request.ChainId, k.GetAuthorityKeeper().GetChainList(ctx))
chain := chains.GetChainFromChainID(request.ChainId, k.GetAuthorityKeeper().GetAdditionalChainList(ctx))

if chain == nil {
return nil, zetaObserverTypes.ErrSupportedChains
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/initiate_outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type InitiateOutboundConfig struct {
// which handles the state changes and error handling.
func (k Keeper) InitiateOutbound(ctx sdk.Context, config InitiateOutboundConfig) (types.CctxStatus, error) {
receiverChainID := config.CCTX.GetCurrentOutboundParam().ReceiverChainId
chainInfo := chains.GetChainFromChainID(receiverChainID, k.GetAuthorityKeeper().GetChainList(ctx))
chainInfo := chains.GetChainFromChainID(receiverChainID, k.GetAuthorityKeeper().GetAdditionalChainList(ctx))
if chainInfo == nil {
return config.CCTX.CctxStatus.Status, cosmoserrors.Wrap(
types.ErrInitiatitingOutbound,
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/msg_server_add_outbound_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func verifyProofAndOutboundBody(ctx sdk.Context, k msgServer, msg *types.MsgAddO

// get tss address
var bitcoinChainID int64
if chains.IsBitcoinChain(msg.ChainId, k.GetAuthorityKeeper().GetChainList(ctx)) {
if chains.IsBitcoinChain(msg.ChainId, k.GetAuthorityKeeper().GetAdditionalChainList(ctx)) {
bitcoinChainID = msg.ChainId
}

Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/msg_server_migrate_tss_funds.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (k Keeper) MigrateTSSFundsForChain(
}

// retrieve from authority keeper additional chains
additionalChains := k.GetAuthorityKeeper().GetChainList(ctx)
additionalChains := k.GetAuthorityKeeper().GetAdditionalChainList(ctx)

// Set the sender and receiver addresses for EVM chain
if chains.IsEVMChain(chainID, additionalChains) {
Expand Down
4 changes: 2 additions & 2 deletions x/crosschain/keeper/refund.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (k Keeper) RefundAmountOnZetaChainZeta(
refundAmount := GetAbortedAmount(cctx)
chainID := cctx.InboundParams.SenderChainId
// check if chain is an EVM chain
if !chains.IsEVMChain(chainID, k.GetAuthorityKeeper().GetChainList(ctx)) {
if !chains.IsEVMChain(chainID, k.GetAuthorityKeeper().GetAdditionalChainList(ctx)) {
return errors.New("only EVM chains are supported for refund when coin type is Zeta")
}
if cctx.InboundParams.Amount.IsNil() || cctx.InboundParams.Amount.IsZero() {
Expand All @@ -96,7 +96,7 @@ func (k Keeper) RefundAmountOnZetaChainERC20(
if cctx.InboundParams.CoinType != coin.CoinType_ERC20 {
return errors.New("unsupported coin type for refund on ZetaChain")
}
if !chains.IsEVMChain(cctx.InboundParams.SenderChainId, k.GetAuthorityKeeper().GetChainList(ctx)) {
if !chains.IsEVMChain(cctx.InboundParams.SenderChainId, k.GetAuthorityKeeper().GetAdditionalChainList(ctx)) {
return errors.New("only EVM chains are supported for refund on ZetaChain")
}

Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ type FungibleKeeper interface {

type AuthorityKeeper interface {
CheckAuthorization(ctx sdk.Context, msg sdk.Msg) error
GetChainList(ctx sdk.Context) (list []chains.Chain)
GetAdditionalChainList(ctx sdk.Context) (list []chains.Chain)
}

type LightclientKeeper interface {
Expand Down
2 changes: 1 addition & 1 deletion x/fungible/keeper/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (k Keeper) DeployZRC20Contract(
erc20Contract string,
gasLimit *big.Int,
) (common.Address, error) {
chain := chains.GetChainFromChainID(chainID, k.GetAuthorityKeeper().GetChainList(ctx))
chain := chains.GetChainFromChainID(chainID, k.GetAuthorityKeeper().GetAdditionalChainList(ctx))
if chain == nil {
return common.Address{}, cosmoserrors.Wrapf(zetaObserverTypes.ErrSupportedChains, "chain %d not found", chainID)
}
Expand Down
2 changes: 1 addition & 1 deletion x/fungible/keeper/gas_coin_and_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (k Keeper) SetupChainGasCoinAndPool(
gasLimit *big.Int,
) (ethcommon.Address, error) {
// additional on-chain static chain information
additionalChains := k.GetAuthorityKeeper().GetChainList(ctx)
additionalChains := k.GetAuthorityKeeper().GetAdditionalChainList(ctx)

chain := chains.GetChainFromChainID(chainID, additionalChains)
if chain == nil {
Expand Down
2 changes: 1 addition & 1 deletion x/fungible/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ type EVMKeeper interface {

type AuthorityKeeper interface {
CheckAuthorization(ctx sdk.Context, msg sdk.Msg) error
GetChainList(ctx sdk.Context) (list []chains.Chain)
GetAdditionalChainList(ctx sdk.Context) (list []chains.Chain)
}
2 changes: 1 addition & 1 deletion x/lightclient/keeper/grpc_query_prove.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (k Keeper) Prove(c context.Context, req *types.QueryProveRequest) (*types.Q

// additionalChains is a list of additional chains to search from
// it is used in the protocol to dynamically support new chains without doing an upgrade
additionalChains := k.GetAuthorityKeeper().GetChainList(ctx)
additionalChains := k.GetAuthorityKeeper().GetAdditionalChainList(ctx)

blockHash, err := chains.StringToHash(req.ChainId, req.BlockHash, additionalChains)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion x/lightclient/keeper/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (k Keeper) VerifyProof(

// additionalChains is a list of additional chains to search from
// it is used in the protocol to dynamically support new chains without doing an upgrade
additionalChains := k.GetAuthorityKeeper().GetChainList(ctx)
additionalChains := k.GetAuthorityKeeper().GetAdditionalChainList(ctx)

// get block header from the store
hashBytes, err := chains.StringToHash(chainID, blockHash, additionalChains)
Expand Down
2 changes: 1 addition & 1 deletion x/lightclient/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import (

type AuthorityKeeper interface {
CheckAuthorization(ctx sdk.Context, msg sdk.Msg) error
GetChainList(ctx sdk.Context) (list []chains.Chain)
GetAdditionalChainList(ctx sdk.Context) (list []chains.Chain)
}
4 changes: 2 additions & 2 deletions x/observer/keeper/chain_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (k Keeper) GetSupportedChainFromChainID(ctx sdk.Context, chainID int64) *ch

for _, cp := range cpl.ChainParams {
if cp.ChainId == chainID && cp.IsSupported {
return chains.GetChainFromChainID(chainID, k.GetAuthorityKeeper().GetChainList(ctx))
return chains.GetChainFromChainID(chainID, k.GetAuthorityKeeper().GetAdditionalChainList(ctx))
}
}
return nil
Expand All @@ -67,7 +67,7 @@ func (k Keeper) GetSupportedChains(ctx sdk.Context) []*chains.Chain {
var c []*chains.Chain
for _, cp := range cpl.ChainParams {
if cp.IsSupported {
c = append(c, chains.GetChainFromChainID(cp.ChainId, k.GetAuthorityKeeper().GetChainList(ctx)))
c = append(c, chains.GetChainFromChainID(cp.ChainId, k.GetAuthorityKeeper().GetAdditionalChainList(ctx)))
}
}
return c
Expand Down
2 changes: 1 addition & 1 deletion x/observer/keeper/msg_server_reset_chain_nonces.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (k msgServer) ResetChainNonces(
return nil, types.ErrTssNotFound
}

chain := chains.GetChainFromChainID(msg.ChainId, k.GetAuthorityKeeper().GetChainList(ctx))
chain := chains.GetChainFromChainID(msg.ChainId, k.GetAuthorityKeeper().GetAdditionalChainList(ctx))
if chain == nil {
return nil, types.ErrSupportedChains
}
Expand Down
2 changes: 1 addition & 1 deletion x/observer/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type StakingHooks interface {

type AuthorityKeeper interface {
CheckAuthorization(ctx sdk.Context, msg sdk.Msg) error
GetChainList(ctx sdk.Context) (list []chains.Chain)
GetAdditionalChainList(ctx sdk.Context) (list []chains.Chain)

// SetPolicies is solely used for the migration of policies from observer to authority
SetPolicies(ctx sdk.Context, policies authoritytypes.Policies)
Expand Down

0 comments on commit 54dd10c

Please sign in to comment.