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

feat!: bank precompile #2860

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d06485f
feat: bank precompile
fbac Sep 10, 2024
969d2d2
feat: add deposit
fbac Sep 11, 2024
71aa8d5
feat: extend deposit
fbac Sep 11, 2024
322618b
PoC: spend amount on behalf of EOA
fbac Sep 11, 2024
7e85925
feat: expand deposit with transferFrom
fbac Sep 11, 2024
5fe30cf
use CallEVM instead on ZRC20 bindings
fbac Sep 11, 2024
f69c695
divide the contract into different files
fbac Sep 11, 2024
5863536
initialize e2e testing
fbac Sep 11, 2024
12a5138
remove duplicated funding
fbac Sep 11, 2024
a4be05e
add codecov
fbac Sep 11, 2024
75efde6
expand e2e
fbac Sep 11, 2024
6340abb
fix: wait for deposit tx to be mined
fbac Sep 11, 2024
0f347f2
apply first round of reviews
fbac Sep 12, 2024
e0fa24a
cover al error types test
fbac Sep 12, 2024
cf17671
fixes using time.Since
fbac Sep 12, 2024
02ddce3
Include CallContract interface
fbac Sep 12, 2024
c1836a3
fix eth events in deposit precompile method
skosito Sep 16, 2024
8503dc8
emit Deposit event
fbac Sep 16, 2024
6a19fb0
add withdraw function
fbac Sep 17, 2024
e7ddcb0
finalize withdraw
fbac Sep 17, 2024
f1e5b3a
pack event arguments generically
fbac Sep 17, 2024
05d0bfb
add high level event function
fbac Sep 17, 2024
0fa8d50
first round of review fixes
fbac Sep 17, 2024
b6b78a9
second round of reviews
fbac Sep 18, 2024
6271e7a
create bank account when instantiating bank
fbac Sep 18, 2024
1a4f553
e2e: add good and bad scenarios
fbac Sep 19, 2024
6caabef
Merge branch 'develop' into feat/bank-precompile
fbac Sep 19, 2024
9ed6bfb
modify fmt
fbac Sep 19, 2024
b8094e2
chore: group input into eventData struct
fbac Sep 19, 2024
a7533eb
docs: document bank's methods
fbac Sep 19, 2024
67ad4fa
chore: generate files with suffix .gen.go
fbac Sep 20, 2024
82f5204
chore: assert errors with errorIs
fbac Sep 20, 2024
4d0a57b
chore: reset e2e test by resetting allowance
fbac Sep 20, 2024
c9bf427
test: add first batch of unit test
fbac Sep 21, 2024
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
4 changes: 2 additions & 2 deletions Dockerfile-localnet
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ EXPOSE 22
FROM base-runtime AS latest-runtime

COPY --from=cosmovisor-build /go/bin/cosmovisor /usr/local/bin
COPY --from=latest-build /go/bin/zetacored /go/bin/zetaclientd /go/bin/zetaclientd-supervisor /go/bin/zetae2e /usr/local/bin
COPY --from=latest-build /go/bin/zetacored /go/bin/zetaclientd /go/bin/zetaclientd-supervisor /go/bin/zetae2e /usr/local/bin/
fbac marked this conversation as resolved.
Show resolved Hide resolved

# Optional old version build (from source). This old build is used as the genesis version in the upgrade tests.
# Use --target latest-runtime to skip.
Expand All @@ -75,7 +75,7 @@ RUN cd node && make install
FROM base-runtime AS old-runtime-source

COPY --from=cosmovisor-build /go/bin/cosmovisor /usr/local/bin
COPY --from=old-build-source /go/bin/zetacored /go/bin/zetaclientd /usr/local/bin
COPY --from=old-build-source /go/bin/zetacored /go/bin/zetaclientd /usr/local/bin/
COPY --from=latest-build /go/bin/zetaclientd-supervisor /usr/local/bin

# Optional old version build (from binary).
Expand Down
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ func New(
precompiles.StatefulContracts(
&app.FungibleKeeper,
app.StakingKeeper,
app.BankKeeper,
appCodec,
storetypes.TransientGasConfig(),
),
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* [2784](https://github.com/zeta-chain/node/pull/2784) - staking precompiled contract
* [2795](https://github.com/zeta-chain/node/pull/2795) - support restricted address in Solana
* [2861](https://github.com/zeta-chain/node/pull/2861) - emit events from staking precompile
* [2860](https://github.com/zeta-chain/node/pull/2860) - bank precompiled contract
* [2870](https://github.com/zeta-chain/node/pull/2870) - support for multiple Bitcoin chains in the zetaclient
* [2883](https://github.com/zeta-chain/node/pull/2883) - add chain static information for btc signet testnet

Expand Down
2 changes: 2 additions & 0 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
e2etests.TestPrecompilesPrototypeThroughContractName,
e2etests.TestPrecompilesStakingName,
e2etests.TestPrecompilesStakingThroughContractName,
e2etests.TestPrecompilesBankName,
e2etests.TestPrecompilesBankFailName,
}
}

Expand Down
4 changes: 4 additions & 0 deletions cmd/zetae2e/local/precompiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func statefulPrecompilesTestRoutine(
precompileRunner.Logger.Print("🏃 starting stateful precompiled contracts tests")
startTime := time.Now()

// Send ERC20 that will be depositted into ERC20ZRC20 tokens.
txERC20Send := deployerRunner.SendERC20OnEvm(account.EVMAddress(), 10000)
precompileRunner.WaitForTxReceiptOnEvm(txERC20Send)

testsToRun, err := precompileRunner.GetE2ETestsToRunByName(
e2etests.AllE2ETests,
testNames...,
Expand Down
3 changes: 1 addition & 2 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,4 @@ ignore:
- "precompiles/**/*.abi"
- "precompiles/**/*.json"
- "precompiles/**/*.sol"
- "precompiles/prototype/IPrototype.go"
- "precompiles/staking/IStaking.go"
- "precompiles/**/*.gen.go"
12 changes: 1 addition & 11 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fund_eth_from_config '.additional_accounts.user_admin.evm_address' 10000 "admin
fund_eth_from_config '.additional_accounts.user_migration.evm_address' 10000 "migration tester"

# unlock precompile tests accounts
fund_eth_from_config '.additional_accounts.user_precompile.evm_address' 10000 "precompile tester"
fund_eth_from_config '.additional_accounts.user_precompile.evm_address' 10000 "precompiles tester"
fbac marked this conversation as resolved.
Show resolved Hide resolved

# unlock v2 ethers tests accounts
fund_eth_from_config '.additional_accounts.user_v2_ether.evm_address' 10000 "V2 ethers tester"
Expand All @@ -131,16 +131,6 @@ fund_eth_from_config '.additional_accounts.user_v2_ether_revert.evm_address' 100
# unlock v2 erc20 revert tests accounts
fund_eth_from_config '.additional_accounts.user_v2_erc20_revert.evm_address' 10000 "V2 ERC20 revert tester"

# unlock precompile tests accounts
address=$(yq -r '.additional_accounts.user_precompile.evm_address' config.yml)
echo "funding precompile tester address ${address} with 10000 Ether"
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545 > /dev/null

# unlock precompile tests accounts
address=$(yq -r '.additional_accounts.user_precompile.evm_address' config.yml)
echo "funding precompile tester address ${address} with 10000 Ether"
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545 > /dev/null

# unlock local solana relayer accounts
if host solana > /dev/null; then
solana_url=$(config_str '.rpcs.solana')
Expand Down
15 changes: 15 additions & 0 deletions e2e/e2etests/e2etests.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ const (
TestPrecompilesPrototypeThroughContractName = "precompile_contracts_prototype_through_contract"
TestPrecompilesStakingName = "precompile_contracts_staking"
TestPrecompilesStakingThroughContractName = "precompile_contracts_staking_through_contract"
TestPrecompilesBankName = "precompile_contracts_bank"
TestPrecompilesBankFailName = "precompile_contracts_bank_fail"
TestPrecompilesBankThroughContractName = "precompile_contracts_bank_through_contract"
)

// AllE2ETests is an ordered list of all e2e tests
Expand Down Expand Up @@ -886,4 +889,16 @@ var AllE2ETests = []runner.E2ETest{
[]runner.ArgDefinition{},
TestPrecompilesStakingThroughContract,
),
runner.NewE2ETest(
TestPrecompilesBankName,
"test stateful precompiled contracts bank with ZRC20 tokens",
[]runner.ArgDefinition{},
TestPrecompilesBank,
),
runner.NewE2ETest(
TestPrecompilesBankFailName,
"test stateful precompiled contracts bank with non ZRC20 tokens",
[]runner.ArgDefinition{},
TestPrecompilesBankNonZRC20,
),
}
192 changes: 192 additions & 0 deletions e2e/e2etests/test_precompiles_bank.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
package e2etests

import (
"math/big"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/stretchr/testify/require"

"github.com/zeta-chain/node/e2e/runner"
"github.com/zeta-chain/node/e2e/utils"
"github.com/zeta-chain/node/precompiles/bank"
)

func TestPrecompilesBank(r *runner.E2ERunner, args []string) {
fbac marked this conversation as resolved.
Show resolved Hide resolved
require.Len(r, args, 0, "No arguments expected")

// Increase the gasLimit. It's required because of the gas consumed by precompiled functions.
previousGasLimit := r.ZEVMAuth.GasLimit
r.ZEVMAuth.GasLimit = 10_000_000
defer func() {
r.ZEVMAuth.GasLimit = previousGasLimit

// Reset the allowance to 0; this is needed when running upgrade tests where
// this test runs twice.
tx, err := r.ERC20ZRC20.Approve(r.ZEVMAuth, bank.ContractAddress, big.NewInt(0))
require.NoError(r, err)
receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
utils.RequireTxSuccessful(r, receipt, "Resetting allowance failed")
}()

totalAmount := big.NewInt(1e3)
depositAmount := big.NewInt(500)
higherBalanceAmount := big.NewInt(1001)
higherAllowanceAmount := big.NewInt(501)
spender := r.EVMAddress()

// Get ERC20ZRC20.
txHash := r.DepositERC20WithAmountAndMessage(r.EVMAddress(), totalAmount, []byte{})
utils.WaitCctxMinedByInboundHash(r.Ctx, txHash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout)

// Create a bank contract caller.
bankContract, err := bank.NewIBank(bank.ContractAddress, r.ZEVMClient)
require.NoError(r, err, "Failed to create bank contract caller")

// Cosmos coin balance should be 0 at this point.
cosmosBalance, err := bankContract.BalanceOf(&bind.CallOpts{Context: r.Ctx}, r.ERC20ZRC20Addr, spender)
require.NoError(r, err, "Call bank.BalanceOf()")
require.Equal(r, uint64(0), cosmosBalance.Uint64(), "spender cosmos coin balance should be 0")

// Approve allowance of 500 ERC20ZRC20 tokens for the bank contract. Should pass.
tx, err := r.ERC20ZRC20.Approve(r.ZEVMAuth, bank.ContractAddress, depositAmount)
require.NoError(r, err)
receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
utils.RequireTxSuccessful(r, receipt, "Approve ETHZRC20 bank allowance tx failed")

// Deposit 501 ERC20ZRC20 tokens to the bank contract.
// It's higher than allowance but lower than balance, should fail.
tx, err = bankContract.Deposit(r.ZEVMAuth, r.ERC20ZRC20Addr, higherAllowanceAmount)
require.NoError(r, err, "Call bank.Deposit() with amout higher than allowance")
receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
utils.RequiredTxFailed(r, receipt, "Depositting an amount higher than allowed should fail")

// Approve allowance of 1000 ERC20ZRC20 tokens.
tx, err = r.ERC20ZRC20.Approve(r.ZEVMAuth, bank.ContractAddress, big.NewInt(1e3))
require.NoError(r, err)
receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
utils.RequireTxSuccessful(r, receipt, "Approve ETHZRC20 bank allowance tx failed")

// Deposit 1001 ERC20ZRC20 tokens to the bank contract.
// It's higher than spender balance but within approved allowance, should fail.
tx, err = bankContract.Deposit(r.ZEVMAuth, r.ERC20ZRC20Addr, higherBalanceAmount)
require.NoError(r, err, "Call bank.Deposit() with amout higher than balance")
receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
utils.RequiredTxFailed(r, receipt, "Depositting an amount higher than balance should fail")

// Deposit 500 ERC20ZRC20 tokens to the bank contract. Should pass.
tx, err = bankContract.Deposit(r.ZEVMAuth, r.ERC20ZRC20Addr, depositAmount)
require.NoError(r, err, "Call bank.Deposit() with correct amount")
receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
utils.RequireTxSuccessful(r, receipt, "Depositting a correct amount should pass")

// Check the deposit event.
eventDeposit, err := bankContract.ParseDeposit(*receipt.Logs[0])
require.NoError(r, err, "Parse Deposit event")
require.Equal(r, r.EVMAddress(), eventDeposit.Zrc20Depositor, "Deposit event token should be r.EVMAddress()")
require.Equal(r, r.ERC20ZRC20Addr, eventDeposit.Zrc20Token, "Deposit event token should be ERC20ZRC20Addr")
require.Equal(r, depositAmount, eventDeposit.Amount, "Deposit event amount should be 500")

// Spender: cosmos coin balance should be 500 at this point.
cosmosBalance, err = bankContract.BalanceOf(&bind.CallOpts{Context: r.Ctx}, r.ERC20ZRC20Addr, spender)
require.NoError(r, err, "Call bank.BalanceOf()")
require.Equal(r, uint64(500), cosmosBalance.Uint64(), "spender cosmos coin balance should be 500")

// Bank: ERC20ZRC20 balance should be 500 tokens locked.
bankZRC20Balance, err := r.ERC20ZRC20.BalanceOf(&bind.CallOpts{Context: r.Ctx}, bank.ContractAddress)
require.NoError(r, err, "Call ERC20ZRC20.BalanceOf")
require.Equal(r, uint64(500), bankZRC20Balance.Uint64(), "bank ERC20ZRC20 balance should be 500")

// Try to withdraw 501 ERC20ZRC20 tokens. Should fail.
tx, err = bankContract.Withdraw(r.ZEVMAuth, r.ERC20ZRC20Addr, big.NewInt(501))
require.NoError(r, err, "Error calling bank.withdraw()")
receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
utils.RequiredTxFailed(r, receipt, "Withdrawing more than cosmos coin balance amount should fail")

// Bank: ERC20ZRC20 balance should be 500 tokens locked after a failed withdraw.
// No tokens should be unlocked with a failed withdraw.
bankZRC20Balance, err = r.ERC20ZRC20.BalanceOf(&bind.CallOpts{Context: r.Ctx}, bank.ContractAddress)
require.NoError(r, err, "Call ERC20ZRC20.BalanceOf")
require.Equal(r, uint64(500), bankZRC20Balance.Uint64(), "bank ERC20ZRC20 balance should be 500")

// Try to withdraw 500 ERC20ZRC20 tokens. Should pass.
tx, err = bankContract.Withdraw(r.ZEVMAuth, r.ERC20ZRC20Addr, depositAmount)
require.NoError(r, err, "Error calling bank.withdraw()")
receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
utils.RequireTxSuccessful(r, receipt, "Withdraw correct amount should pass")

// Check the withdraw event.
eventWithdraw, err := bankContract.ParseWithdraw(*receipt.Logs[0])
require.NoError(r, err, "Parse Deposit event")
require.Equal(r, r.EVMAddress(), eventWithdraw.Zrc20Withdrawer, "Deposit event token should be r.EVMAddress()")
require.Equal(r, r.ERC20ZRC20Addr, eventWithdraw.Zrc20Token, "Deposit event token should be ERC20ZRC20Addr")
require.Equal(r, depositAmount, eventWithdraw.Amount, "Deposit event amount should be 500")

// Spender: cosmos coin balance should be 0 at this point.
cosmosBalance, err = bankContract.BalanceOf(&bind.CallOpts{Context: r.Ctx}, r.ERC20ZRC20Addr, spender)
require.NoError(r, err, "Call bank.BalanceOf()")
require.Equal(r, uint64(0), cosmosBalance.Uint64(), "spender cosmos coin balance should be 0")

// Spender: ERC20ZRC20 balance should be 1000 at this point.
zrc20Balance, err := r.ERC20ZRC20.BalanceOf(&bind.CallOpts{Context: r.Ctx}, spender)
require.NoError(r, err, "Call bank.BalanceOf()")
require.Equal(r, uint64(1000), zrc20Balance.Uint64(), "spender ERC20ZRC20 balance should be 1000")

// Bank: ERC20ZRC20 balance should be 0 tokens locked.
bankZRC20Balance, err = r.ERC20ZRC20.BalanceOf(&bind.CallOpts{Context: r.Ctx}, bank.ContractAddress)
require.NoError(r, err, "Call ERC20ZRC20.BalanceOf")
require.Equal(r, uint64(0), bankZRC20Balance.Uint64(), "bank ERC20ZRC20 balance should be 0")
}

func TestPrecompilesBankNonZRC20(r *runner.E2ERunner, args []string) {
require.Len(r, args, 0, "No arguments expected")

// Increase the gasLimit. It's required because of the gas consumed by precompiled functions.
previousGasLimit := r.ZEVMAuth.GasLimit
r.ZEVMAuth.GasLimit = 10_000_000
defer func() {
r.ZEVMAuth.GasLimit = previousGasLimit
}()

spender, bankAddr := r.EVMAddress(), bank.ContractAddress

// Create a bank contract caller.
bankContract, err := bank.NewIBank(bank.ContractAddress, r.ZEVMClient)
require.NoError(r, err, "Failed to create bank contract caller")

// Deposit and approve 50 WZETA for the test.
fbac marked this conversation as resolved.
Show resolved Hide resolved
fbac marked this conversation as resolved.
Show resolved Hide resolved
approveAmount := big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(50))
r.DepositAndApproveWZeta(approveAmount)

// Non ZRC20 balanceOf check should fail.
_, err = bankContract.BalanceOf(&bind.CallOpts{Context: r.Ctx}, r.WZetaAddr, spender)
require.Error(r, err, "bank.balanceOf() should error out when checking for non ZRC20 balance")
require.Contains(
r,
err.Error(),
"invalid token 0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf: token is not a whitelisted ZRC20",
"Error should be 'token is not a whitelisted ZRC20'",
)

// Allow the bank contract to spend 25 WZeta tokens.
tx, err := r.WZeta.Approve(r.ZEVMAuth, bankAddr, big.NewInt(25))
require.NoError(r, err, "Error approving allowance for bank contract")
receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
require.EqualValues(r, uint64(1), receipt.Status, "approve allowance tx failed")
fbac marked this conversation as resolved.
Show resolved Hide resolved

// Check the allowance of the bank in WZeta tokens. Should be 25.
allowance, err := r.WZeta.Allowance(&bind.CallOpts{Context: r.Ctx}, spender, bankAddr)
require.NoError(r, err, "Error retrieving bank allowance")
require.EqualValues(r, uint64(25), allowance.Uint64(), "Error allowance for bank contract")

// Call Deposit with 25 Non ZRC20 tokens. Should fail.
tx, err = bankContract.Deposit(r.ZEVMAuth, r.WZetaAddr, big.NewInt(25))
require.NoError(r, err, "Error calling bank.deposit()")
receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
require.Equal(r, uint64(0), receipt.Status, "Non ZRC20 deposit should fail")

// Call Withdraw with 25 on ZRC20 tokens. Should fail.
tx, err = bankContract.Withdraw(r.ZEVMAuth, r.WZetaAddr, big.NewInt(25))
require.NoError(r, err, "Error calling bank.withdraw()")
receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
require.Equal(r, uint64(0), receipt.Status, "Non ZRC20 withdraw should fail")
}
4 changes: 2 additions & 2 deletions e2e/e2etests/test_rate_limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func createAndWaitWithdraws(r *runner.E2ERunner, withdrawType withdrawType, with
return err
}

duration := time.Now().Sub(startTime).Seconds()
duration := time.Since(startTime).Seconds()
block, err := r.ZEVMClient.BlockNumber(r.Ctx)
if err != nil {
return fmt.Errorf("error getting block number: %w", err)
Expand Down Expand Up @@ -155,7 +155,7 @@ func waitForWithdrawMined(
}

// record the time for completion
duration := time.Now().Sub(startTime).Seconds()
duration := time.Since(startTime).Seconds()
block, err := r.ZEVMClient.BlockNumber(ctx)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion e2e/e2etests/test_stress_btc_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func monitorBTCDeposit(r *runner.E2ERunner, hash *chainhash.Hash, index int, sta
cctx.Index,
)
}
timeToComplete := time.Now().Sub(startTime)
timeToComplete := time.Since(startTime)
r.Logger.Print("index %d: deposit cctx success in %s", index, timeToComplete.String())

return nil
Expand Down
2 changes: 1 addition & 1 deletion e2e/e2etests/test_stress_btc_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func monitorBTCWithdraw(r *runner.E2ERunner, tx *ethtypes.Transaction, index int
cctx.Index,
)
}
timeToComplete := time.Now().Sub(startTime)
timeToComplete := time.Since(startTime)
r.Logger.Print("index %d: withdraw cctx success in %s", index, timeToComplete.String())

return nil
Expand Down
2 changes: 1 addition & 1 deletion e2e/e2etests/test_stress_eth_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func monitorEtherDeposit(r *runner.E2ERunner, hash ethcommon.Hash, index int, st
cctx.Index,
)
}
timeToComplete := time.Now().Sub(startTime)
timeToComplete := time.Since(startTime)
r.Logger.Print("index %d: deposit cctx success in %s", index, timeToComplete.String())

return nil
Expand Down
2 changes: 1 addition & 1 deletion e2e/e2etests/test_stress_eth_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func monitorEtherWithdraw(r *runner.E2ERunner, tx *ethtypes.Transaction, index i
cctx.Index,
)
}
timeToComplete := time.Now().Sub(startTime)
timeToComplete := time.Since(startTime)
r.Logger.Print("index %d: withdraw cctx success in %s", index, timeToComplete.String())

return nil
Expand Down
4 changes: 4 additions & 0 deletions e2e/utils/require.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,9 @@ func errSuffix(msgAndArgs ...any) string {

template := "; " + msgAndArgs[0].(string)

if len(msgAndArgs) == 1 {
return template
}

return fmt.Sprintf(template, msgAndArgs[1:])
}
Loading
Loading