Skip to content

Commit

Permalink
Rename goerli -> evm
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Mar 7, 2024
1 parent b451a00 commit 072d0e3
Show file tree
Hide file tree
Showing 31 changed files with 321 additions and 321 deletions.
8 changes: 4 additions & 4 deletions LOCAL_TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ type E2ETestFunc func(*E2ERunner)
The test can interact with the different networks using the runned object:
```go
type E2ERunner struct {
ZevmClient *ethclient.Client
GoerliClient *ethclient.Client
ZEVMClient *ethclient.Client
EVMClient *ethclient.Client
BtcRPCClient *rpcclient.Client

CctxClient crosschaintypes.QueryClient
Expand All @@ -204,8 +204,8 @@ type E2ERunner struct {
ObserverClient observertypes.QueryClient
ZetaTxServer txserver.ZetaTxServer

GoerliAuth *bind.TransactOpts
ZevmAuth *bind.TransactOpts
EVMAuth *bind.TransactOpts
ZEVMAuth *bind.TransactOpts

// ...
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/zetae2e/config/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func getClientsFromConfig(ctx context.Context, conf config.Config, evmPrivKey st
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get btc client: %w", err)
}
goerliClient, goerliAuth, err := getEVMClient(ctx, conf.RPCs.EVM, evmPrivKey)
evmClient, evmAuth, err := getEVMClient(ctx, conf.RPCs.EVM, evmPrivKey)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get evm client: %w", err)
}
Expand All @@ -48,8 +48,8 @@ func getClientsFromConfig(ctx context.Context, conf config.Config, evmPrivKey st
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get zevm client: %w", err)
}
return btcRPCClient,
goerliClient,
goerliAuth,
evmClient,
evmAuth,
cctxClient,
fungibleClient,
authClient,
Expand Down Expand Up @@ -85,7 +85,7 @@ func getBtcClient(rpcConf config.BitcoinRPC) (*rpcclient.Client, error) {
return rpcclient.New(connCfg, nil)
}

// getEVMClient get goerli client
// getEVMClient get evm client
func getEVMClient(ctx context.Context, rpc, privKey string) (*ethclient.Client, *bind.TransactOpts, error) {
evmClient, err := ethclient.Dial(rpc)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions cmd/zetae2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func RunnerFromConfig(
) (*runner.E2ERunner, error) {
// initialize clients
btcRPCClient,
goerliClient,
goerliAuth,
evmClient,
evmAuth,
cctxClient,
fungibleClient,
authClient,
Expand Down Expand Up @@ -56,15 +56,15 @@ func RunnerFromConfig(
evmUserAddr,
evmUserPrivKey,
zetaUserMnemonic,
goerliClient,
evmClient,
zevmClient,
cctxClient,
zetaTxServer,
fungibleClient,
authClient,
bankClient,
observerClient,
goerliAuth,
evmAuth,
zevmAuth,
btcRPCClient,
logger,
Expand Down
30 changes: 15 additions & 15 deletions cmd/zetae2e/config/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return fmt.Errorf("invalid ZetaEthAddress: %s", c)
}
r.ZetaEthAddr = ethcommon.HexToAddress(c)
r.ZetaEth, err = zetaeth.NewZetaEth(r.ZetaEthAddr, r.GoerliClient)
r.ZetaEth, err = zetaeth.NewZetaEth(r.ZetaEthAddr, r.EVMClient)
if err != nil {
return err
}
Expand All @@ -40,7 +40,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return fmt.Errorf("invalid ConnectorEthAddr: %s", c)
}
r.ConnectorEthAddr = ethcommon.HexToAddress(c)
r.ConnectorEth, err = zetaconnectoreth.NewZetaConnectorEth(r.ConnectorEthAddr, r.GoerliClient)
r.ConnectorEth, err = zetaconnectoreth.NewZetaConnectorEth(r.ConnectorEthAddr, r.EVMClient)
if err != nil {
return err
}
Expand All @@ -50,7 +50,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return fmt.Errorf("invalid CustodyAddr: %s", c)
}
r.ERC20CustodyAddr = ethcommon.HexToAddress(c)
r.ERC20Custody, err = erc20custody.NewERC20Custody(r.ERC20CustodyAddr, r.GoerliClient)
r.ERC20Custody, err = erc20custody.NewERC20Custody(r.ERC20CustodyAddr, r.EVMClient)
if err != nil {
return err
}
Expand All @@ -60,7 +60,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return fmt.Errorf("invalid ERC20: %s", c)
}
r.ERC20Addr = ethcommon.HexToAddress(c)
r.ERC20, err = erc20.NewERC20(r.ERC20Addr, r.GoerliClient)
r.ERC20, err = erc20.NewERC20(r.ERC20Addr, r.EVMClient)
if err != nil {
return err
}
Expand All @@ -72,7 +72,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return fmt.Errorf("invalid SystemContractAddr: %s", c)
}
r.SystemContractAddr = ethcommon.HexToAddress(c)
r.SystemContract, err = systemcontract.NewSystemContract(r.SystemContractAddr, r.ZevmClient)
r.SystemContract, err = systemcontract.NewSystemContract(r.SystemContractAddr, r.ZEVMClient)
if err != nil {
return err
}
Expand All @@ -82,7 +82,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return fmt.Errorf("invalid ETHZRC20Addr: %s", c)
}
r.ETHZRC20Addr = ethcommon.HexToAddress(c)
r.ETHZRC20, err = zrc20.NewZRC20(r.ETHZRC20Addr, r.ZevmClient)
r.ETHZRC20, err = zrc20.NewZRC20(r.ETHZRC20Addr, r.ZEVMClient)
if err != nil {
return err
}
Expand All @@ -92,7 +92,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return fmt.Errorf("invalid ERC20ZRC20Addr: %s", c)
}
r.ERC20ZRC20Addr = ethcommon.HexToAddress(c)
r.ERC20ZRC20, err = zrc20.NewZRC20(r.ERC20ZRC20Addr, r.ZevmClient)
r.ERC20ZRC20, err = zrc20.NewZRC20(r.ERC20ZRC20Addr, r.ZEVMClient)
if err != nil {
return err
}
Expand All @@ -102,7 +102,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return fmt.Errorf("invalid BTCZRC20Addr: %s", c)
}
r.BTCZRC20Addr = ethcommon.HexToAddress(c)
r.BTCZRC20, err = zrc20.NewZRC20(r.BTCZRC20Addr, r.ZevmClient)
r.BTCZRC20, err = zrc20.NewZRC20(r.BTCZRC20Addr, r.ZEVMClient)
if err != nil {
return err
}
Expand All @@ -112,7 +112,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return fmt.Errorf("invalid ERC20ZRC20Addr: %s", c)
}
r.ERC20ZRC20Addr = ethcommon.HexToAddress(c)
r.ERC20ZRC20, err = zrc20.NewZRC20(r.ERC20ZRC20Addr, r.ZevmClient)
r.ERC20ZRC20, err = zrc20.NewZRC20(r.ERC20ZRC20Addr, r.ZEVMClient)
if err != nil {
return err
}
Expand All @@ -122,7 +122,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return fmt.Errorf("invalid UniswapFactoryAddr: %s", c)
}
r.UniswapV2FactoryAddr = ethcommon.HexToAddress(c)
r.UniswapV2Factory, err = uniswapv2factory.NewUniswapV2Factory(r.UniswapV2FactoryAddr, r.ZevmClient)
r.UniswapV2Factory, err = uniswapv2factory.NewUniswapV2Factory(r.UniswapV2FactoryAddr, r.ZEVMClient)
if err != nil {
return err
}
Expand All @@ -132,7 +132,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return fmt.Errorf("invalid UniswapRouterAddr: %s", c)
}
r.UniswapV2RouterAddr = ethcommon.HexToAddress(c)
r.UniswapV2Router, err = uniswapv2router.NewUniswapV2Router02(r.UniswapV2RouterAddr, r.ZevmClient)
r.UniswapV2Router, err = uniswapv2router.NewUniswapV2Router02(r.UniswapV2RouterAddr, r.ZEVMClient)
if err != nil {
return err
}
Expand All @@ -142,7 +142,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return fmt.Errorf("invalid ConnectorZEVMAddr: %s", c)
}
r.ConnectorZEVMAddr = ethcommon.HexToAddress(c)
r.ConnectorZEVM, err = connectorzevm.NewZetaConnectorZEVM(r.ConnectorZEVMAddr, r.ZevmClient)
r.ConnectorZEVM, err = connectorzevm.NewZetaConnectorZEVM(r.ConnectorZEVMAddr, r.ZEVMClient)
if err != nil {
return err
}
Expand All @@ -152,7 +152,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return fmt.Errorf("invalid WZetaAddr: %s", c)
}
r.WZetaAddr = ethcommon.HexToAddress(c)
r.WZeta, err = wzeta.NewWETH9(r.WZetaAddr, r.ZevmClient)
r.WZeta, err = wzeta.NewWETH9(r.WZetaAddr, r.ZEVMClient)
if err != nil {
return err
}
Expand All @@ -162,7 +162,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return fmt.Errorf("invalid ZEVMSwapAppAddr: %s", c)
}
r.ZEVMSwapAppAddr = ethcommon.HexToAddress(c)
r.ZEVMSwapApp, err = zevmswap.NewZEVMSwapApp(r.ZEVMSwapAppAddr, r.ZevmClient)
r.ZEVMSwapApp, err = zevmswap.NewZEVMSwapApp(r.ZEVMSwapAppAddr, r.ZEVMClient)
if err != nil {
return err
}
Expand All @@ -172,7 +172,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return fmt.Errorf("invalid ContextAppAddr: %s", c)
}
r.ContextAppAddr = ethcommon.HexToAddress(c)
r.ContextApp, err = contextapp.NewContextApp(r.ContextAppAddr, r.ZevmClient)
r.ContextApp, err = contextapp.NewContextApp(r.ContextAppAddr, r.ZEVMClient)
if err != nil {
return err
}
Expand Down
24 changes: 12 additions & 12 deletions cmd/zetae2e/stress.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ func StressTest(cmd *cobra.Command, _ []string) {
}

// Initialize clients ----------------------------------------------------------------
goerliClient, err := ethclient.Dial(conf.RPCs.EVM)
evmClient, err := ethclient.Dial(conf.RPCs.EVM)
if err != nil {
panic(err)
}

bal, err := goerliClient.BalanceAt(context.TODO(), local.DeployerAddress, nil)
bal, err := evmClient.BalanceAt(context.TODO(), local.DeployerAddress, nil)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -171,7 +171,7 @@ func StressTest(cmd *cobra.Command, _ []string) {
panic(err)
}
e2eTest.ETHZRC20Addr = ethZRC20Addr
e2eTest.ETHZRC20, err = zrc20.NewZRC20(e2eTest.ETHZRC20Addr, e2eTest.ZevmClient)
e2eTest.ETHZRC20, err = zrc20.NewZRC20(e2eTest.ETHZRC20Addr, e2eTest.ZEVMClient)
if err != nil {
panic(err)
}
Expand All @@ -190,21 +190,21 @@ func StressTest(cmd *cobra.Command, _ []string) {
//Pre-approve ETH withdraw on ZEVM
fmt.Printf("approving ETH ZRC20...\n")
ethZRC20 := e2eTest.ETHZRC20
tx, err := ethZRC20.Approve(e2eTest.ZevmAuth, e2eTest.ETHZRC20Addr, big.NewInt(1e18))
tx, err := ethZRC20.Approve(e2eTest.ZEVMAuth, e2eTest.ETHZRC20Addr, big.NewInt(1e18))
if err != nil {
panic(err)
}
receipt := utils.MustWaitForTxReceipt(ctx, e2eTest.ZevmClient, tx, logger, e2eTest.ReceiptTimeout)
receipt := utils.MustWaitForTxReceipt(ctx, e2eTest.ZEVMClient, tx, logger, e2eTest.ReceiptTimeout)
fmt.Printf("eth zrc20 approve receipt: status %d\n", receipt.Status)

// Get current nonce on zevm for DeployerAddress - Need to keep track of nonce at client level
blockNum, err := e2eTest.ZevmClient.BlockNumber(context.Background())
blockNum, err := e2eTest.ZEVMClient.BlockNumber(context.Background())
if err != nil {
panic(err)
}

// #nosec G701 e2eTest - always in range
nonce, err := e2eTest.ZevmClient.NonceAt(context.Background(), local.DeployerAddress, big.NewInt(int64(blockNum)))
nonce, err := e2eTest.ZEVMClient.NonceAt(context.Background(), local.DeployerAddress, big.NewInt(int64(blockNum)))
if err != nil {
panic(err)
}
Expand All @@ -215,11 +215,11 @@ func StressTest(cmd *cobra.Command, _ []string) {
// -------------- TEST BEGINS ------------------

fmt.Println("**** STRESS TEST BEGINS ****")
fmt.Println(" 1. Periodically Withdraw ETH from ZEVM to EVM - goerli")
fmt.Println(" 1. Periodically Withdraw ETH from ZEVM to EVM")
fmt.Println(" 2. Display Network metrics to monitor performance [Num Pending outbound tx], [Num Trackers]")

e2eTest.WG.Add(2)
go WithdrawCCtx(e2eTest) // Withdraw from ZEVM to EVM - goerli
go WithdrawCCtx(e2eTest) // Withdraw from ZEVM to EVM
go EchoNetworkMetrics(e2eTest) // Display Network metrics periodically to monitor performance

e2eTest.WG.Wait()
Expand All @@ -242,7 +242,7 @@ func EchoNetworkMetrics(runner *runner.E2ERunner) {
var numTicks = 0
var totalMinedTxns = uint64(0)
var previousMinedTxns = uint64(0)
chainID, err := getChainID(runner.GoerliClient)
chainID, err := getChainID(runner.EVMClient)

if err != nil {
panic(err)
Expand Down Expand Up @@ -306,8 +306,8 @@ func WithdrawETHZRC20(runner *runner.E2ERunner) {

ethZRC20 := runner.ETHZRC20

runner.ZevmAuth.Nonce = zevmNonce
_, err := ethZRC20.Withdraw(runner.ZevmAuth, local.DeployerAddress.Bytes(), big.NewInt(100))
runner.ZEVMAuth.Nonce = zevmNonce
_, err := ethZRC20.Withdraw(runner.ZEVMAuth, local.DeployerAddress.Bytes(), big.NewInt(100))
if err != nil {
panic(err)
}
Expand Down
6 changes: 3 additions & 3 deletions e2e/e2etests/e2etests.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ var AllE2ETests = []runner.E2ETest{
),
runner.NewE2ETest(
TestMessagePassingName,
"goerli->goerli message passing (sending ZETA only)",
"evm->evm message passing (sending ZETA only)",
[]runner.ArgDefinition{
runner.ArgDefinition{Description: "amount in azeta", DefaultValue: "10000000000000000000"},
},
Expand Down Expand Up @@ -153,15 +153,15 @@ var AllE2ETests = []runner.E2ETest{
),
runner.NewE2ETest(
TestMessagePassingRevertFailName,
"goerli->goerli message passing (revert fail)",
"evm->evm message passing (revert fail)",
[]runner.ArgDefinition{
runner.ArgDefinition{Description: "amount in azeta", DefaultValue: "10000000000000000000"},
},
TestMessagePassingRevertFail,
),
runner.NewE2ETest(
TestMessagePassingRevertSuccessName,
"goerli->goerli message passing (revert success)",
"evm->evm message passing (revert success)",
[]runner.ArgDefinition{
runner.ArgDefinition{Description: "amount in azeta", DefaultValue: "10000000000000000000"},
},
Expand Down
18 changes: 9 additions & 9 deletions e2e/e2etests/test_bitcoin_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ func TestBitcoinWithdrawRestricted(r *runner.E2ERunner, args []string) {
}

func withdrawBTCZRC20(r *runner.E2ERunner, to btcutil.Address, amount *big.Int) *btcjson.TxRawResult {
tx, err := r.BTCZRC20.Approve(r.ZevmAuth, r.BTCZRC20Addr, big.NewInt(amount.Int64()*2)) // approve more to cover withdraw fee
tx, err := r.BTCZRC20.Approve(r.ZEVMAuth, r.BTCZRC20Addr, big.NewInt(amount.Int64()*2)) // approve more to cover withdraw fee
if err != nil {
panic(err)
}
receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, tx, r.Logger, r.ReceiptTimeout)
receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
if receipt.Status != 1 {
panic(fmt.Errorf("approve receipt status is not 1"))
}
Expand All @@ -66,11 +66,11 @@ func withdrawBTCZRC20(r *runner.E2ERunner, to btcutil.Address, amount *big.Int)
stop := r.MineBlocks()

// withdraw 'amount' of BTC from ZRC20 to BTC address
tx, err = r.BTCZRC20.Withdraw(r.ZevmAuth, []byte(to.EncodeAddress()), amount)
tx, err = r.BTCZRC20.Withdraw(r.ZEVMAuth, []byte(to.EncodeAddress()), amount)
if err != nil {
panic(err)
}
receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, tx, r.Logger, r.ReceiptTimeout)
receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
if receipt.Status != 1 {
panic(fmt.Errorf("withdraw receipt status is not 1"))
}
Expand Down Expand Up @@ -145,7 +145,7 @@ func WithdrawBitcoinRestricted(r *runner.E2ERunner, amount *big.Int) {
// panic(err)
// }
// r.Logger.Info("BTCZRC20Addr: %s", BTCZRC20Addr.Hex())
// BTCZRC20, err := zrc20.NewZRC20(BTCZRC20Addr, r.ZevmClient)
// BTCZRC20, err := zrc20.NewZRC20(BTCZRC20Addr, r.ZEVMClient)
// if err != nil {
// panic(err)
// }
Expand All @@ -159,11 +159,11 @@ func WithdrawBitcoinRestricted(r *runner.E2ERunner, amount *big.Int) {
// // approve the ZRC20 contract to spend 1 BTC from the deployer address
// {
// // approve more to cover withdraw fee
// tx, err := BTCZRC20.Approve(r.ZevmAuth, BTCZRC20Addr, totalAmount.Mul(totalAmount, big.NewInt(100)))
// tx, err := BTCZRC20.Approve(r.ZEVMAuth, BTCZRC20Addr, totalAmount.Mul(totalAmount, big.NewInt(100)))
// if err != nil {
// panic(err)
// }
// receipt := config.MustWaitForTxReceipt(r.ZevmClient, tx, r.Logger)
// receipt := config.MustWaitForTxReceipt(r.ZEVMClient, tx, r.Logger)
// r.Logger.Info("approve receipt: status %d", receipt.Status)
// if receipt.Status != 1 {
// panic(fmt.Errorf("approve receipt status is not 1"))
Expand All @@ -185,11 +185,11 @@ func WithdrawBitcoinRestricted(r *runner.E2ERunner, amount *big.Int) {
// panic(err)
// }
// r.Logger.Info("withdraw gas fee: %d", gasFee)
// tx, err := BTCZRC20.Withdraw(r.ZevmAuth, []byte(r.BTCDeployerAddress.EncodeAddress()), amount)
// tx, err := BTCZRC20.Withdraw(r.ZEVMAuth, []byte(r.BTCDeployerAddress.EncodeAddress()), amount)
// if err != nil {
// panic(err)
// }
// receipt := config.MustWaitForTxReceipt(r.ZevmClient, tx, r.Logger)
// receipt := config.MustWaitForTxReceipt(r.ZEVMClient, tx, r.Logger)
// r.Logger.Info("withdraw receipt: status %d", receipt.Status)
// if receipt.Status != 1 {
// panic(fmt.Errorf("withdraw receipt status is not 1"))
Expand Down
Loading

0 comments on commit 072d0e3

Please sign in to comment.