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

Tests use permissionless l1 #641

Merged
merged 37 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
651ee90
basic teleporter test passing
cam-schultz Nov 7, 2024
9a46f4f
bind validator manager interfaces
cam-schultz Nov 7, 2024
9012825
consolidate deploy methods
cam-schultz Nov 7, 2024
a47a345
consolidate validator manager function call helpers
cam-schultz Nov 7, 2024
fb8af19
convert subnet on network creation
cam-schultz Nov 8, 2024
68af482
build fix
cam-schultz Nov 8, 2024
ad53a47
consolidate init and deploy helpers
cam-schultz Nov 8, 2024
f4d418d
vdr churn test uses manager
cam-schultz Nov 8, 2024
41b1f13
fix: use type param
cam-schultz Nov 8, 2024
8a21d86
vdr churn uses manager
cam-schultz Nov 8, 2024
0d8309e
collect signatures using sigagg
cam-schultz Nov 8, 2024
2995f90
skip registry test
cam-schultz Nov 8, 2024
1c9e89f
consolidate delegation helpers
cam-schultz Nov 8, 2024
064f849
convert subnet supports proxy & all manager types
cam-schultz Nov 9, 2024
1fd68ff
lint
cam-schultz Nov 9, 2024
c1fc63c
parameterize initial subnet weights
cam-schultz Nov 9, 2024
f53242c
wait to allow churn period to roll over
cam-schultz Nov 9, 2024
f7629d2
remove bootstrap vdrs from subnet
cam-schultz Nov 12, 2024
8e4025d
go mod tidy
cam-schultz Nov 12, 2024
9c783f5
cleanup
cam-schultz Nov 12, 2024
19f1047
remove unused method
cam-schultz Nov 13, 2024
5b3a79c
parameterize number of primary network validators
cam-schultz Nov 13, 2024
fdd3e57
depend on local relayer
cam-schultz Nov 13, 2024
e632c55
remove local dep
cam-schultz Nov 13, 2024
ea2c4d5
wip
cam-schultz Nov 15, 2024
106a220
wip
cam-schultz Nov 20, 2024
d0fa517
p2p tests passing
cam-schultz Nov 21, 2024
4dab87e
cleanup
cam-schultz Nov 21, 2024
c3e06c8
awm-relayer compat
cam-schultz Nov 21, 2024
452b448
revert local awm-relayer dependent changes
cam-schultz Nov 21, 2024
34d761f
Merge branch 'main' into tests-use-permissionless-l1
cam-schultz Nov 21, 2024
5e57afc
initialize with uptime chain
cam-schultz Nov 21, 2024
1bd1eda
build fix
cam-schultz Nov 21, 2024
226937a
bump to ava go v1.12.0-fuji
cam-schultz Nov 21, 2024
997097c
Merge branch 'main' into tests-use-permissionless-l1
cam-schultz Nov 21, 2024
47ee410
feedback
cam-schultz Nov 21, 2024
24dd273
Merge branch 'main' into tests-use-permissionless-l1
cam-schultz Nov 22, 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

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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this to allow the deployment utility to return an IPoSValidatorManager object, and recover the ERC20 instance after the fact. It also seems reasonable that use cases will emerge that will want to access the staked asset programatically.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This addresses an edge case in which the only contract in the combined JSON is the contract to compile itself. In that case, there are no contracts to exclude.

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