Skip to content

Commit

Permalink
Merge pull request #641 from ava-labs/tests-use-permissionless-l1
Browse files Browse the repository at this point in the history
Tests use permissionless l1
  • Loading branch information
cam-schultz authored Nov 22, 2024
2 parents d4ce977 + 24dd273 commit 654e648
Show file tree
Hide file tree
Showing 47 changed files with 4,662 additions and 1,368 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions contracts/validator-manager/ERC20TokenStakingManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ contract ERC20TokenStakingManager is
return _initializeDelegatorRegistration(validationID, _msgSender(), delegationAmount);
}

/**
* @notice Returns the ERC20 token being staked
*/
function erc20() external view returns (IERC20Mintable) {
return _getERC20StakingManagerStorage()._token;
}

/**
* @notice See {PoSValidatorManager-_lock}
* Note: Must be guarded with reentrancy guard for safe transfer from.
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module github.com/ava-labs/teleporter
go 1.22.8

require (
github.com/ava-labs/avalanchego v1.12.0-initial-poc.9
github.com/ava-labs/avalanchego v1.12.0-fuji
github.com/supranational/blst v0.3.13 // indirect
)

require (
github.com/ava-labs/awm-relayer v1.4.1-0.20241114185359-5cd5a982832d
github.com/ava-labs/subnet-evm v0.6.12-rc.0
github.com/ava-labs/awm-relayer v1.4.1-0.20241121212846-90ad76f595d6
github.com/ava-labs/subnet-evm v0.6.12
github.com/ethereum/go-ethereum v1.13.14
github.com/onsi/ginkgo/v2 v2.22.0
github.com/onsi/gomega v1.35.1
Expand All @@ -26,7 +26,7 @@ require (
github.com/DataDog/zstd v1.5.2 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/ava-labs/coreth v0.13.8 // indirect
github.com/ava-labs/coreth v0.13.9-rc.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/ava-labs/avalanchego v1.12.0-initial-poc.9 h1:dQhb+KlPoud+AkRV3A0suKCTodlUSzflGcZElESeVKo=
github.com/ava-labs/avalanchego v1.12.0-initial-poc.9/go.mod h1:86tO6F1FT8emclUwdQ2WCwAtAerqjm5A4IbV6XxNUyM=
github.com/ava-labs/awm-relayer v1.4.1-0.20241114185359-5cd5a982832d h1:Sgn2uD8axkyafPty1iY2ZkPVmT2eVoYgJEAPxkYNYqw=
github.com/ava-labs/awm-relayer v1.4.1-0.20241114185359-5cd5a982832d/go.mod h1:xrZ8FX+mC0PBvUL9yTVqmvCIA9rYYfmdDDY9oTTI6n8=
github.com/ava-labs/coreth v0.13.8 h1:f14X3KgwHl9LwzfxlN6S4bbn5VA2rhEsNnHaRLSTo/8=
github.com/ava-labs/coreth v0.13.8/go.mod h1:t3BSv/eQv0AlDPMfEDCMMoD/jq1RkUsbFzQAFg5qBcE=
github.com/ava-labs/subnet-evm v0.6.12-rc.0 h1:I7s4QkUO8bjg+JB/KTwrmDH8Q2mQYVTKF8mFUSDqk+E=
github.com/ava-labs/subnet-evm v0.6.12-rc.0/go.mod h1:Pf122zopW1fELpOsw0PrdX4u6K/4VOWU2p5C3cHsYAs=
github.com/ava-labs/avalanchego v1.12.0-fuji h1:o/GbXrqW9CAXu2jX/a1dZtvFiiSVCWomJZyxF4hCQOA=
github.com/ava-labs/avalanchego v1.12.0-fuji/go.mod h1:yhD5dpZyStIVbxQ550EDi5w5SL7DQ/xGE6TIxosb7U0=
github.com/ava-labs/awm-relayer v1.4.1-0.20241121212846-90ad76f595d6 h1:diUjomjOuTFwk3Z2FUxA94PzLZy+6ONfZVuaRhDrtmA=
github.com/ava-labs/awm-relayer v1.4.1-0.20241121212846-90ad76f595d6/go.mod h1:mNQitNat92izhmMF0++6/REQQI3W+h0oRAnLl3bs/6I=
github.com/ava-labs/coreth v0.13.9-rc.1 h1:qIICpC/OZGYUP37QnLgIqqwGmxnLwLpZaUlqJNI85vU=
github.com/ava-labs/coreth v0.13.9-rc.1/go.mod h1:7aMsRIo/3GBE44qWZMjnfqdqfcfZ5yShTTm2LObLaYo=
github.com/ava-labs/subnet-evm v0.6.12 h1:jL3FmjdFcNfS0qwbehwN6DkAg9y7zexB1riiGBxRsM0=
github.com/ava-labs/subnet-evm v0.6.12/go.mod h1:vffwL4UqAh7ibpWjveUuUhamm3a9w75q92bG5vXdX5k=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down
39 changes: 24 additions & 15 deletions scripts/abi_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export ARCH=$(uname -m)
echo "ARCH set to $ARCH"

DEFAULT_CONTRACT_LIST="TeleporterMessenger TeleporterRegistry ExampleERC20 ExampleRewardCalculator TestMessenger ValidatorSetSig NativeTokenStakingManager ERC20TokenStakingManager PoAValidatorManager
TokenHome TokenRemote ERC20TokenHome ERC20TokenHomeUpgradeable ERC20TokenRemote ERC20TokenRemoteUpgradeable NativeTokenHome NativeTokenHomeUpgradeable NativeTokenRemote NativeTokenRemoteUpgradeable WrappedNativeToken MockERC20SendAndCallReceiver MockNativeSendAndCallReceiver ExampleERC20Decimals"

TokenHome TokenRemote ERC20TokenHome ERC20TokenHomeUpgradeable ERC20TokenRemote ERC20TokenRemoteUpgradeable NativeTokenHome NativeTokenHomeUpgradeable NativeTokenRemote NativeTokenRemoteUpgradeable
WrappedNativeToken MockERC20SendAndCallReceiver MockNativeSendAndCallReceiver ExampleERC20Decimals IValidatorManager IPoSValidatorManager"
PROXY_LIST="TransparentUpgradeableProxy ProxyAdmin"

SUBNET_EVM_LIST="INativeMinter"
Expand Down Expand Up @@ -139,21 +139,30 @@ function generate_bindings() {

# Filter out the contract we are generating bindings for
filtered_contracts=$(remove_matching_string $contracts $contract_name)

# Filter out external libraries
for lib in $EXTERNAL_LIBS; do
filtered_contracts=$(remove_matching_string $filtered_contracts $lib)
done

echo "Generating Go bindings for $contract_name..."

gen_path=$TELEPORTER_PATH/abi-bindings/go/$dir/$contract_name
mkdir -p $gen_path

$GOPATH/bin/abigen --pkg $(convertToLower $contract_name) \
--combined-json $combined_json \
--type $contract_name \
--out $gen_path/$contract_name.go \
--exc $filtered_contracts
echo "Generating Go bindings for $contract_name..."

if [ -z "$filtered_contracts" ]; then
echo "No external libraries found"
$GOPATH/bin/abigen --pkg $(convertToLower $contract_name) \
--combined-json $combined_json \
--type $contract_name \
--out $gen_path/$contract_name.go
else
# Filter out external libraries
for lib in $EXTERNAL_LIBS; do
filtered_contracts=$(remove_matching_string $filtered_contracts $lib)
done

$GOPATH/bin/abigen --pkg $(convertToLower $contract_name) \
--combined-json $combined_json \
--type $contract_name \
--out $gen_path/$contract_name.go \
--exc $filtered_contracts
fi

echo "Done generating Go bindings for $contract_name."
done
}
Expand Down
8 changes: 4 additions & 4 deletions tests/flows/governance/validator_set_sig.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package governance
import (
"context"
"math/big"
"time"

"github.com/ava-labs/subnet-evm/accounts/abi/bind"
validatorsetsig "github.com/ava-labs/teleporter/abi-bindings/go/governance/ValidatorSetSig"
Expand Down Expand Up @@ -141,9 +140,6 @@ func ValidatorSetSig(network *localnetwork.LocalNetwork) {

// Restart nodes with new chain config
network.SetChainConfigs(chainConfigs)
restartCtx, cancel := context.WithTimeout(ctx, time.Second*30)
defer cancel()
network.RestartNodes(restartCtx, nil)

// ************************************************************************************************
// Test Case 1: validatorChain (subnetB) != targetChain (subnetA)
Expand All @@ -157,6 +153,7 @@ func ValidatorSetSig(network *localnetwork.LocalNetwork) {
validatorSetSigContractAddress,
fundedKey,
&offchainMessages[0],
network.GetSignatureAggregator(),
true,
)

Expand All @@ -179,6 +176,7 @@ func ValidatorSetSig(network *localnetwork.LocalNetwork) {
validatorSetSigContractAddress,
fundedKey,
&offchainMessages[0],
network.GetSignatureAggregator(),
false,
)

Expand All @@ -195,6 +193,7 @@ func ValidatorSetSig(network *localnetwork.LocalNetwork) {
validatorSetSigContractAddress,
fundedKey,
&offchainMessages[1],
network.GetSignatureAggregator(),
true,
)

Expand Down Expand Up @@ -226,6 +225,7 @@ func ValidatorSetSig(network *localnetwork.LocalNetwork) {
validatorSetSigContractAddress2,
fundedKey,
&offchainMessages[2],
network.GetSignatureAggregator(),
true,
)

Expand Down
5 changes: 5 additions & 0 deletions tests/flows/ictt/erc20_home_erc20_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func ERC20TokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, teleport
subnetAInfo,
erc20TokenRemoteAddress,
fundedKey,
network.GetSignatureAggregator(),
)

// Generate new recipient to receive transferred tokens
Expand Down Expand Up @@ -117,6 +118,8 @@ func ERC20TokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, teleport
subnetAInfo,
true,
fundedKey,
nil,
network.GetSignatureAggregator(),
)

utils.CheckERC20TokenRemoteWithdrawal(
Expand Down Expand Up @@ -168,6 +171,8 @@ func ERC20TokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, teleport
cChainInfo,
true,
fundedKey,
nil,
network.GetSignatureAggregator(),
)

utils.CheckERC20TokenHomeWithdrawal(
Expand Down
6 changes: 6 additions & 0 deletions tests/flows/ictt/erc20_home_erc20_remote_multihop.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func ERC20TokenHomeERC20TokenRemoteMultiHop(network *localnetwork.LocalNetwork,
subnetAInfo,
erc20TokenRemoteAddressA,
fundedKey,
network.GetSignatureAggregator(),
)
utils.RegisterERC20TokenRemoteOnHome(
ctx,
Expand All @@ -104,6 +105,7 @@ func ERC20TokenHomeERC20TokenRemoteMultiHop(network *localnetwork.LocalNetwork,
subnetBInfo,
erc20TokenRemoteAddressB,
fundedKey,
network.GetSignatureAggregator(),
)

// Generate new recipient to receive transferred tokens
Expand Down Expand Up @@ -142,6 +144,8 @@ func ERC20TokenHomeERC20TokenRemoteMultiHop(network *localnetwork.LocalNetwork,
subnetAInfo,
true,
fundedKey,
nil,
network.GetSignatureAggregator(),
)

utils.CheckERC20TokenRemoteWithdrawal(
Expand Down Expand Up @@ -175,6 +179,7 @@ func ERC20TokenHomeERC20TokenRemoteMultiHop(network *localnetwork.LocalNetwork,
cChainInfo,
transferredAmount,
secondaryFeeAmount,
network.GetSignatureAggregator(),
)

// Multi-hop transfer back to Subnet A
Expand All @@ -195,5 +200,6 @@ func ERC20TokenHomeERC20TokenRemoteMultiHop(network *localnetwork.LocalNetwork,
cChainInfo,
transferredAmount,
secondaryFeeAmount,
network.GetSignatureAggregator(),
)
}
7 changes: 7 additions & 0 deletions tests/flows/ictt/erc20_home_erc20_remote_send_and_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func ERC20TokenHomeERC20TokenRemoteSendAndCall(
subnetAInfo,
erc20TokenRemoteAddress,
fundedKey,
network.GetSignatureAggregator(),
)

// Generate new recipient to receive transferred tokens
Expand Down Expand Up @@ -145,6 +146,8 @@ func ERC20TokenHomeERC20TokenRemoteSendAndCall(
subnetAInfo,
true,
fundedKey,
nil,
network.GetSignatureAggregator(),
)

event, err := utils.GetEventFromLogs(receipt.Logs, erc20TokenRemote.ParseCallSucceeded)
Expand Down Expand Up @@ -195,6 +198,8 @@ func ERC20TokenHomeERC20TokenRemoteSendAndCall(
subnetAInfo,
true,
fundedKey,
nil,
network.GetSignatureAggregator(),
)

utils.CheckERC20TokenRemoteWithdrawal(
Expand Down Expand Up @@ -252,6 +257,8 @@ func ERC20TokenHomeERC20TokenRemoteSendAndCall(
cChainInfo,
true,
fundedKey,
nil,
network.GetSignatureAggregator(),
)

homeEvent, err := utils.GetEventFromLogs(receipt.Logs, erc20TokenHome.ParseCallSucceeded)
Expand Down
5 changes: 5 additions & 0 deletions tests/flows/ictt/erc20_home_native_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func ERC20TokenHomeNativeTokenRemote(network *localnetwork.LocalNetwork, telepor
utils.GetTokenMultiplier(decimalsShift),
multiplyOnRemote,
fundedKey,
network.GetSignatureAggregator(),
)

utils.AddCollateralToERC20TokenHome(
Expand Down Expand Up @@ -136,6 +137,8 @@ func ERC20TokenHomeNativeTokenRemote(network *localnetwork.LocalNetwork, telepor
subnetAInfo,
true,
fundedKey,
nil,
network.GetSignatureAggregator(),
)

// Verify the recipient received the tokens
Expand Down Expand Up @@ -170,6 +173,8 @@ func ERC20TokenHomeNativeTokenRemote(network *localnetwork.LocalNetwork, telepor
cChainInfo,
true,
fundedKey,
nil,
network.GetSignatureAggregator(),
)

// Check that the recipient received the tokens
Expand Down
8 changes: 8 additions & 0 deletions tests/flows/ictt/erc20_home_native_remote_multihop.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func ERC20TokenHomeNativeTokenRemoteMultiHop(network *localnetwork.LocalNetwork,
utils.GetTokenMultiplier(decimalsShift),
multiplyOnRemote,
fundedKey,
network.GetSignatureAggregator(),
)

collateralAmountB := utils.RegisterTokenRemoteOnHome(
Expand All @@ -103,6 +104,7 @@ func ERC20TokenHomeNativeTokenRemoteMultiHop(network *localnetwork.LocalNetwork,
utils.GetTokenMultiplier(decimalsShift),
multiplyOnRemote,
fundedKey,
network.GetSignatureAggregator(),
)

// Add collateral for both NativeTokenDestinations
Expand Down Expand Up @@ -168,6 +170,8 @@ func ERC20TokenHomeNativeTokenRemoteMultiHop(network *localnetwork.LocalNetwork,
subnetAInfo,
true,
fundedKey,
nil,
network.GetSignatureAggregator(),
)

// Verify the recipient received the tokens
Expand Down Expand Up @@ -203,6 +207,8 @@ func ERC20TokenHomeNativeTokenRemoteMultiHop(network *localnetwork.LocalNetwork,
subnetBInfo,
true,
fundedKey,
nil,
network.GetSignatureAggregator(),
)

// Verify the recipient received the tokens
Expand All @@ -226,6 +232,7 @@ func ERC20TokenHomeNativeTokenRemoteMultiHop(network *localnetwork.LocalNetwork,
cChainInfo,
amountToSend,
big.NewInt(0),
network.GetSignatureAggregator(),
)

// Multi-hop transfer back to Subnet A
Expand All @@ -244,5 +251,6 @@ func ERC20TokenHomeNativeTokenRemoteMultiHop(network *localnetwork.LocalNetwork,
cChainInfo,
amountToSend,
secondaryFeeAmount,
network.GetSignatureAggregator(),
)
}
5 changes: 5 additions & 0 deletions tests/flows/ictt/native_home_erc20_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func NativeTokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, telepor
subnetAInfo,
erc20TokenRemoteAddress,
fundedKey,
network.GetSignatureAggregator(),
)

// Generate new recipient to receive transferred tokens
Expand Down Expand Up @@ -114,6 +115,8 @@ func NativeTokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, telepor
subnetAInfo,
true,
fundedKey,
nil,
network.GetSignatureAggregator(),
)

utils.CheckERC20TokenRemoteWithdrawal(
Expand Down Expand Up @@ -165,6 +168,8 @@ func NativeTokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, telepor
cChainInfo,
true,
fundedKey,
nil,
network.GetSignatureAggregator(),
)

// Check that the recipient received the tokens
Expand Down
Loading

0 comments on commit 654e648

Please sign in to comment.