Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Apr 11, 2024
1 parent 3060eb3 commit bd0ab6f
Show file tree
Hide file tree
Showing 25 changed files with 65 additions and 59 deletions.
20 changes: 10 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,12 @@ type App struct {
FeeMarketKeeper feemarketkeeper.Keeper

// zetachain keepers
AuthorityKeeper authoritykeeper.Keeper
LighclientKeeper lightclientkeeper.Keeper
CrosschainKeeper crosschainkeeper.Keeper
ObserverKeeper *observerkeeper.Keeper
FungibleKeeper fungiblekeeper.Keeper
EmissionsKeeper emissionskeeper.Keeper
AuthorityKeeper authoritykeeper.Keeper
LightclientKeeper lightclientkeeper.Keeper
CrosschainKeeper crosschainkeeper.Keeper
ObserverKeeper *observerkeeper.Keeper
FungibleKeeper fungiblekeeper.Keeper
EmissionsKeeper emissionskeeper.Keeper
}

// New returns a reference to an initialized ZetaApp.
Expand Down Expand Up @@ -371,7 +371,7 @@ func New(
authtypes.NewModuleAddress(govtypes.ModuleName),
)

app.LighclientKeeper = lightclientkeeper.NewKeeper(
app.LightclientKeeper = lightclientkeeper.NewKeeper(
appCodec,
keys[lightclienttypes.StoreKey],
keys[lightclienttypes.MemStoreKey],
Expand All @@ -386,7 +386,7 @@ func New(
&stakingKeeper,
app.SlashingKeeper,
app.AuthorityKeeper,
app.LighclientKeeper,
app.LightclientKeeper,
)

// register the staking hooks
Expand Down Expand Up @@ -453,7 +453,7 @@ func New(
app.ObserverKeeper,
&app.FungibleKeeper,
app.AuthorityKeeper,
app.LighclientKeeper,
app.LightclientKeeper,
)
app.GroupKeeper = groupkeeper.NewKeeper(keys[group.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper, group.Config{
MaxExecutionPeriod: 2 * time.Hour, // Two hours.
Expand Down Expand Up @@ -525,7 +525,7 @@ func New(
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, evmSs),
feemarket.NewAppModule(app.FeeMarketKeeper, feeSs),
authoritymodule.NewAppModule(appCodec, app.AuthorityKeeper),
lightclientmodule.NewAppModule(appCodec, app.LighclientKeeper),
lightclientmodule.NewAppModule(appCodec, app.LightclientKeeper),
crosschainmodule.NewAppModule(appCodec, app.CrosschainKeeper),
observermodule.NewAppModule(appCodec, *app.ObserverKeeper),
fungiblemodule.NewAppModule(appCodec, app.FungibleKeeper),
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/balances.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ func runBalances(cmd *cobra.Command, args []string) error {
conf,
ethcommon.HexToAddress(evmAddr),
conf.Accounts.EVMPrivKey,
utils.FungibleAdminName, // placeholder value, not used
FungibleAdminMnemonic, // placeholder value, not used
utils.AdminName, // placeholder value, not used
AdminMnemonic, // placeholder value, not used
logger,
)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/bitcoin_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ func runBitcoinAddress(cmd *cobra.Command, args []string) error {
conf,
ethcommon.HexToAddress(evmAddr),
conf.Accounts.EVMPrivKey,
utils.FungibleAdminName, // placeholder value, not used
FungibleAdminMnemonic, // placeholder value, not used
utils.AdminName, // placeholder value, not used
AdminMnemonic, // placeholder value, not used
logger,
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetae2e/local/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ var (
UserAdminAddress = ethcommon.HexToAddress("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266")
UserAdminPrivateKey = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" // #nosec G101 - used for testing

FungibleAdminMnemonic = "snow grace federal cupboard arrive fancy gym lady uniform rotate exercise either leave alien grass" // #nosec G101 - used for testing
AdminMnemonic = "snow grace federal cupboard arrive fancy gym lady uniform rotate exercise either leave alien grass" // #nosec G101 - used for testing
)
4 changes: 2 additions & 2 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
conf,
DeployerAddress,
DeployerPrivateKey,
utils.FungibleAdminName,
FungibleAdminMnemonic,
utils.AdminName,
AdminMnemonic,
logger,
)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/local/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func initTestRunner(
conf,
userAddress,
userPrivKey,
utils.FungibleAdminName,
FungibleAdminMnemonic,
utils.AdminName,
AdminMnemonic,
logger,
)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cmd/zetae2e/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
const flagVerbose = "verbose"
const flagConfig = "config"

const FungibleAdminMnemonic = "snow grace federal cupboard arrive fancy gym lady uniform rotate exercise either leave alien grass" // #nosec G101 - used for testing
const AdminMnemonic = "snow grace federal cupboard arrive fancy gym lady uniform rotate exercise either leave alien grass" // #nosec G101 - used for testing

// NewRunCmd returns the run command
// which runs the E2E from a config file describing the tests, networks, and accounts
Expand Down Expand Up @@ -93,8 +93,8 @@ func runE2ETest(cmd *cobra.Command, args []string) error {
conf,
ethcommon.HexToAddress(evmAddr),
conf.Accounts.EVMPrivKey,
utils.FungibleAdminName, // placeholder value, not used
FungibleAdminMnemonic, // placeholder value, not used
utils.AdminName, // placeholder value, not used
AdminMnemonic, // placeholder value, not used
logger,
)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/setup_bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func runSetupBitcoin(_ *cobra.Command, args []string) error {
conf,
ethcommon.HexToAddress(evmAddr),
conf.Accounts.EVMPrivKey,
utils.FungibleAdminName, // placeholder value, not used
FungibleAdminMnemonic, // placeholder value, not used
utils.AdminName, // placeholder value, not used
AdminMnemonic, // placeholder value, not used
logger,
)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/show_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func runShowTSS(_ *cobra.Command, args []string) error {
conf,
ethcommon.HexToAddress(evmAddr),
conf.Accounts.EVMPrivKey,
utils.FungibleAdminName, // placeholder value, not used
FungibleAdminMnemonic, // placeholder value, not used
utils.AdminName, // placeholder value, not used
AdminMnemonic, // placeholder value, not used
logger,
)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/stress.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ func StressTest(cmd *cobra.Command, _ []string) {
conf,
local.DeployerAddress,
local.DeployerPrivateKey,
utils.FungibleAdminName,
FungibleAdminMnemonic,
utils.AdminName,
AdminMnemonic,
logger,
)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion docs/spec/lightclient/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## MsgUpdateVerificationFlags

UpdateVerificationFlags updates the crosschain related flags.
UpdateVerificationFlags updates the light client verification flags.
This disables/enables blocks verification of the light client for the specified chain.
Emergency group can disable flags while operation group can enable/disable

```proto
Expand Down
2 changes: 1 addition & 1 deletion e2e/e2etests/test_erc20_refund.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestERC20DepositAndCallRefund(r *runner.E2ERunner, _ []string) {
r.ZetaTxServer.GetAccountAddress(0),
cctx.Index,
r.DeployerAddress.String())
_, err = r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msg)
_, err = r.ZetaTxServer.BroadcastTx(utils.AdminName, msg)
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions e2e/e2etests/test_eth_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func TestDepositEtherLiquidityCap(r *runner.E2ERunner, args []string) {
r.ETHZRC20Addr.Hex(),
liquidityCap,
)
res, err := r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msg)
res, err := r.ZetaTxServer.BroadcastTx(utils.AdminName, msg)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -326,7 +326,7 @@ func TestDepositEtherLiquidityCap(r *runner.E2ERunner, args []string) {
r.ETHZRC20Addr.Hex(),
math.ZeroUint(),
)
res, err = r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msg)
res, err = r.ZetaTxServer.BroadcastTx(utils.AdminName, msg)
if err != nil {
panic(err)
}
Expand Down
14 changes: 7 additions & 7 deletions e2e/e2etests/test_migrate_chain_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) {

// update the chain params to set up the chain
chainParams := getNewEVMChainParams(newRunner)
adminAddr, err := newRunner.ZetaTxServer.GetAccountAddressFromName(utils.FungibleAdminName)
adminAddr, err := newRunner.ZetaTxServer.GetAccountAddressFromName(utils.AdminName)
if err != nil {
panic(err)
}
_, err = newRunner.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, observertypes.NewMsgUpdateChainParams(
_, err = newRunner.ZetaTxServer.BroadcastTx(utils.AdminName, observertypes.NewMsgUpdateChainParams(
adminAddr,
chainParams,
))
Expand All @@ -73,7 +73,7 @@ func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) {
if err != nil {
panic(err)
}
_, err = newRunner.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, fungibletypes.NewMsgDeployFungibleCoinZRC20(
_, err = newRunner.ZetaTxServer.BroadcastTx(utils.AdminName, fungibletypes.NewMsgDeployFungibleCoinZRC20(
adminAddr,
"",
chainParams.ChainId,
Expand Down Expand Up @@ -103,7 +103,7 @@ func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) {
newRunner.ETHZRC20 = ethZRC20

// set the chain nonces for the new chain
_, err = r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, observertypes.NewMsgResetChainNonces(
_, err = r.ZetaTxServer.BroadcastTx(utils.AdminName, observertypes.NewMsgResetChainNonces(
adminAddr,
chainParams.ChainId,
0,
Expand All @@ -116,7 +116,7 @@ func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) {
// deactivate the previous chain
chainParams = observertypes.GetDefaultGoerliLocalnetChainParams()
chainParams.IsSupported = false
_, err = newRunner.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, observertypes.NewMsgUpdateChainParams(
_, err = newRunner.ZetaTxServer.BroadcastTx(utils.AdminName, observertypes.NewMsgUpdateChainParams(
adminAddr,
chainParams,
))
Expand Down Expand Up @@ -167,7 +167,7 @@ func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) {

// whitelist erc20 zrc20
newRunner.Logger.Info("whitelisting ERC20 on new network")
res, err := newRunner.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, crosschaintypes.NewMsgWhitelistERC20(
res, err := newRunner.ZetaTxServer.BroadcastTx(utils.AdminName, crosschaintypes.NewMsgWhitelistERC20(
adminAddr,
newRunner.ERC20Addr.Hex(),
chains.SepoliaChain().ChainId,
Expand Down Expand Up @@ -221,7 +221,7 @@ func configureEVM2(r *runner.E2ERunner) (*runner.E2ERunner, error) {
r.CtxCancel,
r.DeployerAddress,
r.DeployerPrivateKey,
r.FungibleAdminMnemonic,
r.AdminMnemonic,
r.EVMClient,
r.ZEVMClient,
r.CctxClient,
Expand Down
4 changes: 2 additions & 2 deletions e2e/e2etests/test_pause_zrc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestPauseZRC20(r *runner.E2ERunner, _ []string) {
[]string{r.ETHZRC20Addr.Hex()},
fungibletypes.UpdatePausedStatusAction_PAUSE,
)
res, err := r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msg)
res, err := r.ZetaTxServer.BroadcastTx(utils.AdminName, msg)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -134,7 +134,7 @@ func TestPauseZRC20(r *runner.E2ERunner, _ []string) {
[]string{r.ETHZRC20Addr.Hex()},
fungibletypes.UpdatePausedStatusAction_UNPAUSE,
)
res, err = r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msg)
res, err = r.ZetaTxServer.BroadcastTx(utils.AdminName, msg)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/e2etests/test_update_bytecode.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestUpdateBytecode(r *runner.E2ERunner, _ []string) {
r.ETHZRC20Addr.Hex(),
codeHashRes.CodeHash,
)
res, err := r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msg)
res, err := r.ZetaTxServer.BroadcastTx(utils.AdminName, msg)
if err != nil {
panic(err)
}
Expand Down
20 changes: 10 additions & 10 deletions e2e/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ import (
// It also provides some helper functions
type E2ERunner struct {
// accounts
DeployerAddress ethcommon.Address
DeployerPrivateKey string
TSSAddress ethcommon.Address
BTCTSSAddress btcutil.Address
BTCDeployerAddress *btcutil.AddressWitnessPubKeyHash
FungibleAdminMnemonic string
DeployerAddress ethcommon.Address
DeployerPrivateKey string
TSSAddress ethcommon.Address
BTCTSSAddress btcutil.Address
BTCDeployerAddress *btcutil.AddressWitnessPubKeyHash
AdminMnemonic string

// rpc clients
ZEVMClient *ethclient.Client
Expand Down Expand Up @@ -117,7 +117,7 @@ func NewE2ERunner(
ctxCancel context.CancelFunc,
deployerAddress ethcommon.Address,
deployerPrivateKey string,
fungibleAdminMnemonic string,
adminMnemonic string,
evmClient *ethclient.Client,
zevmClient *ethclient.Client,
cctxClient crosschaintypes.QueryClient,
Expand All @@ -137,9 +137,9 @@ func NewE2ERunner(
Ctx: ctx,
CtxCancel: ctxCancel,

DeployerAddress: deployerAddress,
DeployerPrivateKey: deployerPrivateKey,
FungibleAdminMnemonic: fungibleAdminMnemonic,
DeployerAddress: deployerAddress,
DeployerPrivateKey: deployerPrivateKey,
AdminMnemonic: adminMnemonic,

ZEVMClient: zevmClient,
EVMClient: evmClient,
Expand Down
6 changes: 3 additions & 3 deletions e2e/runner/setup_zeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (runner *E2ERunner) SetZEVMContracts() {

// deploy system contracts and ZRC20 contracts on ZetaChain
uniswapV2FactoryAddr, uniswapV2RouterAddr, zevmConnectorAddr, wzetaAddr, erc20zrc20Addr, err := runner.ZetaTxServer.DeploySystemContractsAndZRC20(
e2eutils.FungibleAdminName,
e2eutils.AdminName,
runner.ERC20Addr.Hex(),
)
if err != nil {
Expand Down Expand Up @@ -208,12 +208,12 @@ func (runner *E2ERunner) SetupBTCZRC20() {
func (runner *E2ERunner) EnableVerificationFlags() error {
runner.Logger.Print("⚙️ enabling verification flags for block headers")

return runner.ZetaTxServer.EnableVerificationFlags(e2eutils.FungibleAdminName)
return runner.ZetaTxServer.EnableVerificationFlags(e2eutils.AdminName)
}

// FundEmissionsPool funds the emissions pool on ZetaChain with the same value as used originally on mainnet (20M ZETA)
func (runner *E2ERunner) FundEmissionsPool() error {
runner.Logger.Print("⚙️ funding the emissions pool on ZetaChain with 20M ZETA (%s)", txserver.EmissionsPoolAddress)

return runner.ZetaTxServer.FundEmissionsPool(e2eutils.FungibleAdminName, EmissionsPoolFunding)
return runner.ZetaTxServer.FundEmissionsPool(e2eutils.AdminName, EmissionsPoolFunding)
}
2 changes: 1 addition & 1 deletion e2e/utils/zetacore.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

const (
FungibleAdminName = "fungibleadmin"
AdminName = "fadmin"

DefaultCctxTimeout = 4 * time.Minute
)
Expand Down
3 changes: 2 additions & 1 deletion x/crosschain/keeper/msg_server_add_to_intx_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ func (k msgServer) AddToInTxTracker(goCtx context.Context, msg *types.MsgAddToIn
isEmergencyGroup := k.GetAuthorityKeeper().IsAuthorized(ctx, msg.Creator, authoritytypes.PolicyType_groupEmergency)
isObserver := k.GetObserverKeeper().IsNonTombstonedObserver(ctx, msg.Creator)

// only emergency group and observer can submit tracker without proof
// if the sender is not from the emergency group or observer, the inbound proof must be provided
if !(isEmergencyGroup || isObserver) {
// if not directly authorized, check the proof, if not provided, return unauthorized
if msg.Proof == nil {
return nil, errorsmod.Wrap(authoritytypes.ErrUnauthorized, fmt.Sprintf("Creator %s", msg.Creator))
}
Expand Down
3 changes: 3 additions & 0 deletions x/crosschain/keeper/msg_server_add_to_outtx_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func (k msgServer) AddToOutTxTracker(goCtx context.Context, msg *types.MsgAddToO
isObserver := k.GetObserverKeeper().IsNonTombstonedObserver(ctx, msg.Creator)
isProven := false

// only emergency group and observer can submit tracker without proof
// if the sender is not from the emergency group or observer, the outbound proof must be provided
if !(isEmergencyGroup || isObserver) {
if msg.Proof == nil {
return nil, cosmoserrors.Wrap(authoritytypes.ErrUnauthorized, fmt.Sprintf("Creator %s", msg.Creator))
Expand Down Expand Up @@ -112,6 +114,7 @@ func (k msgServer) AddToOutTxTracker(goCtx context.Context, msg *types.MsgAddToO
}

// verifyProofAndOutTxBody verifies the proof and outbound tx body
// Precondition: the proof must be non-nil
func verifyProofAndOutTxBody(ctx sdk.Context, k msgServer, msg *types.MsgAddToOutTxTracker) error {
txBytes, err := k.lightclientKeeper.VerifyProof(ctx, msg.Proof, msg.ChainId, msg.BlockHash, msg.TxIndex)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion x/lightclient/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

// GetQueryCmd returns the cli query commands for this module
func GetQueryCmd(_ string) *cobra.Command {
// Group crosschain queries under a subcommand
// Group lightclient queries under a subcommand
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
Expand Down
Loading

0 comments on commit bd0ab6f

Please sign in to comment.