From b668c2432ba28277e7d5fba2d898f94f627197a9 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Sat, 26 Aug 2023 06:02:34 +0000 Subject: [PATCH 01/80] initial draft example for teleporter/warp registry --- .../ERC20Bridge/ERC20Bridge.sol | 36 +++++--- .../src/Teleporter/TeleporterRegistry.sol | 80 ++++++++++++++++++ contracts/src/WarpProtocolRegistry.sol | 84 +++++++++++++++++++ go.work.sum | 7 ++ 4 files changed, 195 insertions(+), 12 deletions(-) create mode 100644 contracts/src/Teleporter/TeleporterRegistry.sol create mode 100644 contracts/src/WarpProtocolRegistry.sol diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol index 543ddab2e..6f7c5fb40 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol @@ -14,6 +14,7 @@ import "@subnet-evm-contracts/interfaces/IWarpMessenger.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; +import "../../Teleporter/TeleporterRegistry.sol"; struct TokenID { bytes32 chainID; @@ -45,7 +46,9 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { bytes32 public immutable currentChainID; // Used for sending an receiving Teleporter messages. - ITeleporterMessenger public immutable teleporterMessenger; + ITeleporterMessenger public teleporterMessenger; + TeleporterReigstry public immutable teleporterRegistry; + uint256 public constant TELEPORTER_VERSION; // Tracks which bridge tokens have been submitted to be created other bridge instances. // (destinationChainID, destinationBridgeAddress) -> nativeTokenContract -> tokenCreationSubmitted @@ -77,16 +80,28 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { * @dev Initializes the Teleporter messenger used for sending and receiving messages, * and initializes the current chain ID. */ - constructor(address teleporterMessengerAddress) { + constructor(address teleporterRegistryAddress) { require( - teleporterMessengerAddress != address(0), - "Invalid teleporter messenger address" + teleporterRegistryAddress != address(0), + "Invalid teleporter registry address" ); - teleporterMessenger = ITeleporterMessenger(teleporterMessengerAddress); + teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); + teleporterMessenger = teleporterRegistry.getTeleporterVersion( + TELEPORTER_VERSION + ); + teleporterRegistry.setAllowedVersions([TELEPORTER_VERSION]); currentChainID = WarpMessenger(WARP_PRECOMPILE_ADDRESS) .getBlockchainID(); } + function setTeleporterVersion(uint256 version) external { + teleporterMessenger = teleporterRegistry.getTeleporterVersion(version); + } + + function setAllowedTeleporterVersions(uint256[] versions) external { + teleporterRegistry.setAllowedVersions(versions); + } + /** * @dev See {IERC20Bridge-bridgeTokens}. * @@ -268,7 +283,10 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { bytes calldata message ) external { // Only allow the Teleporter messenger to deliver messages. - require(msg.sender == address(teleporterMessenger), "Unauthorized."); + require( + teleporterRegistry.isAllowedTeleporterSender(msg.msg.sender), + "Unauthorized." + ); // Decode the payload to recover the action and corresponding function parameters (BridgeAction action, bytes memory actionData) = abi.decode( @@ -451,9 +469,6 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { address recipient, uint256 amount ) private nonReentrant { - // Only allow the Teleporter messenger to deliver messages. - require(msg.sender == address(teleporterMessenger), "Unauthorized."); - // The recipient cannot be the zero address. require( recipient != address(0), @@ -491,9 +506,6 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { uint256 totalAmount, uint256 secondaryFeeAmount ) private nonReentrant { - // Only allow the teleporter messenger to deliver messages. - require(msg.sender == address(teleporterMessenger), "Unauthorized."); - // Neither the recipient nor the destination bridge can be the zero address. require( recipient != address(0), diff --git a/contracts/src/Teleporter/TeleporterRegistry.sol b/contracts/src/Teleporter/TeleporterRegistry.sol new file mode 100644 index 000000000..0af034b8e --- /dev/null +++ b/contracts/src/Teleporter/TeleporterRegistry.sol @@ -0,0 +1,80 @@ +// (c) 2023, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +// SPDX-License-Identifier: BSD-3-Clause + +pragma solidity 0.8.18; + +import "../WarpProtocolRegistry.sol"; +import "./ITeleporterMessenger.sol"; + +contract TeleporterRegistry is WarpProtocolRegistry { + mapping(address => uint256[] versions) private _allowedVersions; + mapping(address => mapping(address => bool)) private _allowedSenders; + mapping(address => bool) private _allowedLatestVersion; + + function getTeleporterVersion( + uint256 version + ) external view returns (ITeleporterMessenger) { + return ITeleporterMessenger(_getProtocolAddress(version)); + } + + function setAllowedVersions(uint256[] versions) external { + // Remove all previous versions that were allowed + for (uint256 i = 0; i < _allowedVersions[msg.sender].length; i++) { + delete _allowedSenders[msg.sender][ + _getProtocolAddress(_allowedVersions[msg.sender][i]) + ]; + } + + // Add all new versions that are allowed + for (uint256 i = 0; i < versions.length; i++) { + require( + versions[i] < _latestVersion, + "TeleporterRegistry: invalid version" + ); + require( + _allowedSenders[msg.sender][_getProtocolAddress(versions[i])] == + false, + "TeleporterRegistry: duplicate version" + ); + + _allowedSenders[msg.sender][ + _getProtocolAddress(versions[i]) + ] = true; + } + _allowedVersions[msg.sender] = versions; + } + + function allowLatestVersion(bool allow) external { + _allowedLatestVersion[msg.sender] = allow; + } + + function isAllowedTeleporterSender( + address sender + ) external view returns (bool) { + if ( + _allowedLatestVersion[msg.sender] && + sender == _getProtocolAddress(_latestVersion) + ) { + return true; + } + + // If no allowed versions, then we always return false + // require( + // _allowedVersions[msg.sender].length > 0, + // "TeleporterRegistry: no allowed versions" + // ); + require(sender != address(0), "TeleporterRegistry: invalid sender"); + + return _allowedSenders[msg.sender][sender]; + } + + function getLatestTeleporterVersion() + external + view + returns (ITeleporterMessenger) + { + return ITeleporterMessenger(_getProtocolAddress(_latestVersion)); + } +} diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol new file mode 100644 index 000000000..fc2f68537 --- /dev/null +++ b/contracts/src/WarpProtocolRegistry.sol @@ -0,0 +1,84 @@ +// (c) 2023, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +// SPDX-License-Identifier: BSD-3-Clause + +pragma solidity 0.8.18; + +import "@subnet-evm-contracts/interfaces/IWarpMessenger.sol"; +import "@openzeppelin/contracts/utils/Address.sol"; + +abstract contract WarpProtocolRegistry { + // Address that the out-of-band warp message sets as the "source" address. + // The address is obviously not owned by any EOA or smart contract account, so it + // can not possibly be the source address of any other warp message emitted by the VM. + bytes32 public constant VALIDATORS_SOURCE_ADDRESS = + 0x0000000000000000000000000000000000000000000000000000000000000000; + + WarpMessenger public constant WARP_MESSENGER = + WarpMessenger(0x0200000000000000000000000000000000000005); + + bytes32 private immutable _chainID; + + uint256 private _latestVersion; + + mapping(uint256 version => address) private _protocolAddresses; + + constructor() { + _latestVersion = 0; + _chainID = WARP_MESSENGER.getBlockchainID(); + } + + function addProtocolVersion() external virtual { + (WarpMessage memory message, bool exists) = WARP_MESSENGER + .getVerifiedWarpMessage(); + require(exists, "WarpProtocolRegistry: no warp message"); + require( + message.originChainID == _chainID, + "WarpProtocolRegistry: invalid origin chain ID" + ); + require( + message.originSenderAddress == VALIDATORS_SOURCE_ADDRESS, + "WarpProtocolRegistry: invalid origin sender address" + ); + require( + message.destinationChainID == _chainID, + "WarpProtocolRegistry: invalid destination chain ID" + ); + require( + message.destinationAddress == address(this), + "WarpProtocolRegistry: invalid destination address" + ); + + (uint256 nonce, address protocolAddress) = abi.decode( + message.payload, + (uint256, address) + ); + + require(nonce == _latestVersion, "WarpProtocolRegistry: invalid nonce"); + _latestVersion++; + + require( + Address.isContract(protocolAddress), + "WarpProtocolRegistry: not a contract" + ); + + _protocolAddresses[_latestVersion] = protocolAddress; + } + + function getProtocolAddress( + uint256 version + ) external view virtual returns (address) { + return _getProtocolAddress(version); + } + + function _getProtocolAddress( + uint256 version + ) internal view returns (address) { + require( + 0 < version <= _latestVersion, + "WarpProtocolRegistry: invalid version" + ); + return _protocolAddresses[version]; + } +} diff --git a/go.work.sum b/go.work.sum index 1cf9f391b..da99f7975 100644 --- a/go.work.sum +++ b/go.work.sum @@ -548,12 +548,15 @@ github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwc github.com/apache/arrow/go/arrow v0.0.0-20191024131854-af6fa24be0db h1:nxAtV4VajJDhKysp2kdcJZsq8Ss1xSA0vZTkVHHJd0E= github.com/armon/go-metrics v0.3.10 h1:FR+drcQStOe+32sYyJYyZ7FIdgoGGBnwLl+flodp8Uo= github.com/ava-labs/avalanche-ledger-go v0.0.13 h1:YTdaSuaZS/1ct1RGirBEJeo2tiSfVeJGaE12XtUSGnE= +github.com/ava-labs/avalanche-network-runner v1.7.1 h1:XRC2NcchESSxSlJEgb47lAkTG5eF1t2sMs8CoJKeAuE= +github.com/ava-labs/avalanche-network-runner v1.7.1/go.mod h1:q/2ws64daRXXsiq08bVA1iESRY1CNOQQQDKPeMauZrc= github.com/ava-labs/avalanche-network-runner-sdk v0.3.0 h1:TVi9JEdKNU/RevYZ9PyW4pULbEdS+KQDA9Ki2DUvuAs= github.com/ava-labs/avalanche-network-runner-sdk v0.3.0/go.mod h1:SgKJvtqvgo/Bl/c8fxEHCLaSxEbzimYfBopcfrajxQk= github.com/ava-labs/avalanchego v1.7.18/go.mod h1:Jo21X9sMxvkZNoo8B7GJbbelGrIJbwFPcMhwanink68= github.com/ava-labs/avalanchego v1.9.1-0.20221020192610-3761bc705fbf/go.mod h1:C/uaJZ1UHGhbOHwKckmQugsJYiK+1A9G2nVO8iAU5fw= github.com/ava-labs/avalanchego v1.9.1-rc.3/go.mod h1:qQJugll8yY/YKiy/Eutjwjn/vSo3ZRoST+jbinfM1G0= github.com/ava-labs/avalanchego v1.10.5-rc.1/go.mod h1:azK88lcF5jwcPSp//RKUh2VncmrZZUrKu998C7no4Ys= +github.com/ava-labs/avalanchego v1.10.5/go.mod h1:rXAX4UaE9ORIEJcMyzN6ibv4rnLwv0zUIPLmzA0MCno= github.com/ava-labs/avalanchego v1.10.6-rc.4/go.mod h1:e8LdGy0xM+QejpMoEK6wOFu2O5HMlAHPJiBPjhoTG78= github.com/ava-labs/avalanchego v1.10.8 h1:fUudA4J37y8wyNG3iiX0kpoZXunsWpCgvsGDgIsi0NY= github.com/ava-labs/coreth v0.11.5-rc.0 h1:EQ4MVWFrG+gtqtTFgquL4yoZnCNA+kbMVGWAnsTMeBE= @@ -562,6 +565,7 @@ github.com/ava-labs/coreth v0.11.7-rc.3 h1:+GaXmcqzBDd6jFJcPrAQ/RKEFJlqCVcdTF/Q5 github.com/ava-labs/coreth v0.11.7-rc.3/go.mod h1:uIKJtaUX5TI60IS+DpYT8SLXLM2JydgngMF+9q8YjXM= github.com/ava-labs/coreth v0.11.8-rc.3 h1:pS+OTFPc9edcFuCJIQGn5TdyAZncT9Hhs9jCcmm7+PM= github.com/ava-labs/coreth v0.11.8-rc.3/go.mod h1:pc44yvJD4jTPIwkPI64pUXyJDvQ/UAqkbmhXOx78PXA= +github.com/ava-labs/coreth v0.12.4-rc.4/go.mod h1:LZ2jvvEjotqna/qZwzeiA8zO9IIpS992DyWNZGbk7CA= github.com/ava-labs/coreth v0.12.5-rc.1 h1:rLJ6mT/44jgc+vPpKaspGpxDIdQGLkSK6wDSmKgYPxY= github.com/ava-labs/coreth v0.12.5-rc.1/go.mod h1:K7Xm2jqx90wxKZXfLvkLEL+zlM5843gGq9XkqVDwKds= github.com/ava-labs/ledger-avalanche/go v0.0.0-20230105152938-00a24d05a8c7 h1:EdxD90j5sClfL5Ngpz2TlnbnkNYdFPDXa0jDOjam65c= @@ -644,6 +648,7 @@ github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go. github.com/envoyproxy/go-control-plane v0.11.0/go.mod h1:VnHyVMpzcLvCFt9yUz1UnCwHLhwx1WguiVDV7pTG/tI= github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A= github.com/envoyproxy/protoc-gen-validate v0.10.0/go.mod h1:DRjgyB0I43LtJapqN6NiRwroiAU2PaFuvk/vjgh61ss= +github.com/ethereum/go-ethereum v1.11.4/go.mod h1:it7x0DWnTDMfVFdXcU6Ti4KEFQynLHVRarcSlPr0HBo= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= @@ -663,8 +668,10 @@ github.com/go-chi/chi/v5 v5.0.0 h1:DBPx88FjZJH3FsICfDAfIfnb7XxKIYVGG6lOPlhENAg= github.com/go-fonts/liberation v0.2.0 h1:jAkAWJP4S+OsrPLZM4/eC9iW7CtHy+HBXrEwZXWo5VM= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1 h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4 h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I= +github.com/go-kit/kit v0.8.0 h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0= github.com/go-kit/kit v0.9.0 h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= +github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= From 38faae3bff1da33f64cf272ca3f3f19d37e207fe Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Thu, 7 Sep 2023 04:54:51 +0000 Subject: [PATCH 02/80] fix msg sender and version variable name --- .../src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol | 2 +- contracts/src/WarpProtocolRegistry.sol | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol index fcde55ed3..11d780385 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol @@ -284,7 +284,7 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { ) external { // Only allow the Teleporter messenger to deliver messages. require( - teleporterRegistry.isAllowedTeleporterSender(msg.msg.sender), + teleporterRegistry.isAllowedTeleporterSender(msg.sender), "Unauthorized." ); diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index fc2f68537..eb67b1f5d 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -50,12 +50,15 @@ abstract contract WarpProtocolRegistry { "WarpProtocolRegistry: invalid destination address" ); - (uint256 nonce, address protocolAddress) = abi.decode( + (uint256 version, address protocolAddress) = abi.decode( message.payload, (uint256, address) ); - require(nonce == _latestVersion, "WarpProtocolRegistry: invalid nonce"); + require( + version == _latestVersion, + "WarpProtocolRegistry: invalid nonce" + ); _latestVersion++; require( From e77c890f734e63bcd252577d0a10156fe6a4127d Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Mon, 25 Sep 2023 16:41:29 -0700 Subject: [PATCH 03/80] update version and registry funcs --- .../src/Teleporter/TeleporterRegistry.sol | 30 +++++++------ contracts/src/WarpProtocolRegistry.sol | 12 ++--- go.work.sum | 44 ++++++++++++++++++- subnet-evm | 2 +- 4 files changed, 67 insertions(+), 21 deletions(-) diff --git a/contracts/src/Teleporter/TeleporterRegistry.sol b/contracts/src/Teleporter/TeleporterRegistry.sol index 0af034b8e..b744ab071 100644 --- a/contracts/src/Teleporter/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/TeleporterRegistry.sol @@ -13,34 +13,38 @@ contract TeleporterRegistry is WarpProtocolRegistry { mapping(address => mapping(address => bool)) private _allowedSenders; mapping(address => bool) private _allowedLatestVersion; - function getTeleporterVersion( + function getTeleporter( uint256 version ) external view returns (ITeleporterMessenger) { - return ITeleporterMessenger(_getProtocolAddress(version)); + return ITeleporterMessenger(_getVersionAddress(version)); } - function setAllowedVersions(uint256[] versions) external { + function getLatestVersion() external view returns (uint256) { + return _latestVersion; + } + + function set_getVersionAddresst256[] versions) external { // Remove all previous versions that were allowed for (uint256 i = 0; i < _allowedVersions[msg.sender].length; i++) { delete _allowedSenders[msg.sender][ - _getProtocolAddress(_allowedVersions[msg.sender][i]) + _getVersionAddress(_allowedVersions[msg.sender][i]) ]; } // Add all new versions that are allowed for (uint256 i = 0; i < versions.length; i++) { require( - versions[i] < _latestVersion, + versions[i] < _latestVersion_getVersionAddress "TeleporterRegistry: invalid version" ); require( - _allowedSenders[msg.sender][_getProtocolAddress(versions[i])] == + _allowedSenders[msg.sender][_getVersionAddress(versions[i])] == false, - "TeleporterRegistry: duplicate version" + _getVersionAddress: duplicate version" ); _allowedSenders[msg.sender][ - _getProtocolAddress(versions[i]) + _getVersionAddress(versions[i]) ] = true; } _allowedVersions[msg.sender] = versions; @@ -51,11 +55,11 @@ contract TeleporterRegistry is WarpProtocolRegistry { } function isAllowedTeleporterSender( - address sender + address sender_getVersionAddress ) external view returns (bool) { if ( _allowedLatestVersion[msg.sender] && - sender == _getProtocolAddress(_latestVersion) + sender == _getVersionAddress(_latestVersion) ) { return true; } @@ -70,11 +74,11 @@ contract TeleporterRegistry is WarpProtocolRegistry { return _allowedSenders[msg.sender][sender]; } - function getLatestTeleporterVersion() - external + function getLatestTeleporter() + external_getVersionAddress view returns (ITeleporterMessenger) { - return ITeleporterMessenger(_getProtocolAddress(_latestVersion)); + return ITeleporterMessenger(_getVersionAddress(_latestVersion)); } } diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index eb67b1f5d..25f718371 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -22,7 +22,7 @@ abstract contract WarpProtocolRegistry { uint256 private _latestVersion; - mapping(uint256 version => address) private _protocolAddresses; + mapping(uint256 version => address) private _versionToAddress; constructor() { _latestVersion = 0; @@ -66,22 +66,22 @@ abstract contract WarpProtocolRegistry { "WarpProtocolRegistry: not a contract" ); - _protocolAddresses[_latestVersion] = protocolAddress; + _versionToAddress[_latestVersion] = protocolAddress; } - function getProtocolAddress( + function getVersionAddress( uint256 version ) external view virtual returns (address) { - return _getProtocolAddress(version); + return _getVersionAddress(version); } - function _getProtocolAddress( + function _getVersionAddress( uint256 version ) internal view returns (address) { require( 0 < version <= _latestVersion, "WarpProtocolRegistry: invalid version" ); - return _protocolAddresses[version]; + return _versionToAddress[version]; } } diff --git a/go.work.sum b/go.work.sum index da99f7975..190cba911 100644 --- a/go.work.sum +++ b/go.work.sum @@ -540,7 +540,9 @@ github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNu github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg= github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b h1:slYM766cy2nI3BwyRiyQj/Ud48djTMtMebDqepE95rw= github.com/alecthomas/kingpin/v2 v2.3.1/go.mod h1:oYL5vtsvEHZGHxU7DMp32Dvx+qL+ptGn6lWaot2vCNE= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E= github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= @@ -590,6 +592,8 @@ github.com/aws/smithy-go v1.1.0 h1:D6CSsM3gdxaGaqXnPgOBCeL6Mophqzu7KJOu7zW78sU= github.com/aws/smithy-go v1.1.0/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40 h1:y4B3+GPxKlrigF1ha5FFErxK+sr6sWxQovRMzwMhejo= github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4= github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= @@ -639,7 +643,6 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954 h1:RMLoZVzv4GliuW github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= -github.com/docker/docker v1.6.2/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs= github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7 h1:tYwu/z8Y0NkkzGEh3z21mSWggMg4LwLRFucLS7TjARg= github.com/eclipse/paho.mqtt.golang v1.2.0 h1:1F8mhG9+aO5/xpdtFkW4SxOJB67ukuDC3t2y2qayIX0= @@ -669,10 +672,16 @@ github.com/go-fonts/liberation v0.2.0 h1:jAkAWJP4S+OsrPLZM4/eC9iW7CtHy+HBXrEwZXW github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1 h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4 h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I= github.com/go-kit/kit v0.8.0 h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0 h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= @@ -696,24 +705,41 @@ github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1C github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= github.com/kilic/bls12-381 v0.1.0/go.mod h1:vDTTHJONJ6G+P2R74EhnyotQDTliQDnFEwhdmfzw1ig= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0= github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo= github.com/onsi/ginkgo/v2 v2.7.0/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo= github.com/onsi/gomega v1.24.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/protolambda/bls12-381-util v0.0.0-20220416220906-d8552aa452c7/go.mod h1:IToEjHuttnUzwZI5KBSM/LOOW3qLbbrHOEfp3SbECGY= @@ -722,11 +748,15 @@ github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNue github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sanity-io/litter v1.5.1/go.mod h1:5Z71SvaYy5kcGtyglXOC9rrUi3c1E8CamFWjQsazTh0= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/supranational/blst v0.3.11-0.20230406105308-e9dfc5ee724b/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/thepudds/fzgen v0.4.2/go.mod h1:kHCWdsv5tdnt32NIHYDdgq083m6bMtaY0M+ipiO9xWE= @@ -739,13 +769,17 @@ github.com/zondax/ledger-go v0.14.1/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2f go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190909091759-094676da4a83/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= @@ -757,16 +791,21 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -774,6 +813,7 @@ golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= @@ -793,6 +833,8 @@ google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwS google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/subnet-evm b/subnet-evm index 71e9f76aa..a05fc0b62 160000 --- a/subnet-evm +++ b/subnet-evm @@ -1 +1 @@ -Subproject commit 71e9f76aa71a830016aa28f05486ac64dd88a353 +Subproject commit a05fc0b629272e604441c73e870a751a415327b2 From b82f3dfb94693d682b9c54b30860b758365d806a Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Mon, 25 Sep 2023 18:23:03 -0700 Subject: [PATCH 04/80] registry contracts and erc20bridge using registry --- .../ERC20Bridge/ERC20Bridge.sol | 27 ++-- .../src/Teleporter/TeleporterRegistry.sol | 65 +--------- contracts/src/WarpProtocolRegistry.sol | 117 +++++++++++------- subnet-evm | 2 +- 4 files changed, 89 insertions(+), 122 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol index d8ae9aa0a..d212d0cec 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol @@ -47,8 +47,8 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { // Used for sending an receiving Teleporter messages. ITeleporterMessenger public teleporterMessenger; - TeleporterReigstry public immutable teleporterRegistry; - uint256 public constant TELEPORTER_VERSION; + TeleporterRegistry public immutable teleporterRegistry; + uint256 private minTeleporterVersion; // Tracks which bridge tokens have been submitted to be created other bridge instances. // (destinationChainID, destinationBridgeAddress) -> nativeTokenContract -> tokenCreationSubmitted @@ -97,24 +97,16 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { * @dev Initializes the Teleporter messenger used for sending and receiving messages, * and initializes the current chain ID. */ - constructor(address teleporterMessengerAddress) { - if (teleporterMessengerAddress == address(0)) { + constructor(address teleporterRegistryAddress) { + if (teleporterRegistryAddress == address(0)) { revert InvalidTeleporterMessengerAddress(); } - teleporterMessenger = ITeleporterMessenger(teleporterMessengerAddress); + teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); currentChainID = WarpMessenger(WARP_PRECOMPILE_ADDRESS) .getBlockchainID(); } - function setTeleporterVersion(uint256 version) external { - teleporterMessenger = teleporterRegistry.getTeleporterVersion(version); - } - - function setAllowedTeleporterVersions(uint256[] versions) external { - teleporterRegistry.setAllowedVersions(versions); - } - /** * @dev See {IERC20Bridge-bridgeTokens}. * @@ -283,6 +275,10 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { ); } + function updateMinTeleporterVersion() external { + minTeleporterVersion = teleporterRegistry.getLatestVersion(); + } + /** * @dev See {ITeleporterReceiver-receiveTeleporterMessage}. * @@ -294,7 +290,10 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { bytes calldata message ) external { // Only allow the Teleporter messenger to deliver messages. - if (msg.sender != address(teleporterMessenger)) { + if ( + teleporterRegistry.getAddressToVersion(msg.sender) < + minTeleporterVersion + ) { revert Unauthorized(); } diff --git a/contracts/src/Teleporter/TeleporterRegistry.sol b/contracts/src/Teleporter/TeleporterRegistry.sol index b744ab071..51da7f35f 100644 --- a/contracts/src/Teleporter/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/TeleporterRegistry.sol @@ -9,76 +9,17 @@ import "../WarpProtocolRegistry.sol"; import "./ITeleporterMessenger.sol"; contract TeleporterRegistry is WarpProtocolRegistry { - mapping(address => uint256[] versions) private _allowedVersions; - mapping(address => mapping(address => bool)) private _allowedSenders; - mapping(address => bool) private _allowedLatestVersion; - function getTeleporter( uint256 version ) external view returns (ITeleporterMessenger) { - return ITeleporterMessenger(_getVersionAddress(version)); - } - - function getLatestVersion() external view returns (uint256) { - return _latestVersion; - } - - function set_getVersionAddresst256[] versions) external { - // Remove all previous versions that were allowed - for (uint256 i = 0; i < _allowedVersions[msg.sender].length; i++) { - delete _allowedSenders[msg.sender][ - _getVersionAddress(_allowedVersions[msg.sender][i]) - ]; - } - - // Add all new versions that are allowed - for (uint256 i = 0; i < versions.length; i++) { - require( - versions[i] < _latestVersion_getVersionAddress - "TeleporterRegistry: invalid version" - ); - require( - _allowedSenders[msg.sender][_getVersionAddress(versions[i])] == - false, - _getVersionAddress: duplicate version" - ); - - _allowedSenders[msg.sender][ - _getVersionAddress(versions[i]) - ] = true; - } - _allowedVersions[msg.sender] = versions; - } - - function allowLatestVersion(bool allow) external { - _allowedLatestVersion[msg.sender] = allow; - } - - function isAllowedTeleporterSender( - address sender_getVersionAddress - ) external view returns (bool) { - if ( - _allowedLatestVersion[msg.sender] && - sender == _getVersionAddress(_latestVersion) - ) { - return true; - } - - // If no allowed versions, then we always return false - // require( - // _allowedVersions[msg.sender].length > 0, - // "TeleporterRegistry: no allowed versions" - // ); - require(sender != address(0), "TeleporterRegistry: invalid sender"); - - return _allowedSenders[msg.sender][sender]; + return ITeleporterMessenger(_getVersionToAddress(version)); } function getLatestTeleporter() - external_getVersionAddress + external view returns (ITeleporterMessenger) { - return ITeleporterMessenger(_getVersionAddress(_latestVersion)); + return ITeleporterMessenger(_getVersionToAddress(_latestVersion)); } } diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 25f718371..c751a72ca 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -12,76 +12,103 @@ abstract contract WarpProtocolRegistry { // Address that the out-of-band warp message sets as the "source" address. // The address is obviously not owned by any EOA or smart contract account, so it // can not possibly be the source address of any other warp message emitted by the VM. - bytes32 public constant VALIDATORS_SOURCE_ADDRESS = - 0x0000000000000000000000000000000000000000000000000000000000000000; + address public constant VALIDATORS_SOURCE_ADDRESS = address(0); WarpMessenger public constant WARP_MESSENGER = WarpMessenger(0x0200000000000000000000000000000000000005); - bytes32 private immutable _chainID; + bytes32 internal immutable _chainID; - uint256 private _latestVersion; + uint256 internal _latestVersion; - mapping(uint256 version => address) private _versionToAddress; + mapping(uint256 version => address) internal _versionToAddress; + mapping(address => uint256 version) internal _addressToVersion; + + // Errors + error InvalidWarpMessage(); + error InvalidOriginChainID(); + error InvalidOriginSenderAddress(); + error InvalidDestinationChainID(); + error InvalidDestinationAddress(); + error InvalidProtocolAddress(); + error InvalidProtocolVersion(); constructor() { _latestVersion = 0; _chainID = WARP_MESSENGER.getBlockchainID(); } - function addProtocolVersion() external virtual { - (WarpMessage memory message, bool exists) = WARP_MESSENGER + function addProtocolVersion() external { + _addProtocolVersion(); + } + + function getVersionToAddress( + uint256 version + ) external view returns (address) { + return _getVersionToAddress(version); + } + + function getAddressToVersion( + address protocolAddress + ) external view returns (uint256) { + return _getAddressToVersion(protocolAddress); + } + + function getLatestVersion() external view returns (uint256) { + return _latestVersion; + } + + function _addProtocolVersion() internal virtual { + (WarpMessage memory message, bool valid) = WARP_MESSENGER .getVerifiedWarpMessage(); - require(exists, "WarpProtocolRegistry: no warp message"); - require( - message.originChainID == _chainID, - "WarpProtocolRegistry: invalid origin chain ID" - ); - require( - message.originSenderAddress == VALIDATORS_SOURCE_ADDRESS, - "WarpProtocolRegistry: invalid origin sender address" - ); - require( - message.destinationChainID == _chainID, - "WarpProtocolRegistry: invalid destination chain ID" - ); - require( - message.destinationAddress == address(this), - "WarpProtocolRegistry: invalid destination address" - ); + if (!valid) { + revert InvalidWarpMessage(); + } + if (message.originChainID != _chainID) { + revert InvalidOriginChainID(); + } + if (message.originSenderAddress != VALIDATORS_SOURCE_ADDRESS) { + revert InvalidOriginSenderAddress(); + } + if (message.destinationChainID != _chainID) { + revert InvalidDestinationChainID(); + } + if (message.destinationAddress != address(this)) { + revert InvalidDestinationAddress(); + } (uint256 version, address protocolAddress) = abi.decode( message.payload, (uint256, address) ); - require( - version == _latestVersion, - "WarpProtocolRegistry: invalid nonce" - ); - _latestVersion++; - - require( - Address.isContract(protocolAddress), - "WarpProtocolRegistry: not a contract" - ); + if (version != _latestVersion) { + revert InvalidProtocolVersion(); + } + if (!Address.isContract(protocolAddress)) { + revert InvalidProtocolAddress(); + } + _latestVersion++; _versionToAddress[_latestVersion] = protocolAddress; + _addressToVersion[protocolAddress] = _latestVersion; } - function getVersionAddress( + function _getVersionToAddress( uint256 version - ) external view virtual returns (address) { - return _getVersionAddress(version); + ) internal view virtual returns (address) { + if (!(0 < version && version < _latestVersion)) { + revert InvalidProtocolVersion(); + } + return _versionToAddress[version]; } - function _getVersionAddress( - uint256 version - ) internal view returns (address) { - require( - 0 < version <= _latestVersion, - "WarpProtocolRegistry: invalid version" - ); - return _versionToAddress[version]; + function _getAddressToVersion( + address protocolAddress + ) internal view virtual returns (uint256) { + if (_addressToVersion[protocolAddress] == 0) { + revert InvalidProtocolAddress(); + } + return _addressToVersion[protocolAddress]; } } diff --git a/subnet-evm b/subnet-evm index a05fc0b62..71e9f76aa 160000 --- a/subnet-evm +++ b/subnet-evm @@ -1 +1 @@ -Subproject commit a05fc0b629272e604441c73e870a751a415327b2 +Subproject commit 71e9f76aa71a830016aa28f05486ac64dd88a353 From 016c039486957368e4907de9a72fb1ef722c0fe9 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Mon, 25 Sep 2023 18:32:33 -0700 Subject: [PATCH 05/80] move addressToVersion to teleporter registry --- .../src/Teleporter/TeleporterRegistry.sol | 15 +++++++++++++++ contracts/src/WarpProtocolRegistry.sol | 19 +------------------ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/contracts/src/Teleporter/TeleporterRegistry.sol b/contracts/src/Teleporter/TeleporterRegistry.sol index 51da7f35f..c53cd8873 100644 --- a/contracts/src/Teleporter/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/TeleporterRegistry.sol @@ -9,6 +9,15 @@ import "../WarpProtocolRegistry.sol"; import "./ITeleporterMessenger.sol"; contract TeleporterRegistry is WarpProtocolRegistry { + mapping(address => uint256) internal _addressToVersion; + + function _addProtocolVersion() internal override { + super._addProtocolVersion(); + _addressToVersion[ + _getVersionToAddress(_latestVersion) + ] = _latestVersion; + } + function getTeleporter( uint256 version ) external view returns (ITeleporterMessenger) { @@ -22,4 +31,10 @@ contract TeleporterRegistry is WarpProtocolRegistry { { return ITeleporterMessenger(_getVersionToAddress(_latestVersion)); } + + function getAddressToVersion( + address protocolAddress + ) external view returns (uint256) { + return _addressToVersion[protocolAddress]; + } } diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index c751a72ca..10e963e32 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -21,8 +21,7 @@ abstract contract WarpProtocolRegistry { uint256 internal _latestVersion; - mapping(uint256 version => address) internal _versionToAddress; - mapping(address => uint256 version) internal _addressToVersion; + mapping(uint256 => address) internal _versionToAddress; // Errors error InvalidWarpMessage(); @@ -48,12 +47,6 @@ abstract contract WarpProtocolRegistry { return _getVersionToAddress(version); } - function getAddressToVersion( - address protocolAddress - ) external view returns (uint256) { - return _getAddressToVersion(protocolAddress); - } - function getLatestVersion() external view returns (uint256) { return _latestVersion; } @@ -91,7 +84,6 @@ abstract contract WarpProtocolRegistry { _latestVersion++; _versionToAddress[_latestVersion] = protocolAddress; - _addressToVersion[protocolAddress] = _latestVersion; } function _getVersionToAddress( @@ -102,13 +94,4 @@ abstract contract WarpProtocolRegistry { } return _versionToAddress[version]; } - - function _getAddressToVersion( - address protocolAddress - ) internal view virtual returns (uint256) { - if (_addressToVersion[protocolAddress] == 0) { - revert InvalidProtocolAddress(); - } - return _addressToVersion[protocolAddress]; - } } From 115fd964b6a1d19c8282810c96d1b6608fa663ba Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Mon, 25 Sep 2023 18:46:45 -0700 Subject: [PATCH 06/80] update erc20bridge registry checks --- .../ERC20Bridge/ERC20Bridge.sol | 24 ++++++++----------- .../src/Teleporter/TeleporterRegistry.sol | 14 +++++------ 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol index d212d0cec..c0516cc1f 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol @@ -45,8 +45,7 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { 0x0200000000000000000000000000000000000005; bytes32 public immutable currentChainID; - // Used for sending an receiving Teleporter messages. - ITeleporterMessenger public teleporterMessenger; + // Used for sending and receiving Teleporter messages. TeleporterRegistry public immutable teleporterRegistry; uint256 private minTeleporterVersion; @@ -90,7 +89,7 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { error InvalidBridgeTokenAddress(); error InvalidDestinationBridgeAddress(); error InvalidRecipientAddress(); - error InvalidTeleporterMessengerAddress(); + error InvalidTeleporterRegistryAddress(); error Unauthorized(); /** @@ -99,7 +98,7 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { */ constructor(address teleporterRegistryAddress) { if (teleporterRegistryAddress == address(0)) { - revert InvalidTeleporterMessengerAddress(); + revert InvalidTeleporterRegistryAddress(); } teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); @@ -225,6 +224,8 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { if (destinationBridgeAddress == address(0)) { revert InvalidDestinationBridgeAddress(); } + ITeleporterMessenger teleporterMessenger = teleporterRegistry + .getLatestTeleporter(); // For non-zero fee amounts, transfer the fee into the control of this contract first, and then // allow the Teleporter contract to spend it. @@ -484,11 +485,6 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { address recipient, uint256 amount ) private nonReentrant { - // Only allow the Teleporter messenger to deliver messages. - if (msg.sender != address(teleporterMessenger)) { - revert Unauthorized(); - } - // The recipient cannot be the zero address. if (recipient == address(0)) { revert InvalidRecipientAddress(); @@ -524,11 +520,6 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { uint256 totalAmount, uint256 secondaryFeeAmount ) private nonReentrant { - // Only allow the teleporter messenger to deliver messages. - if (msg.sender != address(teleporterMessenger)) { - revert Unauthorized(); - } - // Neither the recipient nor the destination bridge can be the zero address. if (recipient == address(0)) { revert InvalidRecipientAddress(); @@ -611,6 +602,8 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { if (destinationChainID == currentChainID) { revert CannotBridgeTokenWithinSameChain(); } + ITeleporterMessenger teleporterMessenger = teleporterRegistry + .getLatestTeleporter(); // Allow the Teleporter messenger to spend the fee amount. if (feeAmount > 0) { @@ -667,6 +660,9 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { function _processWrappedTokenTransfer( WrappedTokenTransferInfo memory wrappedTransferInfo ) private { + ITeleporterMessenger teleporterMessenger = teleporterRegistry + .getLatestTeleporter(); + // If necessary, transfer the primary fee amount to this contract and approve the // Teleporter messenger to spend it when the first message back to the native subnet // is submitted. The secondary fee amount is then handled by the native subnet when diff --git a/contracts/src/Teleporter/TeleporterRegistry.sol b/contracts/src/Teleporter/TeleporterRegistry.sol index c53cd8873..71d2d583c 100644 --- a/contracts/src/Teleporter/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/TeleporterRegistry.sol @@ -11,13 +11,6 @@ import "./ITeleporterMessenger.sol"; contract TeleporterRegistry is WarpProtocolRegistry { mapping(address => uint256) internal _addressToVersion; - function _addProtocolVersion() internal override { - super._addProtocolVersion(); - _addressToVersion[ - _getVersionToAddress(_latestVersion) - ] = _latestVersion; - } - function getTeleporter( uint256 version ) external view returns (ITeleporterMessenger) { @@ -37,4 +30,11 @@ contract TeleporterRegistry is WarpProtocolRegistry { ) external view returns (uint256) { return _addressToVersion[protocolAddress]; } + + function _addProtocolVersion() internal override { + super._addProtocolVersion(); + _addressToVersion[ + _getVersionToAddress(_latestVersion) + ] = _latestVersion; + } } From 0a12bf3d9334367f3f5ffb2d4d17f9a7da3901e3 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 27 Sep 2023 00:41:31 +0000 Subject: [PATCH 07/80] update crossChainApps to use registry --- .../ERC20Bridge/ERC20Bridge.sol | 24 +++++++--- .../ExampleCrossChainMessenger.sol | 25 +++++++++-- .../VerifiedBlockHash/BlockHashPublisher.sol | 45 ++++++++++++------- .../VerifiedBlockHash/BlockHashReceiver.sol | 23 ++++++++-- 4 files changed, 86 insertions(+), 31 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol index c0516cc1f..e30b8faf0 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol @@ -47,7 +47,7 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { // Used for sending and receiving Teleporter messages. TeleporterRegistry public immutable teleporterRegistry; - uint256 private minTeleporterVersion; + uint256 private _minTeleporterVersion;; // Tracks which bridge tokens have been submitted to be created other bridge instances. // (destinationChainID, destinationBridgeAddress) -> nativeTokenContract -> tokenCreationSubmitted @@ -102,6 +102,7 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { } teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); + _minTeleporterVersion = teleporterRegistry.getLatestVersion(); currentChainID = WarpMessenger(WARP_PRECOMPILE_ADDRESS) .getBlockchainID(); } @@ -276,10 +277,6 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { ); } - function updateMinTeleporterVersion() external { - minTeleporterVersion = teleporterRegistry.getLatestVersion(); - } - /** * @dev See {ITeleporterReceiver-receiveTeleporterMessage}. * @@ -290,10 +287,10 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { address nativeBridgeAddress, bytes calldata message ) external { - // Only allow the Teleporter messenger to deliver messages. + // Only allow Teleporter messengers above the minimum version to deliver messages. if ( teleporterRegistry.getAddressToVersion(msg.sender) < - minTeleporterVersion + _minTeleporterVersion; ) { revert Unauthorized(); } @@ -360,6 +357,10 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { } } + function updateMinTeleporterVersion() external { + _minTeleporterVersion = teleporterRegistry.getLatestVersion(); + } + /** * @dev Encodes the parameters for the Create action to be decoded and executed on the destination. */ @@ -427,6 +428,9 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { * @dev Teleporter message receiver for creating a new bridge token on this chain. * * Emits a {CreateBridgeToken} event. + * + * Note: This function is only called within `receiveTeleporterMessage`, which can only be + * called by the Teleporter messenger. */ function _createBridgeToken( bytes32 nativeChainID, @@ -477,6 +481,9 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { * @dev Teleporter message receiver for minting of an existing bridge token on this chain. * * Emits a {MintBridgeTokens} event. + * + * Note: This function is only called within `receiveTeleporterMessage`, which can only be + * called by the Teleporter messenger. */ function _mintBridgeTokens( bytes32 nativeChainID, @@ -509,6 +516,9 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { /** * @dev Teleporter message receiver for handling bridge tokens transfers back from another chain * and optionally routing them to a different third chain. + * + * Note: This function is only called within `receiveTeleporterMessage`, which can only be + * called by the Teleporter messenger. */ function _transferBridgeTokens( bytes32 sourceChainID, diff --git a/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol b/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol index 57f3598c9..d6f5b5916 100644 --- a/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol +++ b/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol @@ -8,6 +8,7 @@ pragma solidity 0.8.18; import "../../Teleporter/ITeleporterMessenger.sol"; import "../../Teleporter/SafeERC20TransferFrom.sol"; import "../../Teleporter/ITeleporterReceiver.sol"; +import "../../Teleporter/TeleporterRegistry.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; @@ -24,7 +25,8 @@ contract ExampleCrossChainMessenger is ITeleporterReceiver, ReentrancyGuard { string message; } - ITeleporterMessenger public immutable teleporterMessenger; + TeleporterRegistry public immutable teleporterRegistry; + uint256 private immutable _minTeleporterVersion; mapping(bytes32 => Message) private _messages; @@ -50,10 +52,16 @@ contract ExampleCrossChainMessenger is ITeleporterReceiver, ReentrancyGuard { ); // Errors + error InvalidTeleporterRegistryAddress(); error Unauthorized(); - constructor(address teleporterMessengerAddress) { - teleporterMessenger = ITeleporterMessenger(teleporterMessengerAddress); + constructor(address teleporterRegistryAddress) { + if (teleporterRegistryAddress == address(0)) { + revert InvalidTeleporterRegistryAddress(); + } + + teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); + _minTeleporterVersion = teleporterRegistry.getLatestVersion(); } /** @@ -67,7 +75,10 @@ contract ExampleCrossChainMessenger is ITeleporterReceiver, ReentrancyGuard { bytes calldata message ) external { // Only the Teleporter receiver can deliver a message. - if (msg.sender != address(teleporterMessenger)) { + if ( + teleporterRegistry.getAddressToVersion(msg.sender) < + _minTeleporterVersion + ) { revert Unauthorized(); } @@ -88,6 +99,8 @@ contract ExampleCrossChainMessenger is ITeleporterReceiver, ReentrancyGuard { uint256 requiredGasLimit, string calldata message ) external nonReentrant returns (uint256 messageID) { + ITeleporterMessenger teleporterMessenger = teleporterRegistry + .getLatestTeleporter(); // For non-zero fee amounts, transfer the fee into the control of this contract first, and then // allow the Teleporter contract to spend it. uint256 adjustedFeeAmount = 0; @@ -126,6 +139,10 @@ contract ExampleCrossChainMessenger is ITeleporterReceiver, ReentrancyGuard { ); } + function updateMinTeleporterVersion() external { + _minTeleporterVersion = teleporterRegistry.getLatestVersion(); + } + /** * @dev Returns the current message from another chain. */ diff --git a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol index bb13de94d..7f6116c69 100644 --- a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol +++ b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol @@ -6,6 +6,7 @@ pragma solidity 0.8.18; import "../../Teleporter/ITeleporterMessenger.sol"; +import "../../Teleporter/TeleporterRegistry.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./BlockHashReceiver.sol"; @@ -13,7 +14,8 @@ import "./BlockHashReceiver.sol"; * Contract that publishes the latest block hash of current chain to another chain. */ contract BlockHashPublisher { - ITeleporterMessenger public immutable teleporterMessenger; + TeleporterRegistry public immutable teleporterRegistry; + uint256 private immutable _minTeleporterVersion; uint256 public constant RECEIVE_BLOCK_HASH_REQUIRED_GAS_LIMIT = 1.5e5; /** @@ -26,8 +28,13 @@ contract BlockHashPublisher { bytes32 blockHash ); - constructor(address teleporterMessengerAddress) { - teleporterMessenger = ITeleporterMessenger(teleporterMessengerAddress); + constructor(address teleporterRegistryAddress) { + if (teleporterRegistryAddress == address(0)) { + revert InvalidTeleporterRegistryAddress(); + } + + teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); + _minTeleporterVersion = teleporterRegistry.getLatestVersion(); } /** @@ -52,18 +59,24 @@ contract BlockHashPublisher { blockHeight, blockHash ); - messageID = teleporterMessenger.sendCrossChainMessage( - TeleporterMessageInput({ - destinationChainID: destinationChainID, - destinationAddress: destinationAddress, - feeInfo: TeleporterFeeInfo({ - contractAddress: address(0), - amount: 0 - }), - requiredGasLimit: RECEIVE_BLOCK_HASH_REQUIRED_GAS_LIMIT, - allowedRelayerAddresses: new address[](0), - message: messageData - }) - ); + messageID = teleporterRegistry + .getLatestTeleporter() + .sendCrossChainMessage( + TeleporterMessageInput({ + destinationChainID: destinationChainID, + destinationAddress: destinationAddress, + feeInfo: TeleporterFeeInfo({ + contractAddress: address(0), + amount: 0 + }), + requiredGasLimit: RECEIVE_BLOCK_HASH_REQUIRED_GAS_LIMIT, + allowedRelayerAddresses: new address[](0), + message: messageData + }) + ); + } + + function updateMinTeleporterVersion() external { + _minTeleporterVersion = teleporterRegistry.getLatestVersion(); } } diff --git a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol index 5b8afb0ca..f5e06ca7e 100644 --- a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol +++ b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol @@ -7,12 +7,14 @@ pragma solidity 0.8.18; import "../../Teleporter/ITeleporterMessenger.sol"; import "../../Teleporter/ITeleporterReceiver.sol"; +import "../../Teleporter/TeleporterRegistry.sol"; /** * Contract for receiving latest block hashes from another chain. */ contract BlockHashReceiver is ITeleporterReceiver { - ITeleporterMessenger public immutable teleporterMessenger; + TeleporterRegistry public immutable teleporterRegistry; + uint256 private immutable _minTeleporterVersion; // Source chain information bytes32 public immutable sourceChainID; @@ -36,13 +38,19 @@ contract BlockHashReceiver is ITeleporterReceiver { error Unauthorized(); error InvalidSourceChainID(); error InvalidSourceChainPublisher(); + error InvalidTeleporterRegistryAddress(); constructor( - address teleporterMessengerAddress, + address teleporterRegistryAddress, bytes32 publisherChainID, address publisherContractAddress ) { - teleporterMessenger = ITeleporterMessenger(teleporterMessengerAddress); + if (teleporterRegistryAddress == address(0)) { + revert InvalidTeleporterRegistryAddress(); + } + + teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); + _minTeleporterVersion = teleporterRegistry.getLatestVersion(); sourceChainID = publisherChainID; sourcePublisherContractAddress = publisherContractAddress; } @@ -63,7 +71,10 @@ contract BlockHashReceiver is ITeleporterReceiver { address originSenderAddress, bytes calldata message ) external { - if (msg.sender != address(teleporterMessenger)) { + if ( + teleporterRegistry.getAddressToVersion(msg.sender) < + _minTeleporterVersion + ) { revert Unauthorized(); } @@ -92,6 +103,10 @@ contract BlockHashReceiver is ITeleporterReceiver { } } + function updateMinTeleporterVersion() external { + _minTeleporterVersion = teleporterRegistry.getLatestVersion(); + } + /** * @dev Returns the latest block information. */ From 6c8cf3fd3f3372f7767427e76b7baf85d74a9a5a Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 27 Sep 2023 20:35:20 +0000 Subject: [PATCH 08/80] add docs, license, and event --- .../src/Teleporter/TeleporterRegistry.sol | 22 +++++++++- contracts/src/WarpProtocolRegistry.sol | 40 ++++++++++++++++++- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/contracts/src/Teleporter/TeleporterRegistry.sol b/contracts/src/Teleporter/TeleporterRegistry.sol index 71d2d583c..f54f731d9 100644 --- a/contracts/src/Teleporter/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/TeleporterRegistry.sol @@ -1,22 +1,32 @@ // (c) 2023, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -// SPDX-License-Identifier: BSD-3-Clause +// SPDX-License-Identifier: Ecosystem pragma solidity 0.8.18; import "../WarpProtocolRegistry.sol"; import "./ITeleporterMessenger.sol"; +/** + * @dev TeleporterRegistry contract is a {WarpProtocolRegistry} and provides an upgrade + * mechanism for teleporter messenger contracts. + */ contract TeleporterRegistry is WarpProtocolRegistry { mapping(address => uint256) internal _addressToVersion; + /** + * @dev Gets the {ITeleporterMessenger} contract of the given `version`. + */ function getTeleporter( uint256 version ) external view returns (ITeleporterMessenger) { return ITeleporterMessenger(_getVersionToAddress(version)); } + /** + * @dev Gets the latest {ITeleporterMessenger} contract. + */ function getLatestTeleporter() external view @@ -25,12 +35,22 @@ contract TeleporterRegistry is WarpProtocolRegistry { return ITeleporterMessenger(_getVersionToAddress(_latestVersion)); } + /** + * @dev Gets the version of the given `protocolAddress`. + * If `protocolAddress` is not a valid protocol address, returns 0. + */ function getAddressToVersion( address protocolAddress ) external view returns (uint256) { return _addressToVersion[protocolAddress]; } + /** + * @dev See {WarpProtocolRegistry-addProtocolVersion} + * + * Adds the new protocol version address to the `_addressToVersion` mapping + * so that the registry can be queried for the version of a given protocol address. + */ function _addProtocolVersion() internal override { super._addProtocolVersion(); _addressToVersion[ diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 10e963e32..2ffa1172c 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -1,14 +1,28 @@ // (c) 2023, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -// SPDX-License-Identifier: BSD-3-Clause +// SPDX-License-Identifier: Ecosystem pragma solidity 0.8.18; import "@subnet-evm-contracts/interfaces/IWarpMessenger.sol"; import "@openzeppelin/contracts/utils/Address.sol"; +/** + * @dev Implementation of an abstract `WarpProtocolRegistry` contract. + * + * This implementation is a contract that can be used as a base contract for protocols that are + * build on top of Warp. It allows the protocol to be upgraded through a warp out of band message. + */ abstract contract WarpProtocolRegistry { + /** + * @dev Emitted when a new protocol version is added to the registry. + */ + event AddProtocolVersion( + uint256 indexed version, + address indexed protocolAddress + ); + // Address that the out-of-band warp message sets as the "source" address. // The address is obviously not owned by any EOA or smart contract account, so it // can not possibly be the source address of any other warp message emitted by the VM. @@ -32,21 +46,44 @@ abstract contract WarpProtocolRegistry { error InvalidProtocolAddress(); error InvalidProtocolVersion(); + /** + * @dev Initializes the contract by setting a `chainID` and `latestVersion`. + */ constructor() { _latestVersion = 0; _chainID = WARP_MESSENGER.getBlockchainID(); } + /** + * @dev Gets and verifies a warp out of band message, and adds the new protocol version + * addres to the registry. + * + * Emits a {AddProtocolVersion} event when successful. + * Requirements: + * + * - a valid warp out of band message must be provided. + * - the version must be the increment of the latest version. + * - the protocol address must be a contract address. + */ function addProtocolVersion() external { _addProtocolVersion(); } + /** + * @dev Gets the address of a protocol version. + * Requirements: + * + * - the version must be a valid version. + */ function getVersionToAddress( uint256 version ) external view returns (address) { return _getVersionToAddress(version); } + /** + * @dev Gets the latest protocol version. + */ function getLatestVersion() external view returns (uint256) { return _latestVersion; } @@ -84,6 +121,7 @@ abstract contract WarpProtocolRegistry { _latestVersion++; _versionToAddress[_latestVersion] = protocolAddress; + emit AddProtocolVersion(_latestVersion, protocolAddress); } function _getVersionToAddress( From 61e8d4812cfbb383227dc3a46216ace1f3c07e12 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 27 Sep 2023 21:00:10 +0000 Subject: [PATCH 09/80] registry accepts initial values and v0.5.6 compatible --- .../ERC20Bridge/ERC20Bridge.sol | 4 +- .../ExampleCrossChainMessenger.sol | 2 +- .../VerifiedBlockHash/BlockHashPublisher.sol | 4 +- .../VerifiedBlockHash/BlockHashReceiver.sol | 2 +- .../src/Teleporter/TeleporterRegistry.sol | 9 +++- contracts/src/WarpProtocolRegistry.sol | 41 +++++++++++++++---- 6 files changed, 46 insertions(+), 16 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol index e30b8faf0..a5b124fbf 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol @@ -47,7 +47,7 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { // Used for sending and receiving Teleporter messages. TeleporterRegistry public immutable teleporterRegistry; - uint256 private _minTeleporterVersion;; + uint256 internal _minTeleporterVersion; // Tracks which bridge tokens have been submitted to be created other bridge instances. // (destinationChainID, destinationBridgeAddress) -> nativeTokenContract -> tokenCreationSubmitted @@ -290,7 +290,7 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { // Only allow Teleporter messengers above the minimum version to deliver messages. if ( teleporterRegistry.getAddressToVersion(msg.sender) < - _minTeleporterVersion; + _minTeleporterVersion ) { revert Unauthorized(); } diff --git a/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol b/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol index d6f5b5916..59f03ae3a 100644 --- a/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol +++ b/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol @@ -26,7 +26,7 @@ contract ExampleCrossChainMessenger is ITeleporterReceiver, ReentrancyGuard { } TeleporterRegistry public immutable teleporterRegistry; - uint256 private immutable _minTeleporterVersion; + uint256 internal _minTeleporterVersion; mapping(bytes32 => Message) private _messages; diff --git a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol index 7f6116c69..29f58c939 100644 --- a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol +++ b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol @@ -15,9 +15,11 @@ import "./BlockHashReceiver.sol"; */ contract BlockHashPublisher { TeleporterRegistry public immutable teleporterRegistry; - uint256 private immutable _minTeleporterVersion; + uint256 internal _minTeleporterVersion; uint256 public constant RECEIVE_BLOCK_HASH_REQUIRED_GAS_LIMIT = 1.5e5; + error InvalidTeleporterRegistryAddress(); + /** * @dev Emitted when a block hash is submitted to be published to another chain. */ diff --git a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol index f5e06ca7e..50bc22579 100644 --- a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol +++ b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol @@ -14,7 +14,7 @@ import "../../Teleporter/TeleporterRegistry.sol"; */ contract BlockHashReceiver is ITeleporterReceiver { TeleporterRegistry public immutable teleporterRegistry; - uint256 private immutable _minTeleporterVersion; + uint256 internal _minTeleporterVersion; // Source chain information bytes32 public immutable sourceChainID; diff --git a/contracts/src/Teleporter/TeleporterRegistry.sol b/contracts/src/Teleporter/TeleporterRegistry.sol index f54f731d9..623c3f770 100644 --- a/contracts/src/Teleporter/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/TeleporterRegistry.sol @@ -15,6 +15,11 @@ import "./ITeleporterMessenger.sol"; contract TeleporterRegistry is WarpProtocolRegistry { mapping(address => uint256) internal _addressToVersion; + constructor( + uint256[] memory initialVersions, + address[] memory initialProtocolAddresses + ) WarpProtocolRegistry(initialVersions, initialProtocolAddresses) {} + /** * @dev Gets the {ITeleporterMessenger} contract of the given `version`. */ @@ -51,8 +56,8 @@ contract TeleporterRegistry is WarpProtocolRegistry { * Adds the new protocol version address to the `_addressToVersion` mapping * so that the registry can be queried for the version of a given protocol address. */ - function _addProtocolVersion() internal override { - super._addProtocolVersion(); + function _addProtocolVersion(uint32 messageIndex) internal override { + super._addProtocolVersion(messageIndex); _addressToVersion[ _getVersionToAddress(_latestVersion) ] = _latestVersion; diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 2ffa1172c..7fe81a2a6 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -39,19 +39,31 @@ abstract contract WarpProtocolRegistry { // Errors error InvalidWarpMessage(); - error InvalidOriginChainID(); + error InvalidSourceChainID(); error InvalidOriginSenderAddress(); error InvalidDestinationChainID(); error InvalidDestinationAddress(); error InvalidProtocolAddress(); error InvalidProtocolVersion(); + error InvalidRegistryInitialization(); /** * @dev Initializes the contract by setting a `chainID` and `latestVersion`. */ - constructor() { + constructor( + uint256[] memory initialVersions, + address[] memory initialProtocolAddresses + ) { _latestVersion = 0; _chainID = WARP_MESSENGER.getBlockchainID(); + uint256 _numVersions = initialVersions.length; + if (initialProtocolAddresses.length != _numVersions) { + revert InvalidRegistryInitialization(); + } + + for (uint256 i = 0; i < _numVersions; i++) { + _addToRegistry(initialVersions[i], initialProtocolAddresses[i]); + } } /** @@ -65,8 +77,8 @@ abstract contract WarpProtocolRegistry { * - the version must be the increment of the latest version. * - the protocol address must be a contract address. */ - function addProtocolVersion() external { - _addProtocolVersion(); + function addProtocolVersion(uint32 messageIndex) external { + _addProtocolVersion(messageIndex); } /** @@ -88,14 +100,15 @@ abstract contract WarpProtocolRegistry { return _latestVersion; } - function _addProtocolVersion() internal virtual { + function _addProtocolVersion(uint32 messageIndex) internal virtual { + // Get and verify a valid warp out of band message. (WarpMessage memory message, bool valid) = WARP_MESSENGER - .getVerifiedWarpMessage(); + .getVerifiedWarpMessage(messageIndex); if (!valid) { revert InvalidWarpMessage(); } - if (message.originChainID != _chainID) { - revert InvalidOriginChainID(); + if (message.sourceChainID != _chainID) { + revert InvalidSourceChainID(); } if (message.originSenderAddress != VALIDATORS_SOURCE_ADDRESS) { revert InvalidOriginSenderAddress(); @@ -112,9 +125,18 @@ abstract contract WarpProtocolRegistry { (uint256, address) ); - if (version != _latestVersion) { + _addToRegistry(version, protocolAddress); + } + + function _addToRegistry( + uint256 version, + address protocolAddress + ) internal virtual { + // Check that the version is the increment of the latest version. + if (version != _latestVersion + 1) { revert InvalidProtocolVersion(); } + // Check that the protocol address is a contract address. if (!Address.isContract(protocolAddress)) { revert InvalidProtocolAddress(); } @@ -127,6 +149,7 @@ abstract contract WarpProtocolRegistry { function _getVersionToAddress( uint256 version ) internal view virtual returns (address) { + // Check that the version provided is a valid version. if (!(0 < version && version < _latestVersion)) { revert InvalidProtocolVersion(); } From 0c244edb4a3212eaffbc531fd38728433119ace4 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 27 Sep 2023 21:27:26 +0000 Subject: [PATCH 10/80] lint fixes --- contracts/src/.solhint.json | 1 - .../VerifiedBlockHash/BlockHashPublisher.sol | 4 ++-- contracts/src/WarpProtocolRegistry.sol | 22 +++++++++---------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/contracts/src/.solhint.json b/contracts/src/.solhint.json index 457ab6485..8374f0c41 100644 --- a/contracts/src/.solhint.json +++ b/contracts/src/.solhint.json @@ -16,7 +16,6 @@ "strict": true } ], - "reason-string": ["off"], "ordering": "warn", "immutable-vars-naming": [ "warn", diff --git a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol index 29f58c939..ddf048fb6 100644 --- a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol +++ b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol @@ -18,8 +18,6 @@ contract BlockHashPublisher { uint256 internal _minTeleporterVersion; uint256 public constant RECEIVE_BLOCK_HASH_REQUIRED_GAS_LIMIT = 1.5e5; - error InvalidTeleporterRegistryAddress(); - /** * @dev Emitted when a block hash is submitted to be published to another chain. */ @@ -30,6 +28,8 @@ contract BlockHashPublisher { bytes32 blockHash ); + error InvalidTeleporterRegistryAddress(); + constructor(address teleporterRegistryAddress) { if (teleporterRegistryAddress == address(0)) { revert InvalidTeleporterRegistryAddress(); diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 7fe81a2a6..30dc35bc0 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -15,14 +15,6 @@ import "@openzeppelin/contracts/utils/Address.sol"; * build on top of Warp. It allows the protocol to be upgraded through a warp out of band message. */ abstract contract WarpProtocolRegistry { - /** - * @dev Emitted when a new protocol version is added to the registry. - */ - event AddProtocolVersion( - uint256 indexed version, - address indexed protocolAddress - ); - // Address that the out-of-band warp message sets as the "source" address. // The address is obviously not owned by any EOA or smart contract account, so it // can not possibly be the source address of any other warp message emitted by the VM. @@ -37,6 +29,14 @@ abstract contract WarpProtocolRegistry { mapping(uint256 => address) internal _versionToAddress; + /** + * @dev Emitted when a new protocol version is added to the registry. + */ + event AddProtocolVersion( + uint256 indexed version, + address indexed protocolAddress + ); + // Errors error InvalidWarpMessage(); error InvalidSourceChainID(); @@ -56,12 +56,12 @@ abstract contract WarpProtocolRegistry { ) { _latestVersion = 0; _chainID = WARP_MESSENGER.getBlockchainID(); - uint256 _numVersions = initialVersions.length; - if (initialProtocolAddresses.length != _numVersions) { + uint256 numVersions_ = initialVersions.length; + if (initialProtocolAddresses.length != numVersions_) { revert InvalidRegistryInitialization(); } - for (uint256 i = 0; i < _numVersions; i++) { + for (uint256 i = 0; i < numVersions_; i++) { _addToRegistry(initialVersions[i], initialProtocolAddresses[i]); } } From b676a2bf284b41af4ada32f5e3341214732e25ba Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 27 Sep 2023 22:40:48 +0000 Subject: [PATCH 11/80] fix erc20bridge tests with registry integration --- .../ERC20Bridge/tests/ERC20BridgeTests.t.sol | 83 ++++++++++++++++--- 1 file changed, 73 insertions(+), 10 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol index 206f8cfe6..ad01379df 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol @@ -12,6 +12,8 @@ import "../../../Mocks/UnitTestMockERC20.sol"; contract ERC20BridgeTest is Test { address public constant MOCK_TELEPORTER_MESSENGER_ADDRESS = 0x644E5b7c5D4Bc8073732CEa72c66e0BB90dFC00f; + address public constant MOCK_TELEPORTER_REGISTRY_ADDRESS = + 0xf9FA4a0c696b659328DDaaBCB46Ae4eBFC9e68e4; address public constant WARP_PRECOMPILE_ADDRESS = address(0x0200000000000000000000000000000000000005); bytes32 private constant _MOCK_BLOCKCHAIN_ID = bytes32(uint256(123456)); @@ -65,11 +67,60 @@ contract ERC20BridgeTest is Test { abi.encodeWithSelector(WarpMessenger.getBlockchainID.selector), abi.encode(_MOCK_BLOCKCHAIN_ID) ); + vm.expectCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeWithSelector(WarpMessenger.getBlockchainID.selector) + ); + + initMockTeleporterRegistry(); + + vm.expectCall( + MOCK_TELEPORTER_REGISTRY_ADDRESS, + abi.encodeWithSelector( + WarpProtocolRegistry.getLatestVersion.selector + ) + ); - erc20Bridge = new ERC20Bridge(MOCK_TELEPORTER_MESSENGER_ADDRESS); + erc20Bridge = new ERC20Bridge(MOCK_TELEPORTER_REGISTRY_ADDRESS); mockERC20 = new UnitTestMockERC20(); } + function initMockTeleporterRegistry() internal { + vm.mockCall( + MOCK_TELEPORTER_REGISTRY_ADDRESS, + abi.encodeWithSelector( + WarpProtocolRegistry.getLatestVersion.selector + ), + abi.encode(1) + ); + + vm.mockCall( + MOCK_TELEPORTER_REGISTRY_ADDRESS, + abi.encodeWithSelector( + TeleporterRegistry.getAddressToVersion.selector, + (MOCK_TELEPORTER_MESSENGER_ADDRESS) + ), + abi.encode(1) + ); + + vm.mockCall( + MOCK_TELEPORTER_REGISTRY_ADDRESS, + abi.encodeWithSelector( + WarpProtocolRegistry.getVersionToAddress.selector, + (1) + ), + abi.encode(MOCK_TELEPORTER_MESSENGER_ADDRESS) + ); + + vm.mockCall( + MOCK_TELEPORTER_REGISTRY_ADDRESS, + abi.encodeWithSelector( + TeleporterRegistry.getLatestTeleporter.selector + ), + abi.encode(ITeleporterMessenger(MOCK_TELEPORTER_MESSENGER_ADDRESS)) + ); + } + function testSameChainID() public { vm.expectRevert(ERC20Bridge.CannotBridgeTokenWithinSameChain.selector); erc20Bridge.bridgeTokens({ @@ -90,9 +141,13 @@ contract ERC20BridgeTest is Test { _DEFAULT_OTHER_BRIDGE_ADDRESS, address(mockERC20) ); - vm.expectRevert(abi.encodePacked( - ERC20Bridge.InsufficientAdjustedAmount.selector, - uint256(130), uint256(130))); + vm.expectRevert( + abi.encodePacked( + ERC20Bridge.InsufficientAdjustedAmount.selector, + uint256(130), + uint256(130) + ) + ); erc20Bridge.bridgeTokens({ destinationChainID: _DEFAULT_OTHER_CHAIN_ID, destinationBridgeAddress: _DEFAULT_OTHER_BRIDGE_ADDRESS, @@ -115,9 +170,13 @@ contract ERC20BridgeTest is Test { contractNonce: 1 }); - vm.expectRevert(abi.encodePacked( - ERC20Bridge.InsufficientTotalAmount.selector, - uint256(130), uint256(130))); + vm.expectRevert( + abi.encodePacked( + ERC20Bridge.InsufficientTotalAmount.selector, + uint256(130), + uint256(130) + ) + ); erc20Bridge.bridgeTokens({ destinationChainID: _DEFAULT_OTHER_CHAIN_ID, destinationBridgeAddress: _DEFAULT_OTHER_BRIDGE_ADDRESS, @@ -494,9 +553,13 @@ contract ERC20BridgeTest is Test { address(mockERC20) ); - vm.expectRevert(abi.encodePacked( - ERC20Bridge.InsufficientAdjustedAmount.selector, - uint256(totalAmount - tokenFeeOnTransferAmount), uint256(bridgeFeeAmount))); + vm.expectRevert( + abi.encodePacked( + ERC20Bridge.InsufficientAdjustedAmount.selector, + uint256(totalAmount - tokenFeeOnTransferAmount), + uint256(bridgeFeeAmount) + ) + ); erc20Bridge.bridgeTokens({ destinationChainID: _DEFAULT_OTHER_CHAIN_ID, destinationBridgeAddress: _DEFAULT_OTHER_BRIDGE_ADDRESS, From a5039b7b986e7af1dceef101abe6d64f562ece16 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 27 Sep 2023 23:52:54 +0000 Subject: [PATCH 12/80] init teleporter registry tests --- .../tests/TeleporterRegistryTest.t.sol | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 contracts/src/Teleporter/tests/TeleporterRegistryTest.t.sol diff --git a/contracts/src/Teleporter/tests/TeleporterRegistryTest.t.sol b/contracts/src/Teleporter/tests/TeleporterRegistryTest.t.sol new file mode 100644 index 000000000..782a1cf42 --- /dev/null +++ b/contracts/src/Teleporter/tests/TeleporterRegistryTest.t.sol @@ -0,0 +1,70 @@ +// (c) 2023, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +// SPDX-License-Identifier: Ecosystem + +pragma solidity 0.8.18; + +import "forge-std/Test.sol"; +import "../TeleporterRegistry.sol"; + +contract TeleporterRegistryTest is Test { + TeleporterRegistry teleporterRegistry; + + function setUp() public override { + teleporterRegistry = new TeleporterRegistry( + new uint256[](0), + new address[](0) + ); + } + + function test_getLatestVersion() public { + Assert.equal(teleporterRegistry.getLatestVersion(), 0, "should be 0"); + } + + function test_addProtocolVersion() public { + teleporterRegistry.addProtocolVersion(address(0x1), 1); + Assert.equal(teleporterRegistry.getLatestVersion(), 1, "should be 1"); + Assert.equal( + teleporterRegistry.getAddressToVersion(address(0x1)), + 1, + "should be 1" + ); + } + + function test_getVersionToAddress() public { + teleporterRegistry.addProtocolVersion(address(0x1), 1); + Assert.equal( + teleporterRegistry.getVersionToAddress(1), + address(0x1), + "should be 0x1" + ); + } + + function test_getAddressToVersion() public { + teleporterRegistry.addProtocolVersion(address(0x1), 1); + Assert.equal( + teleporterRegistry.getAddressToVersion(address(0x1)), + 1, + "should be 1" + ); + } + + function test_getTeleporter() public { + teleporterRegistry.addProtocolVersion(address(0x1), 1); + Assert.equal( + teleporterRegistry.getTeleporter(1), + address(0x1), + "should be 0x1" + ); + } + + function test_getLatestTeleporter() public { + teleporterRegistry.addProtocolVersion(address(0x1), 1); + Assert.equal( + teleporterRegistry.getLatestTeleporter(), + address(0x1), + "should be 0x1" + ); + } +} From 71958145268512811f2d8aca8194b2ab9ea1e0a1 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Thu, 28 Sep 2023 22:46:11 +0000 Subject: [PATCH 13/80] add registry unit tests --- .../tests/TeleporterRegistryTest.t.sol | 306 ++++++++++++++++-- contracts/src/WarpProtocolRegistry.sol | 8 +- go.work.sum | 150 +++++++++ 3 files changed, 425 insertions(+), 39 deletions(-) diff --git a/contracts/src/Teleporter/tests/TeleporterRegistryTest.t.sol b/contracts/src/Teleporter/tests/TeleporterRegistryTest.t.sol index 782a1cf42..cb5607af5 100644 --- a/contracts/src/Teleporter/tests/TeleporterRegistryTest.t.sol +++ b/contracts/src/Teleporter/tests/TeleporterRegistryTest.t.sol @@ -7,64 +7,300 @@ pragma solidity 0.8.18; import "forge-std/Test.sol"; import "../TeleporterRegistry.sol"; +import "../TeleporterMessenger.sol"; contract TeleporterRegistryTest is Test { - TeleporterRegistry teleporterRegistry; + TeleporterRegistry public teleporterRegistry; + address public teleporterAddress; - function setUp() public override { + bytes32 public constant MOCK_BLOCK_CHAIN_ID = bytes32(uint256(123456)); + address public constant WARP_PRECOMPILE_ADDRESS = + 0x0200000000000000000000000000000000000005; + + event AddProtocolVersion( + uint256 indexed version, + address indexed protocolAddress + ); + + function setUp() public { + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeWithSelector(WarpMessenger.getBlockchainID.selector), + abi.encode(MOCK_BLOCK_CHAIN_ID) + ); teleporterRegistry = new TeleporterRegistry( new uint256[](0), new address[](0) ); + assertEq(0, teleporterRegistry.getLatestVersion()); + + teleporterAddress = address(new TeleporterMessenger()); } - function test_getLatestVersion() public { - Assert.equal(teleporterRegistry.getLatestVersion(), 0, "should be 0"); + function testRegistryInitializationFails() public { + uint256[] memory initialVersions = new uint256[](1); + initialVersions[0] = 1; + address[] memory initialProtocolAddresses = new address[](0); + + vm.expectCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall(WarpMessenger.getBlockchainID, ()) + ); + + vm.expectRevert( + WarpProtocolRegistry.InvalidRegistryInitialization.selector + ); + new TeleporterRegistry(initialVersions, initialProtocolAddresses); } - function test_addProtocolVersion() public { - teleporterRegistry.addProtocolVersion(address(0x1), 1); - Assert.equal(teleporterRegistry.getLatestVersion(), 1, "should be 1"); - Assert.equal( - teleporterRegistry.getAddressToVersion(address(0x1)), - 1, - "should be 1" + function testAddProtocolVersionSuccess() public { + uint256 latestVersion = teleporterRegistry.getLatestVersion(); + assertEq(0, latestVersion); + + _addProtocolVersion(teleporterRegistry); + assertEq(latestVersion + 1, teleporterRegistry.getLatestVersion()); + assertEq( + teleporterAddress, + address(teleporterRegistry.getLatestTeleporter()) + ); + assertEq( + teleporterRegistry.getAddressToVersion(teleporterAddress), + teleporterRegistry.getLatestVersion() ); } - function test_getVersionToAddress() public { - teleporterRegistry.addProtocolVersion(address(0x1), 1); - Assert.equal( - teleporterRegistry.getVersionToAddress(1), - address(0x1), - "should be 0x1" + function testAddToRegistryFails() public { + uint256 latestVersion = teleporterRegistry.getLatestVersion(); + uint32 messageIndex = 0; + + // Create a warp out of band message with same version as latest version + WarpMessage memory warpMessage = _createWarpOutofBandMessage( + latestVersion, + teleporterAddress, + address(teleporterRegistry) ); + + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall( + WarpMessenger.getVerifiedWarpMessage, + (messageIndex) + ), + abi.encode(warpMessage, true) + ); + vm.expectCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (messageIndex)) + ); + + // Check that adding a protocol version with the same version fails + vm.expectRevert(WarpProtocolRegistry.InvalidProtocolVersion.selector); + teleporterRegistry.addProtocolVersion(messageIndex); + + // Check that adding a protocol version with a version that is not the increment of the latest version fails + warpMessage = _createWarpOutofBandMessage( + latestVersion + 2, + teleporterAddress, + address(teleporterRegistry) + ); + + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall( + WarpMessenger.getVerifiedWarpMessage, + (messageIndex) + ), + abi.encode(warpMessage, true) + ); + + vm.expectRevert(WarpProtocolRegistry.InvalidProtocolVersion.selector); + teleporterRegistry.addProtocolVersion(messageIndex); + + // Check that adding a protocol address that is not a contract fails + warpMessage = _createWarpOutofBandMessage( + latestVersion + 1, + address(0), + address(teleporterRegistry) + ); + + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall( + WarpMessenger.getVerifiedWarpMessage, + (messageIndex) + ), + abi.encode(warpMessage, true) + ); + + vm.expectRevert(WarpProtocolRegistry.InvalidProtocolAddress.selector); + teleporterRegistry.addProtocolVersion(messageIndex); } - function test_getAddressToVersion() public { - teleporterRegistry.addProtocolVersion(address(0x1), 1); - Assert.equal( - teleporterRegistry.getAddressToVersion(address(0x1)), - 1, - "should be 1" + function testGetVersionToAddress() public { + _addProtocolVersion(teleporterRegistry); + uint256 latestVersion = teleporterRegistry.getLatestVersion(); + + // First test success case + assertEq( + teleporterAddress, + teleporterRegistry.getVersionToAddress(latestVersion) ); + + // Check that getting version 0 fails + vm.expectRevert(WarpProtocolRegistry.InvalidProtocolVersion.selector); + teleporterRegistry.getVersionToAddress(0); + + // Check that getting a version that doesn't exist fails + vm.expectRevert(WarpProtocolRegistry.InvalidProtocolVersion.selector); + teleporterRegistry.getVersionToAddress(latestVersion + 1); } - function test_getTeleporter() public { - teleporterRegistry.addProtocolVersion(address(0x1), 1); - Assert.equal( - teleporterRegistry.getTeleporter(1), - address(0x1), - "should be 0x1" + function testGetAddressToVersion() public { + _addProtocolVersion(teleporterRegistry); + uint256 latestVersion = teleporterRegistry.getLatestVersion(); + + // First test success case + assertEq( + latestVersion, + teleporterRegistry.getAddressToVersion(teleporterAddress) ); + + // Check that getting a version of an address that doesn't exist returns 0 + assertEq(0, teleporterRegistry.getAddressToVersion(address(this))); + } + + function testInvalidWarpMessage() public { + uint256 latestVersion = teleporterRegistry.getLatestVersion(); + uint32 messageIndex = 0; + WarpMessage memory warpMessage = _createWarpOutofBandMessage( + latestVersion + 1, + teleporterAddress, + address(teleporterRegistry) + ); + + // First check if warp message is invalid from getVerifiedWarpMessage + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall( + WarpMessenger.getVerifiedWarpMessage, + (messageIndex) + ), + abi.encode(warpMessage, false) + ); + vm.expectCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (messageIndex)) + ); + + vm.expectRevert(WarpProtocolRegistry.InvalidWarpMessage.selector); + teleporterRegistry.addProtocolVersion(messageIndex); + + // Check if we have an invalid source chain ID + warpMessage.sourceChainID = bytes32(uint256(1234567)); + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall( + WarpMessenger.getVerifiedWarpMessage, + (messageIndex) + ), + abi.encode(warpMessage, true) + ); + + vm.expectRevert(WarpProtocolRegistry.InvalidSourceChainID.selector); + teleporterRegistry.addProtocolVersion(messageIndex); + + // Check if we have an invalid origin sender address + warpMessage.sourceChainID = MOCK_BLOCK_CHAIN_ID; + warpMessage.originSenderAddress = address(this); + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall( + WarpMessenger.getVerifiedWarpMessage, + (messageIndex) + ), + abi.encode(warpMessage, true) + ); + + vm.expectRevert( + WarpProtocolRegistry.InvalidOriginSenderAddress.selector + ); + teleporterRegistry.addProtocolVersion(messageIndex); + + // Check if we have an invalid destination chain ID + warpMessage.originSenderAddress = teleporterRegistry + .VALIDATORS_SOURCE_ADDRESS(); + warpMessage.destinationChainID = bytes32(uint256(1234567)); + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall( + WarpMessenger.getVerifiedWarpMessage, + (messageIndex) + ), + abi.encode(warpMessage, true) + ); + + vm.expectRevert( + WarpProtocolRegistry.InvalidDestinationChainID.selector + ); + teleporterRegistry.addProtocolVersion(messageIndex); + + // Check if we have an invalid destination address + warpMessage.destinationChainID = MOCK_BLOCK_CHAIN_ID; + warpMessage.destinationAddress = address(this); + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall( + WarpMessenger.getVerifiedWarpMessage, + (messageIndex) + ), + abi.encode(warpMessage, true) + ); + + vm.expectRevert( + WarpProtocolRegistry.InvalidDestinationAddress.selector + ); + teleporterRegistry.addProtocolVersion(messageIndex); } - function test_getLatestTeleporter() public { - teleporterRegistry.addProtocolVersion(address(0x1), 1); - Assert.equal( - teleporterRegistry.getLatestTeleporter(), - address(0x1), - "should be 0x1" + function _addProtocolVersion(TeleporterRegistry registry) internal { + uint256 latestVersion = registry.getLatestVersion(); + uint32 messageIndex = 0; + WarpMessage memory warpMessage = _createWarpOutofBandMessage( + latestVersion + 1, + teleporterAddress, + address(registry) + ); + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall( + WarpMessenger.getVerifiedWarpMessage, + (messageIndex) + ), + abi.encode(warpMessage, true) + ); + vm.expectCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (messageIndex)) ); + + vm.expectEmit(true, true, false, false, address(registry)); + emit AddProtocolVersion(latestVersion + 1, teleporterAddress); + registry.addProtocolVersion(messageIndex); + } + + function _createWarpOutofBandMessage( + uint256 version, + address protocolAddress, + address registryAddress + ) internal view returns (WarpMessage memory) { + return + WarpMessage({ + sourceChainID: MOCK_BLOCK_CHAIN_ID, + originSenderAddress: TeleporterRegistry(registryAddress) + .VALIDATORS_SOURCE_ADDRESS(), + destinationChainID: MOCK_BLOCK_CHAIN_ID, + destinationAddress: address(registryAddress), + payload: abi.encode(version, protocolAddress) + }); } } diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 30dc35bc0..9e20cf522 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -25,6 +25,7 @@ abstract contract WarpProtocolRegistry { bytes32 internal immutable _chainID; + // The latest protocol version. 0 means no protocol version has been added, and isn't a valid version. uint256 internal _latestVersion; mapping(uint256 => address) internal _versionToAddress; @@ -56,12 +57,11 @@ abstract contract WarpProtocolRegistry { ) { _latestVersion = 0; _chainID = WARP_MESSENGER.getBlockchainID(); - uint256 numVersions_ = initialVersions.length; - if (initialProtocolAddresses.length != numVersions_) { + if (initialProtocolAddresses.length != initialVersions.length) { revert InvalidRegistryInitialization(); } - for (uint256 i = 0; i < numVersions_; i++) { + for (uint256 i = 0; i < initialVersions.length; i++) { _addToRegistry(initialVersions[i], initialProtocolAddresses[i]); } } @@ -150,7 +150,7 @@ abstract contract WarpProtocolRegistry { uint256 version ) internal view virtual returns (address) { // Check that the version provided is a valid version. - if (!(0 < version && version < _latestVersion)) { + if (!(0 < version && version <= _latestVersion)) { revert InvalidProtocolVersion(); } return _versionToAddress[version]; diff --git a/go.work.sum b/go.work.sum index d9431a84c..1a7563a97 100644 --- a/go.work.sum +++ b/go.work.sum @@ -550,8 +550,158 @@ github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwc github.com/apache/arrow/go/arrow v0.0.0-20191024131854-af6fa24be0db h1:nxAtV4VajJDhKysp2kdcJZsq8Ss1xSA0vZTkVHHJd0E= github.com/armon/go-metrics v0.3.10 h1:FR+drcQStOe+32sYyJYyZ7FIdgoGGBnwLl+flodp8Uo= github.com/ava-labs/avalanche-ledger-go v0.0.13 h1:YTdaSuaZS/1ct1RGirBEJeo2tiSfVeJGaE12XtUSGnE= +github.com/ava-labs/avalanche-network-runner v1.7.2 h1:XFad/wZfYzDnqbLzPAPPRYU3a1Zc8QT8x5dtLTS3lUo= +github.com/ava-labs/avalanche-network-runner v1.7.2/go.mod h1:naLveusSrP7YgTAqRykD1SyLOAUilCp9jGjk3MDxoPI= +github.com/ava-labs/avalanche-network-runner-sdk v0.3.0/go.mod h1:SgKJvtqvgo/Bl/c8fxEHCLaSxEbzimYfBopcfrajxQk= +github.com/ava-labs/avalanchego v1.10.10-rc.4/go.mod h1:BN97sZppDSvIMIfEjrLTjdPTFkGLkb0ISJHEcoxMMNk= +github.com/ava-labs/coreth v0.12.5-rc.6 h1:OajGUyKkO5Q82XSuMa8T5UD6QywtCHUiZ4Tv3RFmRBU= +github.com/ava-labs/coreth v0.12.5-rc.6/go.mod h1:s5wVyy+5UCCk2m0Tq3jVmy0UqOpKBDYqRE13gInCJVs= +github.com/ava-labs/ledger-avalanche/go v0.0.0-20230105152938-00a24d05a8c7/go.mod h1:XhiXSrh90sHUbkERzaxEftCmUz53eCijshDLZ4fByVM= +github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= +github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20230310173818-32f1caf87195/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= +github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/envoyproxy/go-control-plane v0.11.0/go.mod h1:VnHyVMpzcLvCFt9yUz1UnCwHLhwx1WguiVDV7pTG/tI= +github.com/envoyproxy/protoc-gen-validate v0.10.0/go.mod h1:DRjgyB0I43LtJapqN6NiRwroiAU2PaFuvk/vjgh61ss= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= +github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= +github.com/googleapis/enterprise-certificate-proxy v0.2.1/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= +github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= +github.com/googleapis/gax-go/v2 v2.7.0/go.mod h1:TEop28CZZQ2y+c0VxMUmu1lV+fQx57QpBWsYpwqHJx8= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.12.0/go.mod h1:ummNFgdgLhhX7aIiy35vVmQNS0rWXknfPE0qe6fmFXg= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo= +github.com/onsi/ginkgo/v2 v2.7.0/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo= +github.com/onsi/gomega v1.24.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sanity-io/litter v1.5.1/go.mod h1:5Z71SvaYy5kcGtyglXOC9rrUi3c1E8CamFWjQsazTh0= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/thepudds/fzgen v0.4.2/go.mod h1:kHCWdsv5tdnt32NIHYDdgq083m6bMtaY0M+ipiO9xWE= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/xhit/go-str2duration v1.2.0/go.mod h1:3cPSlfZlUHVlneIVfePFWcJZsuwf+P1v2SRTV4cUmp4= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= +github.com/zondax/ledger-go v0.14.1/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2feOQv8K320= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= +golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= +golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= +golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +google.golang.org/api v0.108.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= +google.golang.org/api v0.110.0/go.mod h1:7FC4Vvx1Mooxh8C5HWjzZHcavuS2f6pmJpZx60ca7iI= +google.golang.org/genproto v0.0.0-20230124163310-31e0e69b6fc2/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= +google.golang.org/genproto v0.0.0-20230209215440-0dfe4f8abfcc/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= +google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44/go.mod h1:8B0gmkoRebU8ukX6HP+4wrVQUY1+6PkQ44BSyIlflHA= +google.golang.org/genproto v0.0.0-20230223222841-637eb2293923/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= +google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= +google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= From 6d14e84d471360ceacc46ded06bc5b1160898956 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Fri, 29 Sep 2023 21:55:01 +0000 Subject: [PATCH 14/80] deploy registry in tests and erc20bridge test working --- .gitignore | 1 + .../src/Teleporter/TeleporterRegistry.sol | 6 +++++- contracts/src/WarpProtocolRegistry.sol | 6 +++++- docker/run_setup.sh | 18 ++++++++++++++++++ .../integration-tests/erc20_bridge_multihop.sh | 11 +++++++---- 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index fefdf3aaa..1860daa1f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ subnetGenesis_* vars.sh NETWORK_READY NETWORK_RUNNING +.awm-relayer-storage/ # Raw Contract Deployment Transaction UniversalTeleporterDeployerTransaction.txt diff --git a/contracts/src/Teleporter/TeleporterRegistry.sol b/contracts/src/Teleporter/TeleporterRegistry.sol index 623c3f770..077c0e24a 100644 --- a/contracts/src/Teleporter/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/TeleporterRegistry.sol @@ -18,7 +18,11 @@ contract TeleporterRegistry is WarpProtocolRegistry { constructor( uint256[] memory initialVersions, address[] memory initialProtocolAddresses - ) WarpProtocolRegistry(initialVersions, initialProtocolAddresses) {} + ) WarpProtocolRegistry(initialVersions, initialProtocolAddresses) { + for (uint256 i = 0; i < initialVersions.length; i++) { + _addressToVersion[initialProtocolAddresses[i]] = initialVersions[i]; + } + } /** * @dev Gets the {ITeleporterMessenger} contract of the given `version`. diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 9e20cf522..fd8241f45 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -150,7 +150,11 @@ abstract contract WarpProtocolRegistry { uint256 version ) internal view virtual returns (address) { // Check that the version provided is a valid version. - if (!(0 < version && version <= _latestVersion)) { + if (version == 0) { + revert InvalidProtocolVersion(; + } + + if (version > _latestVersion) { revert InvalidProtocolVersion(); } return _versionToAddress[version]; diff --git a/docker/run_setup.sh b/docker/run_setup.sh index 8950c27a9..10ac01cd9 100755 --- a/docker/run_setup.sh +++ b/docker/run_setup.sh @@ -127,6 +127,24 @@ if [ ! -e $dir_prefix/NETWORK_RUNNING ]; then fi echo "Deployed TeleporterMessenger to Subnet C" + # Deploy TeleporterRegistry to each chain. + cd contracts + registry_deploy_result_a=$(forge create --private-key $user_private_key --constructor-args [1] "[$teleporter_contract_address]" \ + --rpc-url $subnet_a_url src/Teleporter/TeleporterRegistry.sol:TeleporterRegistry) + registry_address_a=$(parseContractAddress "$registry_deploy_result_a") + echo "TeleporterRegistry contract deployed to subnet A at $registry_address_a." + + registry_deploy_result_b=$(forge create --private-key $user_private_key --constructor-args [1] "[$teleporter_contract_address]" \ + --rpc-url $subnet_b_url src/Teleporter/TeleporterRegistry.sol:TeleporterRegistry) + registry_address_b=$(parseContractAddress "$registry_deploy_result_b") + echo "TeleporterRegistry contract deployed to subnet A at $registry_address_b." + + registry_deploy_result_c=$(forge create --private-key $user_private_key --constructor-args [1] "[$teleporter_contract_address]" \ + --rpc-url $subnet_c_url src/Teleporter/TeleporterRegistry.sol:TeleporterRegistry) + registry_address_c=$(parseContractAddress "$registry_deploy_result_c") + echo "TeleporterRegistry contract deployed to subnet A at $registry_address_c." + cd .. + # Send tokens to cover gas costs for the relayers. relayer_private_key=C2CE4E001B7585F543982A01FBC537CFF261A672FA8BD1FAFC08A207098FE2DE relayer_address=0xA100fF48a37cab9f87c8b5Da933DA46ea1a5fb80 diff --git a/scripts/local/integration-tests/erc20_bridge_multihop.sh b/scripts/local/integration-tests/erc20_bridge_multihop.sh index 7ba9760db..8665fec50 100755 --- a/scripts/local/integration-tests/erc20_bridge_multihop.sh +++ b/scripts/local/integration-tests/erc20_bridge_multihop.sh @@ -26,6 +26,9 @@ set -e # Stop on first error # subnet_b_subnet_id_hex # subnet_c_subnet_id_hex # teleporter_contract_address +# registry_address_a +# registry_address_b +# registry_address_c # Test covers: # - Creating bridged tokens on subnets different from the original subnet with the native token asset. @@ -39,18 +42,18 @@ native_erc20_deploy_result=$(forge create --private-key $user_private_key src/Mo native_erc20_contract_address=$(parseContractAddress "$native_erc20_deploy_result") echo "Test ERC20 contract deployed to $native_erc20_contract_address on Subnet A" -# Deploy the ERC20 bridge contract to both chains. -bridge_a_deploy_result=$(forge create --private-key $user_private_key --constructor-args $teleporter_contract_address \ +# Deploy the ERC20 bridge contract to all chains. +bridge_a_deploy_result=$(forge create --private-key $user_private_key --constructor-args $registry_address_a \ --rpc-url $subnet_a_url src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol:ERC20Bridge) bridge_a_address=$(parseContractAddress "$bridge_a_deploy_result") echo "ERC20 bridge contract deployed to subnet A at $bridge_a_address." -bridge_b_deploy_result=$(forge create --private-key $user_private_key --constructor-args $teleporter_contract_address \ +bridge_b_deploy_result=$(forge create --private-key $user_private_key --constructor-args $registry_address_b \ --rpc-url $subnet_b_url src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol:ERC20Bridge) bridge_b_address=$(parseContractAddress "$bridge_b_deploy_result") echo "ERC20 bridge contract deployed to subnet B at $bridge_b_address." -bridge_c_deploy_result=$(forge create --private-key $user_private_key --constructor-args $teleporter_contract_address \ +bridge_c_deploy_result=$(forge create --private-key $user_private_key --constructor-args $registry_address_c \ --rpc-url $subnet_c_url src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol:ERC20Bridge) bridge_c_address=$(parseContractAddress "$bridge_c_deploy_result") echo "ERC20 bridge contract deployed to subnet C at $bridge_c_address." From 733c3c20413b83b023de428aa1eb4fdcffff89d5 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Fri, 29 Sep 2023 22:13:03 +0000 Subject: [PATCH 15/80] use registry for cross chain app tests --- contracts/src/WarpProtocolRegistry.sol | 2 +- .../integration-tests/basic_send_receive.sh | 3 ++ .../block_hash_publish_receive.sh | 8 +++- .../erc20_bridge_multihop.sh | 1 + .../integration-tests/example_messenger.sh | 7 +++- .../integration-tests/registry_basics.sh | 40 +++++++++++++++++++ .../local/integration-tests/retry_receipts.sh | 3 ++ 7 files changed, 59 insertions(+), 5 deletions(-) create mode 100755 scripts/local/integration-tests/registry_basics.sh diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index fd8241f45..d9866b753 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -151,7 +151,7 @@ abstract contract WarpProtocolRegistry { ) internal view virtual returns (address) { // Check that the version provided is a valid version. if (version == 0) { - revert InvalidProtocolVersion(; + revert InvalidProtocolVersion(); } if (version > _latestVersion) { diff --git a/scripts/local/integration-tests/basic_send_receive.sh b/scripts/local/integration-tests/basic_send_receive.sh index aab750b6f..a6aff1f3b 100755 --- a/scripts/local/integration-tests/basic_send_receive.sh +++ b/scripts/local/integration-tests/basic_send_receive.sh @@ -22,6 +22,9 @@ set -e # Stop on first error # subnet_b_subnet_id_hex # teleporter_contract_address # warp_messenger_precompile_addr +# registry_address_a +# registry_address_b +# registry_address_c # Test covers: # - Sending bidirectional cross chain messages between two chains, by calling Teleporter contract sendCrossChainMessage function directly. diff --git a/scripts/local/integration-tests/block_hash_publish_receive.sh b/scripts/local/integration-tests/block_hash_publish_receive.sh index 314817d5e..8e9b3695e 100755 --- a/scripts/local/integration-tests/block_hash_publish_receive.sh +++ b/scripts/local/integration-tests/block_hash_publish_receive.sh @@ -21,6 +21,10 @@ set -e # Stop on first error # subnet_a_subnet_id_hex # subnet_b_subnet_id_hex # teleporter_contract_address +# warp_messenger_precompile_addr +# registry_address_a +# registry_address_b +# registry_address_c # Test covers: # - Deploying block hash publisher smart contract, which is built on top of teleporter. @@ -28,14 +32,14 @@ set -e # Stop on first error # Deploy the block hash publisher to subnet A cd contracts -block_hash_publisher_deploy_result=$(forge create --private-key $user_private_key --constructor-args $teleporter_contract_address \ +block_hash_publisher_deploy_result=$(forge create --private-key $user_private_key --constructor-args $registry_address_a \ --rpc-url $subnet_a_url src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol:BlockHashPublisher) block_hash_publisher_contract_address=$(parseContractAddress "$block_hash_publisher_deploy_result") echo "Block hash publisher contract deployed to subnet A at $block_hash_publisher_contract_address" # Deploy the example messenger application on subnet B block_hash_receiver_deploy_result=$(forge create --private-key $user_private_key \ - --constructor-args $teleporter_contract_address $subnet_a_chain_id_hex $block_hash_publisher_contract_address \ + --constructor-args $registry_address_a $subnet_a_chain_id_hex $block_hash_publisher_contract_address \ --rpc-url $subnet_b_url src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol:BlockHashReceiver) block_hash_receiver_contract_address=$(parseContractAddress "$block_hash_receiver_deploy_result") echo "Block hash receiver contract deployed to subnet B at $block_hash_receiver_contract_address" diff --git a/scripts/local/integration-tests/erc20_bridge_multihop.sh b/scripts/local/integration-tests/erc20_bridge_multihop.sh index 8665fec50..e053d0931 100755 --- a/scripts/local/integration-tests/erc20_bridge_multihop.sh +++ b/scripts/local/integration-tests/erc20_bridge_multihop.sh @@ -26,6 +26,7 @@ set -e # Stop on first error # subnet_b_subnet_id_hex # subnet_c_subnet_id_hex # teleporter_contract_address +# warp_messenger_precompile_addr # registry_address_a # registry_address_b # registry_address_c diff --git a/scripts/local/integration-tests/example_messenger.sh b/scripts/local/integration-tests/example_messenger.sh index c746ab3f1..2baf95efa 100755 --- a/scripts/local/integration-tests/example_messenger.sh +++ b/scripts/local/integration-tests/example_messenger.sh @@ -22,6 +22,9 @@ set -e # Stop on first error # subnet_b_subnet_id_hex # teleporter_contract_address # warp_messenger_precompile_addr +# registry_address_a +# registry_address_b +# registry_address_c # Deploy a test ERC20 on subnet A. cd contracts @@ -30,13 +33,13 @@ erc20_contract_address=$(parseContractAddress "$erc20_deploy_result") echo "Test ERC20 contract deployed to $erc20_contract_address on Subnet A" # Deploy the example messenger application on subnet A -example_messenger_a_deploy_result=$(forge create --private-key $user_private_key --constructor-args $teleporter_contract_address \ +example_messenger_a_deploy_result=$(forge create --private-key $user_private_key --constructor-args $registry_address_a \ --rpc-url $subnet_a_url src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol:ExampleCrossChainMessenger) example_messenger_a_contract_address=$(parseContractAddress "$example_messenger_a_deploy_result") echo "Example Messenger contract deployed to subnet A at $example_messenger_a_contract_address" # Deploy the example messenger application on subnet B -example_messenger_b_deploy_result=$(forge create --private-key $user_private_key --constructor-args $teleporter_contract_address \ +example_messenger_b_deploy_result=$(forge create --private-key $user_private_key --constructor-args $registry_address_b \ --rpc-url $subnet_b_url src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol:ExampleCrossChainMessenger) example_messenger_b_contract_address=$(parseContractAddress "$example_messenger_b_deploy_result") echo "Example Messenger contract deployed to subnet B at $example_messenger_b_contract_address" diff --git a/scripts/local/integration-tests/registry_basics.sh b/scripts/local/integration-tests/registry_basics.sh new file mode 100755 index 000000000..cc8009e38 --- /dev/null +++ b/scripts/local/integration-tests/registry_basics.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# Copyright (C) 2023, Ava Labs, Inc. All rights reserved. +# See the file LICENSE for licensing terms. + +set -e # Stop on first error + +# Variables provided by run_test.sh: +# c_chain_url +# user_private_key +# user_address_bytes +# user_address +# relayer_address +# subnet_a_chain_id +# subnet_b_chain_id +# subnet_c_chain_id +# subnet_a_subnet_id +# subnet_b_subnet_id +# subnet_c_subnet_id +# subnet_a_url +# subnet_b_url +# subnet_c_url +# subnet_a_chain_id_hex +# subnet_b_chain_id_hex +# subnet_c_chain_id_hex +# subnet_a_subnet_id_hex +# subnet_b_subnet_id_hex +# subnet_c_subnet_id_hex +# teleporter_contract_address +# registry_address_a +# registry_address_b +# registry_address_c + +latestVersion=$(cast call $registry_address_a "getLatestVersion()(uint256)" --rpc-url $subnet_a_url) +echo "Got latest Teleporter version $latestVersion" + +result=$(cast call $registry_address_a "getAddressToVersion(address)(uint256)" $teleporter_contract_address --rpc-url $subnet_a_url) +echo "Teleporter address $teleporter_contract_address is at version $result" + +latestAddress=$(cast call $registry_address_a "getVersionToAddress(uint256)(address)" $latestVersion --rpc-url $subnet_a_url) +echo "Latest Teleporter address is $latestAddress" \ No newline at end of file diff --git a/scripts/local/integration-tests/retry_receipts.sh b/scripts/local/integration-tests/retry_receipts.sh index 24fff68d0..141fd7e45 100755 --- a/scripts/local/integration-tests/retry_receipts.sh +++ b/scripts/local/integration-tests/retry_receipts.sh @@ -22,6 +22,9 @@ set -e # Stop on first error # subnet_b_subnet_id_hex # teleporter_contract_address # warp_messenger_precompile_addr +# registry_address_a +# registry_address_b +# registry_address_c # Test covers: # - Sending cross chain messages between two chains, by calling Teleporter contract sendCrossChainMessage function directly. From 051c6bb4df52518bf9ffd3ced3e658516a05bed7 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Mon, 2 Oct 2023 18:45:41 +0000 Subject: [PATCH 16/80] draft teleporterUpgradeable contract --- .../ERC20Bridge/ERC20Bridge.sol | 1 - .../src/Teleporter/TeleporterUpgradeable.sol | 43 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 contracts/src/Teleporter/TeleporterUpgradeable.sol diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol index a5b124fbf..442871f30 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol @@ -89,7 +89,6 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { error InvalidBridgeTokenAddress(); error InvalidDestinationBridgeAddress(); error InvalidRecipientAddress(); - error InvalidTeleporterRegistryAddress(); error Unauthorized(); /** diff --git a/contracts/src/Teleporter/TeleporterUpgradeable.sol b/contracts/src/Teleporter/TeleporterUpgradeable.sol new file mode 100644 index 000000000..b6a7b7fc5 --- /dev/null +++ b/contracts/src/Teleporter/TeleporterUpgradeable.sol @@ -0,0 +1,43 @@ +// (c) 2023, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +// SPDX-License-Identifier: Ecosystem + +pragma solidity 0.8.18; + +import "./TeleporterRegistry.sol"; + +abstract contract TeleporterUpgradeable { + TeleporterRegistry public immutable teleporterRegistry; + uint256 internal _minTeleporterVersion; + + error InvalidTeleporterRegistryAddress(); + error InvalidTeleporterSender(); + + constructor(address teleporterRegistryAddress) { + if (teleporterRegistryAddress == address(0)) { + revert InvalidTeleporterRegistryAddress(); + } + + teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); + _minTeleporterVersion = teleporterRegistry.getLatestVersion(); + } + + modifier onlyAllowedTeleporter() { + _checkTeleporterMinVersion(); + _; + } + + function updateMinTeleporterversion() external { + _minTeleporterVersion = teleporterRegistry.getLatestVersion(); + } + + function _checkTeleporterMinVersion() view virtual interal { + if ( + teleporterRegistry.getAddressToVersion(msg.sender) < + _minTeleporterVersion + ) { + revert InvalidTeleporterSender(); + } + } +} From 8dfb4fe5ecd7c9529b228e2d878e9f4e0d9b4488 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Mon, 2 Oct 2023 19:01:29 +0000 Subject: [PATCH 17/80] use TeleporterUpgradeable in cross chain apps --- .../ERC20Bridge/ERC20Bridge.sol | 43 ++++++------------- .../ExampleCrossChainMessenger.sol | 39 +++++------------ .../VerifiedBlockHash/BlockHashPublisher.sol | 22 +++------- .../VerifiedBlockHash/BlockHashReceiver.sol | 29 ++----------- .../src/Teleporter/TeleporterUpgradeable.sol | 2 +- 5 files changed, 34 insertions(+), 101 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol index 442871f30..48f978a70 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol @@ -10,11 +10,12 @@ import "./BridgeToken.sol"; import "../../Teleporter/ITeleporterMessenger.sol"; import "../../Teleporter/ITeleporterReceiver.sol"; import "../../Teleporter/SafeERC20TransferFrom.sol"; +import "../../Teleporter/TeleporterRegistry.sol"; +import "../../Teleporter/TeleporterUpgradeable.sol"; import "@subnet-evm-contracts/interfaces/IWarpMessenger.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; -import "../../Teleporter/TeleporterRegistry.sol"; struct TokenID { bytes32 chainID; @@ -28,7 +29,12 @@ struct TokenID { * This implementation uses the {BridgeToken} contract to represent tokens on this chain, and uses * {ITeleporterMessenger} to send and receive messages to other chains. */ -contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { +contract ERC20Bridge is + IERC20Bridge, + ITeleporterReceiver, + ReentrancyGuard, + TeleporterUpgradeable +{ using SafeERC20 for IERC20; struct WrappedTokenTransferInfo { @@ -45,10 +51,6 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { 0x0200000000000000000000000000000000000005; bytes32 public immutable currentChainID; - // Used for sending and receiving Teleporter messages. - TeleporterRegistry public immutable teleporterRegistry; - uint256 internal _minTeleporterVersion; - // Tracks which bridge tokens have been submitted to be created other bridge instances. // (destinationChainID, destinationBridgeAddress) -> nativeTokenContract -> tokenCreationSubmitted // Note that the existence of a bridge token in this mapping does not ensure that it exists on @@ -89,19 +91,14 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { error InvalidBridgeTokenAddress(); error InvalidDestinationBridgeAddress(); error InvalidRecipientAddress(); - error Unauthorized(); /** * @dev Initializes the Teleporter messenger used for sending and receiving messages, * and initializes the current chain ID. */ - constructor(address teleporterRegistryAddress) { - if (teleporterRegistryAddress == address(0)) { - revert InvalidTeleporterRegistryAddress(); - } - - teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); - _minTeleporterVersion = teleporterRegistry.getLatestVersion(); + constructor( + address teleporterRegistryAddress + ) TeleporterUpgradeable(teleporterRegistryAddress) { currentChainID = WarpMessenger(WARP_PRECOMPILE_ADDRESS) .getBlockchainID(); } @@ -285,15 +282,7 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { bytes32 nativeChainID, address nativeBridgeAddress, bytes calldata message - ) external { - // Only allow Teleporter messengers above the minimum version to deliver messages. - if ( - teleporterRegistry.getAddressToVersion(msg.sender) < - _minTeleporterVersion - ) { - revert Unauthorized(); - } - + ) external onlyAllowedTeleporter { // Decode the payload to recover the action and corresponding function parameters (BridgeAction action, bytes memory actionData) = abi.decode( message, @@ -356,10 +345,6 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { } } - function updateMinTeleporterVersion() external { - _minTeleporterVersion = teleporterRegistry.getLatestVersion(); - } - /** * @dev Encodes the parameters for the Create action to be decoded and executed on the destination. */ @@ -490,7 +475,7 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { address nativeContractAddress, address recipient, uint256 amount - ) private nonReentrant { + ) private nonReentrant onlyAllowedTeleporter { // The recipient cannot be the zero address. if (recipient == address(0)) { revert InvalidRecipientAddress(); @@ -528,7 +513,7 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard { address recipient, uint256 totalAmount, uint256 secondaryFeeAmount - ) private nonReentrant { + ) private nonReentrant onlyAllowedTeleporter { // Neither the recipient nor the destination bridge can be the zero address. if (recipient == address(0)) { revert InvalidRecipientAddress(); diff --git a/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol b/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol index 59f03ae3a..4bb23b2e4 100644 --- a/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol +++ b/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol @@ -9,6 +9,7 @@ import "../../Teleporter/ITeleporterMessenger.sol"; import "../../Teleporter/SafeERC20TransferFrom.sol"; import "../../Teleporter/ITeleporterReceiver.sol"; import "../../Teleporter/TeleporterRegistry.sol"; +import "../../Teleporter/TeleporterUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; @@ -16,7 +17,11 @@ import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; * @dev ExampleCrossChainMessenger is an example contract that demonstrates how to send and receive * messages cross chain. */ -contract ExampleCrossChainMessenger is ITeleporterReceiver, ReentrancyGuard { +contract ExampleCrossChainMessenger is + ITeleporterReceiver, + ReentrancyGuard, + TeleporterUpgradeable +{ using SafeERC20 for IERC20; // Messages sent to this contract. @@ -25,9 +30,6 @@ contract ExampleCrossChainMessenger is ITeleporterReceiver, ReentrancyGuard { string message; } - TeleporterRegistry public immutable teleporterRegistry; - uint256 internal _minTeleporterVersion; - mapping(bytes32 => Message) private _messages; /** @@ -51,18 +53,9 @@ contract ExampleCrossChainMessenger is ITeleporterReceiver, ReentrancyGuard { string message ); - // Errors - error InvalidTeleporterRegistryAddress(); - error Unauthorized(); - - constructor(address teleporterRegistryAddress) { - if (teleporterRegistryAddress == address(0)) { - revert InvalidTeleporterRegistryAddress(); - } - - teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); - _minTeleporterVersion = teleporterRegistry.getLatestVersion(); - } + constructor( + address teleporterRegistryAddress + ) TeleporterUpgradeable(teleporterRegistryAddress) {} /** * @dev See {ITeleporterReceiver-receiveTeleporterMessage}. @@ -73,15 +66,7 @@ contract ExampleCrossChainMessenger is ITeleporterReceiver, ReentrancyGuard { bytes32 originChainID, address originSenderAddress, bytes calldata message - ) external { - // Only the Teleporter receiver can deliver a message. - if ( - teleporterRegistry.getAddressToVersion(msg.sender) < - _minTeleporterVersion - ) { - revert Unauthorized(); - } - + ) external onlyAllowedTeleporter { // Store the message. string memory messageString = abi.decode(message, (string)); _messages[originChainID] = Message(originSenderAddress, messageString); @@ -139,10 +124,6 @@ contract ExampleCrossChainMessenger is ITeleporterReceiver, ReentrancyGuard { ); } - function updateMinTeleporterVersion() external { - _minTeleporterVersion = teleporterRegistry.getLatestVersion(); - } - /** * @dev Returns the current message from another chain. */ diff --git a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol index ddf048fb6..cf4c96e78 100644 --- a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol +++ b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol @@ -7,15 +7,14 @@ pragma solidity 0.8.18; import "../../Teleporter/ITeleporterMessenger.sol"; import "../../Teleporter/TeleporterRegistry.sol"; +import "../../Teleporter/TeleporterUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./BlockHashReceiver.sol"; /** * Contract that publishes the latest block hash of current chain to another chain. */ -contract BlockHashPublisher { - TeleporterRegistry public immutable teleporterRegistry; - uint256 internal _minTeleporterVersion; +contract BlockHashPublisher is TeleporterUpgradeable { uint256 public constant RECEIVE_BLOCK_HASH_REQUIRED_GAS_LIMIT = 1.5e5; /** @@ -28,16 +27,9 @@ contract BlockHashPublisher { bytes32 blockHash ); - error InvalidTeleporterRegistryAddress(); - - constructor(address teleporterRegistryAddress) { - if (teleporterRegistryAddress == address(0)) { - revert InvalidTeleporterRegistryAddress(); - } - - teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); - _minTeleporterVersion = teleporterRegistry.getLatestVersion(); - } + constructor( + address teleporterRegistryAddress + ) TeleporterUpgradeable(teleporterRegistryAddress) {} /** * @dev Publishes the latest block hash to another chain. @@ -77,8 +69,4 @@ contract BlockHashPublisher { }) ); } - - function updateMinTeleporterVersion() external { - _minTeleporterVersion = teleporterRegistry.getLatestVersion(); - } } diff --git a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol index 50bc22579..92462ebe4 100644 --- a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol +++ b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol @@ -8,14 +8,12 @@ pragma solidity 0.8.18; import "../../Teleporter/ITeleporterMessenger.sol"; import "../../Teleporter/ITeleporterReceiver.sol"; import "../../Teleporter/TeleporterRegistry.sol"; +import "../../Teleporter/TeleporterUpgradeable.sol"; /** * Contract for receiving latest block hashes from another chain. */ -contract BlockHashReceiver is ITeleporterReceiver { - TeleporterRegistry public immutable teleporterRegistry; - uint256 internal _minTeleporterVersion; - +contract BlockHashReceiver is ITeleporterReceiver, TeleporterUpgradeable { // Source chain information bytes32 public immutable sourceChainID; address public immutable sourcePublisherContractAddress; @@ -35,22 +33,14 @@ contract BlockHashReceiver is ITeleporterReceiver { ); // Errors - error Unauthorized(); error InvalidSourceChainID(); error InvalidSourceChainPublisher(); - error InvalidTeleporterRegistryAddress(); constructor( address teleporterRegistryAddress, bytes32 publisherChainID, address publisherContractAddress - ) { - if (teleporterRegistryAddress == address(0)) { - revert InvalidTeleporterRegistryAddress(); - } - - teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); - _minTeleporterVersion = teleporterRegistry.getLatestVersion(); + ) TeleporterUpgradeable(teleporterRegistryAddress) { sourceChainID = publisherChainID; sourcePublisherContractAddress = publisherContractAddress; } @@ -70,14 +60,7 @@ contract BlockHashReceiver is ITeleporterReceiver { bytes32 originChainID, address originSenderAddress, bytes calldata message - ) external { - if ( - teleporterRegistry.getAddressToVersion(msg.sender) < - _minTeleporterVersion - ) { - revert Unauthorized(); - } - + ) external onlyAllowedTeleporter { if (originChainID != sourceChainID) { revert InvalidSourceChainID(); } @@ -103,10 +86,6 @@ contract BlockHashReceiver is ITeleporterReceiver { } } - function updateMinTeleporterVersion() external { - _minTeleporterVersion = teleporterRegistry.getLatestVersion(); - } - /** * @dev Returns the latest block information. */ diff --git a/contracts/src/Teleporter/TeleporterUpgradeable.sol b/contracts/src/Teleporter/TeleporterUpgradeable.sol index b6a7b7fc5..62b432405 100644 --- a/contracts/src/Teleporter/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/TeleporterUpgradeable.sol @@ -32,7 +32,7 @@ abstract contract TeleporterUpgradeable { _minTeleporterVersion = teleporterRegistry.getLatestVersion(); } - function _checkTeleporterMinVersion() view virtual interal { + function _checkTeleporterMinVersion() internal view virtual { if ( teleporterRegistry.getAddressToVersion(msg.sender) < _minTeleporterVersion From 7552339bda61e8515d1bcfa27c10cdc435af47cd Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Mon, 2 Oct 2023 19:14:33 +0000 Subject: [PATCH 18/80] docs and cleanup --- .../src/Teleporter/TeleporterUpgradeable.sol | 17 ++++++++ .../integration-tests/registry_basics.sh | 40 ------------------- 2 files changed, 17 insertions(+), 40 deletions(-) delete mode 100755 scripts/local/integration-tests/registry_basics.sh diff --git a/contracts/src/Teleporter/TeleporterUpgradeable.sol b/contracts/src/Teleporter/TeleporterUpgradeable.sol index 62b432405..7ff124196 100644 --- a/contracts/src/Teleporter/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/TeleporterUpgradeable.sol @@ -7,6 +7,10 @@ pragma solidity 0.8.18; import "./TeleporterRegistry.sol"; +/** + * @dev TeleporterUpgradeable provides upgrade utility for applications built on top + * of the Teleporter protocol by integrating with the {TeleporterRegistry}. + */ abstract contract TeleporterUpgradeable { TeleporterRegistry public immutable teleporterRegistry; uint256 internal _minTeleporterVersion; @@ -14,6 +18,10 @@ abstract contract TeleporterUpgradeable { error InvalidTeleporterRegistryAddress(); error InvalidTeleporterSender(); + /** + * @dev Initializes the {TeleporterUpgradeable} contract by getting `teleporterRegistry` + * instance and setting `_minTeleporterVersion`. + */ constructor(address teleporterRegistryAddress) { if (teleporterRegistryAddress == address(0)) { revert InvalidTeleporterRegistryAddress(); @@ -23,15 +31,24 @@ abstract contract TeleporterUpgradeable { _minTeleporterVersion = teleporterRegistry.getLatestVersion(); } + /** + * @dev Throws if called by a `msg.sender` that is not an allowed Telepoter version. + */ modifier onlyAllowedTeleporter() { _checkTeleporterMinVersion(); _; } + /** + * @dev Updates `_minTeleporterVersion` to the latest version. + */ function updateMinTeleporterversion() external { _minTeleporterVersion = teleporterRegistry.getLatestVersion(); } + /** + * @dev Checks that `msg.sender` matches a Teleporter version greater than or equal to `_minTeleporterVersion`. + */ function _checkTeleporterMinVersion() internal view virtual { if ( teleporterRegistry.getAddressToVersion(msg.sender) < diff --git a/scripts/local/integration-tests/registry_basics.sh b/scripts/local/integration-tests/registry_basics.sh deleted file mode 100755 index cc8009e38..000000000 --- a/scripts/local/integration-tests/registry_basics.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash -# Copyright (C) 2023, Ava Labs, Inc. All rights reserved. -# See the file LICENSE for licensing terms. - -set -e # Stop on first error - -# Variables provided by run_test.sh: -# c_chain_url -# user_private_key -# user_address_bytes -# user_address -# relayer_address -# subnet_a_chain_id -# subnet_b_chain_id -# subnet_c_chain_id -# subnet_a_subnet_id -# subnet_b_subnet_id -# subnet_c_subnet_id -# subnet_a_url -# subnet_b_url -# subnet_c_url -# subnet_a_chain_id_hex -# subnet_b_chain_id_hex -# subnet_c_chain_id_hex -# subnet_a_subnet_id_hex -# subnet_b_subnet_id_hex -# subnet_c_subnet_id_hex -# teleporter_contract_address -# registry_address_a -# registry_address_b -# registry_address_c - -latestVersion=$(cast call $registry_address_a "getLatestVersion()(uint256)" --rpc-url $subnet_a_url) -echo "Got latest Teleporter version $latestVersion" - -result=$(cast call $registry_address_a "getAddressToVersion(address)(uint256)" $teleporter_contract_address --rpc-url $subnet_a_url) -echo "Teleporter address $teleporter_contract_address is at version $result" - -latestAddress=$(cast call $registry_address_a "getVersionToAddress(uint256)(address)" $latestVersion --rpc-url $subnet_a_url) -echo "Latest Teleporter address is $latestAddress" \ No newline at end of file From 2474f2ea6c4fc8c5a7152e83b80fecfb339fd3da Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Mon, 2 Oct 2023 21:44:53 +0000 Subject: [PATCH 19/80] refactor and test TeleporterUprgradeable --- .../ERC20Bridge/ERC20Bridge.sol | 4 +- .../ExampleCrossChainMessenger.sol | 4 +- .../VerifiedBlockHash/BlockHashPublisher.sol | 4 +- .../VerifiedBlockHash/BlockHashReceiver.sol | 4 +- .../{ => upgrades}/TeleporterRegistry.sol | 31 ++++--- .../{ => upgrades}/TeleporterUpgradeable.sol | 19 ++-- .../tests/TeleporterRegistryTests.t.sol} | 41 ++++++++- .../tests/TeleporterUpgradeableTests.t.sol | 89 +++++++++++++++++++ contracts/src/WarpProtocolRegistry.sol | 19 ++++ docker/run_setup.sh | 6 +- 10 files changed, 186 insertions(+), 35 deletions(-) rename contracts/src/Teleporter/{ => upgrades}/TeleporterRegistry.sol (72%) rename contracts/src/Teleporter/{ => upgrades}/TeleporterUpgradeable.sol (84%) rename contracts/src/Teleporter/{tests/TeleporterRegistryTest.t.sol => upgrades/tests/TeleporterRegistryTests.t.sol} (87%) create mode 100644 contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol index 48f978a70..8dd388fa9 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol @@ -10,8 +10,8 @@ import "./BridgeToken.sol"; import "../../Teleporter/ITeleporterMessenger.sol"; import "../../Teleporter/ITeleporterReceiver.sol"; import "../../Teleporter/SafeERC20TransferFrom.sol"; -import "../../Teleporter/TeleporterRegistry.sol"; -import "../../Teleporter/TeleporterUpgradeable.sol"; +import "../../Teleporter/upgrades/TeleporterRegistry.sol"; +import "../../Teleporter/upgrades/TeleporterUpgradeable.sol"; import "@subnet-evm-contracts/interfaces/IWarpMessenger.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; diff --git a/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol b/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol index 4bb23b2e4..ad9f4593f 100644 --- a/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol +++ b/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol @@ -8,8 +8,8 @@ pragma solidity 0.8.18; import "../../Teleporter/ITeleporterMessenger.sol"; import "../../Teleporter/SafeERC20TransferFrom.sol"; import "../../Teleporter/ITeleporterReceiver.sol"; -import "../../Teleporter/TeleporterRegistry.sol"; -import "../../Teleporter/TeleporterUpgradeable.sol"; +import "../../Teleporter/upgrades/TeleporterRegistry.sol"; +import "../../Teleporter/upgrades/TeleporterUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; diff --git a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol index cf4c96e78..18cdaded2 100644 --- a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol +++ b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol @@ -6,8 +6,8 @@ pragma solidity 0.8.18; import "../../Teleporter/ITeleporterMessenger.sol"; -import "../../Teleporter/TeleporterRegistry.sol"; -import "../../Teleporter/TeleporterUpgradeable.sol"; +import "../../Teleporter/upgrades/TeleporterRegistry.sol"; +import "../../Teleporter/upgrades/TeleporterUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./BlockHashReceiver.sol"; diff --git a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol index 92462ebe4..bb42cbea2 100644 --- a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol +++ b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol @@ -7,8 +7,8 @@ pragma solidity 0.8.18; import "../../Teleporter/ITeleporterMessenger.sol"; import "../../Teleporter/ITeleporterReceiver.sol"; -import "../../Teleporter/TeleporterRegistry.sol"; -import "../../Teleporter/TeleporterUpgradeable.sol"; +import "../../Teleporter/upgrades/TeleporterRegistry.sol"; +import "../../Teleporter/upgrades/TeleporterUpgradeable.sol"; /** * Contract for receiving latest block hashes from another chain. diff --git a/contracts/src/Teleporter/TeleporterRegistry.sol b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol similarity index 72% rename from contracts/src/Teleporter/TeleporterRegistry.sol rename to contracts/src/Teleporter/upgrades/TeleporterRegistry.sol index 077c0e24a..d6a61ad03 100644 --- a/contracts/src/Teleporter/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol @@ -5,8 +5,8 @@ pragma solidity 0.8.18; -import "../WarpProtocolRegistry.sol"; -import "./ITeleporterMessenger.sol"; +import "../../WarpProtocolRegistry.sol"; +import "../ITeleporterMessenger.sol"; /** * @dev TeleporterRegistry contract is a {WarpProtocolRegistry} and provides an upgrade @@ -15,14 +15,12 @@ import "./ITeleporterMessenger.sol"; contract TeleporterRegistry is WarpProtocolRegistry { mapping(address => uint256) internal _addressToVersion; + error DuplicateProtocolAddress(); + constructor( uint256[] memory initialVersions, address[] memory initialProtocolAddresses - ) WarpProtocolRegistry(initialVersions, initialProtocolAddresses) { - for (uint256 i = 0; i < initialVersions.length; i++) { - _addressToVersion[initialProtocolAddresses[i]] = initialVersions[i]; - } - } + ) WarpProtocolRegistry(initialVersions, initialProtocolAddresses) {} /** * @dev Gets the {ITeleporterMessenger} contract of the given `version`. @@ -55,15 +53,22 @@ contract TeleporterRegistry is WarpProtocolRegistry { } /** - * @dev See {WarpProtocolRegistry-addProtocolVersion} + * @dev See {WarpProtocolRegistry-_addToRegistry} * * Adds the new protocol version address to the `_addressToVersion` mapping * so that the registry can be queried for the version of a given protocol address. + * Requirements: + * + * - `protocolAddress` must not have been previously registered. */ - function _addProtocolVersion(uint32 messageIndex) internal override { - super._addProtocolVersion(messageIndex); - _addressToVersion[ - _getVersionToAddress(_latestVersion) - ] = _latestVersion; + function _addToRegistry( + uint256 version, + address protocolAddress + ) internal override { + WarpProtocolRegistry._addToRegistry(version, protocolAddress); + if (_addressToVersion[protocolAddress] != 0) { + revert DuplicateProtocolAddress(); + } + _addressToVersion[protocolAddress] = version; } } diff --git a/contracts/src/Teleporter/TeleporterUpgradeable.sol b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol similarity index 84% rename from contracts/src/Teleporter/TeleporterUpgradeable.sol rename to contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol index 7ff124196..39f7ebb80 100644 --- a/contracts/src/Teleporter/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol @@ -33,9 +33,15 @@ abstract contract TeleporterUpgradeable { /** * @dev Throws if called by a `msg.sender` that is not an allowed Telepoter version. + * Checks that `msg.sender` matches a Teleporter version greater than or equal to `_minTeleporterVersion`. */ modifier onlyAllowedTeleporter() { - _checkTeleporterMinVersion(); + if ( + teleporterRegistry.getAddressToVersion(msg.sender) < + _minTeleporterVersion + ) { + revert InvalidTeleporterSender(); + } _; } @@ -47,14 +53,9 @@ abstract contract TeleporterUpgradeable { } /** - * @dev Checks that `msg.sender` matches a Teleporter version greater than or equal to `_minTeleporterVersion`. + * @dev Gets the minimum Teleporter version that is allowed to call this contract. */ - function _checkTeleporterMinVersion() internal view virtual { - if ( - teleporterRegistry.getAddressToVersion(msg.sender) < - _minTeleporterVersion - ) { - revert InvalidTeleporterSender(); - } + function getMinTeleporterVersion() external view returns (uint256) { + return _minTeleporterVersion; } } diff --git a/contracts/src/Teleporter/tests/TeleporterRegistryTest.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol similarity index 87% rename from contracts/src/Teleporter/tests/TeleporterRegistryTest.t.sol rename to contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol index cb5607af5..c4a65d299 100644 --- a/contracts/src/Teleporter/tests/TeleporterRegistryTest.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol @@ -7,7 +7,7 @@ pragma solidity 0.8.18; import "forge-std/Test.sol"; import "../TeleporterRegistry.sol"; -import "../TeleporterMessenger.sol"; +import "../../TeleporterMessenger.sol"; contract TeleporterRegistryTest is Test { TeleporterRegistry public teleporterRegistry; @@ -37,7 +37,7 @@ contract TeleporterRegistryTest is Test { teleporterAddress = address(new TeleporterMessenger()); } - function testRegistryInitializationFails() public { + function testRegistryInitializationMismatchFails() public { uint256[] memory initialVersions = new uint256[](1); initialVersions[0] = 1; address[] memory initialProtocolAddresses = new address[](0); @@ -53,6 +53,18 @@ contract TeleporterRegistryTest is Test { new TeleporterRegistry(initialVersions, initialProtocolAddresses); } + function testRegistryInitializationDuplicateFails() public { + uint256[] memory initialVersions = new uint256[](2); + initialVersions[0] = 1; + initialVersions[1] = 2; + address[] memory initialProtocolAddresses = new address[](2); + initialProtocolAddresses[0] = teleporterAddress; + initialProtocolAddresses[1] = teleporterAddress; + + vm.expectRevert(TeleporterRegistry.DuplicateProtocolAddress.selector); + new TeleporterRegistry(initialVersions, initialProtocolAddresses); + } + function testAddProtocolVersionSuccess() public { uint256 latestVersion = teleporterRegistry.getLatestVersion(); assertEq(0, latestVersion); @@ -136,6 +148,31 @@ contract TeleporterRegistryTest is Test { teleporterRegistry.addProtocolVersion(messageIndex); } + function testAddToRegistryDuplicateFails() public { + _addProtocolVersion(teleporterRegistry); + uint256 latestVersion = teleporterRegistry.getLatestVersion(); + uint32 messageIndex = 0; + + // Check that adding a protocol address that is already registered fails + WarpMessage memory warpMessage = _createWarpOutofBandMessage( + latestVersion + 1, + teleporterAddress, + address(teleporterRegistry) + ); + + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall( + WarpMessenger.getVerifiedWarpMessage, + (messageIndex) + ), + abi.encode(warpMessage, true) + ); + + vm.expectRevert(TeleporterRegistry.DuplicateProtocolAddress.selector); + teleporterRegistry.addProtocolVersion(messageIndex); + } + function testGetVersionToAddress() public { _addProtocolVersion(teleporterRegistry); uint256 latestVersion = teleporterRegistry.getLatestVersion(); diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol new file mode 100644 index 000000000..66a3723fd --- /dev/null +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol @@ -0,0 +1,89 @@ +// (c) 2023, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +// SPDX-License-Identifier: Ecosystem + +pragma solidity 0.8.18; + +import "forge-std/Test.sol"; +import "../TeleporterRegistry.sol"; +import "../TeleporterUpgradeable.sol"; + +contract ExampleUpgradeableApp is TeleporterUpgradeable { + constructor( + address teleporterRegistryAddress + ) TeleporterUpgradeable(teleporterRegistryAddress) {} + + function teleporterCall() external onlyAllowedTeleporter {} +} + +contract TeleporterUpgradeableTest is Test { + address public constant MOCK_TELEPORTER_REGISTRY_ADDRESS = + 0xf9FA4a0c696b659328DDaaBCB46Ae4eBFC9e68e4; + address public constant MOCK_TELEPORTER_MESSENGER_ADDRESS = + 0x644E5b7c5D4Bc8073732CEa72c66e0BB90dFC00f; + + function setUp() public { + vm.mockCall( + MOCK_TELEPORTER_REGISTRY_ADDRESS, + abi.encodeCall(WarpProtocolRegistry.getLatestVersion, ()), + abi.encode(1) + ); + + vm.mockCall( + MOCK_TELEPORTER_REGISTRY_ADDRESS, + abi.encodeCall( + TeleporterRegistry.getAddressToVersion, + (MOCK_TELEPORTER_MESSENGER_ADDRESS) + ), + abi.encode(1) + ); + } + + function testInvalidRegistryAddress() public { + vm.expectRevert( + TeleporterUpgradeable.InvalidTeleporterRegistryAddress.selector + ); + new ExampleUpgradeableApp(address(0)); + } + + function testOnlyAllowedTeleporter() public { + ExampleUpgradeableApp app = new ExampleUpgradeableApp( + MOCK_TELEPORTER_REGISTRY_ADDRESS + ); + + assertEq(app.getMinTeleporterVersion(), 1); + + vm.expectRevert(TeleporterUpgradeable.InvalidTeleporterSender.selector); + app.teleporterCall(); + + vm.prank(MOCK_TELEPORTER_MESSENGER_ADDRESS); + app.teleporterCall(); + } + + function testUpdateMinTeleporterVersion() public { + ExampleUpgradeableApp app = new ExampleUpgradeableApp( + MOCK_TELEPORTER_REGISTRY_ADDRESS + ); + + // First check that calling with initial teleporter address works + assertEq(app.getMinTeleporterVersion(), 1); + vm.prank(MOCK_TELEPORTER_MESSENGER_ADDRESS); + app.teleporterCall(); + + // Now mock the registry getting a new version and updating the app's min version + vm.mockCall( + MOCK_TELEPORTER_REGISTRY_ADDRESS, + abi.encodeCall(WarpProtocolRegistry.getLatestVersion, ()), + abi.encode(2) + ); + + app.updateMinTeleporterversion(); + assertEq(app.getMinTeleporterVersion(), 2); + + // Check that calling with the old teleporter address fails + vm.expectRevert(TeleporterUpgradeable.InvalidTeleporterSender.selector); + vm.prank(MOCK_TELEPORTER_MESSENGER_ADDRESS); + app.teleporterCall(); + } +} diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index d9866b753..1cf113962 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -100,6 +100,10 @@ abstract contract WarpProtocolRegistry { return _latestVersion; } + /** + * @dev Gets and verifies for a warp out of band message, and adds the new protocol version + * addres to the registry. + */ function _addProtocolVersion(uint32 messageIndex) internal virtual { // Get and verify a valid warp out of band message. (WarpMessage memory message, bool valid) = WARP_MESSENGER @@ -128,6 +132,15 @@ abstract contract WarpProtocolRegistry { _addToRegistry(version, protocolAddress); } + /** + * @dev Adds the new protocol version address to the registry. + * + * Emits a {AddProtocolVersion} event when successful. + * Requirements: + * + * - `version` must be the increment of the latest version. + * - `protocolAddress` must be a contract address. + */ function _addToRegistry( uint256 version, address protocolAddress @@ -146,6 +159,12 @@ abstract contract WarpProtocolRegistry { emit AddProtocolVersion(_latestVersion, protocolAddress); } + /** + * @dev Gets the address of a protocol version. + * Requirements: + * + * - `version` must be a valid version, i.e. greater than 0 and not greater than the latest version. + */ function _getVersionToAddress( uint256 version ) internal view virtual returns (address) { diff --git a/docker/run_setup.sh b/docker/run_setup.sh index 10ac01cd9..24e10e668 100755 --- a/docker/run_setup.sh +++ b/docker/run_setup.sh @@ -130,17 +130,17 @@ if [ ! -e $dir_prefix/NETWORK_RUNNING ]; then # Deploy TeleporterRegistry to each chain. cd contracts registry_deploy_result_a=$(forge create --private-key $user_private_key --constructor-args [1] "[$teleporter_contract_address]" \ - --rpc-url $subnet_a_url src/Teleporter/TeleporterRegistry.sol:TeleporterRegistry) + --rpc-url $subnet_a_url src/Teleporter/upgrades/TeleporterRegistry.sol:TeleporterRegistry) registry_address_a=$(parseContractAddress "$registry_deploy_result_a") echo "TeleporterRegistry contract deployed to subnet A at $registry_address_a." registry_deploy_result_b=$(forge create --private-key $user_private_key --constructor-args [1] "[$teleporter_contract_address]" \ - --rpc-url $subnet_b_url src/Teleporter/TeleporterRegistry.sol:TeleporterRegistry) + --rpc-url $subnet_b_url src/Teleporter/upgrades/TeleporterRegistry.sol:TeleporterRegistry) registry_address_b=$(parseContractAddress "$registry_deploy_result_b") echo "TeleporterRegistry contract deployed to subnet A at $registry_address_b." registry_deploy_result_c=$(forge create --private-key $user_private_key --constructor-args [1] "[$teleporter_contract_address]" \ - --rpc-url $subnet_c_url src/Teleporter/TeleporterRegistry.sol:TeleporterRegistry) + --rpc-url $subnet_c_url src/Teleporter/upgrades/TeleporterRegistry.sol:TeleporterRegistry) registry_address_c=$(parseContractAddress "$registry_deploy_result_c") echo "TeleporterRegistry contract deployed to subnet A at $registry_address_c." cd .. From a1de5d8e8815c2979542d566e8b89077084632fe Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Mon, 2 Oct 2023 21:47:50 +0000 Subject: [PATCH 20/80] lint fixes --- .../ERC20Bridge/tests/ERC20BridgeTests.t.sol | 74 +++++++++---------- .../upgrades/TeleporterUpgradeable.sol | 26 +++---- .../tests/TeleporterUpgradeableTests.t.sol | 1 + 3 files changed, 51 insertions(+), 50 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol index ad01379df..4a4f9c6b6 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol @@ -72,7 +72,7 @@ contract ERC20BridgeTest is Test { abi.encodeWithSelector(WarpMessenger.getBlockchainID.selector) ); - initMockTeleporterRegistry(); + _initMockTeleporterRegistry(); vm.expectCall( MOCK_TELEPORTER_REGISTRY_ADDRESS, @@ -85,42 +85,6 @@ contract ERC20BridgeTest is Test { mockERC20 = new UnitTestMockERC20(); } - function initMockTeleporterRegistry() internal { - vm.mockCall( - MOCK_TELEPORTER_REGISTRY_ADDRESS, - abi.encodeWithSelector( - WarpProtocolRegistry.getLatestVersion.selector - ), - abi.encode(1) - ); - - vm.mockCall( - MOCK_TELEPORTER_REGISTRY_ADDRESS, - abi.encodeWithSelector( - TeleporterRegistry.getAddressToVersion.selector, - (MOCK_TELEPORTER_MESSENGER_ADDRESS) - ), - abi.encode(1) - ); - - vm.mockCall( - MOCK_TELEPORTER_REGISTRY_ADDRESS, - abi.encodeWithSelector( - WarpProtocolRegistry.getVersionToAddress.selector, - (1) - ), - abi.encode(MOCK_TELEPORTER_MESSENGER_ADDRESS) - ); - - vm.mockCall( - MOCK_TELEPORTER_REGISTRY_ADDRESS, - abi.encodeWithSelector( - TeleporterRegistry.getLatestTeleporter.selector - ), - abi.encode(ITeleporterMessenger(MOCK_TELEPORTER_MESSENGER_ADDRESS)) - ); - } - function testSameChainID() public { vm.expectRevert(ERC20Bridge.CannotBridgeTokenWithinSameChain.selector); erc20Bridge.bridgeTokens({ @@ -670,6 +634,42 @@ contract ERC20BridgeTest is Test { assertEq(address(mockERC20), newBridgeToken.nativeAsset()); } + function _initMockTeleporterRegistry() internal { + vm.mockCall( + MOCK_TELEPORTER_REGISTRY_ADDRESS, + abi.encodeWithSelector( + WarpProtocolRegistry.getLatestVersion.selector + ), + abi.encode(1) + ); + + vm.mockCall( + MOCK_TELEPORTER_REGISTRY_ADDRESS, + abi.encodeWithSelector( + TeleporterRegistry.getAddressToVersion.selector, + (MOCK_TELEPORTER_MESSENGER_ADDRESS) + ), + abi.encode(1) + ); + + vm.mockCall( + MOCK_TELEPORTER_REGISTRY_ADDRESS, + abi.encodeWithSelector( + WarpProtocolRegistry.getVersionToAddress.selector, + (1) + ), + abi.encode(MOCK_TELEPORTER_MESSENGER_ADDRESS) + ); + + vm.mockCall( + MOCK_TELEPORTER_REGISTRY_ADDRESS, + abi.encodeWithSelector( + TeleporterRegistry.getLatestTeleporter.selector + ), + abi.encode(ITeleporterMessenger(MOCK_TELEPORTER_MESSENGER_ADDRESS)) + ); + } + function _setUpExpectedTransferFromCall( address tokenContract, uint256 amount diff --git a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol index 39f7ebb80..5753b627d 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol @@ -18,19 +18,6 @@ abstract contract TeleporterUpgradeable { error InvalidTeleporterRegistryAddress(); error InvalidTeleporterSender(); - /** - * @dev Initializes the {TeleporterUpgradeable} contract by getting `teleporterRegistry` - * instance and setting `_minTeleporterVersion`. - */ - constructor(address teleporterRegistryAddress) { - if (teleporterRegistryAddress == address(0)) { - revert InvalidTeleporterRegistryAddress(); - } - - teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); - _minTeleporterVersion = teleporterRegistry.getLatestVersion(); - } - /** * @dev Throws if called by a `msg.sender` that is not an allowed Telepoter version. * Checks that `msg.sender` matches a Teleporter version greater than or equal to `_minTeleporterVersion`. @@ -45,6 +32,19 @@ abstract contract TeleporterUpgradeable { _; } + /** + * @dev Initializes the {TeleporterUpgradeable} contract by getting `teleporterRegistry` + * instance and setting `_minTeleporterVersion`. + */ + constructor(address teleporterRegistryAddress) { + if (teleporterRegistryAddress == address(0)) { + revert InvalidTeleporterRegistryAddress(); + } + + teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); + _minTeleporterVersion = teleporterRegistry.getLatestVersion(); + } + /** * @dev Updates `_minTeleporterVersion` to the latest version. */ diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol index 66a3723fd..ca161c30b 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol @@ -14,6 +14,7 @@ contract ExampleUpgradeableApp is TeleporterUpgradeable { address teleporterRegistryAddress ) TeleporterUpgradeable(teleporterRegistryAddress) {} + // solhint-disable-next-line no-empty-blocks function teleporterCall() external onlyAllowedTeleporter {} } From 34d6ea5db5f33c77d57c7b5d2cf739bfcccdb6c1 Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Tue, 3 Oct 2023 15:19:44 -0700 Subject: [PATCH 21/80] Update contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol Co-authored-by: Michael Kaplan <55204436+michaelkaplan13@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol index 5753b627d..daa14535b 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol @@ -19,7 +19,7 @@ abstract contract TeleporterUpgradeable { error InvalidTeleporterSender(); /** - * @dev Throws if called by a `msg.sender` that is not an allowed Telepoter version. + * @dev Throws if called by a `msg.sender` that is not an allowed Teleporter version. * Checks that `msg.sender` matches a Teleporter version greater than or equal to `_minTeleporterVersion`. */ modifier onlyAllowedTeleporter() { From eb67e674c0d7e8043e2a0d49ddb675e2b2029b69 Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Tue, 3 Oct 2023 15:19:58 -0700 Subject: [PATCH 22/80] Update contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol Co-authored-by: Michael Kaplan <55204436+michaelkaplan13@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol index daa14535b..9291296c5 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol @@ -48,7 +48,7 @@ abstract contract TeleporterUpgradeable { /** * @dev Updates `_minTeleporterVersion` to the latest version. */ - function updateMinTeleporterversion() external { + function updateMinTeleporterVersion() external { _minTeleporterVersion = teleporterRegistry.getLatestVersion(); } From ff1c1c484db8f406c536bba0bcbd8fb7184e67bf Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Tue, 3 Oct 2023 23:50:24 +0000 Subject: [PATCH 23/80] remove extra onlyAllowedTeleporter calls and nits --- .../CrossChainApplications/ERC20Bridge/ERC20Bridge.sol | 4 ++-- .../upgrades/tests/TeleporterUpgradeableTests.t.sol | 2 +- contracts/src/WarpProtocolRegistry.sol | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol index 8dd388fa9..a5e295db6 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol @@ -475,7 +475,7 @@ contract ERC20Bridge is address nativeContractAddress, address recipient, uint256 amount - ) private nonReentrant onlyAllowedTeleporter { + ) private nonReentrant { // The recipient cannot be the zero address. if (recipient == address(0)) { revert InvalidRecipientAddress(); @@ -513,7 +513,7 @@ contract ERC20Bridge is address recipient, uint256 totalAmount, uint256 secondaryFeeAmount - ) private nonReentrant onlyAllowedTeleporter { + ) private nonReentrant { // Neither the recipient nor the destination bridge can be the zero address. if (recipient == address(0)) { revert InvalidRecipientAddress(); diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol index ca161c30b..3cec76c51 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol @@ -79,7 +79,7 @@ contract TeleporterUpgradeableTest is Test { abi.encode(2) ); - app.updateMinTeleporterversion(); + app.updateMinTeleporterSersion(); assertEq(app.getMinTeleporterVersion(), 2); // Check that calling with the old teleporter address fails diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 1cf113962..b1aa05381 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -12,7 +12,7 @@ import "@openzeppelin/contracts/utils/Address.sol"; * @dev Implementation of an abstract `WarpProtocolRegistry` contract. * * This implementation is a contract that can be used as a base contract for protocols that are - * build on top of Warp. It allows the protocol to be upgraded through a warp out of band message. + * build on top of warp. It allows the protocol to be upgraded through a warp out-of-band message. */ abstract contract WarpProtocolRegistry { // Address that the out-of-band warp message sets as the "source" address. @@ -67,13 +67,13 @@ abstract contract WarpProtocolRegistry { } /** - * @dev Gets and verifies a warp out of band message, and adds the new protocol version + * @dev Gets and verifies a warp out-of-band message, and adds the new protocol version * addres to the registry. * * Emits a {AddProtocolVersion} event when successful. * Requirements: * - * - a valid warp out of band message must be provided. + * - a valid warp out-of-band message must be provided. * - the version must be the increment of the latest version. * - the protocol address must be a contract address. */ @@ -101,11 +101,11 @@ abstract contract WarpProtocolRegistry { } /** - * @dev Gets and verifies for a warp out of band message, and adds the new protocol version + * @dev Gets and verifies for a warp out-of-band message, and adds the new protocol version * addres to the registry. */ function _addProtocolVersion(uint32 messageIndex) internal virtual { - // Get and verify a valid warp out of band message. + // Get and validate for a warp out-of-band message. (WarpMessage memory message, bool valid) = WARP_MESSENGER .getVerifiedWarpMessage(messageIndex); if (!valid) { From c449bdd3165cef76b912c24812422ddee31a882e Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 4 Oct 2023 00:12:03 +0000 Subject: [PATCH 24/80] remove check for duplicate protocol address and rename funcs --- .../upgrades/TeleporterRegistry.sol | 13 ++---- .../upgrades/TeleporterUpgradeable.sol | 2 +- .../tests/TeleporterRegistryTests.t.sol | 45 ++----------------- .../tests/TeleporterUpgradeableTests.t.sol | 2 +- contracts/src/WarpProtocolRegistry.sol | 6 +-- 5 files changed, 13 insertions(+), 55 deletions(-) diff --git a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol index d6a61ad03..4fdf75038 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol @@ -15,8 +15,6 @@ import "../ITeleporterMessenger.sol"; contract TeleporterRegistry is WarpProtocolRegistry { mapping(address => uint256) internal _addressToVersion; - error DuplicateProtocolAddress(); - constructor( uint256[] memory initialVersions, address[] memory initialProtocolAddresses @@ -25,10 +23,10 @@ contract TeleporterRegistry is WarpProtocolRegistry { /** * @dev Gets the {ITeleporterMessenger} contract of the given `version`. */ - function getTeleporter( + function getTeleporterFromVersion( uint256 version ) external view returns (ITeleporterMessenger) { - return ITeleporterMessenger(_getVersionToAddress(version)); + return ITeleporterMessenger(_getAddressToVersion(version)); } /** @@ -39,14 +37,14 @@ contract TeleporterRegistry is WarpProtocolRegistry { view returns (ITeleporterMessenger) { - return ITeleporterMessenger(_getVersionToAddress(_latestVersion)); + return ITeleporterMessenger(_getAddressToVersion(_latestVersion)); } /** * @dev Gets the version of the given `protocolAddress`. * If `protocolAddress` is not a valid protocol address, returns 0. */ - function getAddressToVersion( + function getVersionFromAddress( address protocolAddress ) external view returns (uint256) { return _addressToVersion[protocolAddress]; @@ -66,9 +64,6 @@ contract TeleporterRegistry is WarpProtocolRegistry { address protocolAddress ) internal override { WarpProtocolRegistry._addToRegistry(version, protocolAddress); - if (_addressToVersion[protocolAddress] != 0) { - revert DuplicateProtocolAddress(); - } _addressToVersion[protocolAddress] = version; } } diff --git a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol index 9291296c5..558daae64 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol @@ -24,7 +24,7 @@ abstract contract TeleporterUpgradeable { */ modifier onlyAllowedTeleporter() { if ( - teleporterRegistry.getAddressToVersion(msg.sender) < + teleporterRegistry.getVersionFromAddress(msg.sender) < _minTeleporterVersion ) { revert InvalidTeleporterSender(); diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol index c4a65d299..3f90f9396 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol @@ -53,18 +53,6 @@ contract TeleporterRegistryTest is Test { new TeleporterRegistry(initialVersions, initialProtocolAddresses); } - function testRegistryInitializationDuplicateFails() public { - uint256[] memory initialVersions = new uint256[](2); - initialVersions[0] = 1; - initialVersions[1] = 2; - address[] memory initialProtocolAddresses = new address[](2); - initialProtocolAddresses[0] = teleporterAddress; - initialProtocolAddresses[1] = teleporterAddress; - - vm.expectRevert(TeleporterRegistry.DuplicateProtocolAddress.selector); - new TeleporterRegistry(initialVersions, initialProtocolAddresses); - } - function testAddProtocolVersionSuccess() public { uint256 latestVersion = teleporterRegistry.getLatestVersion(); assertEq(0, latestVersion); @@ -76,7 +64,7 @@ contract TeleporterRegistryTest is Test { address(teleporterRegistry.getLatestTeleporter()) ); assertEq( - teleporterRegistry.getAddressToVersion(teleporterAddress), + teleporterRegistry.getVersionFromAddress(teleporterAddress), teleporterRegistry.getLatestVersion() ); } @@ -85,7 +73,7 @@ contract TeleporterRegistryTest is Test { uint256 latestVersion = teleporterRegistry.getLatestVersion(); uint32 messageIndex = 0; - // Create a warp out of band message with same version as latest version + // Create a Warp out-of-band message with same version as latest version WarpMessage memory warpMessage = _createWarpOutofBandMessage( latestVersion, teleporterAddress, @@ -148,31 +136,6 @@ contract TeleporterRegistryTest is Test { teleporterRegistry.addProtocolVersion(messageIndex); } - function testAddToRegistryDuplicateFails() public { - _addProtocolVersion(teleporterRegistry); - uint256 latestVersion = teleporterRegistry.getLatestVersion(); - uint32 messageIndex = 0; - - // Check that adding a protocol address that is already registered fails - WarpMessage memory warpMessage = _createWarpOutofBandMessage( - latestVersion + 1, - teleporterAddress, - address(teleporterRegistry) - ); - - vm.mockCall( - WARP_PRECOMPILE_ADDRESS, - abi.encodeCall( - WarpMessenger.getVerifiedWarpMessage, - (messageIndex) - ), - abi.encode(warpMessage, true) - ); - - vm.expectRevert(TeleporterRegistry.DuplicateProtocolAddress.selector); - teleporterRegistry.addProtocolVersion(messageIndex); - } - function testGetVersionToAddress() public { _addProtocolVersion(teleporterRegistry); uint256 latestVersion = teleporterRegistry.getLatestVersion(); @@ -199,11 +162,11 @@ contract TeleporterRegistryTest is Test { // First test success case assertEq( latestVersion, - teleporterRegistry.getAddressToVersion(teleporterAddress) + teleporterRegistry.getVersionFromAddress(teleporterAddress) ); // Check that getting a version of an address that doesn't exist returns 0 - assertEq(0, teleporterRegistry.getAddressToVersion(address(this))); + assertEq(0, teleporterRegistry.getVersionFromAddress(address(this))); } function testInvalidWarpMessage() public { diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol index 3cec76c51..51f17cfcd 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol @@ -34,7 +34,7 @@ contract TeleporterUpgradeableTest is Test { vm.mockCall( MOCK_TELEPORTER_REGISTRY_ADDRESS, abi.encodeCall( - TeleporterRegistry.getAddressToVersion, + TeleporterRegistry.getVersionFromAddress, (MOCK_TELEPORTER_MESSENGER_ADDRESS) ), abi.encode(1) diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index b1aa05381..b5aed3fe4 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -87,10 +87,10 @@ abstract contract WarpProtocolRegistry { * * - the version must be a valid version. */ - function getVersionToAddress( + function getAddressFromVersion( uint256 version ) external view returns (address) { - return _getVersionToAddress(version); + return _getAddressToVersion(version); } /** @@ -165,7 +165,7 @@ abstract contract WarpProtocolRegistry { * * - `version` must be a valid version, i.e. greater than 0 and not greater than the latest version. */ - function _getVersionToAddress( + function _getAddressToVersion( uint256 version ) internal view virtual returns (address) { // Check that the version provided is a valid version. From 951cbf4d468056ff26b360f6759f919c018176f5 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 4 Oct 2023 00:42:35 +0000 Subject: [PATCH 25/80] fix up naming and tests --- .../ERC20Bridge/tests/ERC20BridgeTests.t.sol | 4 ++-- .../src/Teleporter/upgrades/TeleporterRegistry.sol | 4 ++-- .../upgrades/tests/TeleporterRegistryTests.t.sol | 10 +++++----- .../upgrades/tests/TeleporterUpgradeableTests.t.sol | 4 ++-- contracts/src/WarpProtocolRegistry.sol | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol index 4a4f9c6b6..cec4786ec 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol @@ -646,7 +646,7 @@ contract ERC20BridgeTest is Test { vm.mockCall( MOCK_TELEPORTER_REGISTRY_ADDRESS, abi.encodeWithSelector( - TeleporterRegistry.getAddressToVersion.selector, + TeleporterRegistry.getVersionFromAddress.selector, (MOCK_TELEPORTER_MESSENGER_ADDRESS) ), abi.encode(1) @@ -655,7 +655,7 @@ contract ERC20BridgeTest is Test { vm.mockCall( MOCK_TELEPORTER_REGISTRY_ADDRESS, abi.encodeWithSelector( - WarpProtocolRegistry.getVersionToAddress.selector, + WarpProtocolRegistry.getAddressFromVersion.selector, (1) ), abi.encode(MOCK_TELEPORTER_MESSENGER_ADDRESS) diff --git a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol index 4fdf75038..fbcd3b6e4 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol @@ -26,7 +26,7 @@ contract TeleporterRegistry is WarpProtocolRegistry { function getTeleporterFromVersion( uint256 version ) external view returns (ITeleporterMessenger) { - return ITeleporterMessenger(_getAddressToVersion(version)); + return ITeleporterMessenger(_getAddressFromVersion(version)); } /** @@ -37,7 +37,7 @@ contract TeleporterRegistry is WarpProtocolRegistry { view returns (ITeleporterMessenger) { - return ITeleporterMessenger(_getAddressToVersion(_latestVersion)); + return ITeleporterMessenger(_getAddressFromVersion(_latestVersion)); } /** diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol index 3f90f9396..1a7b88ed5 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol @@ -136,26 +136,26 @@ contract TeleporterRegistryTest is Test { teleporterRegistry.addProtocolVersion(messageIndex); } - function testGetVersionToAddress() public { + function testGetAddressFromVersion() public { _addProtocolVersion(teleporterRegistry); uint256 latestVersion = teleporterRegistry.getLatestVersion(); // First test success case assertEq( teleporterAddress, - teleporterRegistry.getVersionToAddress(latestVersion) + teleporterRegistry.getAddressFromVersion(latestVersion) ); // Check that getting version 0 fails vm.expectRevert(WarpProtocolRegistry.InvalidProtocolVersion.selector); - teleporterRegistry.getVersionToAddress(0); + teleporterRegistry.getAddressFromVersion(0); // Check that getting a version that doesn't exist fails vm.expectRevert(WarpProtocolRegistry.InvalidProtocolVersion.selector); - teleporterRegistry.getVersionToAddress(latestVersion + 1); + teleporterRegistry.getAddressFromVersion(latestVersion + 1); } - function testGetAddressToVersion() public { + function testGetVersionFromAddress() public { _addProtocolVersion(teleporterRegistry); uint256 latestVersion = teleporterRegistry.getLatestVersion(); diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol index 51f17cfcd..02c36fa54 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol @@ -15,7 +15,7 @@ contract ExampleUpgradeableApp is TeleporterUpgradeable { ) TeleporterUpgradeable(teleporterRegistryAddress) {} // solhint-disable-next-line no-empty-blocks - function teleporterCall() external onlyAllowedTeleporter {} + function teleporterCall() public onlyAllowedTeleporter {} } contract TeleporterUpgradeableTest is Test { @@ -79,7 +79,7 @@ contract TeleporterUpgradeableTest is Test { abi.encode(2) ); - app.updateMinTeleporterSersion(); + app.updateMinTeleporterVersion(); assertEq(app.getMinTeleporterVersion(), 2); // Check that calling with the old teleporter address fails diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index b5aed3fe4..213042e2d 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -90,7 +90,7 @@ abstract contract WarpProtocolRegistry { function getAddressFromVersion( uint256 version ) external view returns (address) { - return _getAddressToVersion(version); + return _getAddressFromVersion(version); } /** @@ -165,7 +165,7 @@ abstract contract WarpProtocolRegistry { * * - `version` must be a valid version, i.e. greater than 0 and not greater than the latest version. */ - function _getAddressToVersion( + function _getAddressFromVersion( uint256 version ) internal view virtual returns (address) { // Check that the version provided is a valid version. From 3654e48ad66d107e81bcadf5f3aac64509cb5daa Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 4 Oct 2023 01:30:00 +0000 Subject: [PATCH 26/80] fix unit tests --- .../upgrades/tests/TeleporterUpgradeableTests.t.sol | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol index 02c36fa54..9d731568e 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol @@ -39,6 +39,15 @@ contract TeleporterUpgradeableTest is Test { ), abi.encode(1) ); + + vm.mockCall( + MOCK_TELEPORTER_REGISTRY_ADDRESS, + abi.encodeCall( + TeleporterRegistry.getVersionFromAddress, + (address(this)) + ), + abi.encode(0) + ); } function testInvalidRegistryAddress() public { From feebce8b6f017cdb6e6b787394855ceffef6e4fd Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 4 Oct 2023 23:26:34 +0000 Subject: [PATCH 27/80] remove contract address requirement and docs --- .../upgrades/TeleporterRegistry.sol | 2 +- .../upgrades/TeleporterUpgradeable.sol | 4 ++++ .../tests/TeleporterRegistryTests.t.sol | 19 ------------------- contracts/src/WarpProtocolRegistry.sol | 9 +++------ 4 files changed, 8 insertions(+), 26 deletions(-) diff --git a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol index fbcd3b6e4..ac6518a03 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol @@ -57,7 +57,7 @@ contract TeleporterRegistry is WarpProtocolRegistry { * so that the registry can be queried for the version of a given protocol address. * Requirements: * - * - `protocolAddress` must not have been previously registered. + * - `version` must be the increment of the latest version. */ function _addToRegistry( uint256 version, diff --git a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol index 558daae64..927e7fa05 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol @@ -10,6 +10,10 @@ import "./TeleporterRegistry.sol"; /** * @dev TeleporterUpgradeable provides upgrade utility for applications built on top * of the Teleporter protocol by integrating with the {TeleporterRegistry}. + * + * This contract is intended to be inherited by other contracts that wish to use the + * upgrade mechanism. It provides a modifier that restricts access to only Teleporter + * versions that are greater than or equal to `_minTeleporterVersion`. */ abstract contract TeleporterUpgradeable { TeleporterRegistry public immutable teleporterRegistry; diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol index 1a7b88ed5..07d1d2412 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol @@ -115,25 +115,6 @@ contract TeleporterRegistryTest is Test { vm.expectRevert(WarpProtocolRegistry.InvalidProtocolVersion.selector); teleporterRegistry.addProtocolVersion(messageIndex); - - // Check that adding a protocol address that is not a contract fails - warpMessage = _createWarpOutofBandMessage( - latestVersion + 1, - address(0), - address(teleporterRegistry) - ); - - vm.mockCall( - WARP_PRECOMPILE_ADDRESS, - abi.encodeCall( - WarpMessenger.getVerifiedWarpMessage, - (messageIndex) - ), - abi.encode(warpMessage, true) - ); - - vm.expectRevert(WarpProtocolRegistry.InvalidProtocolAddress.selector); - teleporterRegistry.addProtocolVersion(messageIndex); } function testGetAddressFromVersion() public { diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 213042e2d..5f6c33d91 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -44,7 +44,6 @@ abstract contract WarpProtocolRegistry { error InvalidOriginSenderAddress(); error InvalidDestinationChainID(); error InvalidDestinationAddress(); - error InvalidProtocolAddress(); error InvalidProtocolVersion(); error InvalidRegistryInitialization(); @@ -136,10 +135,12 @@ abstract contract WarpProtocolRegistry { * @dev Adds the new protocol version address to the registry. * * Emits a {AddProtocolVersion} event when successful. + * Note: `protocolAddress` doesn't have to be a contract address, this is primarily + * to support the case we want to register a new protocol address meant for a security patch + * before the contract is deployed, to prevent the vulnerabilitiy from being exposed before registry update. * Requirements: * * - `version` must be the increment of the latest version. - * - `protocolAddress` must be a contract address. */ function _addToRegistry( uint256 version, @@ -149,10 +150,6 @@ abstract contract WarpProtocolRegistry { if (version != _latestVersion + 1) { revert InvalidProtocolVersion(); } - // Check that the protocol address is a contract address. - if (!Address.isContract(protocolAddress)) { - revert InvalidProtocolAddress(); - } _latestVersion++; _versionToAddress[_latestVersion] = protocolAddress; From 62863932a5606d0ad75246bfe599acc4b88b7ad9 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 4 Oct 2023 23:35:53 +0000 Subject: [PATCH 28/80] change to private variable --- contracts/src/Teleporter/upgrades/TeleporterRegistry.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol index ac6518a03..ab2c0a16b 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol @@ -13,7 +13,7 @@ import "../ITeleporterMessenger.sol"; * mechanism for teleporter messenger contracts. */ contract TeleporterRegistry is WarpProtocolRegistry { - mapping(address => uint256) internal _addressToVersion; + mapping(address => uint256) private _addressToVersion; constructor( uint256[] memory initialVersions, From cc3a1ecb89d6be242ef8d2ab64f186155317c895 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Thu, 5 Oct 2023 20:21:49 +0000 Subject: [PATCH 29/80] doc about invalid version 0 --- contracts/src/Teleporter/upgrades/TeleporterRegistry.sol | 5 ++++- contracts/src/WarpProtocolRegistry.sol | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol index ab2c0a16b..09510a667 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol @@ -22,6 +22,9 @@ contract TeleporterRegistry is WarpProtocolRegistry { /** * @dev Gets the {ITeleporterMessenger} contract of the given `version`. + * Requirements: + * + * - `version` must be a valid version, i.e. greater than 0 and not greater than the latest version. */ function getTeleporterFromVersion( uint256 version @@ -42,7 +45,7 @@ contract TeleporterRegistry is WarpProtocolRegistry { /** * @dev Gets the version of the given `protocolAddress`. - * If `protocolAddress` is not a valid protocol address, returns 0. + * If `protocolAddress` is not a valid protocol address, returns 0, which is an invalid version. */ function getVersionFromAddress( address protocolAddress diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 5f6c33d91..4f7baea6c 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -67,7 +67,7 @@ abstract contract WarpProtocolRegistry { /** * @dev Gets and verifies a warp out-of-band message, and adds the new protocol version - * addres to the registry. + * address to the registry. * * Emits a {AddProtocolVersion} event when successful. * Requirements: From 0ea24d95a6d5207adfc041abdaaa87149fdc6fc1 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Thu, 5 Oct 2023 21:38:34 +0000 Subject: [PATCH 30/80] move _addressToVersion to WarpProtocolRegistry --- .../ERC20Bridge/tests/ERC20BridgeTests.t.sol | 2 +- .../upgrades/TeleporterRegistry.sol | 29 ------------------- .../tests/TeleporterUpgradeableTests.t.sol | 4 +-- contracts/src/WarpProtocolRegistry.sol | 12 ++++++++ 4 files changed, 15 insertions(+), 32 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol index cec4786ec..f84b69379 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol @@ -646,7 +646,7 @@ contract ERC20BridgeTest is Test { vm.mockCall( MOCK_TELEPORTER_REGISTRY_ADDRESS, abi.encodeWithSelector( - TeleporterRegistry.getVersionFromAddress.selector, + WarpProtocolRegistry.getVersionFromAddress.selector, (MOCK_TELEPORTER_MESSENGER_ADDRESS) ), abi.encode(1) diff --git a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol index 09510a667..c1c25dbb4 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol @@ -13,8 +13,6 @@ import "../ITeleporterMessenger.sol"; * mechanism for teleporter messenger contracts. */ contract TeleporterRegistry is WarpProtocolRegistry { - mapping(address => uint256) private _addressToVersion; - constructor( uint256[] memory initialVersions, address[] memory initialProtocolAddresses @@ -42,31 +40,4 @@ contract TeleporterRegistry is WarpProtocolRegistry { { return ITeleporterMessenger(_getAddressFromVersion(_latestVersion)); } - - /** - * @dev Gets the version of the given `protocolAddress`. - * If `protocolAddress` is not a valid protocol address, returns 0, which is an invalid version. - */ - function getVersionFromAddress( - address protocolAddress - ) external view returns (uint256) { - return _addressToVersion[protocolAddress]; - } - - /** - * @dev See {WarpProtocolRegistry-_addToRegistry} - * - * Adds the new protocol version address to the `_addressToVersion` mapping - * so that the registry can be queried for the version of a given protocol address. - * Requirements: - * - * - `version` must be the increment of the latest version. - */ - function _addToRegistry( - uint256 version, - address protocolAddress - ) internal override { - WarpProtocolRegistry._addToRegistry(version, protocolAddress); - _addressToVersion[protocolAddress] = version; - } } diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol index 9d731568e..a0382568f 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol @@ -34,7 +34,7 @@ contract TeleporterUpgradeableTest is Test { vm.mockCall( MOCK_TELEPORTER_REGISTRY_ADDRESS, abi.encodeCall( - TeleporterRegistry.getVersionFromAddress, + WarpProtocolRegistry.getVersionFromAddress, (MOCK_TELEPORTER_MESSENGER_ADDRESS) ), abi.encode(1) @@ -43,7 +43,7 @@ contract TeleporterUpgradeableTest is Test { vm.mockCall( MOCK_TELEPORTER_REGISTRY_ADDRESS, abi.encodeCall( - TeleporterRegistry.getVersionFromAddress, + WarpProtocolRegistry.getVersionFromAddress, (address(this)) ), abi.encode(0) diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 4f7baea6c..4cea390d4 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -29,6 +29,7 @@ abstract contract WarpProtocolRegistry { uint256 internal _latestVersion; mapping(uint256 => address) internal _versionToAddress; + mapping(address => uint256) internal _addressToVersion; /** * @dev Emitted when a new protocol version is added to the registry. @@ -92,6 +93,16 @@ abstract contract WarpProtocolRegistry { return _getAddressFromVersion(version); } + /** + * @dev Gets the version of the given `protocolAddress`. + * If `protocolAddress` is not a valid protocol address, returns 0, which is an invalid version. + */ + function getVersionFromAddress( + address protocolAddress + ) external view returns (uint256) { + return _addressToVersion[protocolAddress]; + } + /** * @dev Gets the latest protocol version. */ @@ -153,6 +164,7 @@ abstract contract WarpProtocolRegistry { _latestVersion++; _versionToAddress[_latestVersion] = protocolAddress; + _addressToVersion[protocolAddress] = _latestVersion; emit AddProtocolVersion(_latestVersion, protocolAddress); } From 52de62d58ff855855285fed423f632b6725d7f64 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Thu, 5 Oct 2023 22:01:45 +0000 Subject: [PATCH 31/80] use protocol registry entry struct --- .../upgrades/TeleporterRegistry.sol | 5 +- .../tests/TeleporterRegistryTests.t.sol | 46 +++++++++++-------- contracts/src/WarpProtocolRegistry.sol | 43 +++++++++-------- 3 files changed, 53 insertions(+), 41 deletions(-) diff --git a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol index c1c25dbb4..07a82c20a 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol @@ -14,9 +14,8 @@ import "../ITeleporterMessenger.sol"; */ contract TeleporterRegistry is WarpProtocolRegistry { constructor( - uint256[] memory initialVersions, - address[] memory initialProtocolAddresses - ) WarpProtocolRegistry(initialVersions, initialProtocolAddresses) {} + ProtocolRegistryEntry[] memory initialEntries + ) WarpProtocolRegistry(initialEntries) {} /** * @dev Gets the {ITeleporterMessenger} contract of the given `version`. diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol index 07d1d2412..8f25207aa 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol @@ -8,6 +8,7 @@ pragma solidity 0.8.18; import "forge-std/Test.sol"; import "../TeleporterRegistry.sol"; import "../../TeleporterMessenger.sol"; +import "../../../WarpProtocolRegistry.sol"; contract TeleporterRegistryTest is Test { TeleporterRegistry public teleporterRegistry; @@ -29,30 +30,13 @@ contract TeleporterRegistryTest is Test { abi.encode(MOCK_BLOCK_CHAIN_ID) ); teleporterRegistry = new TeleporterRegistry( - new uint256[](0), - new address[](0) + new ProtocolRegistryEntry[](0) ); assertEq(0, teleporterRegistry.getLatestVersion()); teleporterAddress = address(new TeleporterMessenger()); } - function testRegistryInitializationMismatchFails() public { - uint256[] memory initialVersions = new uint256[](1); - initialVersions[0] = 1; - address[] memory initialProtocolAddresses = new address[](0); - - vm.expectCall( - WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getBlockchainID, ()) - ); - - vm.expectRevert( - WarpProtocolRegistry.InvalidRegistryInitialization.selector - ); - new TeleporterRegistry(initialVersions, initialProtocolAddresses); - } - function testAddProtocolVersionSuccess() public { uint256 latestVersion = teleporterRegistry.getLatestVersion(); assertEq(0, latestVersion); @@ -115,6 +99,25 @@ contract TeleporterRegistryTest is Test { vm.expectRevert(WarpProtocolRegistry.InvalidProtocolVersion.selector); teleporterRegistry.addProtocolVersion(messageIndex); + + // Check that adding an invalid protocol address of address(0) fails + warpMessage = _createWarpOutofBandMessage( + latestVersion + 1, + address(0), + address(teleporterRegistry) + ); + + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall( + WarpMessenger.getVerifiedWarpMessage, + (messageIndex) + ), + abi.encode(warpMessage, true) + ); + + vm.expectRevert(WarpProtocolRegistry.InvalidProtocolAddress.selector); + teleporterRegistry.addProtocolVersion(messageIndex); } function testGetAddressFromVersion() public { @@ -281,7 +284,12 @@ contract TeleporterRegistryTest is Test { .VALIDATORS_SOURCE_ADDRESS(), destinationChainID: MOCK_BLOCK_CHAIN_ID, destinationAddress: address(registryAddress), - payload: abi.encode(version, protocolAddress) + payload: abi.encode( + ProtocolRegistryEntry({ + version: version, + protocolAddress: protocolAddress + }) + ) }); } } diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 4cea390d4..ea4bbcda9 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -8,6 +8,14 @@ pragma solidity 0.8.18; import "@subnet-evm-contracts/interfaces/IWarpMessenger.sol"; import "@openzeppelin/contracts/utils/Address.sol"; +/** + * @dev Registry entry that represents a mapping between protocolAddress and version. + */ +struct ProtocolRegistryEntry { + uint256 version; + address protocolAddress; +} + /** * @dev Implementation of an abstract `WarpProtocolRegistry` contract. * @@ -46,23 +54,17 @@ abstract contract WarpProtocolRegistry { error InvalidDestinationChainID(); error InvalidDestinationAddress(); error InvalidProtocolVersion(); - error InvalidRegistryInitialization(); + error InvalidProtocolAddress(); /** * @dev Initializes the contract by setting a `chainID` and `latestVersion`. */ - constructor( - uint256[] memory initialVersions, - address[] memory initialProtocolAddresses - ) { + constructor(ProtocolRegistryEntry[] memory initialEntries) { _latestVersion = 0; _chainID = WARP_MESSENGER.getBlockchainID(); - if (initialProtocolAddresses.length != initialVersions.length) { - revert InvalidRegistryInitialization(); - } - for (uint256 i = 0; i < initialVersions.length; i++) { - _addToRegistry(initialVersions[i], initialProtocolAddresses[i]); + for (uint256 i = 0; i < initialEntries.length; i++) { + _addToRegistry(initialEntries[i]); } } @@ -134,12 +136,12 @@ abstract contract WarpProtocolRegistry { revert InvalidDestinationAddress(); } - (uint256 version, address protocolAddress) = abi.decode( + ProtocolRegistryEntry memory entry = abi.decode( message.payload, - (uint256, address) + (ProtocolRegistryEntry) ); - _addToRegistry(version, protocolAddress); + _addToRegistry(entry); } /** @@ -154,18 +156,21 @@ abstract contract WarpProtocolRegistry { * - `version` must be the increment of the latest version. */ function _addToRegistry( - uint256 version, - address protocolAddress + ProtocolRegistryEntry memory entry ) internal virtual { // Check that the version is the increment of the latest version. - if (version != _latestVersion + 1) { + if (entry.version != _latestVersion + 1) { revert InvalidProtocolVersion(); } + if (entry.protocolAddress == address(0)) { + revert InvalidProtocolAddress(); + } + _latestVersion++; - _versionToAddress[_latestVersion] = protocolAddress; - _addressToVersion[protocolAddress] = _latestVersion; - emit AddProtocolVersion(_latestVersion, protocolAddress); + _versionToAddress[entry.version] = entry.protocolAddress; + _addressToVersion[entry.protocolAddress] = entry.version; + emit AddProtocolVersion(entry.version, entry.protocolAddress); } /** From 7a518a5faf36088d2a4533dfb326bae4501ee6eb Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Fri, 6 Oct 2023 15:23:26 -0700 Subject: [PATCH 32/80] Update contracts/src/WarpProtocolRegistry.sol Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- contracts/src/WarpProtocolRegistry.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index ea4bbcda9..b6ec0f500 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -20,7 +20,7 @@ struct ProtocolRegistryEntry { * @dev Implementation of an abstract `WarpProtocolRegistry` contract. * * This implementation is a contract that can be used as a base contract for protocols that are - * build on top of warp. It allows the protocol to be upgraded through a warp out-of-band message. + * build on top of Warp. It allows the protocol to be upgraded through a Warp out-of-band message. */ abstract contract WarpProtocolRegistry { // Address that the out-of-band warp message sets as the "source" address. From 05c714c826af84b9b6409bda6489a604bf6f451a Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Fri, 6 Oct 2023 15:23:39 -0700 Subject: [PATCH 33/80] Update contracts/src/WarpProtocolRegistry.sol Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- contracts/src/WarpProtocolRegistry.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index b6ec0f500..d3102e987 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -25,7 +25,7 @@ struct ProtocolRegistryEntry { abstract contract WarpProtocolRegistry { // Address that the out-of-band warp message sets as the "source" address. // The address is obviously not owned by any EOA or smart contract account, so it - // can not possibly be the source address of any other warp message emitted by the VM. + // cannot possibly be the source address of any other Warp message emitted by the VM. address public constant VALIDATORS_SOURCE_ADDRESS = address(0); WarpMessenger public constant WARP_MESSENGER = From cea7d1939b920bc574e2512cc45ef64a0a7d9e70 Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Fri, 6 Oct 2023 15:23:56 -0700 Subject: [PATCH 34/80] Update contracts/src/WarpProtocolRegistry.sol Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- contracts/src/WarpProtocolRegistry.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index d3102e987..c84688388 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -23,7 +23,7 @@ struct ProtocolRegistryEntry { * build on top of Warp. It allows the protocol to be upgraded through a Warp out-of-band message. */ abstract contract WarpProtocolRegistry { - // Address that the out-of-band warp message sets as the "source" address. + // Address that the out-of-band Warp message sets as the "source" address. // The address is obviously not owned by any EOA or smart contract account, so it // cannot possibly be the source address of any other Warp message emitted by the VM. address public constant VALIDATORS_SOURCE_ADDRESS = address(0); From 44fd2c14702ecd64bb579cccee1e3becc15fe81e Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Fri, 13 Oct 2023 18:46:43 +0000 Subject: [PATCH 35/80] rename blockchainID and add virtuals --- contracts/src/WarpProtocolRegistry.sol | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index c84688388..7d3a70e90 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -31,7 +31,7 @@ abstract contract WarpProtocolRegistry { WarpMessenger public constant WARP_MESSENGER = WarpMessenger(0x0200000000000000000000000000000000000005); - bytes32 internal immutable _chainID; + bytes32 internal immutable _blockchainID; // The latest protocol version. 0 means no protocol version has been added, and isn't a valid version. uint256 internal _latestVersion; @@ -61,7 +61,7 @@ abstract contract WarpProtocolRegistry { */ constructor(ProtocolRegistryEntry[] memory initialEntries) { _latestVersion = 0; - _chainID = WARP_MESSENGER.getBlockchainID(); + _blockchainID = WARP_MESSENGER.getBlockchainID(); for (uint256 i = 0; i < initialEntries.length; i++) { _addToRegistry(initialEntries[i]); @@ -79,7 +79,7 @@ abstract contract WarpProtocolRegistry { * - the version must be the increment of the latest version. * - the protocol address must be a contract address. */ - function addProtocolVersion(uint32 messageIndex) external { + function addProtocolVersion(uint32 messageIndex) external virtual { _addProtocolVersion(messageIndex); } @@ -91,7 +91,7 @@ abstract contract WarpProtocolRegistry { */ function getAddressFromVersion( uint256 version - ) external view returns (address) { + ) external view virtual returns (address) { return _getAddressFromVersion(version); } @@ -101,20 +101,20 @@ abstract contract WarpProtocolRegistry { */ function getVersionFromAddress( address protocolAddress - ) external view returns (uint256) { + ) external view virtual returns (uint256) { return _addressToVersion[protocolAddress]; } /** * @dev Gets the latest protocol version. */ - function getLatestVersion() external view returns (uint256) { + function getLatestVersion() external view virtual returns (uint256) { return _latestVersion; } /** * @dev Gets and verifies for a warp out-of-band message, and adds the new protocol version - * addres to the registry. + * address to the registry. */ function _addProtocolVersion(uint32 messageIndex) internal virtual { // Get and validate for a warp out-of-band message. @@ -123,13 +123,13 @@ abstract contract WarpProtocolRegistry { if (!valid) { revert InvalidWarpMessage(); } - if (message.sourceChainID != _chainID) { + if (message.sourceChainID != _blockchainID) { revert InvalidSourceChainID(); } if (message.originSenderAddress != VALIDATORS_SOURCE_ADDRESS) { revert InvalidOriginSenderAddress(); } - if (message.destinationChainID != _chainID) { + if (message.destinationChainID != _blockchainID) { revert InvalidDestinationChainID(); } if (message.destinationAddress != address(this)) { From 8a89233669106e684d781e8dea137c12e3fadc35 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Fri, 13 Oct 2023 18:50:35 +0000 Subject: [PATCH 36/80] add comment and fix typo --- contracts/src/WarpProtocolRegistry.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 7d3a70e90..4cfc04b32 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -20,7 +20,7 @@ struct ProtocolRegistryEntry { * @dev Implementation of an abstract `WarpProtocolRegistry` contract. * * This implementation is a contract that can be used as a base contract for protocols that are - * build on top of Warp. It allows the protocol to be upgraded through a Warp out-of-band message. + * built on top of Warp. It allows the protocol to be upgraded through a Warp out-of-band message. */ abstract contract WarpProtocolRegistry { // Address that the out-of-band Warp message sets as the "source" address. @@ -126,6 +126,8 @@ abstract contract WarpProtocolRegistry { if (message.sourceChainID != _blockchainID) { revert InvalidSourceChainID(); } + + // Check that the message is sent through a warp out of band message. if (message.originSenderAddress != VALIDATORS_SOURCE_ADDRESS) { revert InvalidOriginSenderAddress(); } From eb9b3edba73a41c529764cbcca7918ebf7f31766 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Fri, 13 Oct 2023 18:57:18 +0000 Subject: [PATCH 37/80] update abi bindings --- .../ERC20Bridge/ERC20Bridge/ERC20Bridge.go | 78 +++++++++++++++---- .../ExampleCrossChainMessenger.go | 78 +++++++++++++++---- .../BlockHashPublisher/BlockHashPublisher.go | 78 +++++++++++++++---- .../BlockHashReceiver/BlockHashReceiver.go | 78 +++++++++++++++---- 4 files changed, 260 insertions(+), 52 deletions(-) diff --git a/abi-bindings/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go b/abi-bindings/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go index 5a98d6b84..3b152253e 100644 --- a/abi-bindings/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go +++ b/abi-bindings/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go @@ -31,7 +31,7 @@ var ( // ERC20BridgeMetaData contains all meta data concerning the ERC20Bridge contract. var ERC20BridgeMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterMessengerAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BalanceNotIncreased\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"bridgeTokenAddress\",\"type\":\"address\"}],\"name\":\"BridgeTokenAlreadyExists\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CannotBridgeTokenWithinSameChain\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeTokenAddress\",\"type\":\"address\"}],\"name\":\"CannotBridgeWrappedToken\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"adjustedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"InsufficientAdjustedAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"InsufficientTotalAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"currentBalance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requestAmount\",\"type\":\"uint256\"}],\"name\":\"InsufficientWrappedTokenBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidAction\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidBridgeTokenAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidDestinationBridgeAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidRecipientAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTeleporterMessengerAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"Unauthorized\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"BridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"bridgeTokenAddress\",\"type\":\"address\"}],\"name\":\"CreateBridgeToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"contractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MintBridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"}],\"name\":\"SubmitCreateBridgeToken\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CREATE_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINT_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TRANSFER_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WARP_PRECOMPILE_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"primaryFeeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"secondaryFeeAmount\",\"type\":\"uint256\"}],\"name\":\"bridgeTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"bridgedBalances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"nativeName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"nativeSymbol\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"nativeDecimals\",\"type\":\"uint8\"}],\"name\":\"encodeCreateBridgeTokenData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"bridgeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeMintBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeTransferBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nativeToWrappedTokens\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"contractERC20\",\"name\":\"nativeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"messageFeeAsset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"messageFeeAmount\",\"type\":\"uint256\"}],\"name\":\"submitCreateBridgeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"submittedBridgeTokenCreations\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterMessenger\",\"outputs\":[{\"internalType\":\"contractITeleporterMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedTokenContracts\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BalanceNotIncreased\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"bridgeTokenAddress\",\"type\":\"address\"}],\"name\":\"BridgeTokenAlreadyExists\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CannotBridgeTokenWithinSameChain\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeTokenAddress\",\"type\":\"address\"}],\"name\":\"CannotBridgeWrappedToken\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"adjustedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"InsufficientAdjustedAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"InsufficientTotalAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"currentBalance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requestAmount\",\"type\":\"uint256\"}],\"name\":\"InsufficientWrappedTokenBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidAction\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidBridgeTokenAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidDestinationBridgeAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidRecipientAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTeleporterRegistryAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTeleporterSender\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"BridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"bridgeTokenAddress\",\"type\":\"address\"}],\"name\":\"CreateBridgeToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"contractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MintBridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"}],\"name\":\"SubmitCreateBridgeToken\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CREATE_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINT_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TRANSFER_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WARP_PRECOMPILE_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"primaryFeeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"secondaryFeeAmount\",\"type\":\"uint256\"}],\"name\":\"bridgeTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"bridgedBalances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"nativeName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"nativeSymbol\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"nativeDecimals\",\"type\":\"uint8\"}],\"name\":\"encodeCreateBridgeTokenData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"bridgeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeMintBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeTransferBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nativeToWrappedTokens\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"contractERC20\",\"name\":\"nativeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"messageFeeAsset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"messageFeeAmount\",\"type\":\"uint256\"}],\"name\":\"submitCreateBridgeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"submittedBridgeTokenCreations\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedTokenContracts\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // ERC20BridgeABI is the input ABI used to generate the binding from. @@ -459,6 +459,37 @@ func (_ERC20Bridge *ERC20BridgeCallerSession) EncodeTransferBridgeTokensData(des return _ERC20Bridge.Contract.EncodeTransferBridgeTokensData(&_ERC20Bridge.CallOpts, destinationChainID, destinationBridgeAddress, nativeContractAddress, recipient, amount, feeAmount) } +// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// +// Solidity: function getMinTeleporterVersion() view returns(uint256) +func (_ERC20Bridge *ERC20BridgeCaller) GetMinTeleporterVersion(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _ERC20Bridge.contract.Call(opts, &out, "getMinTeleporterVersion") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// +// Solidity: function getMinTeleporterVersion() view returns(uint256) +func (_ERC20Bridge *ERC20BridgeSession) GetMinTeleporterVersion() (*big.Int, error) { + return _ERC20Bridge.Contract.GetMinTeleporterVersion(&_ERC20Bridge.CallOpts) +} + +// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// +// Solidity: function getMinTeleporterVersion() view returns(uint256) +func (_ERC20Bridge *ERC20BridgeCallerSession) GetMinTeleporterVersion() (*big.Int, error) { + return _ERC20Bridge.Contract.GetMinTeleporterVersion(&_ERC20Bridge.CallOpts) +} + // NativeToWrappedTokens is a free data retrieval call binding the contract method 0x65435568. // // Solidity: function nativeToWrappedTokens(bytes32 , address , address ) view returns(address) @@ -521,12 +552,12 @@ func (_ERC20Bridge *ERC20BridgeCallerSession) SubmittedBridgeTokenCreations(arg0 return _ERC20Bridge.Contract.SubmittedBridgeTokenCreations(&_ERC20Bridge.CallOpts, arg0, arg1, arg2) } -// TeleporterMessenger is a free data retrieval call binding the contract method 0x9b3e5803. +// TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. // -// Solidity: function teleporterMessenger() view returns(address) -func (_ERC20Bridge *ERC20BridgeCaller) TeleporterMessenger(opts *bind.CallOpts) (common.Address, error) { +// Solidity: function teleporterRegistry() view returns(address) +func (_ERC20Bridge *ERC20BridgeCaller) TeleporterRegistry(opts *bind.CallOpts) (common.Address, error) { var out []interface{} - err := _ERC20Bridge.contract.Call(opts, &out, "teleporterMessenger") + err := _ERC20Bridge.contract.Call(opts, &out, "teleporterRegistry") if err != nil { return *new(common.Address), err @@ -538,18 +569,18 @@ func (_ERC20Bridge *ERC20BridgeCaller) TeleporterMessenger(opts *bind.CallOpts) } -// TeleporterMessenger is a free data retrieval call binding the contract method 0x9b3e5803. +// TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. // -// Solidity: function teleporterMessenger() view returns(address) -func (_ERC20Bridge *ERC20BridgeSession) TeleporterMessenger() (common.Address, error) { - return _ERC20Bridge.Contract.TeleporterMessenger(&_ERC20Bridge.CallOpts) +// Solidity: function teleporterRegistry() view returns(address) +func (_ERC20Bridge *ERC20BridgeSession) TeleporterRegistry() (common.Address, error) { + return _ERC20Bridge.Contract.TeleporterRegistry(&_ERC20Bridge.CallOpts) } -// TeleporterMessenger is a free data retrieval call binding the contract method 0x9b3e5803. +// TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. // -// Solidity: function teleporterMessenger() view returns(address) -func (_ERC20Bridge *ERC20BridgeCallerSession) TeleporterMessenger() (common.Address, error) { - return _ERC20Bridge.Contract.TeleporterMessenger(&_ERC20Bridge.CallOpts) +// Solidity: function teleporterRegistry() view returns(address) +func (_ERC20Bridge *ERC20BridgeCallerSession) TeleporterRegistry() (common.Address, error) { + return _ERC20Bridge.Contract.TeleporterRegistry(&_ERC20Bridge.CallOpts) } // WrappedTokenContracts is a free data retrieval call binding the contract method 0x9bd9abc0. @@ -646,6 +677,27 @@ func (_ERC20Bridge *ERC20BridgeTransactorSession) SubmitCreateBridgeToken(destin return _ERC20Bridge.Contract.SubmitCreateBridgeToken(&_ERC20Bridge.TransactOpts, destinationChainID, destinationBridgeAddress, nativeToken, messageFeeAsset, messageFeeAmount) } +// UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. +// +// Solidity: function updateMinTeleporterVersion() returns() +func (_ERC20Bridge *ERC20BridgeTransactor) UpdateMinTeleporterVersion(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ERC20Bridge.contract.Transact(opts, "updateMinTeleporterVersion") +} + +// UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. +// +// Solidity: function updateMinTeleporterVersion() returns() +func (_ERC20Bridge *ERC20BridgeSession) UpdateMinTeleporterVersion() (*types.Transaction, error) { + return _ERC20Bridge.Contract.UpdateMinTeleporterVersion(&_ERC20Bridge.TransactOpts) +} + +// UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. +// +// Solidity: function updateMinTeleporterVersion() returns() +func (_ERC20Bridge *ERC20BridgeTransactorSession) UpdateMinTeleporterVersion() (*types.Transaction, error) { + return _ERC20Bridge.Contract.UpdateMinTeleporterVersion(&_ERC20Bridge.TransactOpts) +} + // ERC20BridgeBridgeTokensIterator is returned from FilterBridgeTokens and is used to iterate over the raw logs and unpacked data for BridgeTokens events raised by the ERC20Bridge contract. type ERC20BridgeBridgeTokensIterator struct { Event *ERC20BridgeBridgeTokens // Event containing the contract specifics and raw log diff --git a/abi-bindings/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go b/abi-bindings/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go index ea2bb9bdd..b65507bb4 100644 --- a/abi-bindings/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go +++ b/abi-bindings/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go @@ -31,7 +31,7 @@ var ( // ExampleCrossChainMessengerMetaData contains all meta data concerning the ExampleCrossChainMessenger contract. var ExampleCrossChainMessengerMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterMessengerAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BalanceNotIncreased\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"Unauthorized\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"ReceiveMessage\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeAsset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"SendMessage\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"}],\"name\":\"getCurrentMessage\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeContractAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"sendMessage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterMessenger\",\"outputs\":[{\"internalType\":\"contractITeleporterMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BalanceNotIncreased\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTeleporterRegistryAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTeleporterSender\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"ReceiveMessage\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeAsset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"SendMessage\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"}],\"name\":\"getCurrentMessage\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeContractAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"sendMessage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // ExampleCrossChainMessengerABI is the input ABI used to generate the binding from. @@ -225,12 +225,43 @@ func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCallerSession) GetC return _ExampleCrossChainMessenger.Contract.GetCurrentMessage(&_ExampleCrossChainMessenger.CallOpts, originChainID) } -// TeleporterMessenger is a free data retrieval call binding the contract method 0x9b3e5803. +// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. // -// Solidity: function teleporterMessenger() view returns(address) -func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCaller) TeleporterMessenger(opts *bind.CallOpts) (common.Address, error) { +// Solidity: function getMinTeleporterVersion() view returns(uint256) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCaller) GetMinTeleporterVersion(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} - err := _ExampleCrossChainMessenger.contract.Call(opts, &out, "teleporterMessenger") + err := _ExampleCrossChainMessenger.contract.Call(opts, &out, "getMinTeleporterVersion") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// +// Solidity: function getMinTeleporterVersion() view returns(uint256) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerSession) GetMinTeleporterVersion() (*big.Int, error) { + return _ExampleCrossChainMessenger.Contract.GetMinTeleporterVersion(&_ExampleCrossChainMessenger.CallOpts) +} + +// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// +// Solidity: function getMinTeleporterVersion() view returns(uint256) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCallerSession) GetMinTeleporterVersion() (*big.Int, error) { + return _ExampleCrossChainMessenger.Contract.GetMinTeleporterVersion(&_ExampleCrossChainMessenger.CallOpts) +} + +// TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. +// +// Solidity: function teleporterRegistry() view returns(address) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCaller) TeleporterRegistry(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ExampleCrossChainMessenger.contract.Call(opts, &out, "teleporterRegistry") if err != nil { return *new(common.Address), err @@ -242,18 +273,18 @@ func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCaller) TeleporterM } -// TeleporterMessenger is a free data retrieval call binding the contract method 0x9b3e5803. +// TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. // -// Solidity: function teleporterMessenger() view returns(address) -func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerSession) TeleporterMessenger() (common.Address, error) { - return _ExampleCrossChainMessenger.Contract.TeleporterMessenger(&_ExampleCrossChainMessenger.CallOpts) +// Solidity: function teleporterRegistry() view returns(address) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerSession) TeleporterRegistry() (common.Address, error) { + return _ExampleCrossChainMessenger.Contract.TeleporterRegistry(&_ExampleCrossChainMessenger.CallOpts) } -// TeleporterMessenger is a free data retrieval call binding the contract method 0x9b3e5803. +// TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. // -// Solidity: function teleporterMessenger() view returns(address) -func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCallerSession) TeleporterMessenger() (common.Address, error) { - return _ExampleCrossChainMessenger.Contract.TeleporterMessenger(&_ExampleCrossChainMessenger.CallOpts) +// Solidity: function teleporterRegistry() view returns(address) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCallerSession) TeleporterRegistry() (common.Address, error) { + return _ExampleCrossChainMessenger.Contract.TeleporterRegistry(&_ExampleCrossChainMessenger.CallOpts) } // ReceiveTeleporterMessage is a paid mutator transaction binding the contract method 0xc868efaa. @@ -298,6 +329,27 @@ func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerTransactorSession) return _ExampleCrossChainMessenger.Contract.SendMessage(&_ExampleCrossChainMessenger.TransactOpts, destinationChainID, destinationAddress, feeContractAddress, feeAmount, requiredGasLimit, message) } +// UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. +// +// Solidity: function updateMinTeleporterVersion() returns() +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerTransactor) UpdateMinTeleporterVersion(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ExampleCrossChainMessenger.contract.Transact(opts, "updateMinTeleporterVersion") +} + +// UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. +// +// Solidity: function updateMinTeleporterVersion() returns() +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerSession) UpdateMinTeleporterVersion() (*types.Transaction, error) { + return _ExampleCrossChainMessenger.Contract.UpdateMinTeleporterVersion(&_ExampleCrossChainMessenger.TransactOpts) +} + +// UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. +// +// Solidity: function updateMinTeleporterVersion() returns() +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerTransactorSession) UpdateMinTeleporterVersion() (*types.Transaction, error) { + return _ExampleCrossChainMessenger.Contract.UpdateMinTeleporterVersion(&_ExampleCrossChainMessenger.TransactOpts) +} + // ExampleCrossChainMessengerReceiveMessageIterator is returned from FilterReceiveMessage and is used to iterate over the raw logs and unpacked data for ReceiveMessage events raised by the ExampleCrossChainMessenger contract. type ExampleCrossChainMessengerReceiveMessageIterator struct { Event *ExampleCrossChainMessengerReceiveMessage // Event containing the contract specifics and raw log diff --git a/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go b/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go index cc8b99e61..d858584f3 100644 --- a/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go +++ b/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go @@ -31,7 +31,7 @@ var ( // BlockHashPublisherMetaData contains all meta data concerning the BlockHashPublisher contract. var BlockHashPublisherMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterMessengerAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"PublishBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"RECEIVE_BLOCK_HASH_REQUIRED_GAS_LIMIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"}],\"name\":\"publishLatestBlockHash\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterMessenger\",\"outputs\":[{\"internalType\":\"contractITeleporterMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"InvalidTeleporterRegistryAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTeleporterSender\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"PublishBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"RECEIVE_BLOCK_HASH_REQUIRED_GAS_LIMIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"}],\"name\":\"publishLatestBlockHash\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // BlockHashPublisherABI is the input ABI used to generate the binding from. @@ -211,12 +211,43 @@ func (_BlockHashPublisher *BlockHashPublisherCallerSession) RECEIVEBLOCKHASHREQU return _BlockHashPublisher.Contract.RECEIVEBLOCKHASHREQUIREDGASLIMIT(&_BlockHashPublisher.CallOpts) } -// TeleporterMessenger is a free data retrieval call binding the contract method 0x9b3e5803. +// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. // -// Solidity: function teleporterMessenger() view returns(address) -func (_BlockHashPublisher *BlockHashPublisherCaller) TeleporterMessenger(opts *bind.CallOpts) (common.Address, error) { +// Solidity: function getMinTeleporterVersion() view returns(uint256) +func (_BlockHashPublisher *BlockHashPublisherCaller) GetMinTeleporterVersion(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} - err := _BlockHashPublisher.contract.Call(opts, &out, "teleporterMessenger") + err := _BlockHashPublisher.contract.Call(opts, &out, "getMinTeleporterVersion") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// +// Solidity: function getMinTeleporterVersion() view returns(uint256) +func (_BlockHashPublisher *BlockHashPublisherSession) GetMinTeleporterVersion() (*big.Int, error) { + return _BlockHashPublisher.Contract.GetMinTeleporterVersion(&_BlockHashPublisher.CallOpts) +} + +// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// +// Solidity: function getMinTeleporterVersion() view returns(uint256) +func (_BlockHashPublisher *BlockHashPublisherCallerSession) GetMinTeleporterVersion() (*big.Int, error) { + return _BlockHashPublisher.Contract.GetMinTeleporterVersion(&_BlockHashPublisher.CallOpts) +} + +// TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. +// +// Solidity: function teleporterRegistry() view returns(address) +func (_BlockHashPublisher *BlockHashPublisherCaller) TeleporterRegistry(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _BlockHashPublisher.contract.Call(opts, &out, "teleporterRegistry") if err != nil { return *new(common.Address), err @@ -228,18 +259,18 @@ func (_BlockHashPublisher *BlockHashPublisherCaller) TeleporterMessenger(opts *b } -// TeleporterMessenger is a free data retrieval call binding the contract method 0x9b3e5803. +// TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. // -// Solidity: function teleporterMessenger() view returns(address) -func (_BlockHashPublisher *BlockHashPublisherSession) TeleporterMessenger() (common.Address, error) { - return _BlockHashPublisher.Contract.TeleporterMessenger(&_BlockHashPublisher.CallOpts) +// Solidity: function teleporterRegistry() view returns(address) +func (_BlockHashPublisher *BlockHashPublisherSession) TeleporterRegistry() (common.Address, error) { + return _BlockHashPublisher.Contract.TeleporterRegistry(&_BlockHashPublisher.CallOpts) } -// TeleporterMessenger is a free data retrieval call binding the contract method 0x9b3e5803. +// TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. // -// Solidity: function teleporterMessenger() view returns(address) -func (_BlockHashPublisher *BlockHashPublisherCallerSession) TeleporterMessenger() (common.Address, error) { - return _BlockHashPublisher.Contract.TeleporterMessenger(&_BlockHashPublisher.CallOpts) +// Solidity: function teleporterRegistry() view returns(address) +func (_BlockHashPublisher *BlockHashPublisherCallerSession) TeleporterRegistry() (common.Address, error) { + return _BlockHashPublisher.Contract.TeleporterRegistry(&_BlockHashPublisher.CallOpts) } // PublishLatestBlockHash is a paid mutator transaction binding the contract method 0x82ab2b86. @@ -263,6 +294,27 @@ func (_BlockHashPublisher *BlockHashPublisherTransactorSession) PublishLatestBlo return _BlockHashPublisher.Contract.PublishLatestBlockHash(&_BlockHashPublisher.TransactOpts, destinationChainID, destinationAddress) } +// UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. +// +// Solidity: function updateMinTeleporterVersion() returns() +func (_BlockHashPublisher *BlockHashPublisherTransactor) UpdateMinTeleporterVersion(opts *bind.TransactOpts) (*types.Transaction, error) { + return _BlockHashPublisher.contract.Transact(opts, "updateMinTeleporterVersion") +} + +// UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. +// +// Solidity: function updateMinTeleporterVersion() returns() +func (_BlockHashPublisher *BlockHashPublisherSession) UpdateMinTeleporterVersion() (*types.Transaction, error) { + return _BlockHashPublisher.Contract.UpdateMinTeleporterVersion(&_BlockHashPublisher.TransactOpts) +} + +// UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. +// +// Solidity: function updateMinTeleporterVersion() returns() +func (_BlockHashPublisher *BlockHashPublisherTransactorSession) UpdateMinTeleporterVersion() (*types.Transaction, error) { + return _BlockHashPublisher.Contract.UpdateMinTeleporterVersion(&_BlockHashPublisher.TransactOpts) +} + // BlockHashPublisherPublishBlockHashIterator is returned from FilterPublishBlockHash and is used to iterate over the raw logs and unpacked data for PublishBlockHash events raised by the BlockHashPublisher contract. type BlockHashPublisherPublishBlockHashIterator struct { Event *BlockHashPublisherPublishBlockHash // Event containing the contract specifics and raw log diff --git a/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go b/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go index 49167f7b3..f9edd98f2 100644 --- a/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go +++ b/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go @@ -31,7 +31,7 @@ var ( // BlockHashReceiverMetaData contains all meta data concerning the BlockHashReceiver contract. var BlockHashReceiverMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterMessengerAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"publisherChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"publisherContractAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"InvalidSourceChainID\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidSourceChainPublisher\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"Unauthorized\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"getLatestBlockInfo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"height\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourceChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourcePublisherContractAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterMessenger\",\"outputs\":[{\"internalType\":\"contractITeleporterMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"publisherChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"publisherContractAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"InvalidSourceChainID\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidSourceChainPublisher\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTeleporterRegistryAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTeleporterSender\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"getLatestBlockInfo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"height\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourceChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourcePublisherContractAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // BlockHashReceiverABI is the input ABI used to generate the binding from. @@ -225,6 +225,37 @@ func (_BlockHashReceiver *BlockHashReceiverCallerSession) GetLatestBlockInfo() ( return _BlockHashReceiver.Contract.GetLatestBlockInfo(&_BlockHashReceiver.CallOpts) } +// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// +// Solidity: function getMinTeleporterVersion() view returns(uint256) +func (_BlockHashReceiver *BlockHashReceiverCaller) GetMinTeleporterVersion(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _BlockHashReceiver.contract.Call(opts, &out, "getMinTeleporterVersion") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// +// Solidity: function getMinTeleporterVersion() view returns(uint256) +func (_BlockHashReceiver *BlockHashReceiverSession) GetMinTeleporterVersion() (*big.Int, error) { + return _BlockHashReceiver.Contract.GetMinTeleporterVersion(&_BlockHashReceiver.CallOpts) +} + +// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// +// Solidity: function getMinTeleporterVersion() view returns(uint256) +func (_BlockHashReceiver *BlockHashReceiverCallerSession) GetMinTeleporterVersion() (*big.Int, error) { + return _BlockHashReceiver.Contract.GetMinTeleporterVersion(&_BlockHashReceiver.CallOpts) +} + // LatestBlockHash is a free data retrieval call binding the contract method 0x6c4f6ba9. // // Solidity: function latestBlockHash() view returns(bytes32) @@ -349,12 +380,12 @@ func (_BlockHashReceiver *BlockHashReceiverCallerSession) SourcePublisherContrac return _BlockHashReceiver.Contract.SourcePublisherContractAddress(&_BlockHashReceiver.CallOpts) } -// TeleporterMessenger is a free data retrieval call binding the contract method 0x9b3e5803. +// TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. // -// Solidity: function teleporterMessenger() view returns(address) -func (_BlockHashReceiver *BlockHashReceiverCaller) TeleporterMessenger(opts *bind.CallOpts) (common.Address, error) { +// Solidity: function teleporterRegistry() view returns(address) +func (_BlockHashReceiver *BlockHashReceiverCaller) TeleporterRegistry(opts *bind.CallOpts) (common.Address, error) { var out []interface{} - err := _BlockHashReceiver.contract.Call(opts, &out, "teleporterMessenger") + err := _BlockHashReceiver.contract.Call(opts, &out, "teleporterRegistry") if err != nil { return *new(common.Address), err @@ -366,18 +397,18 @@ func (_BlockHashReceiver *BlockHashReceiverCaller) TeleporterMessenger(opts *bin } -// TeleporterMessenger is a free data retrieval call binding the contract method 0x9b3e5803. +// TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. // -// Solidity: function teleporterMessenger() view returns(address) -func (_BlockHashReceiver *BlockHashReceiverSession) TeleporterMessenger() (common.Address, error) { - return _BlockHashReceiver.Contract.TeleporterMessenger(&_BlockHashReceiver.CallOpts) +// Solidity: function teleporterRegistry() view returns(address) +func (_BlockHashReceiver *BlockHashReceiverSession) TeleporterRegistry() (common.Address, error) { + return _BlockHashReceiver.Contract.TeleporterRegistry(&_BlockHashReceiver.CallOpts) } -// TeleporterMessenger is a free data retrieval call binding the contract method 0x9b3e5803. +// TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. // -// Solidity: function teleporterMessenger() view returns(address) -func (_BlockHashReceiver *BlockHashReceiverCallerSession) TeleporterMessenger() (common.Address, error) { - return _BlockHashReceiver.Contract.TeleporterMessenger(&_BlockHashReceiver.CallOpts) +// Solidity: function teleporterRegistry() view returns(address) +func (_BlockHashReceiver *BlockHashReceiverCallerSession) TeleporterRegistry() (common.Address, error) { + return _BlockHashReceiver.Contract.TeleporterRegistry(&_BlockHashReceiver.CallOpts) } // ReceiveTeleporterMessage is a paid mutator transaction binding the contract method 0xc868efaa. @@ -401,6 +432,27 @@ func (_BlockHashReceiver *BlockHashReceiverTransactorSession) ReceiveTeleporterM return _BlockHashReceiver.Contract.ReceiveTeleporterMessage(&_BlockHashReceiver.TransactOpts, originChainID, originSenderAddress, message) } +// UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. +// +// Solidity: function updateMinTeleporterVersion() returns() +func (_BlockHashReceiver *BlockHashReceiverTransactor) UpdateMinTeleporterVersion(opts *bind.TransactOpts) (*types.Transaction, error) { + return _BlockHashReceiver.contract.Transact(opts, "updateMinTeleporterVersion") +} + +// UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. +// +// Solidity: function updateMinTeleporterVersion() returns() +func (_BlockHashReceiver *BlockHashReceiverSession) UpdateMinTeleporterVersion() (*types.Transaction, error) { + return _BlockHashReceiver.Contract.UpdateMinTeleporterVersion(&_BlockHashReceiver.TransactOpts) +} + +// UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. +// +// Solidity: function updateMinTeleporterVersion() returns() +func (_BlockHashReceiver *BlockHashReceiverTransactorSession) UpdateMinTeleporterVersion() (*types.Transaction, error) { + return _BlockHashReceiver.Contract.UpdateMinTeleporterVersion(&_BlockHashReceiver.TransactOpts) +} + // BlockHashReceiverReceiveBlockHashIterator is returned from FilterReceiveBlockHash and is used to iterate over the raw logs and unpacked data for ReceiveBlockHash events raised by the BlockHashReceiver contract. type BlockHashReceiverReceiveBlockHashIterator struct { Event *BlockHashReceiverReceiveBlockHash // Event containing the contract specifics and raw log From 77ec0785de229121f71012c1fd4c608bbec27b98 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Fri, 13 Oct 2023 21:23:28 +0000 Subject: [PATCH 38/80] fix integration tests and log --- docker/run_setup.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/run_setup.sh b/docker/run_setup.sh index 24e10e668..0348ddea6 100755 --- a/docker/run_setup.sh +++ b/docker/run_setup.sh @@ -129,20 +129,20 @@ if [ ! -e $dir_prefix/NETWORK_RUNNING ]; then # Deploy TeleporterRegistry to each chain. cd contracts - registry_deploy_result_a=$(forge create --private-key $user_private_key --constructor-args [1] "[$teleporter_contract_address]" \ + registry_deploy_result_a=$(forge create --private-key $user_private_key --constructor-args "[(1,$teleporter_contract_address)]" \ --rpc-url $subnet_a_url src/Teleporter/upgrades/TeleporterRegistry.sol:TeleporterRegistry) registry_address_a=$(parseContractAddress "$registry_deploy_result_a") echo "TeleporterRegistry contract deployed to subnet A at $registry_address_a." - registry_deploy_result_b=$(forge create --private-key $user_private_key --constructor-args [1] "[$teleporter_contract_address]" \ + registry_deploy_result_b=$(forge create --private-key $user_private_key --constructor-args "[(1,$teleporter_contract_address)]" \ --rpc-url $subnet_b_url src/Teleporter/upgrades/TeleporterRegistry.sol:TeleporterRegistry) registry_address_b=$(parseContractAddress "$registry_deploy_result_b") - echo "TeleporterRegistry contract deployed to subnet A at $registry_address_b." + echo "TeleporterRegistry contract deployed to subnet B at $registry_address_b." - registry_deploy_result_c=$(forge create --private-key $user_private_key --constructor-args [1] "[$teleporter_contract_address]" \ + registry_deploy_result_c=$(forge create --private-key $user_private_key --constructor-args "[(1,$teleporter_contract_address)]" \ --rpc-url $subnet_c_url src/Teleporter/upgrades/TeleporterRegistry.sol:TeleporterRegistry) registry_address_c=$(parseContractAddress "$registry_deploy_result_c") - echo "TeleporterRegistry contract deployed to subnet A at $registry_address_c." + echo "TeleporterRegistry contract deployed to subnet C at $registry_address_c." cd .. # Send tokens to cover gas costs for the relayers. From 1f38e6c650b192405acbafd513e9cffa6a26f165 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Tue, 17 Oct 2023 21:06:04 +0000 Subject: [PATCH 39/80] draft new registry mapping approach --- contracts/src/WarpProtocolRegistry.sol | 100 ++++++++++++------------- 1 file changed, 47 insertions(+), 53 deletions(-) diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 4cfc04b32..911df8079 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -60,8 +60,8 @@ abstract contract WarpProtocolRegistry { * @dev Initializes the contract by setting a `chainID` and `latestVersion`. */ constructor(ProtocolRegistryEntry[] memory initialEntries) { - _latestVersion = 0; _blockchainID = WARP_MESSENGER.getBlockchainID(); + _latestVersion = 0; for (uint256 i = 0; i < initialEntries.length; i++) { _addToRegistry(initialEntries[i]); @@ -80,7 +80,33 @@ abstract contract WarpProtocolRegistry { * - the protocol address must be a contract address. */ function addProtocolVersion(uint32 messageIndex) external virtual { - _addProtocolVersion(messageIndex); + // Get and validate for a warp out-of-band message. + (WarpMessage memory message, bool valid) = WARP_MESSENGER + .getVerifiedWarpMessage(messageIndex); + if (!valid) { + revert InvalidWarpMessage(); + } + if (message.sourceChainID != _blockchainID) { + revert InvalidSourceChainID(); + } + + // Check that the message is sent through a warp out of band message. + if (message.originSenderAddress != VALIDATORS_SOURCE_ADDRESS) { + revert InvalidOriginSenderAddress(); + } + if (message.destinationChainID != _blockchainID) { + revert InvalidDestinationChainID(); + } + if (message.destinationAddress != address(this)) { + revert InvalidDestinationAddress(); + } + + ProtocolRegistryEntry memory entry = abi.decode( + message.payload, + (ProtocolRegistryEntry) + ); + + _addToRegistry(entry); } /** @@ -112,40 +138,6 @@ abstract contract WarpProtocolRegistry { return _latestVersion; } - /** - * @dev Gets and verifies for a warp out-of-band message, and adds the new protocol version - * address to the registry. - */ - function _addProtocolVersion(uint32 messageIndex) internal virtual { - // Get and validate for a warp out-of-band message. - (WarpMessage memory message, bool valid) = WARP_MESSENGER - .getVerifiedWarpMessage(messageIndex); - if (!valid) { - revert InvalidWarpMessage(); - } - if (message.sourceChainID != _blockchainID) { - revert InvalidSourceChainID(); - } - - // Check that the message is sent through a warp out of band message. - if (message.originSenderAddress != VALIDATORS_SOURCE_ADDRESS) { - revert InvalidOriginSenderAddress(); - } - if (message.destinationChainID != _blockchainID) { - revert InvalidDestinationChainID(); - } - if (message.destinationAddress != address(this)) { - revert InvalidDestinationAddress(); - } - - ProtocolRegistryEntry memory entry = abi.decode( - message.payload, - (ProtocolRegistryEntry) - ); - - _addToRegistry(entry); - } - /** * @dev Adds the new protocol version address to the registry. * @@ -160,19 +152,25 @@ abstract contract WarpProtocolRegistry { function _addToRegistry( ProtocolRegistryEntry memory entry ) internal virtual { - // Check that the version is the increment of the latest version. - if (entry.version != _latestVersion + 1) { - revert InvalidProtocolVersion(); - } - - if (entry.protocolAddress == address(0)) { - revert InvalidProtocolAddress(); - } + require(entry.version != 0, "WarpProtocolRegistry: zero version"); + // Check that the version has not previously been registered. + require( + _versionToAddress[entry.version] == address(0), + "WarpProtocolRegistry: version already exists" + ); + require( + entry.protocolAddress != address(0), + "WarpProtocolRegistry: zero protocol address" + ); - _latestVersion++; _versionToAddress[entry.version] = entry.protocolAddress; _addressToVersion[entry.protocolAddress] = entry.version; emit AddProtocolVersion(entry.version, entry.protocolAddress); + + // Set latest version if the version is greater than the current latest version. + if (entry.version > _latestVersion) { + _latestVersion = entry.version; + } } /** @@ -184,14 +182,10 @@ abstract contract WarpProtocolRegistry { function _getAddressFromVersion( uint256 version ) internal view virtual returns (address) { - // Check that the version provided is a valid version. - if (version == 0) { - revert InvalidProtocolVersion(); - } - - if (version > _latestVersion) { - revert InvalidProtocolVersion(); - } + require( + 0 < version <= _latestVersion, + "WarpProtocolRegistry: invalid version" + ); return _versionToAddress[version]; } } From 1530a0e492a1db0d12892a6df20e6bdd69ef48b3 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Tue, 17 Oct 2023 21:48:47 +0000 Subject: [PATCH 40/80] add unit tests and use require statements --- .../upgrades/TeleporterUpgradeable.sol | 21 +- .../tests/TeleporterRegistryTests.t.sol | 181 +++++++++++++++--- .../tests/TeleporterUpgradeableTests.t.sol | 12 +- contracts/src/WarpProtocolRegistry.sol | 47 ++--- 4 files changed, 192 insertions(+), 69 deletions(-) diff --git a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol index 927e7fa05..31282305a 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol @@ -19,20 +19,16 @@ abstract contract TeleporterUpgradeable { TeleporterRegistry public immutable teleporterRegistry; uint256 internal _minTeleporterVersion; - error InvalidTeleporterRegistryAddress(); - error InvalidTeleporterSender(); - /** * @dev Throws if called by a `msg.sender` that is not an allowed Teleporter version. * Checks that `msg.sender` matches a Teleporter version greater than or equal to `_minTeleporterVersion`. */ modifier onlyAllowedTeleporter() { - if ( - teleporterRegistry.getVersionFromAddress(msg.sender) < - _minTeleporterVersion - ) { - revert InvalidTeleporterSender(); - } + require( + teleporterRegistry.getVersionFromAddress(msg.sender) >= + _minTeleporterVersion, + "TeleporterUpgradeable: invalid teleporter sender" + ); _; } @@ -41,9 +37,10 @@ abstract contract TeleporterUpgradeable { * instance and setting `_minTeleporterVersion`. */ constructor(address teleporterRegistryAddress) { - if (teleporterRegistryAddress == address(0)) { - revert InvalidTeleporterRegistryAddress(); - } + require( + teleporterRegistryAddress != address(0), + "TeleporterUpgradeable: invalid teleporter registry address" + ); teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); _minTeleporterVersion = teleporterRegistry.getLatestVersion(); diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol index 8f25207aa..cb5a328a8 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterRegistryTests.t.sol @@ -37,8 +37,9 @@ contract TeleporterRegistryTest is Test { teleporterAddress = address(new TeleporterMessenger()); } - function testAddProtocolVersionSuccess() public { + function testAddProtocolVersionBasic() public { uint256 latestVersion = teleporterRegistry.getLatestVersion(); + uint32 messageIndex = 0; assertEq(0, latestVersion); _addProtocolVersion(teleporterRegistry); @@ -51,15 +52,66 @@ contract TeleporterRegistryTest is Test { teleporterRegistry.getVersionFromAddress(teleporterAddress), teleporterRegistry.getLatestVersion() ); + + // Check that adding a protocol version with a version that is not the increment of the latest version succeeds + latestVersion = teleporterRegistry.getLatestVersion(); + WarpMessage memory warpMessage = _createWarpOutofBandMessage( + latestVersion + 2, + teleporterAddress, + address(teleporterRegistry) + ); + + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall( + WarpMessenger.getVerifiedWarpMessage, + (messageIndex) + ), + abi.encode(warpMessage, true) + ); + + teleporterRegistry.addProtocolVersion(messageIndex); + assertEq(latestVersion + 2, teleporterRegistry.getLatestVersion()); + assertEq( + teleporterAddress, + address(teleporterRegistry.getLatestTeleporter()) + ); } - function testAddToRegistryFails() public { + function testAddNonContractAddress() public { + // Check that adding a protocol version with a protocol address that is not a contract address succeeds uint256 latestVersion = teleporterRegistry.getLatestVersion(); uint32 messageIndex = 0; + WarpMessage memory warpMessage = _createWarpOutofBandMessage( + latestVersion + 2, + address(this), + address(teleporterRegistry) + ); - // Create a Warp out-of-band message with same version as latest version + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall( + WarpMessenger.getVerifiedWarpMessage, + (messageIndex) + ), + abi.encode(warpMessage, true) + ); + + teleporterRegistry.addProtocolVersion(messageIndex); + assertEq(latestVersion + 2, teleporterRegistry.getLatestVersion()); + assertEq( + address(this), + teleporterRegistry.getAddressFromVersion(latestVersion + 2) + ); + } + + function testAddOldVersion() public { + // Check that adding a protocol version that has not been registered, but is less than the latest version succeeds + // First add to latest version by skipping a version. + uint256 latestVersion = teleporterRegistry.getLatestVersion(); + uint32 messageIndex = 0; WarpMessage memory warpMessage = _createWarpOutofBandMessage( - latestVersion, + latestVersion + 2, teleporterAddress, address(teleporterRegistry) ); @@ -72,18 +124,53 @@ contract TeleporterRegistryTest is Test { ), abi.encode(warpMessage, true) ); - vm.expectCall( + + teleporterRegistry.addProtocolVersion(messageIndex); + assertEq(latestVersion + 2, teleporterRegistry.getLatestVersion()); + assertEq( + teleporterAddress, + teleporterRegistry.getAddressFromVersion(latestVersion + 2) + ); + + // latestVersion + 1 was skipped in previous check, is not registered, and is less than getLatestVersion() + uint256 oldVersion = latestVersion + 1; + warpMessage = _createWarpOutofBandMessage( + oldVersion, + address(this), + address(teleporterRegistry) + ); + + // Make sure that oldVersion is not registered, and is less than getLatestVersion() + assertEq(oldVersion, teleporterRegistry.getLatestVersion() - 1); + assertEq( + address(0), + teleporterRegistry.getAddressFromVersion(oldVersion) + ); + + vm.mockCall( WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (messageIndex)) + abi.encodeCall( + WarpMessenger.getVerifiedWarpMessage, + (messageIndex) + ), + abi.encode(warpMessage, true) ); - // Check that adding a protocol version with the same version fails - vm.expectRevert(WarpProtocolRegistry.InvalidProtocolVersion.selector); teleporterRegistry.addProtocolVersion(messageIndex); + assertEq( + address(this), + teleporterRegistry.getAddressFromVersion(oldVersion) + ); + assertEq(oldVersion + 1, teleporterRegistry.getLatestVersion()); + } - // Check that adding a protocol version with a version that is not the increment of the latest version fails - warpMessage = _createWarpOutofBandMessage( - latestVersion + 2, + function testAddExistingVersion() public { + uint256 latestVersion = teleporterRegistry.getLatestVersion(); + uint32 messageIndex = 0; + + // Add a new version to the registiry + WarpMessage memory warpMessage = _createWarpOutofBandMessage( + latestVersion + 1, teleporterAddress, address(teleporterRegistry) ); @@ -96,12 +183,29 @@ contract TeleporterRegistryTest is Test { ), abi.encode(warpMessage, true) ); + vm.expectCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (messageIndex)) + ); - vm.expectRevert(WarpProtocolRegistry.InvalidProtocolVersion.selector); teleporterRegistry.addProtocolVersion(messageIndex); + assertEq(latestVersion + 1, teleporterRegistry.getLatestVersion()); + assertEq( + teleporterAddress, + teleporterRegistry.getAddressFromVersion(latestVersion + 1) + ); + + // Check that adding a protocol version with the same version fails + vm.expectRevert(_formatErrorMessage("version already exists")); + teleporterRegistry.addProtocolVersion(messageIndex); + } + + function testAddZeroProtocolAddress() public { + uint256 latestVersion = teleporterRegistry.getLatestVersion(); + uint32 messageIndex = 0; // Check that adding an invalid protocol address of address(0) fails - warpMessage = _createWarpOutofBandMessage( + WarpMessage memory warpMessage = _createWarpOutofBandMessage( latestVersion + 1, address(0), address(teleporterRegistry) @@ -116,7 +220,30 @@ contract TeleporterRegistryTest is Test { abi.encode(warpMessage, true) ); - vm.expectRevert(WarpProtocolRegistry.InvalidProtocolAddress.selector); + vm.expectRevert(_formatErrorMessage("zero protocol address")); + teleporterRegistry.addProtocolVersion(messageIndex); + } + + function testAddZeroVersion() public { + uint32 messageIndex = 0; + + // Check that adding an invalid version of 0 fails + WarpMessage memory warpMessage = _createWarpOutofBandMessage( + 0, + teleporterAddress, + address(teleporterRegistry) + ); + + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall( + WarpMessenger.getVerifiedWarpMessage, + (messageIndex) + ), + abi.encode(warpMessage, true) + ); + + vm.expectRevert(_formatErrorMessage("zero version")); teleporterRegistry.addProtocolVersion(messageIndex); } @@ -131,11 +258,11 @@ contract TeleporterRegistryTest is Test { ); // Check that getting version 0 fails - vm.expectRevert(WarpProtocolRegistry.InvalidProtocolVersion.selector); + vm.expectRevert(_formatErrorMessage("zero version")); teleporterRegistry.getAddressFromVersion(0); // Check that getting a version that doesn't exist fails - vm.expectRevert(WarpProtocolRegistry.InvalidProtocolVersion.selector); + vm.expectRevert(_formatErrorMessage("invalid version")); teleporterRegistry.getAddressFromVersion(latestVersion + 1); } @@ -176,7 +303,7 @@ contract TeleporterRegistryTest is Test { abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (messageIndex)) ); - vm.expectRevert(WarpProtocolRegistry.InvalidWarpMessage.selector); + vm.expectRevert(_formatErrorMessage("invalid warp message")); teleporterRegistry.addProtocolVersion(messageIndex); // Check if we have an invalid source chain ID @@ -190,7 +317,7 @@ contract TeleporterRegistryTest is Test { abi.encode(warpMessage, true) ); - vm.expectRevert(WarpProtocolRegistry.InvalidSourceChainID.selector); + vm.expectRevert(_formatErrorMessage("invalid source chain ID")); teleporterRegistry.addProtocolVersion(messageIndex); // Check if we have an invalid origin sender address @@ -205,9 +332,7 @@ contract TeleporterRegistryTest is Test { abi.encode(warpMessage, true) ); - vm.expectRevert( - WarpProtocolRegistry.InvalidOriginSenderAddress.selector - ); + vm.expectRevert(_formatErrorMessage("invalid origin sender address")); teleporterRegistry.addProtocolVersion(messageIndex); // Check if we have an invalid destination chain ID @@ -223,9 +348,7 @@ contract TeleporterRegistryTest is Test { abi.encode(warpMessage, true) ); - vm.expectRevert( - WarpProtocolRegistry.InvalidDestinationChainID.selector - ); + vm.expectRevert(_formatErrorMessage("invalid destination chain ID")); teleporterRegistry.addProtocolVersion(messageIndex); // Check if we have an invalid destination address @@ -240,9 +363,7 @@ contract TeleporterRegistryTest is Test { abi.encode(warpMessage, true) ); - vm.expectRevert( - WarpProtocolRegistry.InvalidDestinationAddress.selector - ); + vm.expectRevert(_formatErrorMessage("invalid destination address")); teleporterRegistry.addProtocolVersion(messageIndex); } @@ -292,4 +413,10 @@ contract TeleporterRegistryTest is Test { ) }); } + + function _formatErrorMessage( + string memory errorMessage + ) private pure returns (bytes memory) { + return bytes(string.concat("WarpProtocolRegistry: ", errorMessage)); + } } diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol index a0382568f..7a5d79c4b 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol @@ -52,7 +52,7 @@ contract TeleporterUpgradeableTest is Test { function testInvalidRegistryAddress() public { vm.expectRevert( - TeleporterUpgradeable.InvalidTeleporterRegistryAddress.selector + _formatErrorMessage("invalid teleporter registry address") ); new ExampleUpgradeableApp(address(0)); } @@ -64,7 +64,7 @@ contract TeleporterUpgradeableTest is Test { assertEq(app.getMinTeleporterVersion(), 1); - vm.expectRevert(TeleporterUpgradeable.InvalidTeleporterSender.selector); + vm.expectRevert(_formatErrorMessage("invalid teleporter sender")); app.teleporterCall(); vm.prank(MOCK_TELEPORTER_MESSENGER_ADDRESS); @@ -92,8 +92,14 @@ contract TeleporterUpgradeableTest is Test { assertEq(app.getMinTeleporterVersion(), 2); // Check that calling with the old teleporter address fails - vm.expectRevert(TeleporterUpgradeable.InvalidTeleporterSender.selector); + vm.expectRevert(_formatErrorMessage("invalid teleporter sender")); vm.prank(MOCK_TELEPORTER_MESSENGER_ADDRESS); app.teleporterCall(); } + + function _formatErrorMessage( + string memory errorMessage + ) private pure returns (bytes memory) { + return bytes(string.concat("TeleporterUpgradeable: ", errorMessage)); + } } diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 911df8079..b225ee56a 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -47,15 +47,6 @@ abstract contract WarpProtocolRegistry { address indexed protocolAddress ); - // Errors - error InvalidWarpMessage(); - error InvalidSourceChainID(); - error InvalidOriginSenderAddress(); - error InvalidDestinationChainID(); - error InvalidDestinationAddress(); - error InvalidProtocolVersion(); - error InvalidProtocolAddress(); - /** * @dev Initializes the contract by setting a `chainID` and `latestVersion`. */ @@ -81,25 +72,26 @@ abstract contract WarpProtocolRegistry { */ function addProtocolVersion(uint32 messageIndex) external virtual { // Get and validate for a warp out-of-band message. - (WarpMessage memory message, bool valid) = WARP_MESSENGER + (WarpMessage memory message, bool success) = WARP_MESSENGER .getVerifiedWarpMessage(messageIndex); - if (!valid) { - revert InvalidWarpMessage(); - } - if (message.sourceChainID != _blockchainID) { - revert InvalidSourceChainID(); - } - + require(success, "WarpProtocolRegistry: invalid warp message"); + require( + message.sourceChainID == _blockchainID, + "WarpProtocolRegistry: invalid source chain ID" + ); // Check that the message is sent through a warp out of band message. - if (message.originSenderAddress != VALIDATORS_SOURCE_ADDRESS) { - revert InvalidOriginSenderAddress(); - } - if (message.destinationChainID != _blockchainID) { - revert InvalidDestinationChainID(); - } - if (message.destinationAddress != address(this)) { - revert InvalidDestinationAddress(); - } + require( + message.originSenderAddress == VALIDATORS_SOURCE_ADDRESS, + "WarpProtocolRegistry: invalid origin sender address" + ); + require( + message.destinationChainID == _blockchainID, + "WarpProtocolRegistry: invalid destination chain ID" + ); + require( + message.destinationAddress == address(this), + "WarpProtocolRegistry: invalid destination address" + ); ProtocolRegistryEntry memory entry = abi.decode( message.payload, @@ -182,8 +174,9 @@ abstract contract WarpProtocolRegistry { function _getAddressFromVersion( uint256 version ) internal view virtual returns (address) { + require(version != 0, "WarpProtocolRegistry: zero version"); require( - 0 < version <= _latestVersion, + version <= _latestVersion, "WarpProtocolRegistry: invalid version" ); return _versionToAddress[version]; From 201416e6d5b8a7769fc5e61121c56a2c673748ef Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Tue, 17 Oct 2023 22:02:10 +0000 Subject: [PATCH 41/80] update documentation and abi bindings --- .../ERC20Bridge/ERC20Bridge/ERC20Bridge.go | 2 +- .../ExampleCrossChainMessenger.go | 2 +- .../BlockHashPublisher/BlockHashPublisher.go | 2 +- .../BlockHashReceiver/BlockHashReceiver.go | 2 +- .../TeleporterRegistry/TeleporterRegistry.go | 578 ++++++++++++++++++ .../upgrades/TeleporterRegistry.sol | 2 +- contracts/src/WarpProtocolRegistry.sol | 21 +- 7 files changed, 598 insertions(+), 11 deletions(-) create mode 100644 abi-bindings/Teleporter/upgrades/TeleporterRegistry/TeleporterRegistry.go diff --git a/abi-bindings/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go b/abi-bindings/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go index 3b152253e..8359d1c0c 100644 --- a/abi-bindings/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go +++ b/abi-bindings/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go @@ -31,7 +31,7 @@ var ( // ERC20BridgeMetaData contains all meta data concerning the ERC20Bridge contract. var ERC20BridgeMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BalanceNotIncreased\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"bridgeTokenAddress\",\"type\":\"address\"}],\"name\":\"BridgeTokenAlreadyExists\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CannotBridgeTokenWithinSameChain\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeTokenAddress\",\"type\":\"address\"}],\"name\":\"CannotBridgeWrappedToken\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"adjustedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"InsufficientAdjustedAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"InsufficientTotalAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"currentBalance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requestAmount\",\"type\":\"uint256\"}],\"name\":\"InsufficientWrappedTokenBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidAction\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidBridgeTokenAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidDestinationBridgeAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidRecipientAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTeleporterRegistryAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTeleporterSender\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"BridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"bridgeTokenAddress\",\"type\":\"address\"}],\"name\":\"CreateBridgeToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"contractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MintBridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"}],\"name\":\"SubmitCreateBridgeToken\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CREATE_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINT_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TRANSFER_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WARP_PRECOMPILE_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"primaryFeeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"secondaryFeeAmount\",\"type\":\"uint256\"}],\"name\":\"bridgeTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"bridgedBalances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"nativeName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"nativeSymbol\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"nativeDecimals\",\"type\":\"uint8\"}],\"name\":\"encodeCreateBridgeTokenData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"bridgeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeMintBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeTransferBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nativeToWrappedTokens\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"contractERC20\",\"name\":\"nativeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"messageFeeAsset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"messageFeeAmount\",\"type\":\"uint256\"}],\"name\":\"submitCreateBridgeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"submittedBridgeTokenCreations\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedTokenContracts\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BalanceNotIncreased\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"bridgeTokenAddress\",\"type\":\"address\"}],\"name\":\"BridgeTokenAlreadyExists\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CannotBridgeTokenWithinSameChain\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeTokenAddress\",\"type\":\"address\"}],\"name\":\"CannotBridgeWrappedToken\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"adjustedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"InsufficientAdjustedAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"InsufficientTotalAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"currentBalance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requestAmount\",\"type\":\"uint256\"}],\"name\":\"InsufficientWrappedTokenBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidAction\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidBridgeTokenAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidDestinationBridgeAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidRecipientAddress\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"BridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"bridgeTokenAddress\",\"type\":\"address\"}],\"name\":\"CreateBridgeToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"contractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MintBridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"}],\"name\":\"SubmitCreateBridgeToken\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CREATE_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINT_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TRANSFER_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WARP_PRECOMPILE_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"primaryFeeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"secondaryFeeAmount\",\"type\":\"uint256\"}],\"name\":\"bridgeTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"bridgedBalances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"nativeName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"nativeSymbol\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"nativeDecimals\",\"type\":\"uint8\"}],\"name\":\"encodeCreateBridgeTokenData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"bridgeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeMintBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeTransferBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nativeToWrappedTokens\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"contractERC20\",\"name\":\"nativeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"messageFeeAsset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"messageFeeAmount\",\"type\":\"uint256\"}],\"name\":\"submitCreateBridgeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"submittedBridgeTokenCreations\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedTokenContracts\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // ERC20BridgeABI is the input ABI used to generate the binding from. diff --git a/abi-bindings/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go b/abi-bindings/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go index b65507bb4..9982cf1c4 100644 --- a/abi-bindings/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go +++ b/abi-bindings/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go @@ -31,7 +31,7 @@ var ( // ExampleCrossChainMessengerMetaData contains all meta data concerning the ExampleCrossChainMessenger contract. var ExampleCrossChainMessengerMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BalanceNotIncreased\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTeleporterRegistryAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTeleporterSender\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"ReceiveMessage\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeAsset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"SendMessage\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"}],\"name\":\"getCurrentMessage\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeContractAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"sendMessage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"BalanceNotIncreased\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"ReceiveMessage\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeAsset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"SendMessage\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"}],\"name\":\"getCurrentMessage\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeContractAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"sendMessage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // ExampleCrossChainMessengerABI is the input ABI used to generate the binding from. diff --git a/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go b/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go index d858584f3..a6b2874f5 100644 --- a/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go +++ b/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go @@ -31,7 +31,7 @@ var ( // BlockHashPublisherMetaData contains all meta data concerning the BlockHashPublisher contract. var BlockHashPublisherMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"InvalidTeleporterRegistryAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTeleporterSender\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"PublishBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"RECEIVE_BLOCK_HASH_REQUIRED_GAS_LIMIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"}],\"name\":\"publishLatestBlockHash\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"PublishBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"RECEIVE_BLOCK_HASH_REQUIRED_GAS_LIMIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"}],\"name\":\"publishLatestBlockHash\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // BlockHashPublisherABI is the input ABI used to generate the binding from. diff --git a/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go b/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go index f9edd98f2..97aaba67e 100644 --- a/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go +++ b/abi-bindings/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go @@ -31,7 +31,7 @@ var ( // BlockHashReceiverMetaData contains all meta data concerning the BlockHashReceiver contract. var BlockHashReceiverMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"publisherChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"publisherContractAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"InvalidSourceChainID\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidSourceChainPublisher\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTeleporterRegistryAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidTeleporterSender\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"getLatestBlockInfo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"height\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourceChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourcePublisherContractAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"publisherChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"publisherContractAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"InvalidSourceChainID\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidSourceChainPublisher\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"getLatestBlockInfo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"height\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourceChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourcePublisherContractAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // BlockHashReceiverABI is the input ABI used to generate the binding from. diff --git a/abi-bindings/Teleporter/upgrades/TeleporterRegistry/TeleporterRegistry.go b/abi-bindings/Teleporter/upgrades/TeleporterRegistry/TeleporterRegistry.go new file mode 100644 index 000000000..ef6385100 --- /dev/null +++ b/abi-bindings/Teleporter/upgrades/TeleporterRegistry/TeleporterRegistry.go @@ -0,0 +1,578 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package teleporterregistry + +import ( + "errors" + "math/big" + "strings" + + "github.com/ava-labs/subnet-evm/accounts/abi" + "github.com/ava-labs/subnet-evm/accounts/abi/bind" + "github.com/ava-labs/subnet-evm/core/types" + "github.com/ava-labs/subnet-evm/interfaces" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = interfaces.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// ProtocolRegistryEntry is an auto generated low-level Go binding around an user-defined struct. +type ProtocolRegistryEntry struct { + Version *big.Int + ProtocolAddress common.Address +} + +// TeleporterRegistryMetaData contains all meta data concerning the TeleporterRegistry contract. +var TeleporterRegistryMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"protocolAddress\",\"type\":\"address\"}],\"internalType\":\"structProtocolRegistryEntry[]\",\"name\":\"initialEntries\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"protocolAddress\",\"type\":\"address\"}],\"name\":\"AddProtocolVersion\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"VALIDATORS_SOURCE_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WARP_MESSENGER\",\"outputs\":[{\"internalType\":\"contractWarpMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"messageIndex\",\"type\":\"uint32\"}],\"name\":\"addProtocolVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"getAddressFromVersion\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLatestTeleporter\",\"outputs\":[{\"internalType\":\"contractITeleporterMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLatestVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"getTeleporterFromVersion\",\"outputs\":[{\"internalType\":\"contractITeleporterMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"protocolAddress\",\"type\":\"address\"}],\"name\":\"getVersionFromAddress\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", +} + +// TeleporterRegistryABI is the input ABI used to generate the binding from. +// Deprecated: Use TeleporterRegistryMetaData.ABI instead. +var TeleporterRegistryABI = TeleporterRegistryMetaData.ABI + +// TeleporterRegistry is an auto generated Go binding around an Ethereum contract. +type TeleporterRegistry struct { + TeleporterRegistryCaller // Read-only binding to the contract + TeleporterRegistryTransactor // Write-only binding to the contract + TeleporterRegistryFilterer // Log filterer for contract events +} + +// TeleporterRegistryCaller is an auto generated read-only Go binding around an Ethereum contract. +type TeleporterRegistryCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TeleporterRegistryTransactor is an auto generated write-only Go binding around an Ethereum contract. +type TeleporterRegistryTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TeleporterRegistryFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type TeleporterRegistryFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TeleporterRegistrySession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type TeleporterRegistrySession struct { + Contract *TeleporterRegistry // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// TeleporterRegistryCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type TeleporterRegistryCallerSession struct { + Contract *TeleporterRegistryCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// TeleporterRegistryTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type TeleporterRegistryTransactorSession struct { + Contract *TeleporterRegistryTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// TeleporterRegistryRaw is an auto generated low-level Go binding around an Ethereum contract. +type TeleporterRegistryRaw struct { + Contract *TeleporterRegistry // Generic contract binding to access the raw methods on +} + +// TeleporterRegistryCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type TeleporterRegistryCallerRaw struct { + Contract *TeleporterRegistryCaller // Generic read-only contract binding to access the raw methods on +} + +// TeleporterRegistryTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type TeleporterRegistryTransactorRaw struct { + Contract *TeleporterRegistryTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewTeleporterRegistry creates a new instance of TeleporterRegistry, bound to a specific deployed contract. +func NewTeleporterRegistry(address common.Address, backend bind.ContractBackend) (*TeleporterRegistry, error) { + contract, err := bindTeleporterRegistry(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &TeleporterRegistry{TeleporterRegistryCaller: TeleporterRegistryCaller{contract: contract}, TeleporterRegistryTransactor: TeleporterRegistryTransactor{contract: contract}, TeleporterRegistryFilterer: TeleporterRegistryFilterer{contract: contract}}, nil +} + +// NewTeleporterRegistryCaller creates a new read-only instance of TeleporterRegistry, bound to a specific deployed contract. +func NewTeleporterRegistryCaller(address common.Address, caller bind.ContractCaller) (*TeleporterRegistryCaller, error) { + contract, err := bindTeleporterRegistry(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &TeleporterRegistryCaller{contract: contract}, nil +} + +// NewTeleporterRegistryTransactor creates a new write-only instance of TeleporterRegistry, bound to a specific deployed contract. +func NewTeleporterRegistryTransactor(address common.Address, transactor bind.ContractTransactor) (*TeleporterRegistryTransactor, error) { + contract, err := bindTeleporterRegistry(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &TeleporterRegistryTransactor{contract: contract}, nil +} + +// NewTeleporterRegistryFilterer creates a new log filterer instance of TeleporterRegistry, bound to a specific deployed contract. +func NewTeleporterRegistryFilterer(address common.Address, filterer bind.ContractFilterer) (*TeleporterRegistryFilterer, error) { + contract, err := bindTeleporterRegistry(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &TeleporterRegistryFilterer{contract: contract}, nil +} + +// bindTeleporterRegistry binds a generic wrapper to an already deployed contract. +func bindTeleporterRegistry(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := TeleporterRegistryMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_TeleporterRegistry *TeleporterRegistryRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _TeleporterRegistry.Contract.TeleporterRegistryCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_TeleporterRegistry *TeleporterRegistryRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TeleporterRegistry.Contract.TeleporterRegistryTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_TeleporterRegistry *TeleporterRegistryRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _TeleporterRegistry.Contract.TeleporterRegistryTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_TeleporterRegistry *TeleporterRegistryCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _TeleporterRegistry.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_TeleporterRegistry *TeleporterRegistryTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TeleporterRegistry.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_TeleporterRegistry *TeleporterRegistryTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _TeleporterRegistry.Contract.contract.Transact(opts, method, params...) +} + +// VALIDATORSSOURCEADDRESS is a free data retrieval call binding the contract method 0x0731775d. +// +// Solidity: function VALIDATORS_SOURCE_ADDRESS() view returns(address) +func (_TeleporterRegistry *TeleporterRegistryCaller) VALIDATORSSOURCEADDRESS(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _TeleporterRegistry.contract.Call(opts, &out, "VALIDATORS_SOURCE_ADDRESS") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// VALIDATORSSOURCEADDRESS is a free data retrieval call binding the contract method 0x0731775d. +// +// Solidity: function VALIDATORS_SOURCE_ADDRESS() view returns(address) +func (_TeleporterRegistry *TeleporterRegistrySession) VALIDATORSSOURCEADDRESS() (common.Address, error) { + return _TeleporterRegistry.Contract.VALIDATORSSOURCEADDRESS(&_TeleporterRegistry.CallOpts) +} + +// VALIDATORSSOURCEADDRESS is a free data retrieval call binding the contract method 0x0731775d. +// +// Solidity: function VALIDATORS_SOURCE_ADDRESS() view returns(address) +func (_TeleporterRegistry *TeleporterRegistryCallerSession) VALIDATORSSOURCEADDRESS() (common.Address, error) { + return _TeleporterRegistry.Contract.VALIDATORSSOURCEADDRESS(&_TeleporterRegistry.CallOpts) +} + +// WARPMESSENGER is a free data retrieval call binding the contract method 0xb771b3bc. +// +// Solidity: function WARP_MESSENGER() view returns(address) +func (_TeleporterRegistry *TeleporterRegistryCaller) WARPMESSENGER(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _TeleporterRegistry.contract.Call(opts, &out, "WARP_MESSENGER") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// WARPMESSENGER is a free data retrieval call binding the contract method 0xb771b3bc. +// +// Solidity: function WARP_MESSENGER() view returns(address) +func (_TeleporterRegistry *TeleporterRegistrySession) WARPMESSENGER() (common.Address, error) { + return _TeleporterRegistry.Contract.WARPMESSENGER(&_TeleporterRegistry.CallOpts) +} + +// WARPMESSENGER is a free data retrieval call binding the contract method 0xb771b3bc. +// +// Solidity: function WARP_MESSENGER() view returns(address) +func (_TeleporterRegistry *TeleporterRegistryCallerSession) WARPMESSENGER() (common.Address, error) { + return _TeleporterRegistry.Contract.WARPMESSENGER(&_TeleporterRegistry.CallOpts) +} + +// GetAddressFromVersion is a free data retrieval call binding the contract method 0x46f9ef49. +// +// Solidity: function getAddressFromVersion(uint256 version) view returns(address) +func (_TeleporterRegistry *TeleporterRegistryCaller) GetAddressFromVersion(opts *bind.CallOpts, version *big.Int) (common.Address, error) { + var out []interface{} + err := _TeleporterRegistry.contract.Call(opts, &out, "getAddressFromVersion", version) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// GetAddressFromVersion is a free data retrieval call binding the contract method 0x46f9ef49. +// +// Solidity: function getAddressFromVersion(uint256 version) view returns(address) +func (_TeleporterRegistry *TeleporterRegistrySession) GetAddressFromVersion(version *big.Int) (common.Address, error) { + return _TeleporterRegistry.Contract.GetAddressFromVersion(&_TeleporterRegistry.CallOpts, version) +} + +// GetAddressFromVersion is a free data retrieval call binding the contract method 0x46f9ef49. +// +// Solidity: function getAddressFromVersion(uint256 version) view returns(address) +func (_TeleporterRegistry *TeleporterRegistryCallerSession) GetAddressFromVersion(version *big.Int) (common.Address, error) { + return _TeleporterRegistry.Contract.GetAddressFromVersion(&_TeleporterRegistry.CallOpts, version) +} + +// GetLatestTeleporter is a free data retrieval call binding the contract method 0xd820e64f. +// +// Solidity: function getLatestTeleporter() view returns(address) +func (_TeleporterRegistry *TeleporterRegistryCaller) GetLatestTeleporter(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _TeleporterRegistry.contract.Call(opts, &out, "getLatestTeleporter") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// GetLatestTeleporter is a free data retrieval call binding the contract method 0xd820e64f. +// +// Solidity: function getLatestTeleporter() view returns(address) +func (_TeleporterRegistry *TeleporterRegistrySession) GetLatestTeleporter() (common.Address, error) { + return _TeleporterRegistry.Contract.GetLatestTeleporter(&_TeleporterRegistry.CallOpts) +} + +// GetLatestTeleporter is a free data retrieval call binding the contract method 0xd820e64f. +// +// Solidity: function getLatestTeleporter() view returns(address) +func (_TeleporterRegistry *TeleporterRegistryCallerSession) GetLatestTeleporter() (common.Address, error) { + return _TeleporterRegistry.Contract.GetLatestTeleporter(&_TeleporterRegistry.CallOpts) +} + +// GetLatestVersion is a free data retrieval call binding the contract method 0x0e6d1de9. +// +// Solidity: function getLatestVersion() view returns(uint256) +func (_TeleporterRegistry *TeleporterRegistryCaller) GetLatestVersion(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _TeleporterRegistry.contract.Call(opts, &out, "getLatestVersion") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetLatestVersion is a free data retrieval call binding the contract method 0x0e6d1de9. +// +// Solidity: function getLatestVersion() view returns(uint256) +func (_TeleporterRegistry *TeleporterRegistrySession) GetLatestVersion() (*big.Int, error) { + return _TeleporterRegistry.Contract.GetLatestVersion(&_TeleporterRegistry.CallOpts) +} + +// GetLatestVersion is a free data retrieval call binding the contract method 0x0e6d1de9. +// +// Solidity: function getLatestVersion() view returns(uint256) +func (_TeleporterRegistry *TeleporterRegistryCallerSession) GetLatestVersion() (*big.Int, error) { + return _TeleporterRegistry.Contract.GetLatestVersion(&_TeleporterRegistry.CallOpts) +} + +// GetTeleporterFromVersion is a free data retrieval call binding the contract method 0x215abce9. +// +// Solidity: function getTeleporterFromVersion(uint256 version) view returns(address) +func (_TeleporterRegistry *TeleporterRegistryCaller) GetTeleporterFromVersion(opts *bind.CallOpts, version *big.Int) (common.Address, error) { + var out []interface{} + err := _TeleporterRegistry.contract.Call(opts, &out, "getTeleporterFromVersion", version) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// GetTeleporterFromVersion is a free data retrieval call binding the contract method 0x215abce9. +// +// Solidity: function getTeleporterFromVersion(uint256 version) view returns(address) +func (_TeleporterRegistry *TeleporterRegistrySession) GetTeleporterFromVersion(version *big.Int) (common.Address, error) { + return _TeleporterRegistry.Contract.GetTeleporterFromVersion(&_TeleporterRegistry.CallOpts, version) +} + +// GetTeleporterFromVersion is a free data retrieval call binding the contract method 0x215abce9. +// +// Solidity: function getTeleporterFromVersion(uint256 version) view returns(address) +func (_TeleporterRegistry *TeleporterRegistryCallerSession) GetTeleporterFromVersion(version *big.Int) (common.Address, error) { + return _TeleporterRegistry.Contract.GetTeleporterFromVersion(&_TeleporterRegistry.CallOpts, version) +} + +// GetVersionFromAddress is a free data retrieval call binding the contract method 0x4c1f08ce. +// +// Solidity: function getVersionFromAddress(address protocolAddress) view returns(uint256) +func (_TeleporterRegistry *TeleporterRegistryCaller) GetVersionFromAddress(opts *bind.CallOpts, protocolAddress common.Address) (*big.Int, error) { + var out []interface{} + err := _TeleporterRegistry.contract.Call(opts, &out, "getVersionFromAddress", protocolAddress) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetVersionFromAddress is a free data retrieval call binding the contract method 0x4c1f08ce. +// +// Solidity: function getVersionFromAddress(address protocolAddress) view returns(uint256) +func (_TeleporterRegistry *TeleporterRegistrySession) GetVersionFromAddress(protocolAddress common.Address) (*big.Int, error) { + return _TeleporterRegistry.Contract.GetVersionFromAddress(&_TeleporterRegistry.CallOpts, protocolAddress) +} + +// GetVersionFromAddress is a free data retrieval call binding the contract method 0x4c1f08ce. +// +// Solidity: function getVersionFromAddress(address protocolAddress) view returns(uint256) +func (_TeleporterRegistry *TeleporterRegistryCallerSession) GetVersionFromAddress(protocolAddress common.Address) (*big.Int, error) { + return _TeleporterRegistry.Contract.GetVersionFromAddress(&_TeleporterRegistry.CallOpts, protocolAddress) +} + +// AddProtocolVersion is a paid mutator transaction binding the contract method 0x41f34ed9. +// +// Solidity: function addProtocolVersion(uint32 messageIndex) returns() +func (_TeleporterRegistry *TeleporterRegistryTransactor) AddProtocolVersion(opts *bind.TransactOpts, messageIndex uint32) (*types.Transaction, error) { + return _TeleporterRegistry.contract.Transact(opts, "addProtocolVersion", messageIndex) +} + +// AddProtocolVersion is a paid mutator transaction binding the contract method 0x41f34ed9. +// +// Solidity: function addProtocolVersion(uint32 messageIndex) returns() +func (_TeleporterRegistry *TeleporterRegistrySession) AddProtocolVersion(messageIndex uint32) (*types.Transaction, error) { + return _TeleporterRegistry.Contract.AddProtocolVersion(&_TeleporterRegistry.TransactOpts, messageIndex) +} + +// AddProtocolVersion is a paid mutator transaction binding the contract method 0x41f34ed9. +// +// Solidity: function addProtocolVersion(uint32 messageIndex) returns() +func (_TeleporterRegistry *TeleporterRegistryTransactorSession) AddProtocolVersion(messageIndex uint32) (*types.Transaction, error) { + return _TeleporterRegistry.Contract.AddProtocolVersion(&_TeleporterRegistry.TransactOpts, messageIndex) +} + +// TeleporterRegistryAddProtocolVersionIterator is returned from FilterAddProtocolVersion and is used to iterate over the raw logs and unpacked data for AddProtocolVersion events raised by the TeleporterRegistry contract. +type TeleporterRegistryAddProtocolVersionIterator struct { + Event *TeleporterRegistryAddProtocolVersion // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub interfaces.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *TeleporterRegistryAddProtocolVersionIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(TeleporterRegistryAddProtocolVersion) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(TeleporterRegistryAddProtocolVersion) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *TeleporterRegistryAddProtocolVersionIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *TeleporterRegistryAddProtocolVersionIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// TeleporterRegistryAddProtocolVersion represents a AddProtocolVersion event raised by the TeleporterRegistry contract. +type TeleporterRegistryAddProtocolVersion struct { + Version *big.Int + ProtocolAddress common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterAddProtocolVersion is a free log retrieval operation binding the contract event 0xa5eed93d951a9603d5f7c0a57de79a299dd3dbd5e51429be209d8053a42ab43a. +// +// Solidity: event AddProtocolVersion(uint256 indexed version, address indexed protocolAddress) +func (_TeleporterRegistry *TeleporterRegistryFilterer) FilterAddProtocolVersion(opts *bind.FilterOpts, version []*big.Int, protocolAddress []common.Address) (*TeleporterRegistryAddProtocolVersionIterator, error) { + + var versionRule []interface{} + for _, versionItem := range version { + versionRule = append(versionRule, versionItem) + } + var protocolAddressRule []interface{} + for _, protocolAddressItem := range protocolAddress { + protocolAddressRule = append(protocolAddressRule, protocolAddressItem) + } + + logs, sub, err := _TeleporterRegistry.contract.FilterLogs(opts, "AddProtocolVersion", versionRule, protocolAddressRule) + if err != nil { + return nil, err + } + return &TeleporterRegistryAddProtocolVersionIterator{contract: _TeleporterRegistry.contract, event: "AddProtocolVersion", logs: logs, sub: sub}, nil +} + +// WatchAddProtocolVersion is a free log subscription operation binding the contract event 0xa5eed93d951a9603d5f7c0a57de79a299dd3dbd5e51429be209d8053a42ab43a. +// +// Solidity: event AddProtocolVersion(uint256 indexed version, address indexed protocolAddress) +func (_TeleporterRegistry *TeleporterRegistryFilterer) WatchAddProtocolVersion(opts *bind.WatchOpts, sink chan<- *TeleporterRegistryAddProtocolVersion, version []*big.Int, protocolAddress []common.Address) (event.Subscription, error) { + + var versionRule []interface{} + for _, versionItem := range version { + versionRule = append(versionRule, versionItem) + } + var protocolAddressRule []interface{} + for _, protocolAddressItem := range protocolAddress { + protocolAddressRule = append(protocolAddressRule, protocolAddressItem) + } + + logs, sub, err := _TeleporterRegistry.contract.WatchLogs(opts, "AddProtocolVersion", versionRule, protocolAddressRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(TeleporterRegistryAddProtocolVersion) + if err := _TeleporterRegistry.contract.UnpackLog(event, "AddProtocolVersion", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseAddProtocolVersion is a log parse operation binding the contract event 0xa5eed93d951a9603d5f7c0a57de79a299dd3dbd5e51429be209d8053a42ab43a. +// +// Solidity: event AddProtocolVersion(uint256 indexed version, address indexed protocolAddress) +func (_TeleporterRegistry *TeleporterRegistryFilterer) ParseAddProtocolVersion(log types.Log) (*TeleporterRegistryAddProtocolVersion, error) { + event := new(TeleporterRegistryAddProtocolVersion) + if err := _TeleporterRegistry.contract.UnpackLog(event, "AddProtocolVersion", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol index 07a82c20a..529c899bc 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterRegistry.sol @@ -10,7 +10,7 @@ import "../ITeleporterMessenger.sol"; /** * @dev TeleporterRegistry contract is a {WarpProtocolRegistry} and provides an upgrade - * mechanism for teleporter messenger contracts. + * mechanism for {ITeleporterMessenger} contracts. */ contract TeleporterRegistry is WarpProtocolRegistry { constructor( diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index b225ee56a..96cb6611e 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -24,7 +24,7 @@ struct ProtocolRegistryEntry { */ abstract contract WarpProtocolRegistry { // Address that the out-of-band Warp message sets as the "source" address. - // The address is obviously not owned by any EOA or smart contract account, so it + // The address is not owned by any EOA or smart contract account, so it // cannot possibly be the source address of any other Warp message emitted by the VM. address public constant VALIDATORS_SOURCE_ADDRESS = address(0); @@ -36,6 +36,7 @@ abstract contract WarpProtocolRegistry { // The latest protocol version. 0 means no protocol version has been added, and isn't a valid version. uint256 internal _latestVersion; + // Mappings that keep track of the protocol version and corresponding contract address. mapping(uint256 => address) internal _versionToAddress; mapping(address => uint256) internal _addressToVersion; @@ -48,7 +49,8 @@ abstract contract WarpProtocolRegistry { ); /** - * @dev Initializes the contract by setting a `chainID` and `latestVersion`. + * @dev Initializes the contract by setting `_blockchainID` and `_latestVersion`. + * Also adds the initial protocol versions to the registry. */ constructor(ProtocolRegistryEntry[] memory initialEntries) { _blockchainID = WARP_MESSENGER.getBlockchainID(); @@ -62,13 +64,16 @@ abstract contract WarpProtocolRegistry { /** * @dev Gets and verifies a warp out-of-band message, and adds the new protocol version * address to the registry. + * If a version is greater than the current latest version, it will be set as the latest version. + * If a version is less than the current latest version, it is added to the registry, but + * doesn't change the latest version. * * Emits a {AddProtocolVersion} event when successful. * Requirements: * * - a valid warp out-of-band message must be provided. - * - the version must be the increment of the latest version. - * - the protocol address must be a contract address. + * - the version must not already be registered. + * - version and protocol address can not be the zero values. */ function addProtocolVersion(uint32 messageIndex) external virtual { // Get and validate for a warp out-of-band message. @@ -115,7 +120,7 @@ abstract contract WarpProtocolRegistry { /** * @dev Gets the version of the given `protocolAddress`. - * If `protocolAddress` is not a valid protocol address, returns 0, which is an invalid version. + * If `protocolAddress` is not a registered protocol address, returns 0, which is an invalid version. */ function getVersionFromAddress( address protocolAddress @@ -125,6 +130,7 @@ abstract contract WarpProtocolRegistry { /** * @dev Gets the latest protocol version. + * If the registry has no versions, we return 0, which is an invalid version. */ function getLatestVersion() external view virtual returns (uint256) { return _latestVersion; @@ -132,6 +138,7 @@ abstract contract WarpProtocolRegistry { /** * @dev Adds the new protocol version address to the registry. + * Updates latest version if the version is greater than the current latest version. * * Emits a {AddProtocolVersion} event when successful. * Note: `protocolAddress` doesn't have to be a contract address, this is primarily @@ -139,7 +146,9 @@ abstract contract WarpProtocolRegistry { * before the contract is deployed, to prevent the vulnerabilitiy from being exposed before registry update. * Requirements: * - * - `version` must be the increment of the latest version. + * - `version` is not zero + * - `version` is not already registered + * - `protocolAddress` is not zero address */ function _addToRegistry( ProtocolRegistryEntry memory entry From 2f526ded74ee0ca68ae1a52da7eec79b55040420 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 18 Oct 2023 23:43:00 +0000 Subject: [PATCH 42/80] add additional requirements to doc --- contracts/src/WarpProtocolRegistry.sol | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 96cb6611e..5310b5c57 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -71,9 +71,14 @@ abstract contract WarpProtocolRegistry { * Emits a {AddProtocolVersion} event when successful. * Requirements: * - * - a valid warp out-of-band message must be provided. + * - a valid Warp out-of-band message must be provided. + * - Message source chain ID must be the same as the blockchain ID of the registry. + * - Message origin sender address must be the same as the `VALIDATORS_SOURCE_ADDRESS`. + * - Message destination chain ID must be the same as the blockchain ID of the registry. + * - Message destination address must be the same as the address of the registry. + * - the version must not be zero. * - the version must not already be registered. - * - version and protocol address can not be the zero values. + * - protocol address must not be zero address. */ function addProtocolVersion(uint32 messageIndex) external virtual { // Get and validate for a warp out-of-band message. From 3330c221fd9a451ca13453c704fdc21d4dca07e6 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Thu, 19 Oct 2023 00:27:56 +0000 Subject: [PATCH 43/80] add README for upgrades --- contracts/src/Teleporter/upgrades/README.md | 62 +++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 contracts/src/Teleporter/upgrades/README.md diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md new file mode 100644 index 000000000..8dd676cff --- /dev/null +++ b/contracts/src/Teleporter/upgrades/README.md @@ -0,0 +1,62 @@ +# Upgrades + +## Overview + +The `TeleporterMessenger` contract is non-upgradable, once a version of the contract is deployed it cannot be changed. This is with the intention of preventing any changes to the contract that could potentially introduce bugs or vulnerabilities. + +However, we do want to be able to provide new features and improvements to the `TeleporterMessenger` contract. To do this we have implemented a `TeleporterRegistry`. + +The `TeleporterRegistry` keeps track of a mapping of `TeleporterMessenger` contract versions to their addresses. This allows us to deploy new versions of the `TeleporterMessenger` contract and then update the `TeleporterRegistry` to point to different versions. The `TeleporterRegistry` can only be updated through a Warp out-of-band message that qualifies the following requirements: + +- `sourceChainAddress` must match `VALIDATORS_SOURCE_ADDRESS = address(0)` +- `sourceChainID` must match blockchain ID that the registry is deployed on +- `destinationChainID` must match blockchain ID that the registry is deployed on +- `destinationAddress` must match the address of the registry + +## Design + +- `TeleporterRegistry` is deployed on each blockchain that needs to keep track of `TeleporterMessenger` contract versions, and does not need to be deployed through Nick's method, contrary to `TeleporterMessenger`. +- `TeleporterRegistry` contract can be initialized through a list of initial registry entries, which are `TeleporterMessenger` contract versions and their addresses. +- The registry keeps track of a mapping of `TeleporterMessenger` contract versions to their addresses, and vice versa, a mapping of `TeleporterMessenger` contract addresses to their versions. +- Version zero is an invalid version, and is used to indicate that a `TeleporterMessenger` contract has not been registered yet. +- Once a version number is registered in the registry, it cannot be changed, but a previous registered protocol address can be added to the registry with a new version. + +## How to use `TeleporterRegistry` + +We've added an abstract `TeleporterUpgradeable` contract that helps integrate the `TeleporterRegistry` into a dapp. The dapp contract can inherit `TeleporterUpgradeable`, and pass in the Teleporter registry address inside the constructor, for example in [ERC20Bridge](../ERC20Bridge.sol): + +```solidity +contract ERC20Bridge is + IERC20Bridge, + ITeleporterReceiver, + ReentrancyGuard, + TeleporterUpgradeable +{ + ... + constructor( + address teleporterRegistryAddress + ) TeleporterUpgradeable(teleporterRegistryAddress) { + currentChainID = WarpMessenger(WARP_PRECOMPILE_ADDRESS) + .getBlockchainID(); + } + ... +} +``` + +The `TeleporterUpgradeable` contract saves the Teleporter registry in a state variable used by the inheriting contract, and initializes a `_minTeleporterVersion`. `_minTeleporterVersion` is used to create a modifier that checks if the `msg.sender` is a `TeleporterMessenger` contract with a version greater than or equal to `_minTeleporterVersion`. This modifier is used to restrict access to functions that should only be called by a `TeleporterMessenger` contract, i.e. `ITeleporterReceiver.receiveTeleporterMessage`. This is to support the case where a dapp wants to upgrade to a new version of the `TeleporterMessenger` contract, but still wants to be able to receive messages from the old Teleporter contract. Then once the dapp completes delivery of messages from the old Teleporter contract, it can call `TeleporterUpgradeable.updateMinTeleporterVersion` to update the `_minTeleporterVersion` to the new version. + +For sending messages with the Teleporter registry, dapps should generally use `TeleporterRegistry.getLatestTeleporter` for the latest version, but if the dapp wants to send a message to a specific version, it can use `TeleporterRegistry.getTeleporterFromVersion` to get the specific Teleporter version. + +Using latest version: + +```solidity + ITeleporterMessenger teleporterMessenger = teleporterRegistry + .getLatestTeleporter(); +``` + +Using specific version: + +```solidity + ITeleporterMessenger teleporterMessenger = teleporterRegistry + .getTeleporterFromVersion(version); +``` \ No newline at end of file From 4a152a61dccfd45a9efc8e0649814f29f0a9371a Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Thu, 19 Oct 2023 00:30:08 +0000 Subject: [PATCH 44/80] change to upgradeability --- contracts/src/Teleporter/upgrades/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md index 8dd676cff..e86d4217b 100644 --- a/contracts/src/Teleporter/upgrades/README.md +++ b/contracts/src/Teleporter/upgrades/README.md @@ -1,4 +1,4 @@ -# Upgrades +# Upgradeability ## Overview From ca15150c4c0c7a13b3fdb039bc8420d1880f937f Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Thu, 19 Oct 2023 08:47:30 -0700 Subject: [PATCH 45/80] Update contracts/src/Teleporter/upgrades/README.md Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- contracts/src/Teleporter/upgrades/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md index e86d4217b..9e6ffa293 100644 --- a/contracts/src/Teleporter/upgrades/README.md +++ b/contracts/src/Teleporter/upgrades/README.md @@ -6,7 +6,7 @@ The `TeleporterMessenger` contract is non-upgradable, once a version of the cont However, we do want to be able to provide new features and improvements to the `TeleporterMessenger` contract. To do this we have implemented a `TeleporterRegistry`. -The `TeleporterRegistry` keeps track of a mapping of `TeleporterMessenger` contract versions to their addresses. This allows us to deploy new versions of the `TeleporterMessenger` contract and then update the `TeleporterRegistry` to point to different versions. The `TeleporterRegistry` can only be updated through a Warp out-of-band message that qualifies the following requirements: +The `TeleporterRegistry` keeps track of a mapping of `TeleporterMessenger` contract versions to their addresses. This allows us to deploy new versions of the `TeleporterMessenger` contract and then update the `TeleporterRegistry` to point to different versions. The `TeleporterRegistry` can only be updated through a Warp out-of-band message that meets the following requirements: - `sourceChainAddress` must match `VALIDATORS_SOURCE_ADDRESS = address(0)` - `sourceChainID` must match blockchain ID that the registry is deployed on From 8a0187bbac4ee3b613545127e8c06e3e2024d209 Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Thu, 19 Oct 2023 08:47:40 -0700 Subject: [PATCH 46/80] Update contracts/src/Teleporter/upgrades/README.md Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- contracts/src/Teleporter/upgrades/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md index 9e6ffa293..4c14290fd 100644 --- a/contracts/src/Teleporter/upgrades/README.md +++ b/contracts/src/Teleporter/upgrades/README.md @@ -10,7 +10,7 @@ The `TeleporterRegistry` keeps track of a mapping of `TeleporterMessenger` contr - `sourceChainAddress` must match `VALIDATORS_SOURCE_ADDRESS = address(0)` - `sourceChainID` must match blockchain ID that the registry is deployed on -- `destinationChainID` must match blockchain ID that the registry is deployed on +- `destinationChainID` must match the blockchain ID that the registry is deployed on - `destinationAddress` must match the address of the registry ## Design From 313c305166ac75212f87d2e53cc51ed9c6d9dfc7 Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Thu, 19 Oct 2023 08:47:57 -0700 Subject: [PATCH 47/80] Update contracts/src/Teleporter/upgrades/README.md Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- contracts/src/Teleporter/upgrades/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md index 4c14290fd..87699ef2f 100644 --- a/contracts/src/Teleporter/upgrades/README.md +++ b/contracts/src/Teleporter/upgrades/README.md @@ -9,7 +9,7 @@ However, we do want to be able to provide new features and improvements to the ` The `TeleporterRegistry` keeps track of a mapping of `TeleporterMessenger` contract versions to their addresses. This allows us to deploy new versions of the `TeleporterMessenger` contract and then update the `TeleporterRegistry` to point to different versions. The `TeleporterRegistry` can only be updated through a Warp out-of-band message that meets the following requirements: - `sourceChainAddress` must match `VALIDATORS_SOURCE_ADDRESS = address(0)` -- `sourceChainID` must match blockchain ID that the registry is deployed on +- `sourceChainID` must match the blockchain ID that the registry is deployed on - `destinationChainID` must match the blockchain ID that the registry is deployed on - `destinationAddress` must match the address of the registry From f6377dab6bcd2e45475811467a474bd2271c4c75 Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Thu, 19 Oct 2023 08:48:11 -0700 Subject: [PATCH 48/80] Update contracts/src/Teleporter/upgrades/README.md Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- contracts/src/Teleporter/upgrades/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md index 87699ef2f..1b6b0d0d9 100644 --- a/contracts/src/Teleporter/upgrades/README.md +++ b/contracts/src/Teleporter/upgrades/README.md @@ -15,7 +15,7 @@ The `TeleporterRegistry` keeps track of a mapping of `TeleporterMessenger` contr ## Design -- `TeleporterRegistry` is deployed on each blockchain that needs to keep track of `TeleporterMessenger` contract versions, and does not need to be deployed through Nick's method, contrary to `TeleporterMessenger`. +- `TeleporterRegistry` is deployed on each blockchain that needs to keep track of `TeleporterMessenger` contract versions. - `TeleporterRegistry` contract can be initialized through a list of initial registry entries, which are `TeleporterMessenger` contract versions and their addresses. - The registry keeps track of a mapping of `TeleporterMessenger` contract versions to their addresses, and vice versa, a mapping of `TeleporterMessenger` contract addresses to their versions. - Version zero is an invalid version, and is used to indicate that a `TeleporterMessenger` contract has not been registered yet. From aac50e80ab3c037368b6bd0e0e0fb53bb4c3c502 Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Thu, 19 Oct 2023 08:49:30 -0700 Subject: [PATCH 49/80] Update contracts/src/Teleporter/upgrades/README.md Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- contracts/src/Teleporter/upgrades/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md index 1b6b0d0d9..d60def1f2 100644 --- a/contracts/src/Teleporter/upgrades/README.md +++ b/contracts/src/Teleporter/upgrades/README.md @@ -43,7 +43,7 @@ contract ERC20Bridge is } ``` -The `TeleporterUpgradeable` contract saves the Teleporter registry in a state variable used by the inheriting contract, and initializes a `_minTeleporterVersion`. `_minTeleporterVersion` is used to create a modifier that checks if the `msg.sender` is a `TeleporterMessenger` contract with a version greater than or equal to `_minTeleporterVersion`. This modifier is used to restrict access to functions that should only be called by a `TeleporterMessenger` contract, i.e. `ITeleporterReceiver.receiveTeleporterMessage`. This is to support the case where a dapp wants to upgrade to a new version of the `TeleporterMessenger` contract, but still wants to be able to receive messages from the old Teleporter contract. Then once the dapp completes delivery of messages from the old Teleporter contract, it can call `TeleporterUpgradeable.updateMinTeleporterVersion` to update the `_minTeleporterVersion` to the new version. +The `TeleporterUpgradeable` contract saves the Teleporter registry in a state variable used by the inheriting contract, and initializes a `_minTeleporterVersion` to the latest `TeleporterMessenger` version registered in `TeleporterRegistry`. The `onlyAllowedTeleporter` modifier ensures that `msg.sender` is a `TeleporterMessenger` contract with a version greater than or equal to `_minTeleporterVersion`. This modifier is used to restrict access to functions that should only be called by a `TeleporterMessenger` contract, i.e. `ITeleporterReceiver.receiveTeleporterMessage`. This is to support the case where a dapp wants to upgrade to a new version of the `TeleporterMessenger` contract, but still wants to be able to receive messages from the old Teleporter contract. Then once the dapp completes delivery of messages from the old Teleporter contract, it can call `TeleporterUpgradeable.updateMinTeleporterVersion` to update the `_minTeleporterVersion` to the new version. For sending messages with the Teleporter registry, dapps should generally use `TeleporterRegistry.getLatestTeleporter` for the latest version, but if the dapp wants to send a message to a specific version, it can use `TeleporterRegistry.getTeleporterFromVersion` to get the specific Teleporter version. From 4cff9731677e8cfe0b5956c5e9e6369ec3d5dfc2 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Thu, 19 Oct 2023 19:16:14 +0000 Subject: [PATCH 50/80] update readme to include rollback and remove we --- contracts/src/Teleporter/upgrades/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md index d60def1f2..eaed512cc 100644 --- a/contracts/src/Teleporter/upgrades/README.md +++ b/contracts/src/Teleporter/upgrades/README.md @@ -2,9 +2,9 @@ ## Overview -The `TeleporterMessenger` contract is non-upgradable, once a version of the contract is deployed it cannot be changed. This is with the intention of preventing any changes to the contract that could potentially introduce bugs or vulnerabilities. +The `TeleporterMessenger` contract is non-upgradable, once a version of the contract is deployed it cannot be changed. This is with the intention of preventing any changes to the deployed contract that could potentially introduce bugs or vulnerabilities. -However, we do want to be able to provide new features and improvements to the `TeleporterMessenger` contract. To do this we have implemented a `TeleporterRegistry`. +However, there should still be new versions of the `TeleporterMessenger` contract that provide new features, and `TeleporterRegistry` supports the integration with these new versions. The `TeleporterRegistry` keeps track of a mapping of `TeleporterMessenger` contract versions to their addresses. This allows us to deploy new versions of the `TeleporterMessenger` contract and then update the `TeleporterRegistry` to point to different versions. The `TeleporterRegistry` can only be updated through a Warp out-of-band message that meets the following requirements: @@ -16,14 +16,15 @@ The `TeleporterRegistry` keeps track of a mapping of `TeleporterMessenger` contr ## Design - `TeleporterRegistry` is deployed on each blockchain that needs to keep track of `TeleporterMessenger` contract versions. +- Each registry's mapping of version to contract address is independent of registries on other blockchains, and chains can decide on their own registry mapping entries. - `TeleporterRegistry` contract can be initialized through a list of initial registry entries, which are `TeleporterMessenger` contract versions and their addresses. - The registry keeps track of a mapping of `TeleporterMessenger` contract versions to their addresses, and vice versa, a mapping of `TeleporterMessenger` contract addresses to their versions. - Version zero is an invalid version, and is used to indicate that a `TeleporterMessenger` contract has not been registered yet. -- Once a version number is registered in the registry, it cannot be changed, but a previous registered protocol address can be added to the registry with a new version. +- Once a version number is registered in the registry, it cannot be changed, but a previous registered protocol address can be added to the registry with a new version. This is especially important in the case of a rollback to a previous version, the previous Teleporter contract address can be registered with a new version to the registry. ## How to use `TeleporterRegistry` -We've added an abstract `TeleporterUpgradeable` contract that helps integrate the `TeleporterRegistry` into a dapp. The dapp contract can inherit `TeleporterUpgradeable`, and pass in the Teleporter registry address inside the constructor, for example in [ERC20Bridge](../ERC20Bridge.sol): +`TeleporterUpgradeable` is an abstract contract that helps integrate the `TeleporterRegistry` into a dapp. The dapp contract can inherit `TeleporterUpgradeable`, and pass in the Teleporter registry address inside the constructor, for example in [ERC20Bridge](../ERC20Bridge.sol): ```solidity contract ERC20Bridge is From d18c6574f743255332ebf8dd1d8f41d2446367d0 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Thu, 19 Oct 2023 22:31:33 +0000 Subject: [PATCH 51/80] make zero error consistent and add unit test --- .../ERC20Bridge/tests/ERC20BridgeTests.t.sol | 7 +++++++ .../upgrades/TeleporterUpgradeable.sol | 2 +- .../tests/TeleporterUpgradeableTests.t.sol | 18 ++++++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol index e99d8cba6..a6d093134 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol @@ -736,6 +736,13 @@ contract ERC20BridgeTest is Test { ); } + function testZeroTeleporterRegistryAddress() public { + vm.expectRevert( + "TeleporterUpgradeable: zero teleporter registry address" + ); + new ERC20Bridge(address(0)); + } + function _setUpBridgeToken( bytes32 nativeChainID, address nativeBridgeAddress, diff --git a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol index 31282305a..b3de9fa90 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol @@ -39,7 +39,7 @@ abstract contract TeleporterUpgradeable { constructor(address teleporterRegistryAddress) { require( teleporterRegistryAddress != address(0), - "TeleporterUpgradeable: invalid teleporter registry address" + "TeleporterUpgradeable: zero teleporter registry address" ); teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol index 7a5d79c4b..010547a6f 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol @@ -52,7 +52,9 @@ contract TeleporterUpgradeableTest is Test { function testInvalidRegistryAddress() public { vm.expectRevert( - _formatErrorMessage("invalid teleporter registry address") + _formatTeleporterUpgradeableErrorMessage( + "zero teleporter registry address" + ) ); new ExampleUpgradeableApp(address(0)); } @@ -64,7 +66,11 @@ contract TeleporterUpgradeableTest is Test { assertEq(app.getMinTeleporterVersion(), 1); - vm.expectRevert(_formatErrorMessage("invalid teleporter sender")); + vm.expectRevert( + _formatTeleporterUpgradeableErrorMessage( + "invalid teleporter sender" + ) + ); app.teleporterCall(); vm.prank(MOCK_TELEPORTER_MESSENGER_ADDRESS); @@ -92,12 +98,16 @@ contract TeleporterUpgradeableTest is Test { assertEq(app.getMinTeleporterVersion(), 2); // Check that calling with the old teleporter address fails - vm.expectRevert(_formatErrorMessage("invalid teleporter sender")); + vm.expectRevert( + _formatTeleporterUpgradeableErrorMessage( + "invalid teleporter sender" + ) + ); vm.prank(MOCK_TELEPORTER_MESSENGER_ADDRESS); app.teleporterCall(); } - function _formatErrorMessage( + function _formatTeleporterUpgradeableErrorMessage( string memory errorMessage ) private pure returns (bytes memory) { return bytes(string.concat("TeleporterUpgradeable: ", errorMessage)); From e699689d21b341131b57a2fed91baf4edd482deb Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Thu, 19 Oct 2023 22:32:31 +0000 Subject: [PATCH 52/80] fix function ordering --- .../ERC20Bridge/tests/ERC20BridgeTests.t.sol | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol index a6d093134..97b122fca 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol @@ -624,6 +624,13 @@ contract ERC20BridgeTest is Test { assertEq(address(mockERC20), newBridgeToken.nativeAsset()); } + function testZeroTeleporterRegistryAddress() public { + vm.expectRevert( + "TeleporterUpgradeable: zero teleporter registry address" + ); + new ERC20Bridge(address(0)); + } + function _initMockTeleporterRegistry() internal { vm.mockCall( MOCK_TELEPORTER_REGISTRY_ADDRESS, @@ -736,13 +743,6 @@ contract ERC20BridgeTest is Test { ); } - function testZeroTeleporterRegistryAddress() public { - vm.expectRevert( - "TeleporterUpgradeable: zero teleporter registry address" - ); - new ERC20Bridge(address(0)); - } - function _setUpBridgeToken( bytes32 nativeChainID, address nativeBridgeAddress, From 83f139fc7107a49d946d186ff50253cae1cf58e8 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Thu, 19 Oct 2023 22:33:13 +0000 Subject: [PATCH 53/80] update abi bindings --- .../ERC20Bridge/ERC20Bridge/ERC20Bridge.go | 2 +- .../ExampleCrossChainMessenger/ExampleCrossChainMessenger.go | 2 +- .../VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/abi-bindings/go/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go b/abi-bindings/go/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go index 733d9e4ca..48371c886 100644 --- a/abi-bindings/go/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go +++ b/abi-bindings/go/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go @@ -31,7 +31,7 @@ var ( // ERC20BridgeMetaData contains all meta data concerning the ERC20Bridge contract. var ERC20BridgeMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterMessengerAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"BridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"bridgeTokenAddress\",\"type\":\"address\"}],\"name\":\"CreateBridgeToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"contractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MintBridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"}],\"name\":\"SubmitCreateBridgeToken\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CREATE_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINT_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TRANSFER_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WARP_PRECOMPILE_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"primaryFeeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"secondaryFeeAmount\",\"type\":\"uint256\"}],\"name\":\"bridgeTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"bridgedBalances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"nativeName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"nativeSymbol\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"nativeDecimals\",\"type\":\"uint8\"}],\"name\":\"encodeCreateBridgeTokenData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"bridgeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeMintBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeTransferBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nativeToWrappedTokens\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"contractERC20\",\"name\":\"nativeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"messageFeeAsset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"messageFeeAmount\",\"type\":\"uint256\"}],\"name\":\"submitCreateBridgeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"submittedBridgeTokenCreations\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterMessenger\",\"outputs\":[{\"internalType\":\"contractITeleporterMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedTokenContracts\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"BridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"bridgeTokenAddress\",\"type\":\"address\"}],\"name\":\"CreateBridgeToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"contractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MintBridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"}],\"name\":\"SubmitCreateBridgeToken\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CREATE_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINT_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TRANSFER_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WARP_PRECOMPILE_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"primaryFeeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"secondaryFeeAmount\",\"type\":\"uint256\"}],\"name\":\"bridgeTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"bridgedBalances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"nativeName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"nativeSymbol\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"nativeDecimals\",\"type\":\"uint8\"}],\"name\":\"encodeCreateBridgeTokenData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"bridgeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeMintBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeTransferBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nativeToWrappedTokens\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"contractERC20\",\"name\":\"nativeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"messageFeeAsset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"messageFeeAmount\",\"type\":\"uint256\"}],\"name\":\"submitCreateBridgeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"submittedBridgeTokenCreations\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedTokenContracts\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // ERC20BridgeABI is the input ABI used to generate the binding from. diff --git a/abi-bindings/go/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go b/abi-bindings/go/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go index b67360e1f..91c1b1dff 100644 --- a/abi-bindings/go/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go +++ b/abi-bindings/go/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go @@ -31,7 +31,7 @@ var ( // ExampleCrossChainMessengerMetaData contains all meta data concerning the ExampleCrossChainMessenger contract. var ExampleCrossChainMessengerMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterMessengerAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"ReceiveMessage\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeAsset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"SendMessage\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"}],\"name\":\"getCurrentMessage\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeContractAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"sendMessage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterMessenger\",\"outputs\":[{\"internalType\":\"contractITeleporterMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"ReceiveMessage\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeAsset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"SendMessage\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"}],\"name\":\"getCurrentMessage\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeContractAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"sendMessage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // ExampleCrossChainMessengerABI is the input ABI used to generate the binding from. diff --git a/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go b/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go index 61e9b747c..45e7c45ff 100644 --- a/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go +++ b/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go @@ -31,7 +31,7 @@ var ( // BlockHashReceiverMetaData contains all meta data concerning the BlockHashReceiver contract. var BlockHashReceiverMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterMessengerAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"publisherChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"publisherContractAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"getLatestBlockInfo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"height\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourceChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourcePublisherContractAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterMessenger\",\"outputs\":[{\"internalType\":\"contractITeleporterMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"publisherChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"publisherContractAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"getLatestBlockInfo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"height\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourceChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourcePublisherContractAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // BlockHashReceiverABI is the input ABI used to generate the binding from. From 9c3d63698c0546138fcf79c53f3f0d495f17d18c Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Tue, 24 Oct 2023 08:55:14 -0700 Subject: [PATCH 54/80] Update contracts/src/Teleporter/upgrades/README.md Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- contracts/src/Teleporter/upgrades/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md index eaed512cc..2c0c65cd0 100644 --- a/contracts/src/Teleporter/upgrades/README.md +++ b/contracts/src/Teleporter/upgrades/README.md @@ -20,7 +20,7 @@ The `TeleporterRegistry` keeps track of a mapping of `TeleporterMessenger` contr - `TeleporterRegistry` contract can be initialized through a list of initial registry entries, which are `TeleporterMessenger` contract versions and their addresses. - The registry keeps track of a mapping of `TeleporterMessenger` contract versions to their addresses, and vice versa, a mapping of `TeleporterMessenger` contract addresses to their versions. - Version zero is an invalid version, and is used to indicate that a `TeleporterMessenger` contract has not been registered yet. -- Once a version number is registered in the registry, it cannot be changed, but a previous registered protocol address can be added to the registry with a new version. This is especially important in the case of a rollback to a previous version, the previous Teleporter contract address can be registered with a new version to the registry. +- Once a version number is registered in the registry, it cannot be changed, but a previous registered protocol address can be added to the registry with a new version. This is especially important in the case of a rollback to a previous Teleporter version, in which case the previous Teleporter contract address would need to be registered with a new version to the registry. ## How to use `TeleporterRegistry` From 4064d330f0ce41748e0ad3689d456fbbd55ae6b9 Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Tue, 24 Oct 2023 10:12:09 -0700 Subject: [PATCH 55/80] Update contracts/src/Teleporter/upgrades/README.md Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- contracts/src/Teleporter/upgrades/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md index 2c0c65cd0..896aa47a0 100644 --- a/contracts/src/Teleporter/upgrades/README.md +++ b/contracts/src/Teleporter/upgrades/README.md @@ -44,7 +44,7 @@ contract ERC20Bridge is } ``` -The `TeleporterUpgradeable` contract saves the Teleporter registry in a state variable used by the inheriting contract, and initializes a `_minTeleporterVersion` to the latest `TeleporterMessenger` version registered in `TeleporterRegistry`. The `onlyAllowedTeleporter` modifier ensures that `msg.sender` is a `TeleporterMessenger` contract with a version greater than or equal to `_minTeleporterVersion`. This modifier is used to restrict access to functions that should only be called by a `TeleporterMessenger` contract, i.e. `ITeleporterReceiver.receiveTeleporterMessage`. This is to support the case where a dapp wants to upgrade to a new version of the `TeleporterMessenger` contract, but still wants to be able to receive messages from the old Teleporter contract. Then once the dapp completes delivery of messages from the old Teleporter contract, it can call `TeleporterUpgradeable.updateMinTeleporterVersion` to update the `_minTeleporterVersion` to the new version. +The `TeleporterUpgradeable` contract saves the Teleporter registry in a state variable used by the inheriting contract, and initializes a `_minTeleporterVersion` to the highest number `TeleporterMessenger` version registered in `TeleporterRegistry`. The `onlyAllowedTeleporter` modifier ensures that `msg.sender` is a `TeleporterMessenger` contract with a version greater than or equal to `_minTeleporterVersion`. This modifier is used to restrict access to functions that should only be called by a `TeleporterMessenger` contract, i.e. `ITeleporterReceiver.receiveTeleporterMessage`. This is to support the case where a dapp wants to upgrade to a new version of the `TeleporterMessenger` contract, but still wants to be able to receive messages from the old Teleporter contract. Then once the dapp completes delivery of messages from the old Teleporter contract, it can call `TeleporterUpgradeable.updateMinTeleporterVersion` to update the `_minTeleporterVersion` to the new version. For sending messages with the Teleporter registry, dapps should generally use `TeleporterRegistry.getLatestTeleporter` for the latest version, but if the dapp wants to send a message to a specific version, it can use `TeleporterRegistry.getTeleporterFromVersion` to get the specific Teleporter version. From 26de2d5b673b8e9333ecb5bf37976c41f9256bff Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Tue, 24 Oct 2023 17:21:52 +0000 Subject: [PATCH 56/80] update README with getLatestVersion --- contracts/src/Teleporter/upgrades/README.md | 3 +++ go.work.sum | 1 + 2 files changed, 4 insertions(+) diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md index 896aa47a0..fbe3ce91c 100644 --- a/contracts/src/Teleporter/upgrades/README.md +++ b/contracts/src/Teleporter/upgrades/README.md @@ -9,10 +9,13 @@ However, there should still be new versions of the `TeleporterMessenger` contrac The `TeleporterRegistry` keeps track of a mapping of `TeleporterMessenger` contract versions to their addresses. This allows us to deploy new versions of the `TeleporterMessenger` contract and then update the `TeleporterRegistry` to point to different versions. The `TeleporterRegistry` can only be updated through a Warp out-of-band message that meets the following requirements: - `sourceChainAddress` must match `VALIDATORS_SOURCE_ADDRESS = address(0)` + - The zero address can only be set as the source chain address by a Warp out-of-band message, and cannot be set by an on-chain Warp message. - `sourceChainID` must match the blockchain ID that the registry is deployed on - `destinationChainID` must match the blockchain ID that the registry is deployed on - `destinationAddress` must match the address of the registry +In the `TeleporterRegistry` contract the `getLatestVersion` function returns the highest version number that has been registered in the registry. The `getLatestTeleporter` function returns the `ITeleporterMessenger` that is registered with the corresponding version. + ## Design - `TeleporterRegistry` is deployed on each blockchain that needs to keep track of `TeleporterMessenger` contract versions. diff --git a/go.work.sum b/go.work.sum index fd840dd68..8c48d0e40 100644 --- a/go.work.sum +++ b/go.work.sum @@ -780,6 +780,7 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= +github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA= github.com/google/s2a-go v0.1.3/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/googleapis/enterprise-certificate-proxy v0.2.1/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= From 9e5a3ef6fcf4c846f31e3cdf39bf241e6e491da4 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Tue, 24 Oct 2023 17:23:10 +0000 Subject: [PATCH 57/80] punctuation --- contracts/src/Teleporter/upgrades/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md index fbe3ce91c..f4a744d85 100644 --- a/contracts/src/Teleporter/upgrades/README.md +++ b/contracts/src/Teleporter/upgrades/README.md @@ -14,7 +14,7 @@ The `TeleporterRegistry` keeps track of a mapping of `TeleporterMessenger` contr - `destinationChainID` must match the blockchain ID that the registry is deployed on - `destinationAddress` must match the address of the registry -In the `TeleporterRegistry` contract the `getLatestVersion` function returns the highest version number that has been registered in the registry. The `getLatestTeleporter` function returns the `ITeleporterMessenger` that is registered with the corresponding version. +In the `TeleporterRegistry` contract, the `getLatestVersion` function returns the highest version number that has been registered in the registry. The `getLatestTeleporter` function returns the `ITeleporterMessenger` that is registered with the corresponding version. ## Design From 3606e7a748520c89db59ec1bce83704567a9a41a Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Tue, 24 Oct 2023 22:05:09 +0000 Subject: [PATCH 58/80] make minTeleporterVersion public --- .../Teleporter/upgrades/TeleporterUpgradeable.sol | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol index b3de9fa90..7d452d5fa 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol @@ -17,7 +17,7 @@ import "./TeleporterRegistry.sol"; */ abstract contract TeleporterUpgradeable { TeleporterRegistry public immutable teleporterRegistry; - uint256 internal _minTeleporterVersion; + uint256 public minTeleporterVersion; /** * @dev Throws if called by a `msg.sender` that is not an allowed Teleporter version. @@ -26,7 +26,7 @@ abstract contract TeleporterUpgradeable { modifier onlyAllowedTeleporter() { require( teleporterRegistry.getVersionFromAddress(msg.sender) >= - _minTeleporterVersion, + minTeleporterVersion, "TeleporterUpgradeable: invalid teleporter sender" ); _; @@ -43,20 +43,20 @@ abstract contract TeleporterUpgradeable { ); teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); - _minTeleporterVersion = teleporterRegistry.getLatestVersion(); + minTeleporterVersion = teleporterRegistry.getLatestVersion(); } /** - * @dev Updates `_minTeleporterVersion` to the latest version. + * @dev Updates `minTeleporterVersion` to the latest version. */ function updateMinTeleporterVersion() external { - _minTeleporterVersion = teleporterRegistry.getLatestVersion(); + minTeleporterVersion = teleporterRegistry.getLatestVersion(); } /** * @dev Gets the minimum Teleporter version that is allowed to call this contract. */ function getMinTeleporterVersion() external view returns (uint256) { - return _minTeleporterVersion; + return minTeleporterVersion; } } From 880bf164ec5bd3687fd9a7cf9c50531fe9a51a9e Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Tue, 24 Oct 2023 22:24:30 +0000 Subject: [PATCH 59/80] update tests and event MinTeleporterVersionUpdated --- contracts/src/Teleporter/upgrades/README.md | 4 ++-- .../Teleporter/upgrades/TeleporterUpgradeable.sol | 14 +++++++------- .../tests/TeleporterUpgradeableTests.t.sol | 13 ++++++++++--- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md index f4a744d85..e1293ef9a 100644 --- a/contracts/src/Teleporter/upgrades/README.md +++ b/contracts/src/Teleporter/upgrades/README.md @@ -4,7 +4,7 @@ The `TeleporterMessenger` contract is non-upgradable, once a version of the contract is deployed it cannot be changed. This is with the intention of preventing any changes to the deployed contract that could potentially introduce bugs or vulnerabilities. -However, there should still be new versions of the `TeleporterMessenger` contract that provide new features, and `TeleporterRegistry` supports the integration with these new versions. +However, there could still be new versions of `TeleporterMessenger` contracts needed to be deployed in the future. `TeleporterRegistry` provides applications that use a `TeleporterMessenger` instance a minimal step process to integrate with new versions of `TeleporterMessenger`. The `TeleporterRegistry` keeps track of a mapping of `TeleporterMessenger` contract versions to their addresses. This allows us to deploy new versions of the `TeleporterMessenger` contract and then update the `TeleporterRegistry` to point to different versions. The `TeleporterRegistry` can only be updated through a Warp out-of-band message that meets the following requirements: @@ -47,7 +47,7 @@ contract ERC20Bridge is } ``` -The `TeleporterUpgradeable` contract saves the Teleporter registry in a state variable used by the inheriting contract, and initializes a `_minTeleporterVersion` to the highest number `TeleporterMessenger` version registered in `TeleporterRegistry`. The `onlyAllowedTeleporter` modifier ensures that `msg.sender` is a `TeleporterMessenger` contract with a version greater than or equal to `_minTeleporterVersion`. This modifier is used to restrict access to functions that should only be called by a `TeleporterMessenger` contract, i.e. `ITeleporterReceiver.receiveTeleporterMessage`. This is to support the case where a dapp wants to upgrade to a new version of the `TeleporterMessenger` contract, but still wants to be able to receive messages from the old Teleporter contract. Then once the dapp completes delivery of messages from the old Teleporter contract, it can call `TeleporterUpgradeable.updateMinTeleporterVersion` to update the `_minTeleporterVersion` to the new version. +The `TeleporterUpgradeable` contract saves the Teleporter registry in a state variable used by the inheriting contract, and initializes a `minTeleporterVersion` to the highest number `TeleporterMessenger` version registered in `TeleporterRegistry`. The `onlyAllowedTeleporter` modifier ensures that `msg.sender` is a `TeleporterMessenger` contract with a version greater than or equal to `minTeleporterVersion`. This modifier is used to restrict access to functions that should only be called by a `TeleporterMessenger` contract, i.e. `ITeleporterReceiver.receiveTeleporterMessage`. This is to support the case where a dapp wants to upgrade to a new version of the `TeleporterMessenger` contract, but still wants to be able to receive messages from the old Teleporter contract. Then once the dapp completes delivery of messages from the old Teleporter contract, it can call `TeleporterUpgradeable.updateMinTeleporterVersion` to update the `minTeleporterVersion` to the new version. For sending messages with the Teleporter registry, dapps should generally use `TeleporterRegistry.getLatestTeleporter` for the latest version, but if the dapp wants to send a message to a specific version, it can use `TeleporterRegistry.getTeleporterFromVersion` to get the specific Teleporter version. diff --git a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol index 7d452d5fa..2270563f3 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol @@ -19,6 +19,11 @@ abstract contract TeleporterUpgradeable { TeleporterRegistry public immutable teleporterRegistry; uint256 public minTeleporterVersion; + event MinTeleporterVersionUpdated( + uint256 oldMinTeleporterVersion, + uint256 newMinTeleporterVersion + ); + /** * @dev Throws if called by a `msg.sender` that is not an allowed Teleporter version. * Checks that `msg.sender` matches a Teleporter version greater than or equal to `_minTeleporterVersion`. @@ -50,13 +55,8 @@ abstract contract TeleporterUpgradeable { * @dev Updates `minTeleporterVersion` to the latest version. */ function updateMinTeleporterVersion() external { + uint256 prevVersion = minTeleporterVersion; minTeleporterVersion = teleporterRegistry.getLatestVersion(); - } - - /** - * @dev Gets the minimum Teleporter version that is allowed to call this contract. - */ - function getMinTeleporterVersion() external view returns (uint256) { - return minTeleporterVersion; + emit MinTeleporterVersionUpdated(prevVersion, minTeleporterVersion); } } diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol index 010547a6f..660d5aea9 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol @@ -24,6 +24,11 @@ contract TeleporterUpgradeableTest is Test { address public constant MOCK_TELEPORTER_MESSENGER_ADDRESS = 0x644E5b7c5D4Bc8073732CEa72c66e0BB90dFC00f; + event MinTeleporterVersionUpdated( + uint256 oldMinTeleporterVersion, + uint256 newMinTeleporterVersion + ); + function setUp() public { vm.mockCall( MOCK_TELEPORTER_REGISTRY_ADDRESS, @@ -64,7 +69,7 @@ contract TeleporterUpgradeableTest is Test { MOCK_TELEPORTER_REGISTRY_ADDRESS ); - assertEq(app.getMinTeleporterVersion(), 1); + assertEq(app.minTeleporterVersion(), 1); vm.expectRevert( _formatTeleporterUpgradeableErrorMessage( @@ -83,7 +88,7 @@ contract TeleporterUpgradeableTest is Test { ); // First check that calling with initial teleporter address works - assertEq(app.getMinTeleporterVersion(), 1); + assertEq(app.minTeleporterVersion(), 1); vm.prank(MOCK_TELEPORTER_MESSENGER_ADDRESS); app.teleporterCall(); @@ -94,8 +99,10 @@ contract TeleporterUpgradeableTest is Test { abi.encode(2) ); + vm.expectEmit(true, true, true, true, address(app)); + emit MinTeleporterVersionUpdated(1, 2); app.updateMinTeleporterVersion(); - assertEq(app.getMinTeleporterVersion(), 2); + assertEq(app.minTeleporterVersion(), 2); // Check that calling with the old teleporter address fails vm.expectRevert( From 7b7a6c4b85106f361c105462c029f1032df2c1e1 Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Tue, 24 Oct 2023 15:25:24 -0700 Subject: [PATCH 60/80] Update contracts/src/Teleporter/upgrades/README.md Co-authored-by: Michael Kaplan <55204436+michaelkaplan13@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- contracts/src/Teleporter/upgrades/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md index e1293ef9a..66d5e1bea 100644 --- a/contracts/src/Teleporter/upgrades/README.md +++ b/contracts/src/Teleporter/upgrades/README.md @@ -6,7 +6,7 @@ The `TeleporterMessenger` contract is non-upgradable, once a version of the cont However, there could still be new versions of `TeleporterMessenger` contracts needed to be deployed in the future. `TeleporterRegistry` provides applications that use a `TeleporterMessenger` instance a minimal step process to integrate with new versions of `TeleporterMessenger`. -The `TeleporterRegistry` keeps track of a mapping of `TeleporterMessenger` contract versions to their addresses. This allows us to deploy new versions of the `TeleporterMessenger` contract and then update the `TeleporterRegistry` to point to different versions. The `TeleporterRegistry` can only be updated through a Warp out-of-band message that meets the following requirements: +The `TeleporterRegistry` maintains a mapping of `TeleporterMessenger` contract versions to their addresses. When a new `TeleporterMessenger` version is deployed, it's address can be added to the `TeleporterRegistry`. The `TeleporterRegistry` can only be updated through a Warp out-of-band message that meets the following requirements: - `sourceChainAddress` must match `VALIDATORS_SOURCE_ADDRESS = address(0)` - The zero address can only be set as the source chain address by a Warp out-of-band message, and cannot be set by an on-chain Warp message. From 80044963fba46c94638298d9fa3846b30a45f458 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Tue, 24 Oct 2023 22:29:42 +0000 Subject: [PATCH 61/80] add index and doc --- .../src/Teleporter/upgrades/TeleporterUpgradeable.sol | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol index 2270563f3..fc8b8651b 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol @@ -19,9 +19,12 @@ abstract contract TeleporterUpgradeable { TeleporterRegistry public immutable teleporterRegistry; uint256 public minTeleporterVersion; + /** + * @dev Emitted when `minTeleporterVersion` is updated to a new value. + */ event MinTeleporterVersionUpdated( - uint256 oldMinTeleporterVersion, - uint256 newMinTeleporterVersion + uint256 indexed oldMinTeleporterVersion, + uint256 indexed newMinTeleporterVersion ); /** @@ -53,6 +56,7 @@ abstract contract TeleporterUpgradeable { /** * @dev Updates `minTeleporterVersion` to the latest version. + * Emits a {MinTeleporterVersionUpdated} event. */ function updateMinTeleporterVersion() external { uint256 prevVersion = minTeleporterVersion; From 02cf81b1eb558002dee0a6b0b29f8b1b8e770eac Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Tue, 24 Oct 2023 22:42:05 +0000 Subject: [PATCH 62/80] fix unit tests and update bindings --- .../ERC20Bridge/ERC20Bridge/ERC20Bridge.go | 179 +++++++++++++-- .../ExampleCrossChainMessenger.go | 179 +++++++++++++-- .../BlockHashPublisher/BlockHashPublisher.go | 179 +++++++++++++-- .../BlockHashReceiver/BlockHashReceiver.go | 217 +++++++++++++++--- .../TeleporterRegistry/TeleporterRegistry.go | 0 .../tests/TeleporterUpgradeableTests.t.sol | 5 +- scripts/abi_bindings.sh | 2 +- 7 files changed, 687 insertions(+), 74 deletions(-) rename abi-bindings/{ => go}/Teleporter/upgrades/TeleporterRegistry/TeleporterRegistry.go (100%) diff --git a/abi-bindings/go/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go b/abi-bindings/go/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go index 48371c886..8b6724ebe 100644 --- a/abi-bindings/go/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go +++ b/abi-bindings/go/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go @@ -31,7 +31,7 @@ var ( // ERC20BridgeMetaData contains all meta data concerning the ERC20Bridge contract. var ERC20BridgeMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"BridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"bridgeTokenAddress\",\"type\":\"address\"}],\"name\":\"CreateBridgeToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"contractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MintBridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"}],\"name\":\"SubmitCreateBridgeToken\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CREATE_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINT_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TRANSFER_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WARP_PRECOMPILE_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"primaryFeeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"secondaryFeeAmount\",\"type\":\"uint256\"}],\"name\":\"bridgeTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"bridgedBalances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"nativeName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"nativeSymbol\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"nativeDecimals\",\"type\":\"uint8\"}],\"name\":\"encodeCreateBridgeTokenData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"bridgeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeMintBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeTransferBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nativeToWrappedTokens\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"contractERC20\",\"name\":\"nativeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"messageFeeAsset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"messageFeeAmount\",\"type\":\"uint256\"}],\"name\":\"submitCreateBridgeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"submittedBridgeTokenCreations\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedTokenContracts\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"BridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"bridgeTokenAddress\",\"type\":\"address\"}],\"name\":\"CreateBridgeToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldMinTeleporterVersion\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"newMinTeleporterVersion\",\"type\":\"uint256\"}],\"name\":\"MinTeleporterVersionUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"contractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MintBridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"}],\"name\":\"SubmitCreateBridgeToken\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CREATE_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINT_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TRANSFER_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WARP_PRECOMPILE_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"primaryFeeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"secondaryFeeAmount\",\"type\":\"uint256\"}],\"name\":\"bridgeTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"bridgedBalances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"nativeName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"nativeSymbol\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"nativeDecimals\",\"type\":\"uint8\"}],\"name\":\"encodeCreateBridgeTokenData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"bridgeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeMintBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeTransferBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nativeToWrappedTokens\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"contractERC20\",\"name\":\"nativeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"messageFeeAsset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"messageFeeAmount\",\"type\":\"uint256\"}],\"name\":\"submitCreateBridgeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"submittedBridgeTokenCreations\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedTokenContracts\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // ERC20BridgeABI is the input ABI used to generate the binding from. @@ -459,12 +459,12 @@ func (_ERC20Bridge *ERC20BridgeCallerSession) EncodeTransferBridgeTokensData(des return _ERC20Bridge.Contract.EncodeTransferBridgeTokensData(&_ERC20Bridge.CallOpts, destinationChainID, destinationBridgeAddress, nativeContractAddress, recipient, amount, feeAmount) } -// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// MinTeleporterVersion is a free data retrieval call binding the contract method 0xe49cc553. // -// Solidity: function getMinTeleporterVersion() view returns(uint256) -func (_ERC20Bridge *ERC20BridgeCaller) GetMinTeleporterVersion(opts *bind.CallOpts) (*big.Int, error) { +// Solidity: function minTeleporterVersion() view returns(uint256) +func (_ERC20Bridge *ERC20BridgeCaller) MinTeleporterVersion(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} - err := _ERC20Bridge.contract.Call(opts, &out, "getMinTeleporterVersion") + err := _ERC20Bridge.contract.Call(opts, &out, "minTeleporterVersion") if err != nil { return *new(*big.Int), err @@ -476,18 +476,18 @@ func (_ERC20Bridge *ERC20BridgeCaller) GetMinTeleporterVersion(opts *bind.CallOp } -// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// MinTeleporterVersion is a free data retrieval call binding the contract method 0xe49cc553. // -// Solidity: function getMinTeleporterVersion() view returns(uint256) -func (_ERC20Bridge *ERC20BridgeSession) GetMinTeleporterVersion() (*big.Int, error) { - return _ERC20Bridge.Contract.GetMinTeleporterVersion(&_ERC20Bridge.CallOpts) +// Solidity: function minTeleporterVersion() view returns(uint256) +func (_ERC20Bridge *ERC20BridgeSession) MinTeleporterVersion() (*big.Int, error) { + return _ERC20Bridge.Contract.MinTeleporterVersion(&_ERC20Bridge.CallOpts) } -// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// MinTeleporterVersion is a free data retrieval call binding the contract method 0xe49cc553. // -// Solidity: function getMinTeleporterVersion() view returns(uint256) -func (_ERC20Bridge *ERC20BridgeCallerSession) GetMinTeleporterVersion() (*big.Int, error) { - return _ERC20Bridge.Contract.GetMinTeleporterVersion(&_ERC20Bridge.CallOpts) +// Solidity: function minTeleporterVersion() view returns(uint256) +func (_ERC20Bridge *ERC20BridgeCallerSession) MinTeleporterVersion() (*big.Int, error) { + return _ERC20Bridge.Contract.MinTeleporterVersion(&_ERC20Bridge.CallOpts) } // NativeToWrappedTokens is a free data retrieval call binding the contract method 0x65435568. @@ -1026,6 +1026,159 @@ func (_ERC20Bridge *ERC20BridgeFilterer) ParseCreateBridgeToken(log types.Log) ( return event, nil } +// ERC20BridgeMinTeleporterVersionUpdatedIterator is returned from FilterMinTeleporterVersionUpdated and is used to iterate over the raw logs and unpacked data for MinTeleporterVersionUpdated events raised by the ERC20Bridge contract. +type ERC20BridgeMinTeleporterVersionUpdatedIterator struct { + Event *ERC20BridgeMinTeleporterVersionUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub interfaces.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ERC20BridgeMinTeleporterVersionUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ERC20BridgeMinTeleporterVersionUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ERC20BridgeMinTeleporterVersionUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ERC20BridgeMinTeleporterVersionUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ERC20BridgeMinTeleporterVersionUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ERC20BridgeMinTeleporterVersionUpdated represents a MinTeleporterVersionUpdated event raised by the ERC20Bridge contract. +type ERC20BridgeMinTeleporterVersionUpdated struct { + OldMinTeleporterVersion *big.Int + NewMinTeleporterVersion *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterMinTeleporterVersionUpdated is a free log retrieval operation binding the contract event 0xa9a7ef57e41f05b4c15480842f5f0c27edfcbb553fed281f7c4068452cc1c02d. +// +// Solidity: event MinTeleporterVersionUpdated(uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion) +func (_ERC20Bridge *ERC20BridgeFilterer) FilterMinTeleporterVersionUpdated(opts *bind.FilterOpts, oldMinTeleporterVersion []*big.Int, newMinTeleporterVersion []*big.Int) (*ERC20BridgeMinTeleporterVersionUpdatedIterator, error) { + + var oldMinTeleporterVersionRule []interface{} + for _, oldMinTeleporterVersionItem := range oldMinTeleporterVersion { + oldMinTeleporterVersionRule = append(oldMinTeleporterVersionRule, oldMinTeleporterVersionItem) + } + var newMinTeleporterVersionRule []interface{} + for _, newMinTeleporterVersionItem := range newMinTeleporterVersion { + newMinTeleporterVersionRule = append(newMinTeleporterVersionRule, newMinTeleporterVersionItem) + } + + logs, sub, err := _ERC20Bridge.contract.FilterLogs(opts, "MinTeleporterVersionUpdated", oldMinTeleporterVersionRule, newMinTeleporterVersionRule) + if err != nil { + return nil, err + } + return &ERC20BridgeMinTeleporterVersionUpdatedIterator{contract: _ERC20Bridge.contract, event: "MinTeleporterVersionUpdated", logs: logs, sub: sub}, nil +} + +// WatchMinTeleporterVersionUpdated is a free log subscription operation binding the contract event 0xa9a7ef57e41f05b4c15480842f5f0c27edfcbb553fed281f7c4068452cc1c02d. +// +// Solidity: event MinTeleporterVersionUpdated(uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion) +func (_ERC20Bridge *ERC20BridgeFilterer) WatchMinTeleporterVersionUpdated(opts *bind.WatchOpts, sink chan<- *ERC20BridgeMinTeleporterVersionUpdated, oldMinTeleporterVersion []*big.Int, newMinTeleporterVersion []*big.Int) (event.Subscription, error) { + + var oldMinTeleporterVersionRule []interface{} + for _, oldMinTeleporterVersionItem := range oldMinTeleporterVersion { + oldMinTeleporterVersionRule = append(oldMinTeleporterVersionRule, oldMinTeleporterVersionItem) + } + var newMinTeleporterVersionRule []interface{} + for _, newMinTeleporterVersionItem := range newMinTeleporterVersion { + newMinTeleporterVersionRule = append(newMinTeleporterVersionRule, newMinTeleporterVersionItem) + } + + logs, sub, err := _ERC20Bridge.contract.WatchLogs(opts, "MinTeleporterVersionUpdated", oldMinTeleporterVersionRule, newMinTeleporterVersionRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ERC20BridgeMinTeleporterVersionUpdated) + if err := _ERC20Bridge.contract.UnpackLog(event, "MinTeleporterVersionUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseMinTeleporterVersionUpdated is a log parse operation binding the contract event 0xa9a7ef57e41f05b4c15480842f5f0c27edfcbb553fed281f7c4068452cc1c02d. +// +// Solidity: event MinTeleporterVersionUpdated(uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion) +func (_ERC20Bridge *ERC20BridgeFilterer) ParseMinTeleporterVersionUpdated(log types.Log) (*ERC20BridgeMinTeleporterVersionUpdated, error) { + event := new(ERC20BridgeMinTeleporterVersionUpdated) + if err := _ERC20Bridge.contract.UnpackLog(event, "MinTeleporterVersionUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + // ERC20BridgeMintBridgeTokensIterator is returned from FilterMintBridgeTokens and is used to iterate over the raw logs and unpacked data for MintBridgeTokens events raised by the ERC20Bridge contract. type ERC20BridgeMintBridgeTokensIterator struct { Event *ERC20BridgeMintBridgeTokens // Event containing the contract specifics and raw log diff --git a/abi-bindings/go/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go b/abi-bindings/go/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go index 91c1b1dff..577daf068 100644 --- a/abi-bindings/go/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go +++ b/abi-bindings/go/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go @@ -31,7 +31,7 @@ var ( // ExampleCrossChainMessengerMetaData contains all meta data concerning the ExampleCrossChainMessenger contract. var ExampleCrossChainMessengerMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"ReceiveMessage\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeAsset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"SendMessage\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"}],\"name\":\"getCurrentMessage\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeContractAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"sendMessage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldMinTeleporterVersion\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"newMinTeleporterVersion\",\"type\":\"uint256\"}],\"name\":\"MinTeleporterVersionUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"ReceiveMessage\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeAsset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"SendMessage\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"}],\"name\":\"getCurrentMessage\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeContractAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"sendMessage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // ExampleCrossChainMessengerABI is the input ABI used to generate the binding from. @@ -225,12 +225,12 @@ func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCallerSession) GetC return _ExampleCrossChainMessenger.Contract.GetCurrentMessage(&_ExampleCrossChainMessenger.CallOpts, originChainID) } -// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// MinTeleporterVersion is a free data retrieval call binding the contract method 0xe49cc553. // -// Solidity: function getMinTeleporterVersion() view returns(uint256) -func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCaller) GetMinTeleporterVersion(opts *bind.CallOpts) (*big.Int, error) { +// Solidity: function minTeleporterVersion() view returns(uint256) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCaller) MinTeleporterVersion(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} - err := _ExampleCrossChainMessenger.contract.Call(opts, &out, "getMinTeleporterVersion") + err := _ExampleCrossChainMessenger.contract.Call(opts, &out, "minTeleporterVersion") if err != nil { return *new(*big.Int), err @@ -242,18 +242,18 @@ func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCaller) GetMinTelep } -// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// MinTeleporterVersion is a free data retrieval call binding the contract method 0xe49cc553. // -// Solidity: function getMinTeleporterVersion() view returns(uint256) -func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerSession) GetMinTeleporterVersion() (*big.Int, error) { - return _ExampleCrossChainMessenger.Contract.GetMinTeleporterVersion(&_ExampleCrossChainMessenger.CallOpts) +// Solidity: function minTeleporterVersion() view returns(uint256) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerSession) MinTeleporterVersion() (*big.Int, error) { + return _ExampleCrossChainMessenger.Contract.MinTeleporterVersion(&_ExampleCrossChainMessenger.CallOpts) } -// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// MinTeleporterVersion is a free data retrieval call binding the contract method 0xe49cc553. // -// Solidity: function getMinTeleporterVersion() view returns(uint256) -func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCallerSession) GetMinTeleporterVersion() (*big.Int, error) { - return _ExampleCrossChainMessenger.Contract.GetMinTeleporterVersion(&_ExampleCrossChainMessenger.CallOpts) +// Solidity: function minTeleporterVersion() view returns(uint256) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCallerSession) MinTeleporterVersion() (*big.Int, error) { + return _ExampleCrossChainMessenger.Contract.MinTeleporterVersion(&_ExampleCrossChainMessenger.CallOpts) } // TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. @@ -350,6 +350,159 @@ func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerTransactorSession) return _ExampleCrossChainMessenger.Contract.UpdateMinTeleporterVersion(&_ExampleCrossChainMessenger.TransactOpts) } +// ExampleCrossChainMessengerMinTeleporterVersionUpdatedIterator is returned from FilterMinTeleporterVersionUpdated and is used to iterate over the raw logs and unpacked data for MinTeleporterVersionUpdated events raised by the ExampleCrossChainMessenger contract. +type ExampleCrossChainMessengerMinTeleporterVersionUpdatedIterator struct { + Event *ExampleCrossChainMessengerMinTeleporterVersionUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub interfaces.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ExampleCrossChainMessengerMinTeleporterVersionUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ExampleCrossChainMessengerMinTeleporterVersionUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ExampleCrossChainMessengerMinTeleporterVersionUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ExampleCrossChainMessengerMinTeleporterVersionUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ExampleCrossChainMessengerMinTeleporterVersionUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ExampleCrossChainMessengerMinTeleporterVersionUpdated represents a MinTeleporterVersionUpdated event raised by the ExampleCrossChainMessenger contract. +type ExampleCrossChainMessengerMinTeleporterVersionUpdated struct { + OldMinTeleporterVersion *big.Int + NewMinTeleporterVersion *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterMinTeleporterVersionUpdated is a free log retrieval operation binding the contract event 0xa9a7ef57e41f05b4c15480842f5f0c27edfcbb553fed281f7c4068452cc1c02d. +// +// Solidity: event MinTeleporterVersionUpdated(uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerFilterer) FilterMinTeleporterVersionUpdated(opts *bind.FilterOpts, oldMinTeleporterVersion []*big.Int, newMinTeleporterVersion []*big.Int) (*ExampleCrossChainMessengerMinTeleporterVersionUpdatedIterator, error) { + + var oldMinTeleporterVersionRule []interface{} + for _, oldMinTeleporterVersionItem := range oldMinTeleporterVersion { + oldMinTeleporterVersionRule = append(oldMinTeleporterVersionRule, oldMinTeleporterVersionItem) + } + var newMinTeleporterVersionRule []interface{} + for _, newMinTeleporterVersionItem := range newMinTeleporterVersion { + newMinTeleporterVersionRule = append(newMinTeleporterVersionRule, newMinTeleporterVersionItem) + } + + logs, sub, err := _ExampleCrossChainMessenger.contract.FilterLogs(opts, "MinTeleporterVersionUpdated", oldMinTeleporterVersionRule, newMinTeleporterVersionRule) + if err != nil { + return nil, err + } + return &ExampleCrossChainMessengerMinTeleporterVersionUpdatedIterator{contract: _ExampleCrossChainMessenger.contract, event: "MinTeleporterVersionUpdated", logs: logs, sub: sub}, nil +} + +// WatchMinTeleporterVersionUpdated is a free log subscription operation binding the contract event 0xa9a7ef57e41f05b4c15480842f5f0c27edfcbb553fed281f7c4068452cc1c02d. +// +// Solidity: event MinTeleporterVersionUpdated(uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerFilterer) WatchMinTeleporterVersionUpdated(opts *bind.WatchOpts, sink chan<- *ExampleCrossChainMessengerMinTeleporterVersionUpdated, oldMinTeleporterVersion []*big.Int, newMinTeleporterVersion []*big.Int) (event.Subscription, error) { + + var oldMinTeleporterVersionRule []interface{} + for _, oldMinTeleporterVersionItem := range oldMinTeleporterVersion { + oldMinTeleporterVersionRule = append(oldMinTeleporterVersionRule, oldMinTeleporterVersionItem) + } + var newMinTeleporterVersionRule []interface{} + for _, newMinTeleporterVersionItem := range newMinTeleporterVersion { + newMinTeleporterVersionRule = append(newMinTeleporterVersionRule, newMinTeleporterVersionItem) + } + + logs, sub, err := _ExampleCrossChainMessenger.contract.WatchLogs(opts, "MinTeleporterVersionUpdated", oldMinTeleporterVersionRule, newMinTeleporterVersionRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ExampleCrossChainMessengerMinTeleporterVersionUpdated) + if err := _ExampleCrossChainMessenger.contract.UnpackLog(event, "MinTeleporterVersionUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseMinTeleporterVersionUpdated is a log parse operation binding the contract event 0xa9a7ef57e41f05b4c15480842f5f0c27edfcbb553fed281f7c4068452cc1c02d. +// +// Solidity: event MinTeleporterVersionUpdated(uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerFilterer) ParseMinTeleporterVersionUpdated(log types.Log) (*ExampleCrossChainMessengerMinTeleporterVersionUpdated, error) { + event := new(ExampleCrossChainMessengerMinTeleporterVersionUpdated) + if err := _ExampleCrossChainMessenger.contract.UnpackLog(event, "MinTeleporterVersionUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + // ExampleCrossChainMessengerReceiveMessageIterator is returned from FilterReceiveMessage and is used to iterate over the raw logs and unpacked data for ReceiveMessage events raised by the ExampleCrossChainMessenger contract. type ExampleCrossChainMessengerReceiveMessageIterator struct { Event *ExampleCrossChainMessengerReceiveMessage // Event containing the contract specifics and raw log diff --git a/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go b/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go index a6b2874f5..f852d7030 100644 --- a/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go +++ b/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go @@ -31,7 +31,7 @@ var ( // BlockHashPublisherMetaData contains all meta data concerning the BlockHashPublisher contract. var BlockHashPublisherMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"PublishBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"RECEIVE_BLOCK_HASH_REQUIRED_GAS_LIMIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"}],\"name\":\"publishLatestBlockHash\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldMinTeleporterVersion\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"newMinTeleporterVersion\",\"type\":\"uint256\"}],\"name\":\"MinTeleporterVersionUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"PublishBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"RECEIVE_BLOCK_HASH_REQUIRED_GAS_LIMIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"}],\"name\":\"publishLatestBlockHash\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // BlockHashPublisherABI is the input ABI used to generate the binding from. @@ -211,12 +211,12 @@ func (_BlockHashPublisher *BlockHashPublisherCallerSession) RECEIVEBLOCKHASHREQU return _BlockHashPublisher.Contract.RECEIVEBLOCKHASHREQUIREDGASLIMIT(&_BlockHashPublisher.CallOpts) } -// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// MinTeleporterVersion is a free data retrieval call binding the contract method 0xe49cc553. // -// Solidity: function getMinTeleporterVersion() view returns(uint256) -func (_BlockHashPublisher *BlockHashPublisherCaller) GetMinTeleporterVersion(opts *bind.CallOpts) (*big.Int, error) { +// Solidity: function minTeleporterVersion() view returns(uint256) +func (_BlockHashPublisher *BlockHashPublisherCaller) MinTeleporterVersion(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} - err := _BlockHashPublisher.contract.Call(opts, &out, "getMinTeleporterVersion") + err := _BlockHashPublisher.contract.Call(opts, &out, "minTeleporterVersion") if err != nil { return *new(*big.Int), err @@ -228,18 +228,18 @@ func (_BlockHashPublisher *BlockHashPublisherCaller) GetMinTeleporterVersion(opt } -// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// MinTeleporterVersion is a free data retrieval call binding the contract method 0xe49cc553. // -// Solidity: function getMinTeleporterVersion() view returns(uint256) -func (_BlockHashPublisher *BlockHashPublisherSession) GetMinTeleporterVersion() (*big.Int, error) { - return _BlockHashPublisher.Contract.GetMinTeleporterVersion(&_BlockHashPublisher.CallOpts) +// Solidity: function minTeleporterVersion() view returns(uint256) +func (_BlockHashPublisher *BlockHashPublisherSession) MinTeleporterVersion() (*big.Int, error) { + return _BlockHashPublisher.Contract.MinTeleporterVersion(&_BlockHashPublisher.CallOpts) } -// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. +// MinTeleporterVersion is a free data retrieval call binding the contract method 0xe49cc553. // -// Solidity: function getMinTeleporterVersion() view returns(uint256) -func (_BlockHashPublisher *BlockHashPublisherCallerSession) GetMinTeleporterVersion() (*big.Int, error) { - return _BlockHashPublisher.Contract.GetMinTeleporterVersion(&_BlockHashPublisher.CallOpts) +// Solidity: function minTeleporterVersion() view returns(uint256) +func (_BlockHashPublisher *BlockHashPublisherCallerSession) MinTeleporterVersion() (*big.Int, error) { + return _BlockHashPublisher.Contract.MinTeleporterVersion(&_BlockHashPublisher.CallOpts) } // TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. @@ -315,6 +315,159 @@ func (_BlockHashPublisher *BlockHashPublisherTransactorSession) UpdateMinTelepor return _BlockHashPublisher.Contract.UpdateMinTeleporterVersion(&_BlockHashPublisher.TransactOpts) } +// BlockHashPublisherMinTeleporterVersionUpdatedIterator is returned from FilterMinTeleporterVersionUpdated and is used to iterate over the raw logs and unpacked data for MinTeleporterVersionUpdated events raised by the BlockHashPublisher contract. +type BlockHashPublisherMinTeleporterVersionUpdatedIterator struct { + Event *BlockHashPublisherMinTeleporterVersionUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub interfaces.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *BlockHashPublisherMinTeleporterVersionUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(BlockHashPublisherMinTeleporterVersionUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(BlockHashPublisherMinTeleporterVersionUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *BlockHashPublisherMinTeleporterVersionUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *BlockHashPublisherMinTeleporterVersionUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// BlockHashPublisherMinTeleporterVersionUpdated represents a MinTeleporterVersionUpdated event raised by the BlockHashPublisher contract. +type BlockHashPublisherMinTeleporterVersionUpdated struct { + OldMinTeleporterVersion *big.Int + NewMinTeleporterVersion *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterMinTeleporterVersionUpdated is a free log retrieval operation binding the contract event 0xa9a7ef57e41f05b4c15480842f5f0c27edfcbb553fed281f7c4068452cc1c02d. +// +// Solidity: event MinTeleporterVersionUpdated(uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion) +func (_BlockHashPublisher *BlockHashPublisherFilterer) FilterMinTeleporterVersionUpdated(opts *bind.FilterOpts, oldMinTeleporterVersion []*big.Int, newMinTeleporterVersion []*big.Int) (*BlockHashPublisherMinTeleporterVersionUpdatedIterator, error) { + + var oldMinTeleporterVersionRule []interface{} + for _, oldMinTeleporterVersionItem := range oldMinTeleporterVersion { + oldMinTeleporterVersionRule = append(oldMinTeleporterVersionRule, oldMinTeleporterVersionItem) + } + var newMinTeleporterVersionRule []interface{} + for _, newMinTeleporterVersionItem := range newMinTeleporterVersion { + newMinTeleporterVersionRule = append(newMinTeleporterVersionRule, newMinTeleporterVersionItem) + } + + logs, sub, err := _BlockHashPublisher.contract.FilterLogs(opts, "MinTeleporterVersionUpdated", oldMinTeleporterVersionRule, newMinTeleporterVersionRule) + if err != nil { + return nil, err + } + return &BlockHashPublisherMinTeleporterVersionUpdatedIterator{contract: _BlockHashPublisher.contract, event: "MinTeleporterVersionUpdated", logs: logs, sub: sub}, nil +} + +// WatchMinTeleporterVersionUpdated is a free log subscription operation binding the contract event 0xa9a7ef57e41f05b4c15480842f5f0c27edfcbb553fed281f7c4068452cc1c02d. +// +// Solidity: event MinTeleporterVersionUpdated(uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion) +func (_BlockHashPublisher *BlockHashPublisherFilterer) WatchMinTeleporterVersionUpdated(opts *bind.WatchOpts, sink chan<- *BlockHashPublisherMinTeleporterVersionUpdated, oldMinTeleporterVersion []*big.Int, newMinTeleporterVersion []*big.Int) (event.Subscription, error) { + + var oldMinTeleporterVersionRule []interface{} + for _, oldMinTeleporterVersionItem := range oldMinTeleporterVersion { + oldMinTeleporterVersionRule = append(oldMinTeleporterVersionRule, oldMinTeleporterVersionItem) + } + var newMinTeleporterVersionRule []interface{} + for _, newMinTeleporterVersionItem := range newMinTeleporterVersion { + newMinTeleporterVersionRule = append(newMinTeleporterVersionRule, newMinTeleporterVersionItem) + } + + logs, sub, err := _BlockHashPublisher.contract.WatchLogs(opts, "MinTeleporterVersionUpdated", oldMinTeleporterVersionRule, newMinTeleporterVersionRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(BlockHashPublisherMinTeleporterVersionUpdated) + if err := _BlockHashPublisher.contract.UnpackLog(event, "MinTeleporterVersionUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseMinTeleporterVersionUpdated is a log parse operation binding the contract event 0xa9a7ef57e41f05b4c15480842f5f0c27edfcbb553fed281f7c4068452cc1c02d. +// +// Solidity: event MinTeleporterVersionUpdated(uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion) +func (_BlockHashPublisher *BlockHashPublisherFilterer) ParseMinTeleporterVersionUpdated(log types.Log) (*BlockHashPublisherMinTeleporterVersionUpdated, error) { + event := new(BlockHashPublisherMinTeleporterVersionUpdated) + if err := _BlockHashPublisher.contract.UnpackLog(event, "MinTeleporterVersionUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + // BlockHashPublisherPublishBlockHashIterator is returned from FilterPublishBlockHash and is used to iterate over the raw logs and unpacked data for PublishBlockHash events raised by the BlockHashPublisher contract. type BlockHashPublisherPublishBlockHashIterator struct { Event *BlockHashPublisherPublishBlockHash // Event containing the contract specifics and raw log diff --git a/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go b/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go index 45e7c45ff..8c3273c10 100644 --- a/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go +++ b/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go @@ -31,7 +31,7 @@ var ( // BlockHashReceiverMetaData contains all meta data concerning the BlockHashReceiver contract. var BlockHashReceiverMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"publisherChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"publisherContractAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"getLatestBlockInfo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"height\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourceChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourcePublisherContractAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"publisherChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"publisherContractAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldMinTeleporterVersion\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"newMinTeleporterVersion\",\"type\":\"uint256\"}],\"name\":\"MinTeleporterVersionUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"getLatestBlockInfo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"height\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourceChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourcePublisherContractAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // BlockHashReceiverABI is the input ABI used to generate the binding from. @@ -225,37 +225,6 @@ func (_BlockHashReceiver *BlockHashReceiverCallerSession) GetLatestBlockInfo() ( return _BlockHashReceiver.Contract.GetLatestBlockInfo(&_BlockHashReceiver.CallOpts) } -// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. -// -// Solidity: function getMinTeleporterVersion() view returns(uint256) -func (_BlockHashReceiver *BlockHashReceiverCaller) GetMinTeleporterVersion(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _BlockHashReceiver.contract.Call(opts, &out, "getMinTeleporterVersion") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. -// -// Solidity: function getMinTeleporterVersion() view returns(uint256) -func (_BlockHashReceiver *BlockHashReceiverSession) GetMinTeleporterVersion() (*big.Int, error) { - return _BlockHashReceiver.Contract.GetMinTeleporterVersion(&_BlockHashReceiver.CallOpts) -} - -// GetMinTeleporterVersion is a free data retrieval call binding the contract method 0xd2cc7a70. -// -// Solidity: function getMinTeleporterVersion() view returns(uint256) -func (_BlockHashReceiver *BlockHashReceiverCallerSession) GetMinTeleporterVersion() (*big.Int, error) { - return _BlockHashReceiver.Contract.GetMinTeleporterVersion(&_BlockHashReceiver.CallOpts) -} - // LatestBlockHash is a free data retrieval call binding the contract method 0x6c4f6ba9. // // Solidity: function latestBlockHash() view returns(bytes32) @@ -318,6 +287,37 @@ func (_BlockHashReceiver *BlockHashReceiverCallerSession) LatestBlockHeight() (* return _BlockHashReceiver.Contract.LatestBlockHeight(&_BlockHashReceiver.CallOpts) } +// MinTeleporterVersion is a free data retrieval call binding the contract method 0xe49cc553. +// +// Solidity: function minTeleporterVersion() view returns(uint256) +func (_BlockHashReceiver *BlockHashReceiverCaller) MinTeleporterVersion(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _BlockHashReceiver.contract.Call(opts, &out, "minTeleporterVersion") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MinTeleporterVersion is a free data retrieval call binding the contract method 0xe49cc553. +// +// Solidity: function minTeleporterVersion() view returns(uint256) +func (_BlockHashReceiver *BlockHashReceiverSession) MinTeleporterVersion() (*big.Int, error) { + return _BlockHashReceiver.Contract.MinTeleporterVersion(&_BlockHashReceiver.CallOpts) +} + +// MinTeleporterVersion is a free data retrieval call binding the contract method 0xe49cc553. +// +// Solidity: function minTeleporterVersion() view returns(uint256) +func (_BlockHashReceiver *BlockHashReceiverCallerSession) MinTeleporterVersion() (*big.Int, error) { + return _BlockHashReceiver.Contract.MinTeleporterVersion(&_BlockHashReceiver.CallOpts) +} + // SourceChainID is a free data retrieval call binding the contract method 0x4c335368. // // Solidity: function sourceChainID() view returns(bytes32) @@ -453,6 +453,159 @@ func (_BlockHashReceiver *BlockHashReceiverTransactorSession) UpdateMinTeleporte return _BlockHashReceiver.Contract.UpdateMinTeleporterVersion(&_BlockHashReceiver.TransactOpts) } +// BlockHashReceiverMinTeleporterVersionUpdatedIterator is returned from FilterMinTeleporterVersionUpdated and is used to iterate over the raw logs and unpacked data for MinTeleporterVersionUpdated events raised by the BlockHashReceiver contract. +type BlockHashReceiverMinTeleporterVersionUpdatedIterator struct { + Event *BlockHashReceiverMinTeleporterVersionUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub interfaces.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *BlockHashReceiverMinTeleporterVersionUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(BlockHashReceiverMinTeleporterVersionUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(BlockHashReceiverMinTeleporterVersionUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *BlockHashReceiverMinTeleporterVersionUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *BlockHashReceiverMinTeleporterVersionUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// BlockHashReceiverMinTeleporterVersionUpdated represents a MinTeleporterVersionUpdated event raised by the BlockHashReceiver contract. +type BlockHashReceiverMinTeleporterVersionUpdated struct { + OldMinTeleporterVersion *big.Int + NewMinTeleporterVersion *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterMinTeleporterVersionUpdated is a free log retrieval operation binding the contract event 0xa9a7ef57e41f05b4c15480842f5f0c27edfcbb553fed281f7c4068452cc1c02d. +// +// Solidity: event MinTeleporterVersionUpdated(uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion) +func (_BlockHashReceiver *BlockHashReceiverFilterer) FilterMinTeleporterVersionUpdated(opts *bind.FilterOpts, oldMinTeleporterVersion []*big.Int, newMinTeleporterVersion []*big.Int) (*BlockHashReceiverMinTeleporterVersionUpdatedIterator, error) { + + var oldMinTeleporterVersionRule []interface{} + for _, oldMinTeleporterVersionItem := range oldMinTeleporterVersion { + oldMinTeleporterVersionRule = append(oldMinTeleporterVersionRule, oldMinTeleporterVersionItem) + } + var newMinTeleporterVersionRule []interface{} + for _, newMinTeleporterVersionItem := range newMinTeleporterVersion { + newMinTeleporterVersionRule = append(newMinTeleporterVersionRule, newMinTeleporterVersionItem) + } + + logs, sub, err := _BlockHashReceiver.contract.FilterLogs(opts, "MinTeleporterVersionUpdated", oldMinTeleporterVersionRule, newMinTeleporterVersionRule) + if err != nil { + return nil, err + } + return &BlockHashReceiverMinTeleporterVersionUpdatedIterator{contract: _BlockHashReceiver.contract, event: "MinTeleporterVersionUpdated", logs: logs, sub: sub}, nil +} + +// WatchMinTeleporterVersionUpdated is a free log subscription operation binding the contract event 0xa9a7ef57e41f05b4c15480842f5f0c27edfcbb553fed281f7c4068452cc1c02d. +// +// Solidity: event MinTeleporterVersionUpdated(uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion) +func (_BlockHashReceiver *BlockHashReceiverFilterer) WatchMinTeleporterVersionUpdated(opts *bind.WatchOpts, sink chan<- *BlockHashReceiverMinTeleporterVersionUpdated, oldMinTeleporterVersion []*big.Int, newMinTeleporterVersion []*big.Int) (event.Subscription, error) { + + var oldMinTeleporterVersionRule []interface{} + for _, oldMinTeleporterVersionItem := range oldMinTeleporterVersion { + oldMinTeleporterVersionRule = append(oldMinTeleporterVersionRule, oldMinTeleporterVersionItem) + } + var newMinTeleporterVersionRule []interface{} + for _, newMinTeleporterVersionItem := range newMinTeleporterVersion { + newMinTeleporterVersionRule = append(newMinTeleporterVersionRule, newMinTeleporterVersionItem) + } + + logs, sub, err := _BlockHashReceiver.contract.WatchLogs(opts, "MinTeleporterVersionUpdated", oldMinTeleporterVersionRule, newMinTeleporterVersionRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(BlockHashReceiverMinTeleporterVersionUpdated) + if err := _BlockHashReceiver.contract.UnpackLog(event, "MinTeleporterVersionUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseMinTeleporterVersionUpdated is a log parse operation binding the contract event 0xa9a7ef57e41f05b4c15480842f5f0c27edfcbb553fed281f7c4068452cc1c02d. +// +// Solidity: event MinTeleporterVersionUpdated(uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion) +func (_BlockHashReceiver *BlockHashReceiverFilterer) ParseMinTeleporterVersionUpdated(log types.Log) (*BlockHashReceiverMinTeleporterVersionUpdated, error) { + event := new(BlockHashReceiverMinTeleporterVersionUpdated) + if err := _BlockHashReceiver.contract.UnpackLog(event, "MinTeleporterVersionUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + // BlockHashReceiverReceiveBlockHashIterator is returned from FilterReceiveBlockHash and is used to iterate over the raw logs and unpacked data for ReceiveBlockHash events raised by the BlockHashReceiver contract. type BlockHashReceiverReceiveBlockHashIterator struct { Event *BlockHashReceiverReceiveBlockHash // Event containing the contract specifics and raw log diff --git a/abi-bindings/Teleporter/upgrades/TeleporterRegistry/TeleporterRegistry.go b/abi-bindings/go/Teleporter/upgrades/TeleporterRegistry/TeleporterRegistry.go similarity index 100% rename from abi-bindings/Teleporter/upgrades/TeleporterRegistry/TeleporterRegistry.go rename to abi-bindings/go/Teleporter/upgrades/TeleporterRegistry/TeleporterRegistry.go diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol index 660d5aea9..539d71e57 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol @@ -25,8 +25,8 @@ contract TeleporterUpgradeableTest is Test { 0x644E5b7c5D4Bc8073732CEa72c66e0BB90dFC00f; event MinTeleporterVersionUpdated( - uint256 oldMinTeleporterVersion, - uint256 newMinTeleporterVersion + uint256 indexed oldMinTeleporterVersion, + uint256 indexed newMinTeleporterVersion ); function setUp() public { @@ -101,6 +101,7 @@ contract TeleporterUpgradeableTest is Test { vm.expectEmit(true, true, true, true, address(app)); emit MinTeleporterVersionUpdated(1, 2); + app.updateMinTeleporterVersion(); assertEq(app.minTeleporterVersion(), 2); diff --git a/scripts/abi_bindings.sh b/scripts/abi_bindings.sh index cfaaa6138..e368d08e3 100755 --- a/scripts/abi_bindings.sh +++ b/scripts/abi_bindings.sh @@ -13,7 +13,7 @@ TELEPORTER_PATH=$( cd .. && pwd ) -DEFAULT_CONTRACT_LIST="TeleporterMessenger ERC20Bridge ExampleCrossChainMessenger BlockHashPublisher BlockHashReceiver BridgeToken" +DEFAULT_CONTRACT_LIST="TeleporterMessenger ERC20Bridge ExampleCrossChainMessenger BlockHashPublisher BlockHashReceiver BridgeToken TeleporterRegistry" CONTRACT_LIST= HELP= From 6450e210835cfea1f431853e57c7e6f9ee220685 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 25 Oct 2023 03:38:16 +0000 Subject: [PATCH 63/80] add virtual to TeleporterUpgradeable --- contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol index fc8b8651b..b39a5106b 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol @@ -31,7 +31,7 @@ abstract contract TeleporterUpgradeable { * @dev Throws if called by a `msg.sender` that is not an allowed Teleporter version. * Checks that `msg.sender` matches a Teleporter version greater than or equal to `_minTeleporterVersion`. */ - modifier onlyAllowedTeleporter() { + modifier onlyAllowedTeleporter() virtual { require( teleporterRegistry.getVersionFromAddress(msg.sender) >= minTeleporterVersion, @@ -58,7 +58,7 @@ abstract contract TeleporterUpgradeable { * @dev Updates `minTeleporterVersion` to the latest version. * Emits a {MinTeleporterVersionUpdated} event. */ - function updateMinTeleporterVersion() external { + function updateMinTeleporterVersion() external virtual { uint256 prevVersion = minTeleporterVersion; minTeleporterVersion = teleporterRegistry.getLatestVersion(); emit MinTeleporterVersionUpdated(prevVersion, minTeleporterVersion); From 93b379ab2f40aa273a06c2785d2e229546ee66f8 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 25 Oct 2023 21:26:48 +0000 Subject: [PATCH 64/80] require derived contracts to implement updateMinTeleporterVersion --- .../ERC20Bridge/ERC20Bridge.sol | 21 +++++++++++++++- .../ExampleCrossChainMessenger.sol | 17 +++++++++++++ .../VerifiedBlockHash/BlockHashPublisher.sol | 16 +++++++++---- .../VerifiedBlockHash/BlockHashReceiver.sol | 17 +++++++++++++ .../upgrades/TeleporterUpgradeable.sol | 24 +++++++++---------- .../tests/TeleporterUpgradeableTests.t.sol | 9 +++++++ 6 files changed, 86 insertions(+), 18 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol index 282cbf2a1..926efa675 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol @@ -16,6 +16,7 @@ import "@subnet-evm-contracts/interfaces/IWarpMessenger.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; /** * @dev Implementation of the {IERC20Bridge} interface. @@ -27,7 +28,8 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard, - TeleporterUpgradeable + TeleporterUpgradeable, + Ownable { using SafeERC20 for IERC20; @@ -322,6 +324,23 @@ contract ERC20Bridge is } } + /** + * @dev See {TeleporterUpgradeable-updateMinTeleporterVersion} + * + * Updates the minimum Teleporter version allowed for receiving on this contract + * to the latest version registered in the {TeleporterRegistry}. Also restricts this function to + * the owner of this contract. + * Emits a {MinTeleporterVersionUpdated} event. + */ + function updateMinTeleporterVersion() external override onlyOwner { + uint256 oldMinTeleporterVersion = minTeleporterVersion; + minTeleporterVersion = teleporterRegistry.getLatestVersion(); + emit MinTeleporterVersionUpdated( + oldMinTeleporterVersion, + minTeleporterVersion + ); + } + /** * @dev Encodes the parameters for the Create action to be decoded and executed on the destination. */ diff --git a/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol b/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol index ad9f4593f..e33af775b 100644 --- a/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol +++ b/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol @@ -124,6 +124,23 @@ contract ExampleCrossChainMessenger is ); } + /** + * @dev See {TeleporterUpgradeable-updateMinTeleporterVersion} + * + * Updates the minimum Teleporter version allowed for receiving on this contract + * to the latest version registered in the {TeleporterRegistry}. + * + * Emits a {MinTeleporterVersionUpdated} event. + */ + function updateMinTeleporterVersion() external override { + uint256 oldMinTeleporterVersion = minTeleporterVersion; + minTeleporterVersion = teleporterRegistry.getLatestVersion(); + emit MinTeleporterVersionUpdated( + oldMinTeleporterVersion, + minTeleporterVersion + ); + } + /** * @dev Returns the current message from another chain. */ diff --git a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol index 18cdaded2..54e2fa17e 100644 --- a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol +++ b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol @@ -7,16 +7,17 @@ pragma solidity 0.8.18; import "../../Teleporter/ITeleporterMessenger.sol"; import "../../Teleporter/upgrades/TeleporterRegistry.sol"; -import "../../Teleporter/upgrades/TeleporterUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./BlockHashReceiver.sol"; /** * Contract that publishes the latest block hash of current chain to another chain. */ -contract BlockHashPublisher is TeleporterUpgradeable { +contract BlockHashPublisher { uint256 public constant RECEIVE_BLOCK_HASH_REQUIRED_GAS_LIMIT = 1.5e5; + TeleporterRegistry public immutable teleporterRegistry; + /** * @dev Emitted when a block hash is submitted to be published to another chain. */ @@ -27,9 +28,14 @@ contract BlockHashPublisher is TeleporterUpgradeable { bytes32 blockHash ); - constructor( - address teleporterRegistryAddress - ) TeleporterUpgradeable(teleporterRegistryAddress) {} + constructor(address teleporterRegistryAddress) { + require( + teleporterRegistryAddress != address(0), + "BlockHashPublisher: zero teleporter registry address" + ); + + teleporterRegistry = TeleporterRegistry(teleporterRegistryAddress); + } /** * @dev Publishes the latest block hash to another chain. diff --git a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol index 7e857822c..391633abd 100644 --- a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol +++ b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol @@ -83,6 +83,23 @@ contract BlockHashReceiver is ITeleporterReceiver, TeleporterUpgradeable { } } + /** + * @dev See {TeleporterUpgradeable-updateMinTeleporterVersion} + * + * Updates the minimum Teleporter version allowed for receiving on this contract + * to the latest version registered in the {TeleporterRegistry}. + * + * Emits a {MinTeleporterVersionUpdated} event. + */ + function updateMinTeleporterVersion() external override { + uint256 oldMinTeleporterVersion = minTeleporterVersion; + minTeleporterVersion = teleporterRegistry.getLatestVersion(); + emit MinTeleporterVersionUpdated( + oldMinTeleporterVersion, + minTeleporterVersion + ); + } + /** * @dev Returns the latest block information. */ diff --git a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol index b39a5106b..1eab9c143 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol @@ -13,15 +13,12 @@ import "./TeleporterRegistry.sol"; * * This contract is intended to be inherited by other contracts that wish to use the * upgrade mechanism. It provides a modifier that restricts access to only Teleporter - * versions that are greater than or equal to `_minTeleporterVersion`. + * versions that are greater than or equal to `minTeleporterVersion`. */ abstract contract TeleporterUpgradeable { TeleporterRegistry public immutable teleporterRegistry; uint256 public minTeleporterVersion; - /** - * @dev Emitted when `minTeleporterVersion` is updated to a new value. - */ event MinTeleporterVersionUpdated( uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion @@ -29,7 +26,7 @@ abstract contract TeleporterUpgradeable { /** * @dev Throws if called by a `msg.sender` that is not an allowed Teleporter version. - * Checks that `msg.sender` matches a Teleporter version greater than or equal to `_minTeleporterVersion`. + * Checks that `msg.sender` matches a Teleporter version greater than or equal to `minTeleporterVersion`. */ modifier onlyAllowedTeleporter() virtual { require( @@ -55,12 +52,15 @@ abstract contract TeleporterUpgradeable { } /** - * @dev Updates `minTeleporterVersion` to the latest version. - * Emits a {MinTeleporterVersionUpdated} event. + * @dev This is a virtual function that should be overridden to update the `minTeleporterVersion` + * allowed for modifier `onlyAllowedTeleporter`, and emit {MinTeleporterVersionUpdated} event after. + * The derived contract should call this function after there is a new Teleporter version + * registered in the `TeleporterRegistry`, and the derived contract no longer needs to receive + * messages from the previous Teleporter versions. + * + * Note: To prevent anyone from being able to call this function, which would disallow messages + * from old Teleporter versions from being received, this function should be safeguarded with access + * controls. For example, if the derived contract has an owner/admin, only they can call this function. */ - function updateMinTeleporterVersion() external virtual { - uint256 prevVersion = minTeleporterVersion; - minTeleporterVersion = teleporterRegistry.getLatestVersion(); - emit MinTeleporterVersionUpdated(prevVersion, minTeleporterVersion); - } + function updateMinTeleporterVersion() external virtual; } diff --git a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol index 539d71e57..a3e34be6c 100644 --- a/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol +++ b/contracts/src/Teleporter/upgrades/tests/TeleporterUpgradeableTests.t.sol @@ -14,6 +14,15 @@ contract ExampleUpgradeableApp is TeleporterUpgradeable { address teleporterRegistryAddress ) TeleporterUpgradeable(teleporterRegistryAddress) {} + function updateMinTeleporterVersion() external override { + uint256 oldMinTeleporterVersion = minTeleporterVersion; + minTeleporterVersion = teleporterRegistry.getLatestVersion(); + emit MinTeleporterVersionUpdated( + oldMinTeleporterVersion, + minTeleporterVersion + ); + } + // solhint-disable-next-line no-empty-blocks function teleporterCall() public onlyAllowedTeleporter {} } From f08ae17ab07635ed64e95626df5a212d67d1bd6d Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 25 Oct 2023 21:49:30 +0000 Subject: [PATCH 65/80] readme updates --- contracts/src/Teleporter/upgrades/README.md | 22 ++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md index 66d5e1bea..61731f4f1 100644 --- a/contracts/src/Teleporter/upgrades/README.md +++ b/contracts/src/Teleporter/upgrades/README.md @@ -34,7 +34,8 @@ contract ERC20Bridge is IERC20Bridge, ITeleporterReceiver, ReentrancyGuard, - TeleporterUpgradeable + TeleporterUpgradeable, + Ownable { ... constructor( @@ -47,7 +48,22 @@ contract ERC20Bridge is } ``` -The `TeleporterUpgradeable` contract saves the Teleporter registry in a state variable used by the inheriting contract, and initializes a `minTeleporterVersion` to the highest number `TeleporterMessenger` version registered in `TeleporterRegistry`. The `onlyAllowedTeleporter` modifier ensures that `msg.sender` is a `TeleporterMessenger` contract with a version greater than or equal to `minTeleporterVersion`. This modifier is used to restrict access to functions that should only be called by a `TeleporterMessenger` contract, i.e. `ITeleporterReceiver.receiveTeleporterMessage`. This is to support the case where a dapp wants to upgrade to a new version of the `TeleporterMessenger` contract, but still wants to be able to receive messages from the old Teleporter contract. Then once the dapp completes delivery of messages from the old Teleporter contract, it can call `TeleporterUpgradeable.updateMinTeleporterVersion` to update the `minTeleporterVersion` to the new version. +The `TeleporterUpgradeable` contract saves the Teleporter registry in a state variable used by the inheriting contract, and initializes a `minTeleporterVersion` to the highest number `TeleporterMessenger` version registered in `TeleporterRegistry`. The `onlyAllowedTeleporter` modifier ensures that `msg.sender` is a `TeleporterMessenger` contract with a version greater than or equal to `minTeleporterVersion`. This modifier is used to restrict access to functions that should only be called by a `TeleporterMessenger` contract, i.e. `ITeleporterReceiver.receiveTeleporterMessage`. This is to support the case where a dapp wants to upgrade to a new version of the `TeleporterMessenger` contract, but still wants to be able to receive messages from the old Teleporter contract. + +Every derived contract of `TeleporterUpgradeable` must implement `TeleporterUpgradeable.updateMinTeleporterVersion`, which updates the `minTeleporterVersion` used by the `onlyAllowedTeleporter` modifier and emits the `MinTeleporterVersionUpdated` event. The `updateMinTeleporterVersion` function should be called by the dapp when it completes delivery of messages from the old Teleporter contract, and now wants to update the `minTeleporterVersion` to only allow the new Teleporter version. + +To prevent anyone from calling the dapp's `updateMinTeleporterVersion`, which would disallow messages from old Teleporter versions from being received, this function should be safeguarded with access controls. For example, the ERC20Bridge inherits `Ownable`, and restricts the `updateMinTeleporterVersion` function call to the owner of the contract. + +```solidity + function updateMinTeleporterVersion() external override onlyOwner { + uint256 oldMinTeleporterVersion = minTeleporterVersion; + minTeleporterVersion = teleporterRegistry.getLatestVersion(); + emit MinTeleporterVersionUpdated( + oldMinTeleporterVersion, + minTeleporterVersion + ); + } +``` For sending messages with the Teleporter registry, dapps should generally use `TeleporterRegistry.getLatestTeleporter` for the latest version, but if the dapp wants to send a message to a specific version, it can use `TeleporterRegistry.getTeleporterFromVersion` to get the specific Teleporter version. @@ -63,4 +79,4 @@ Using specific version: ```solidity ITeleporterMessenger teleporterMessenger = teleporterRegistry .getTeleporterFromVersion(version); -``` \ No newline at end of file +``` From dfa1a3d9d73dd192e22fda4dd1e0427ab39f677c Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 25 Oct 2023 21:51:02 +0000 Subject: [PATCH 66/80] update abi bindings --- .../ERC20Bridge/ERC20Bridge/ERC20Bridge.go | 228 +++++++++++++++++- .../BlockHashPublisher/BlockHashPublisher.go | 207 +--------------- 2 files changed, 228 insertions(+), 207 deletions(-) diff --git a/abi-bindings/go/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go b/abi-bindings/go/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go index 8b6724ebe..5994b4903 100644 --- a/abi-bindings/go/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go +++ b/abi-bindings/go/CrossChainApplications/ERC20Bridge/ERC20Bridge/ERC20Bridge.go @@ -31,7 +31,7 @@ var ( // ERC20BridgeMetaData contains all meta data concerning the ERC20Bridge contract. var ERC20BridgeMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"BridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"bridgeTokenAddress\",\"type\":\"address\"}],\"name\":\"CreateBridgeToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldMinTeleporterVersion\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"newMinTeleporterVersion\",\"type\":\"uint256\"}],\"name\":\"MinTeleporterVersionUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"contractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MintBridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"}],\"name\":\"SubmitCreateBridgeToken\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CREATE_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINT_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TRANSFER_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WARP_PRECOMPILE_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"primaryFeeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"secondaryFeeAmount\",\"type\":\"uint256\"}],\"name\":\"bridgeTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"bridgedBalances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"nativeName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"nativeSymbol\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"nativeDecimals\",\"type\":\"uint8\"}],\"name\":\"encodeCreateBridgeTokenData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"bridgeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeMintBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeTransferBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nativeToWrappedTokens\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"contractERC20\",\"name\":\"nativeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"messageFeeAsset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"messageFeeAmount\",\"type\":\"uint256\"}],\"name\":\"submitCreateBridgeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"submittedBridgeTokenCreations\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedTokenContracts\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"BridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"bridgeTokenAddress\",\"type\":\"address\"}],\"name\":\"CreateBridgeToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldMinTeleporterVersion\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"newMinTeleporterVersion\",\"type\":\"uint256\"}],\"name\":\"MinTeleporterVersionUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"contractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MintBridgeTokens\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"teleporterMessageID\",\"type\":\"uint256\"}],\"name\":\"SubmitCreateBridgeToken\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CREATE_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINT_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TRANSFER_BRIDGE_TOKENS_REQUIRED_GAS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WARP_PRECOMPILE_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"totalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"primaryFeeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"secondaryFeeAmount\",\"type\":\"uint256\"}],\"name\":\"bridgeTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"bridgedBalances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"nativeName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"nativeSymbol\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"nativeDecimals\",\"type\":\"uint8\"}],\"name\":\"encodeCreateBridgeTokenData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"bridgeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeMintBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"nativeContractAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"encodeTransferBridgeTokensData\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nativeToWrappedTokens\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"nativeChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"nativeBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationBridgeAddress\",\"type\":\"address\"},{\"internalType\":\"contractERC20\",\"name\":\"nativeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"messageFeeAsset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"messageFeeAmount\",\"type\":\"uint256\"}],\"name\":\"submitCreateBridgeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"submittedBridgeTokenCreations\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedTokenContracts\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // ERC20BridgeABI is the input ABI used to generate the binding from. @@ -521,6 +521,37 @@ func (_ERC20Bridge *ERC20BridgeCallerSession) NativeToWrappedTokens(arg0 [32]byt return _ERC20Bridge.Contract.NativeToWrappedTokens(&_ERC20Bridge.CallOpts, arg0, arg1, arg2) } +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ERC20Bridge *ERC20BridgeCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ERC20Bridge.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ERC20Bridge *ERC20BridgeSession) Owner() (common.Address, error) { + return _ERC20Bridge.Contract.Owner(&_ERC20Bridge.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ERC20Bridge *ERC20BridgeCallerSession) Owner() (common.Address, error) { + return _ERC20Bridge.Contract.Owner(&_ERC20Bridge.CallOpts) +} + // SubmittedBridgeTokenCreations is a free data retrieval call binding the contract method 0x8343f661. // // Solidity: function submittedBridgeTokenCreations(bytes32 , address , address ) view returns(bool) @@ -656,6 +687,27 @@ func (_ERC20Bridge *ERC20BridgeTransactorSession) ReceiveTeleporterMessage(nativ return _ERC20Bridge.Contract.ReceiveTeleporterMessage(&_ERC20Bridge.TransactOpts, nativeChainID, nativeBridgeAddress, message) } +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ERC20Bridge *ERC20BridgeTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ERC20Bridge.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ERC20Bridge *ERC20BridgeSession) RenounceOwnership() (*types.Transaction, error) { + return _ERC20Bridge.Contract.RenounceOwnership(&_ERC20Bridge.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ERC20Bridge *ERC20BridgeTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _ERC20Bridge.Contract.RenounceOwnership(&_ERC20Bridge.TransactOpts) +} + // SubmitCreateBridgeToken is a paid mutator transaction binding the contract method 0x6c7e40d1. // // Solidity: function submitCreateBridgeToken(bytes32 destinationChainID, address destinationBridgeAddress, address nativeToken, address messageFeeAsset, uint256 messageFeeAmount) returns() @@ -677,6 +729,27 @@ func (_ERC20Bridge *ERC20BridgeTransactorSession) SubmitCreateBridgeToken(destin return _ERC20Bridge.Contract.SubmitCreateBridgeToken(&_ERC20Bridge.TransactOpts, destinationChainID, destinationBridgeAddress, nativeToken, messageFeeAsset, messageFeeAmount) } +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ERC20Bridge *ERC20BridgeTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _ERC20Bridge.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ERC20Bridge *ERC20BridgeSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ERC20Bridge.Contract.TransferOwnership(&_ERC20Bridge.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ERC20Bridge *ERC20BridgeTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ERC20Bridge.Contract.TransferOwnership(&_ERC20Bridge.TransactOpts, newOwner) +} + // UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. // // Solidity: function updateMinTeleporterVersion() returns() @@ -1325,6 +1398,159 @@ func (_ERC20Bridge *ERC20BridgeFilterer) ParseMintBridgeTokens(log types.Log) (* return event, nil } +// ERC20BridgeOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the ERC20Bridge contract. +type ERC20BridgeOwnershipTransferredIterator struct { + Event *ERC20BridgeOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub interfaces.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ERC20BridgeOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ERC20BridgeOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ERC20BridgeOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ERC20BridgeOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ERC20BridgeOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ERC20BridgeOwnershipTransferred represents a OwnershipTransferred event raised by the ERC20Bridge contract. +type ERC20BridgeOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ERC20Bridge *ERC20BridgeFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ERC20BridgeOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ERC20Bridge.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &ERC20BridgeOwnershipTransferredIterator{contract: _ERC20Bridge.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ERC20Bridge *ERC20BridgeFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ERC20BridgeOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ERC20Bridge.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ERC20BridgeOwnershipTransferred) + if err := _ERC20Bridge.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ERC20Bridge *ERC20BridgeFilterer) ParseOwnershipTransferred(log types.Log) (*ERC20BridgeOwnershipTransferred, error) { + event := new(ERC20BridgeOwnershipTransferred) + if err := _ERC20Bridge.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + // ERC20BridgeSubmitCreateBridgeTokenIterator is returned from FilterSubmitCreateBridgeToken and is used to iterate over the raw logs and unpacked data for SubmitCreateBridgeToken events raised by the ERC20Bridge contract. type ERC20BridgeSubmitCreateBridgeTokenIterator struct { Event *ERC20BridgeSubmitCreateBridgeToken // Event containing the contract specifics and raw log diff --git a/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go b/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go index f852d7030..10b22f7b2 100644 --- a/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go +++ b/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher/BlockHashPublisher.go @@ -31,7 +31,7 @@ var ( // BlockHashPublisherMetaData contains all meta data concerning the BlockHashPublisher contract. var BlockHashPublisherMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldMinTeleporterVersion\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"newMinTeleporterVersion\",\"type\":\"uint256\"}],\"name\":\"MinTeleporterVersionUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"PublishBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"RECEIVE_BLOCK_HASH_REQUIRED_GAS_LIMIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"}],\"name\":\"publishLatestBlockHash\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"PublishBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"RECEIVE_BLOCK_HASH_REQUIRED_GAS_LIMIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"}],\"name\":\"publishLatestBlockHash\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // BlockHashPublisherABI is the input ABI used to generate the binding from. @@ -211,37 +211,6 @@ func (_BlockHashPublisher *BlockHashPublisherCallerSession) RECEIVEBLOCKHASHREQU return _BlockHashPublisher.Contract.RECEIVEBLOCKHASHREQUIREDGASLIMIT(&_BlockHashPublisher.CallOpts) } -// MinTeleporterVersion is a free data retrieval call binding the contract method 0xe49cc553. -// -// Solidity: function minTeleporterVersion() view returns(uint256) -func (_BlockHashPublisher *BlockHashPublisherCaller) MinTeleporterVersion(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _BlockHashPublisher.contract.Call(opts, &out, "minTeleporterVersion") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// MinTeleporterVersion is a free data retrieval call binding the contract method 0xe49cc553. -// -// Solidity: function minTeleporterVersion() view returns(uint256) -func (_BlockHashPublisher *BlockHashPublisherSession) MinTeleporterVersion() (*big.Int, error) { - return _BlockHashPublisher.Contract.MinTeleporterVersion(&_BlockHashPublisher.CallOpts) -} - -// MinTeleporterVersion is a free data retrieval call binding the contract method 0xe49cc553. -// -// Solidity: function minTeleporterVersion() view returns(uint256) -func (_BlockHashPublisher *BlockHashPublisherCallerSession) MinTeleporterVersion() (*big.Int, error) { - return _BlockHashPublisher.Contract.MinTeleporterVersion(&_BlockHashPublisher.CallOpts) -} - // TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. // // Solidity: function teleporterRegistry() view returns(address) @@ -294,180 +263,6 @@ func (_BlockHashPublisher *BlockHashPublisherTransactorSession) PublishLatestBlo return _BlockHashPublisher.Contract.PublishLatestBlockHash(&_BlockHashPublisher.TransactOpts, destinationChainID, destinationAddress) } -// UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. -// -// Solidity: function updateMinTeleporterVersion() returns() -func (_BlockHashPublisher *BlockHashPublisherTransactor) UpdateMinTeleporterVersion(opts *bind.TransactOpts) (*types.Transaction, error) { - return _BlockHashPublisher.contract.Transact(opts, "updateMinTeleporterVersion") -} - -// UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. -// -// Solidity: function updateMinTeleporterVersion() returns() -func (_BlockHashPublisher *BlockHashPublisherSession) UpdateMinTeleporterVersion() (*types.Transaction, error) { - return _BlockHashPublisher.Contract.UpdateMinTeleporterVersion(&_BlockHashPublisher.TransactOpts) -} - -// UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. -// -// Solidity: function updateMinTeleporterVersion() returns() -func (_BlockHashPublisher *BlockHashPublisherTransactorSession) UpdateMinTeleporterVersion() (*types.Transaction, error) { - return _BlockHashPublisher.Contract.UpdateMinTeleporterVersion(&_BlockHashPublisher.TransactOpts) -} - -// BlockHashPublisherMinTeleporterVersionUpdatedIterator is returned from FilterMinTeleporterVersionUpdated and is used to iterate over the raw logs and unpacked data for MinTeleporterVersionUpdated events raised by the BlockHashPublisher contract. -type BlockHashPublisherMinTeleporterVersionUpdatedIterator struct { - Event *BlockHashPublisherMinTeleporterVersionUpdated // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub interfaces.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *BlockHashPublisherMinTeleporterVersionUpdatedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(BlockHashPublisherMinTeleporterVersionUpdated) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(BlockHashPublisherMinTeleporterVersionUpdated) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *BlockHashPublisherMinTeleporterVersionUpdatedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *BlockHashPublisherMinTeleporterVersionUpdatedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// BlockHashPublisherMinTeleporterVersionUpdated represents a MinTeleporterVersionUpdated event raised by the BlockHashPublisher contract. -type BlockHashPublisherMinTeleporterVersionUpdated struct { - OldMinTeleporterVersion *big.Int - NewMinTeleporterVersion *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterMinTeleporterVersionUpdated is a free log retrieval operation binding the contract event 0xa9a7ef57e41f05b4c15480842f5f0c27edfcbb553fed281f7c4068452cc1c02d. -// -// Solidity: event MinTeleporterVersionUpdated(uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion) -func (_BlockHashPublisher *BlockHashPublisherFilterer) FilterMinTeleporterVersionUpdated(opts *bind.FilterOpts, oldMinTeleporterVersion []*big.Int, newMinTeleporterVersion []*big.Int) (*BlockHashPublisherMinTeleporterVersionUpdatedIterator, error) { - - var oldMinTeleporterVersionRule []interface{} - for _, oldMinTeleporterVersionItem := range oldMinTeleporterVersion { - oldMinTeleporterVersionRule = append(oldMinTeleporterVersionRule, oldMinTeleporterVersionItem) - } - var newMinTeleporterVersionRule []interface{} - for _, newMinTeleporterVersionItem := range newMinTeleporterVersion { - newMinTeleporterVersionRule = append(newMinTeleporterVersionRule, newMinTeleporterVersionItem) - } - - logs, sub, err := _BlockHashPublisher.contract.FilterLogs(opts, "MinTeleporterVersionUpdated", oldMinTeleporterVersionRule, newMinTeleporterVersionRule) - if err != nil { - return nil, err - } - return &BlockHashPublisherMinTeleporterVersionUpdatedIterator{contract: _BlockHashPublisher.contract, event: "MinTeleporterVersionUpdated", logs: logs, sub: sub}, nil -} - -// WatchMinTeleporterVersionUpdated is a free log subscription operation binding the contract event 0xa9a7ef57e41f05b4c15480842f5f0c27edfcbb553fed281f7c4068452cc1c02d. -// -// Solidity: event MinTeleporterVersionUpdated(uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion) -func (_BlockHashPublisher *BlockHashPublisherFilterer) WatchMinTeleporterVersionUpdated(opts *bind.WatchOpts, sink chan<- *BlockHashPublisherMinTeleporterVersionUpdated, oldMinTeleporterVersion []*big.Int, newMinTeleporterVersion []*big.Int) (event.Subscription, error) { - - var oldMinTeleporterVersionRule []interface{} - for _, oldMinTeleporterVersionItem := range oldMinTeleporterVersion { - oldMinTeleporterVersionRule = append(oldMinTeleporterVersionRule, oldMinTeleporterVersionItem) - } - var newMinTeleporterVersionRule []interface{} - for _, newMinTeleporterVersionItem := range newMinTeleporterVersion { - newMinTeleporterVersionRule = append(newMinTeleporterVersionRule, newMinTeleporterVersionItem) - } - - logs, sub, err := _BlockHashPublisher.contract.WatchLogs(opts, "MinTeleporterVersionUpdated", oldMinTeleporterVersionRule, newMinTeleporterVersionRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(BlockHashPublisherMinTeleporterVersionUpdated) - if err := _BlockHashPublisher.contract.UnpackLog(event, "MinTeleporterVersionUpdated", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseMinTeleporterVersionUpdated is a log parse operation binding the contract event 0xa9a7ef57e41f05b4c15480842f5f0c27edfcbb553fed281f7c4068452cc1c02d. -// -// Solidity: event MinTeleporterVersionUpdated(uint256 indexed oldMinTeleporterVersion, uint256 indexed newMinTeleporterVersion) -func (_BlockHashPublisher *BlockHashPublisherFilterer) ParseMinTeleporterVersionUpdated(log types.Log) (*BlockHashPublisherMinTeleporterVersionUpdated, error) { - event := new(BlockHashPublisherMinTeleporterVersionUpdated) - if err := _BlockHashPublisher.contract.UnpackLog(event, "MinTeleporterVersionUpdated", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - // BlockHashPublisherPublishBlockHashIterator is returned from FilterPublishBlockHash and is used to iterate over the raw logs and unpacked data for PublishBlockHash events raised by the BlockHashPublisher contract. type BlockHashPublisherPublishBlockHashIterator struct { Event *BlockHashPublisherPublishBlockHash // Event containing the contract specifics and raw log From 261e50e21e247609b9436c126f045dcd57cc746d Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 25 Oct 2023 22:01:41 +0000 Subject: [PATCH 67/80] add test for erc20Bridge updateMinTeleporterVersion --- .../ERC20Bridge/tests/ERC20BridgeTests.t.sol | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol index 97b122fca..e60cb1aa5 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol @@ -631,6 +631,29 @@ contract ERC20BridgeTest is Test { new ERC20Bridge(address(0)); } + function testUpdateMinTeleporterVersion() public { + // Check that updating minimum Teleporter version fails if it's not the contract owner. + vm.prank(address(0)); + vm.expectRevert("Ownable: caller is not the owner"); + erc20Bridge.updateMinTeleporterVersion(); + + // Check that the owner can update the minimum Teleporter version. + vm.mockCall( + MOCK_TELEPORTER_REGISTRY_ADDRESS, + abi.encodeWithSelector( + WarpProtocolRegistry.getLatestVersion.selector + ), + abi.encode(2) + ); + vm.expectCall( + MOCK_TELEPORTER_REGISTRY_ADDRESS, + abi.encodeWithSelector( + WarpProtocolRegistry.getLatestVersion.selector + ) + ); + erc20Bridge.updateMinTeleporterVersion(); + } + function _initMockTeleporterRegistry() internal { vm.mockCall( MOCK_TELEPORTER_REGISTRY_ADDRESS, From 7935ed073c4e93f9f611a90865214b7bc4c90639 Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Wed, 25 Oct 2023 16:05:48 -0700 Subject: [PATCH 68/80] Update contracts/src/Teleporter/upgrades/README.md Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- contracts/src/Teleporter/upgrades/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/upgrades/README.md b/contracts/src/Teleporter/upgrades/README.md index 61731f4f1..afc168987 100644 --- a/contracts/src/Teleporter/upgrades/README.md +++ b/contracts/src/Teleporter/upgrades/README.md @@ -6,7 +6,7 @@ The `TeleporterMessenger` contract is non-upgradable, once a version of the cont However, there could still be new versions of `TeleporterMessenger` contracts needed to be deployed in the future. `TeleporterRegistry` provides applications that use a `TeleporterMessenger` instance a minimal step process to integrate with new versions of `TeleporterMessenger`. -The `TeleporterRegistry` maintains a mapping of `TeleporterMessenger` contract versions to their addresses. When a new `TeleporterMessenger` version is deployed, it's address can be added to the `TeleporterRegistry`. The `TeleporterRegistry` can only be updated through a Warp out-of-band message that meets the following requirements: +The `TeleporterRegistry` maintains a mapping of `TeleporterMessenger` contract versions to their addresses. When a new `TeleporterMessenger` version is deployed, its address can be added to the `TeleporterRegistry`. The `TeleporterRegistry` can only be updated through a Warp out-of-band message that meets the following requirements: - `sourceChainAddress` must match `VALIDATORS_SOURCE_ADDRESS = address(0)` - The zero address can only be set as the source chain address by a Warp out-of-band message, and cannot be set by an on-chain Warp message. From 4d37ee326ebc701aafa10b96fb70fc7df92f5f86 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 25 Oct 2023 23:20:13 +0000 Subject: [PATCH 69/80] * make BlockHashReceiver Ownable * remove virtual from onlyAllowedTeleporter * documentation for example cross chain messenger updateMinTeleporterVersion --- .../ExampleMessenger/ExampleCrossChainMessenger.sol | 4 +++- .../VerifiedBlockHash/BlockHashReceiver.sol | 13 +++++++++---- .../Teleporter/upgrades/TeleporterUpgradeable.sol | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol b/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol index e33af775b..6bbe97c75 100644 --- a/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol +++ b/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol @@ -128,7 +128,9 @@ contract ExampleCrossChainMessenger is * @dev See {TeleporterUpgradeable-updateMinTeleporterVersion} * * Updates the minimum Teleporter version allowed for receiving on this contract - * to the latest version registered in the {TeleporterRegistry}. + * to the latest version registered in the {TeleporterRegistry}. We do not have + * access controls for this example messenger so anyone can call the function to update `minTeleporterVersion`, + * and disallow messages from old Teleporter versions from being received. * * Emits a {MinTeleporterVersionUpdated} event. */ diff --git a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol index 391633abd..6fc326a66 100644 --- a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol +++ b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol @@ -9,11 +9,16 @@ import "../../Teleporter/ITeleporterMessenger.sol"; import "../../Teleporter/ITeleporterReceiver.sol"; import "../../Teleporter/upgrades/TeleporterRegistry.sol"; import "../../Teleporter/upgrades/TeleporterUpgradeable.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; /** * Contract for receiving latest block hashes from another chain. */ -contract BlockHashReceiver is ITeleporterReceiver, TeleporterUpgradeable { +contract BlockHashReceiver is + ITeleporterReceiver, + TeleporterUpgradeable, + Ownable +{ // Source chain information bytes32 public immutable sourceChainID; address public immutable sourcePublisherContractAddress; @@ -87,11 +92,11 @@ contract BlockHashReceiver is ITeleporterReceiver, TeleporterUpgradeable { * @dev See {TeleporterUpgradeable-updateMinTeleporterVersion} * * Updates the minimum Teleporter version allowed for receiving on this contract - * to the latest version registered in the {TeleporterRegistry}. - * + * to the latest version registered in the {TeleporterRegistry}. Also restricts this function to + * the owner of this contract. * Emits a {MinTeleporterVersionUpdated} event. */ - function updateMinTeleporterVersion() external override { + function updateMinTeleporterVersion() external override onlyOwner { uint256 oldMinTeleporterVersion = minTeleporterVersion; minTeleporterVersion = teleporterRegistry.getLatestVersion(); emit MinTeleporterVersionUpdated( diff --git a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol index 1eab9c143..9e1be2c81 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol @@ -28,7 +28,7 @@ abstract contract TeleporterUpgradeable { * @dev Throws if called by a `msg.sender` that is not an allowed Teleporter version. * Checks that `msg.sender` matches a Teleporter version greater than or equal to `minTeleporterVersion`. */ - modifier onlyAllowedTeleporter() virtual { + modifier onlyAllowedTeleporter() { require( teleporterRegistry.getVersionFromAddress(msg.sender) >= minTeleporterVersion, From 70c80d0428ac2c36f12adbfd76e03af3df8539c9 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 25 Oct 2023 23:25:45 +0000 Subject: [PATCH 70/80] update doc for updateMinTeleporterVersion --- contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol | 3 --- 1 file changed, 3 deletions(-) diff --git a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol index 9e1be2c81..f7715850a 100644 --- a/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol +++ b/contracts/src/Teleporter/upgrades/TeleporterUpgradeable.sol @@ -54,9 +54,6 @@ abstract contract TeleporterUpgradeable { /** * @dev This is a virtual function that should be overridden to update the `minTeleporterVersion` * allowed for modifier `onlyAllowedTeleporter`, and emit {MinTeleporterVersionUpdated} event after. - * The derived contract should call this function after there is a new Teleporter version - * registered in the `TeleporterRegistry`, and the derived contract no longer needs to receive - * messages from the previous Teleporter versions. * * Note: To prevent anyone from being able to call this function, which would disallow messages * from old Teleporter versions from being received, this function should be safeguarded with access From 834b677c421264344f3f43cc67187238fa6421ec Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 25 Oct 2023 23:28:24 +0000 Subject: [PATCH 71/80] update blockHashReceiver bindings --- .../BlockHashReceiver/BlockHashReceiver.go | 228 +++++++++++++++++- 1 file changed, 227 insertions(+), 1 deletion(-) diff --git a/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go b/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go index 8c3273c10..e57771c63 100644 --- a/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go +++ b/abi-bindings/go/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver/BlockHashReceiver.go @@ -31,7 +31,7 @@ var ( // BlockHashReceiverMetaData contains all meta data concerning the BlockHashReceiver contract. var BlockHashReceiverMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"publisherChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"publisherContractAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldMinTeleporterVersion\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"newMinTeleporterVersion\",\"type\":\"uint256\"}],\"name\":\"MinTeleporterVersionUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"getLatestBlockInfo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"height\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourceChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourcePublisherContractAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"publisherChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"publisherContractAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldMinTeleporterVersion\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"newMinTeleporterVersion\",\"type\":\"uint256\"}],\"name\":\"MinTeleporterVersionUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"getLatestBlockInfo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"height\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestBlockHeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourceChainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourcePublisherContractAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // BlockHashReceiverABI is the input ABI used to generate the binding from. @@ -318,6 +318,37 @@ func (_BlockHashReceiver *BlockHashReceiverCallerSession) MinTeleporterVersion() return _BlockHashReceiver.Contract.MinTeleporterVersion(&_BlockHashReceiver.CallOpts) } +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_BlockHashReceiver *BlockHashReceiverCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _BlockHashReceiver.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_BlockHashReceiver *BlockHashReceiverSession) Owner() (common.Address, error) { + return _BlockHashReceiver.Contract.Owner(&_BlockHashReceiver.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_BlockHashReceiver *BlockHashReceiverCallerSession) Owner() (common.Address, error) { + return _BlockHashReceiver.Contract.Owner(&_BlockHashReceiver.CallOpts) +} + // SourceChainID is a free data retrieval call binding the contract method 0x4c335368. // // Solidity: function sourceChainID() view returns(bytes32) @@ -432,6 +463,48 @@ func (_BlockHashReceiver *BlockHashReceiverTransactorSession) ReceiveTeleporterM return _BlockHashReceiver.Contract.ReceiveTeleporterMessage(&_BlockHashReceiver.TransactOpts, originChainID, originSenderAddress, message) } +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_BlockHashReceiver *BlockHashReceiverTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _BlockHashReceiver.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_BlockHashReceiver *BlockHashReceiverSession) RenounceOwnership() (*types.Transaction, error) { + return _BlockHashReceiver.Contract.RenounceOwnership(&_BlockHashReceiver.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_BlockHashReceiver *BlockHashReceiverTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _BlockHashReceiver.Contract.RenounceOwnership(&_BlockHashReceiver.TransactOpts) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_BlockHashReceiver *BlockHashReceiverTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _BlockHashReceiver.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_BlockHashReceiver *BlockHashReceiverSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _BlockHashReceiver.Contract.TransferOwnership(&_BlockHashReceiver.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_BlockHashReceiver *BlockHashReceiverTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _BlockHashReceiver.Contract.TransferOwnership(&_BlockHashReceiver.TransactOpts, newOwner) +} + // UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. // // Solidity: function updateMinTeleporterVersion() returns() @@ -606,6 +679,159 @@ func (_BlockHashReceiver *BlockHashReceiverFilterer) ParseMinTeleporterVersionUp return event, nil } +// BlockHashReceiverOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the BlockHashReceiver contract. +type BlockHashReceiverOwnershipTransferredIterator struct { + Event *BlockHashReceiverOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub interfaces.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *BlockHashReceiverOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(BlockHashReceiverOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(BlockHashReceiverOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *BlockHashReceiverOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *BlockHashReceiverOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// BlockHashReceiverOwnershipTransferred represents a OwnershipTransferred event raised by the BlockHashReceiver contract. +type BlockHashReceiverOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_BlockHashReceiver *BlockHashReceiverFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*BlockHashReceiverOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _BlockHashReceiver.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &BlockHashReceiverOwnershipTransferredIterator{contract: _BlockHashReceiver.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_BlockHashReceiver *BlockHashReceiverFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *BlockHashReceiverOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _BlockHashReceiver.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(BlockHashReceiverOwnershipTransferred) + if err := _BlockHashReceiver.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_BlockHashReceiver *BlockHashReceiverFilterer) ParseOwnershipTransferred(log types.Log) (*BlockHashReceiverOwnershipTransferred, error) { + event := new(BlockHashReceiverOwnershipTransferred) + if err := _BlockHashReceiver.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + // BlockHashReceiverReceiveBlockHashIterator is returned from FilterReceiveBlockHash and is used to iterate over the raw logs and unpacked data for ReceiveBlockHash events raised by the BlockHashReceiver contract. type BlockHashReceiverReceiveBlockHashIterator struct { Event *BlockHashReceiverReceiveBlockHash // Event containing the contract specifics and raw log From 6d0712a93a40e8d4320ff6b289c93e68637fed98 Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Thu, 26 Oct 2023 11:29:52 -0700 Subject: [PATCH 72/80] Update contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol Co-authored-by: Michael Kaplan <55204436+michaelkaplan13@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- .../src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol index 926efa675..c180ca71f 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol @@ -328,8 +328,8 @@ contract ERC20Bridge is * @dev See {TeleporterUpgradeable-updateMinTeleporterVersion} * * Updates the minimum Teleporter version allowed for receiving on this contract - * to the latest version registered in the {TeleporterRegistry}. Also restricts this function to - * the owner of this contract. + * to the latest version registered in the {TeleporterRegistry}. + * Restricted to only owners of the contract. * Emits a {MinTeleporterVersionUpdated} event. */ function updateMinTeleporterVersion() external override onlyOwner { From 5c7c940cad86ed204756db9fe9b2938f1f95fa80 Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Thu, 26 Oct 2023 11:30:07 -0700 Subject: [PATCH 73/80] Update contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol Co-authored-by: Michael Kaplan <55204436+michaelkaplan13@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- .../VerifiedBlockHash/BlockHashReceiver.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol index 6fc326a66..e7d902f91 100644 --- a/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol +++ b/contracts/src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol @@ -92,8 +92,8 @@ contract BlockHashReceiver is * @dev See {TeleporterUpgradeable-updateMinTeleporterVersion} * * Updates the minimum Teleporter version allowed for receiving on this contract - * to the latest version registered in the {TeleporterRegistry}. Also restricts this function to - * the owner of this contract. + * to the latest version registered in the {TeleporterRegistry}. + * Restricted to only owners of the contract. * Emits a {MinTeleporterVersionUpdated} event. */ function updateMinTeleporterVersion() external override onlyOwner { From 24610ad26a47db0b18c4c1b5090b912fa7565782 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Thu, 26 Oct 2023 18:39:16 +0000 Subject: [PATCH 74/80] exampleCrossChainMessenger ownable --- .../ExampleMessenger/ExampleCrossChainMessenger.sol | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol b/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol index 6bbe97c75..0fcd28801 100644 --- a/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol +++ b/contracts/src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol @@ -12,6 +12,7 @@ import "../../Teleporter/upgrades/TeleporterRegistry.sol"; import "../../Teleporter/upgrades/TeleporterUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; /** * @dev ExampleCrossChainMessenger is an example contract that demonstrates how to send and receive @@ -20,7 +21,8 @@ import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; contract ExampleCrossChainMessenger is ITeleporterReceiver, ReentrancyGuard, - TeleporterUpgradeable + TeleporterUpgradeable, + Ownable { using SafeERC20 for IERC20; @@ -128,13 +130,11 @@ contract ExampleCrossChainMessenger is * @dev See {TeleporterUpgradeable-updateMinTeleporterVersion} * * Updates the minimum Teleporter version allowed for receiving on this contract - * to the latest version registered in the {TeleporterRegistry}. We do not have - * access controls for this example messenger so anyone can call the function to update `minTeleporterVersion`, - * and disallow messages from old Teleporter versions from being received. - * + * to the latest version registered in the {TeleporterRegistry}. Also restricts this function to + * the owner of this contract. * Emits a {MinTeleporterVersionUpdated} event. */ - function updateMinTeleporterVersion() external override { + function updateMinTeleporterVersion() external override onlyOwner { uint256 oldMinTeleporterVersion = minTeleporterVersion; minTeleporterVersion = teleporterRegistry.getLatestVersion(); emit MinTeleporterVersionUpdated( From 791d9d85e4b2fd444e491bc97619a22f46c919da Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Thu, 26 Oct 2023 18:39:33 +0000 Subject: [PATCH 75/80] update unit test and doc --- .../ERC20Bridge/tests/ERC20BridgeTests.t.sol | 8 ++++++++ contracts/src/WarpProtocolRegistry.sol | 12 ++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol index e60cb1aa5..84237b6dc 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol @@ -61,6 +61,11 @@ contract ERC20BridgeTest is Test { uint256 amount ); + event MinTeleporterVersionUpdated( + uint256 indexed oldMinTeleporterVersion, + uint256 indexed newMinTeleporterVersion + ); + function setUp() public virtual { vm.mockCall( WARP_PRECOMPILE_ADDRESS, @@ -651,6 +656,9 @@ contract ERC20BridgeTest is Test { WarpProtocolRegistry.getLatestVersion.selector ) ); + + vm.expectEmit(true, true, true, true, address(erc20Bridge)); + emit MinTeleporterVersionUpdated(1, 2); erc20Bridge.updateMinTeleporterVersion(); } diff --git a/contracts/src/WarpProtocolRegistry.sol b/contracts/src/WarpProtocolRegistry.sol index 5310b5c57..2ec5dc642 100644 --- a/contracts/src/WarpProtocolRegistry.sol +++ b/contracts/src/WarpProtocolRegistry.sol @@ -72,12 +72,12 @@ abstract contract WarpProtocolRegistry { * Requirements: * * - a valid Warp out-of-band message must be provided. - * - Message source chain ID must be the same as the blockchain ID of the registry. - * - Message origin sender address must be the same as the `VALIDATORS_SOURCE_ADDRESS`. - * - Message destination chain ID must be the same as the blockchain ID of the registry. - * - Message destination address must be the same as the address of the registry. - * - the version must not be zero. - * - the version must not already be registered. + * - source chain ID must be the same as the blockchain ID of the registry. + * - origin sender address must be the same as the `VALIDATORS_SOURCE_ADDRESS`. + * - destination chain ID must be the same as the blockchain ID of the registry. + * - destination address must be the same as the address of the registry. + * - version must not be zero. + * - version must not already be registered. * - protocol address must not be zero address. */ function addProtocolVersion(uint32 messageIndex) external virtual { From c64d13fc45c9c29bc2bd0549fb87c161b64ead8b Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Thu, 26 Oct 2023 18:40:55 +0000 Subject: [PATCH 76/80] extra assert for unit test --- .../ERC20Bridge/tests/ERC20BridgeTests.t.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol index 84237b6dc..57de69358 100644 --- a/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol +++ b/contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol @@ -660,6 +660,7 @@ contract ERC20BridgeTest is Test { vm.expectEmit(true, true, true, true, address(erc20Bridge)); emit MinTeleporterVersionUpdated(1, 2); erc20Bridge.updateMinTeleporterVersion(); + assertEq(erc20Bridge.minTeleporterVersion(), 2); } function _initMockTeleporterRegistry() internal { From 0711b2f47a68bfd9405b828f3be70d351694811c Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Thu, 26 Oct 2023 19:31:42 +0000 Subject: [PATCH 77/80] update bindings --- .../ExampleCrossChainMessenger.go | 228 +++++++++++++++++- 1 file changed, 227 insertions(+), 1 deletion(-) diff --git a/abi-bindings/go/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go b/abi-bindings/go/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go index 577daf068..b6b3f54cd 100644 --- a/abi-bindings/go/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go +++ b/abi-bindings/go/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go @@ -31,7 +31,7 @@ var ( // ExampleCrossChainMessengerMetaData contains all meta data concerning the ExampleCrossChainMessenger contract. var ExampleCrossChainMessengerMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldMinTeleporterVersion\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"newMinTeleporterVersion\",\"type\":\"uint256\"}],\"name\":\"MinTeleporterVersionUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"ReceiveMessage\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeAsset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"SendMessage\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"}],\"name\":\"getCurrentMessage\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeContractAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"sendMessage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"teleporterRegistryAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"oldMinTeleporterVersion\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"newMinTeleporterVersion\",\"type\":\"uint256\"}],\"name\":\"MinTeleporterVersionUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"ReceiveMessage\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeAsset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"SendMessage\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"}],\"name\":\"getCurrentMessage\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minTeleporterVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"originSenderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"receiveTeleporterMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationChainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeContractAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"sendMessage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"teleporterRegistry\",\"outputs\":[{\"internalType\":\"contractTeleporterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateMinTeleporterVersion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // ExampleCrossChainMessengerABI is the input ABI used to generate the binding from. @@ -256,6 +256,37 @@ func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCallerSession) MinT return _ExampleCrossChainMessenger.Contract.MinTeleporterVersion(&_ExampleCrossChainMessenger.CallOpts) } +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ExampleCrossChainMessenger.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerSession) Owner() (common.Address, error) { + return _ExampleCrossChainMessenger.Contract.Owner(&_ExampleCrossChainMessenger.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerCallerSession) Owner() (common.Address, error) { + return _ExampleCrossChainMessenger.Contract.Owner(&_ExampleCrossChainMessenger.CallOpts) +} + // TeleporterRegistry is a free data retrieval call binding the contract method 0x1a7f5bec. // // Solidity: function teleporterRegistry() view returns(address) @@ -308,6 +339,27 @@ func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerTransactorSession) return _ExampleCrossChainMessenger.Contract.ReceiveTeleporterMessage(&_ExampleCrossChainMessenger.TransactOpts, originChainID, originSenderAddress, message) } +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ExampleCrossChainMessenger.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerSession) RenounceOwnership() (*types.Transaction, error) { + return _ExampleCrossChainMessenger.Contract.RenounceOwnership(&_ExampleCrossChainMessenger.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _ExampleCrossChainMessenger.Contract.RenounceOwnership(&_ExampleCrossChainMessenger.TransactOpts) +} + // SendMessage is a paid mutator transaction binding the contract method 0xf63d09d7. // // Solidity: function sendMessage(bytes32 destinationChainID, address destinationAddress, address feeContractAddress, uint256 feeAmount, uint256 requiredGasLimit, string message) returns(uint256 messageID) @@ -329,6 +381,27 @@ func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerTransactorSession) return _ExampleCrossChainMessenger.Contract.SendMessage(&_ExampleCrossChainMessenger.TransactOpts, destinationChainID, destinationAddress, feeContractAddress, feeAmount, requiredGasLimit, message) } +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _ExampleCrossChainMessenger.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ExampleCrossChainMessenger.Contract.TransferOwnership(&_ExampleCrossChainMessenger.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ExampleCrossChainMessenger.Contract.TransferOwnership(&_ExampleCrossChainMessenger.TransactOpts, newOwner) +} + // UpdateMinTeleporterVersion is a paid mutator transaction binding the contract method 0xb6109d9d. // // Solidity: function updateMinTeleporterVersion() returns() @@ -503,6 +576,159 @@ func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerFilterer) ParseMinT return event, nil } +// ExampleCrossChainMessengerOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the ExampleCrossChainMessenger contract. +type ExampleCrossChainMessengerOwnershipTransferredIterator struct { + Event *ExampleCrossChainMessengerOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub interfaces.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ExampleCrossChainMessengerOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ExampleCrossChainMessengerOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ExampleCrossChainMessengerOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ExampleCrossChainMessengerOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ExampleCrossChainMessengerOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ExampleCrossChainMessengerOwnershipTransferred represents a OwnershipTransferred event raised by the ExampleCrossChainMessenger contract. +type ExampleCrossChainMessengerOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ExampleCrossChainMessengerOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ExampleCrossChainMessenger.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &ExampleCrossChainMessengerOwnershipTransferredIterator{contract: _ExampleCrossChainMessenger.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ExampleCrossChainMessengerOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ExampleCrossChainMessenger.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ExampleCrossChainMessengerOwnershipTransferred) + if err := _ExampleCrossChainMessenger.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ExampleCrossChainMessenger *ExampleCrossChainMessengerFilterer) ParseOwnershipTransferred(log types.Log) (*ExampleCrossChainMessengerOwnershipTransferred, error) { + event := new(ExampleCrossChainMessengerOwnershipTransferred) + if err := _ExampleCrossChainMessenger.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + // ExampleCrossChainMessengerReceiveMessageIterator is returned from FilterReceiveMessage and is used to iterate over the raw logs and unpacked data for ReceiveMessage events raised by the ExampleCrossChainMessenger contract. type ExampleCrossChainMessengerReceiveMessageIterator struct { Event *ExampleCrossChainMessengerReceiveMessage // Event containing the contract specifics and raw log From f4f27bb5504529c71792aa21ef661fb87e97cd0f Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Fri, 27 Oct 2023 15:59:24 +0000 Subject: [PATCH 78/80] update go work sum --- go.work.sum | 3 +++ 1 file changed, 3 insertions(+) diff --git a/go.work.sum b/go.work.sum index 8c48d0e40..d231741aa 100644 --- a/go.work.sum +++ b/go.work.sum @@ -887,6 +887,7 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= @@ -905,9 +906,11 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= From 000a894789d2c9d6b5e4dc4a086df29f676d2e40 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Fri, 27 Oct 2023 20:22:42 +0000 Subject: [PATCH 79/80] move --constructor-args to last argument --- docker/run_setup.sh | 12 ++++++------ .../block_hash_publish_receive.sh | 8 ++++---- .../integration-tests/erc20_bridge_multihop.sh | 15 +++++++++------ .../local/integration-tests/example_messenger.sh | 8 ++++---- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/docker/run_setup.sh b/docker/run_setup.sh index 105ca9aaa..811cdd482 100755 --- a/docker/run_setup.sh +++ b/docker/run_setup.sh @@ -135,18 +135,18 @@ if [ ! -e $dir_prefix/NETWORK_RUNNING ]; then # Deploy TeleporterRegistry to each chain. cd contracts - registry_deploy_result_a=$(forge create --private-key $user_private_key --constructor-args "[(1,$teleporter_contract_address)]" \ - --rpc-url $subnet_a_url src/Teleporter/upgrades/TeleporterRegistry.sol:TeleporterRegistry) + registry_deploy_result_a=$(forge create --private-key $user_private_key \ + --rpc-url $subnet_a_url src/Teleporter/upgrades/TeleporterRegistry.sol:TeleporterRegistry --constructor-args "[(1,$teleporter_contract_address)]") registry_address_a=$(parseContractAddress "$registry_deploy_result_a") echo "TeleporterRegistry contract deployed to subnet A at $registry_address_a." - registry_deploy_result_b=$(forge create --private-key $user_private_key --constructor-args "[(1,$teleporter_contract_address)]" \ - --rpc-url $subnet_b_url src/Teleporter/upgrades/TeleporterRegistry.sol:TeleporterRegistry) + registry_deploy_result_b=$(forge create --private-key $user_private_key \ + --rpc-url $subnet_b_url src/Teleporter/upgrades/TeleporterRegistry.sol:TeleporterRegistry --constructor-args "[(1,$teleporter_contract_address)]") registry_address_b=$(parseContractAddress "$registry_deploy_result_b") echo "TeleporterRegistry contract deployed to subnet B at $registry_address_b." - registry_deploy_result_c=$(forge create --private-key $user_private_key --constructor-args "[(1,$teleporter_contract_address)]" \ - --rpc-url $subnet_c_url src/Teleporter/upgrades/TeleporterRegistry.sol:TeleporterRegistry) + registry_deploy_result_c=$(forge create --private-key $user_private_key \ + --rpc-url $subnet_c_url src/Teleporter/upgrades/TeleporterRegistry.sol:TeleporterRegistry --constructor-args "[(1,$teleporter_contract_address)]") registry_address_c=$(parseContractAddress "$registry_deploy_result_c") echo "TeleporterRegistry contract deployed to subnet C at $registry_address_c." cd .. diff --git a/scripts/local/integration-tests/block_hash_publish_receive.sh b/scripts/local/integration-tests/block_hash_publish_receive.sh index 8e9b3695e..1e0a3ee8f 100755 --- a/scripts/local/integration-tests/block_hash_publish_receive.sh +++ b/scripts/local/integration-tests/block_hash_publish_receive.sh @@ -32,15 +32,15 @@ set -e # Stop on first error # Deploy the block hash publisher to subnet A cd contracts -block_hash_publisher_deploy_result=$(forge create --private-key $user_private_key --constructor-args $registry_address_a \ - --rpc-url $subnet_a_url src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol:BlockHashPublisher) +block_hash_publisher_deploy_result=$(forge create --private-key $user_private_key \ + --rpc-url $subnet_a_url src/CrossChainApplications/VerifiedBlockHash/BlockHashPublisher.sol:BlockHashPublisher --constructor-args $registry_address_a ) block_hash_publisher_contract_address=$(parseContractAddress "$block_hash_publisher_deploy_result") echo "Block hash publisher contract deployed to subnet A at $block_hash_publisher_contract_address" # Deploy the example messenger application on subnet B block_hash_receiver_deploy_result=$(forge create --private-key $user_private_key \ - --constructor-args $registry_address_a $subnet_a_chain_id_hex $block_hash_publisher_contract_address \ - --rpc-url $subnet_b_url src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol:BlockHashReceiver) + --rpc-url $subnet_b_url src/CrossChainApplications/VerifiedBlockHash/BlockHashReceiver.sol:BlockHashReceiver \ + --constructor-args $registry_address_a $subnet_a_chain_id_hex $block_hash_publisher_contract_address) block_hash_receiver_contract_address=$(parseContractAddress "$block_hash_receiver_deploy_result") echo "Block hash receiver contract deployed to subnet B at $block_hash_receiver_contract_address" diff --git a/scripts/local/integration-tests/erc20_bridge_multihop.sh b/scripts/local/integration-tests/erc20_bridge_multihop.sh index e053d0931..d1d8e6033 100755 --- a/scripts/local/integration-tests/erc20_bridge_multihop.sh +++ b/scripts/local/integration-tests/erc20_bridge_multihop.sh @@ -44,18 +44,21 @@ native_erc20_contract_address=$(parseContractAddress "$native_erc20_deploy_resul echo "Test ERC20 contract deployed to $native_erc20_contract_address on Subnet A" # Deploy the ERC20 bridge contract to all chains. -bridge_a_deploy_result=$(forge create --private-key $user_private_key --constructor-args $registry_address_a \ - --rpc-url $subnet_a_url src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol:ERC20Bridge) +bridge_a_deploy_result=$(forge create --private-key $user_private_key \ + --rpc-url $subnet_a_url src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol:ERC20Bridge \ + --constructor-args $registry_address_a) bridge_a_address=$(parseContractAddress "$bridge_a_deploy_result") echo "ERC20 bridge contract deployed to subnet A at $bridge_a_address." -bridge_b_deploy_result=$(forge create --private-key $user_private_key --constructor-args $registry_address_b \ - --rpc-url $subnet_b_url src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol:ERC20Bridge) +bridge_b_deploy_result=$(forge create --private-key $user_private_key \ + --rpc-url $subnet_b_url src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol:ERC20Bridge \ + --constructor-args $registry_address_b) bridge_b_address=$(parseContractAddress "$bridge_b_deploy_result") echo "ERC20 bridge contract deployed to subnet B at $bridge_b_address." -bridge_c_deploy_result=$(forge create --private-key $user_private_key --constructor-args $registry_address_c \ - --rpc-url $subnet_c_url src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol:ERC20Bridge) +bridge_c_deploy_result=$(forge create --private-key $user_private_key \ + --rpc-url $subnet_c_url src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol:ERC20Bridge \ + --constructor-args $registry_address_c) bridge_c_address=$(parseContractAddress "$bridge_c_deploy_result") echo "ERC20 bridge contract deployed to subnet C at $bridge_c_address." diff --git a/scripts/local/integration-tests/example_messenger.sh b/scripts/local/integration-tests/example_messenger.sh index 2baf95efa..c4b91728b 100755 --- a/scripts/local/integration-tests/example_messenger.sh +++ b/scripts/local/integration-tests/example_messenger.sh @@ -33,14 +33,14 @@ erc20_contract_address=$(parseContractAddress "$erc20_deploy_result") echo "Test ERC20 contract deployed to $erc20_contract_address on Subnet A" # Deploy the example messenger application on subnet A -example_messenger_a_deploy_result=$(forge create --private-key $user_private_key --constructor-args $registry_address_a \ - --rpc-url $subnet_a_url src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol:ExampleCrossChainMessenger) +example_messenger_a_deploy_result=$(forge create --private-key $user_private_key \ + --rpc-url $subnet_a_url src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol:ExampleCrossChainMessenger --constructor-args $registry_address_a) example_messenger_a_contract_address=$(parseContractAddress "$example_messenger_a_deploy_result") echo "Example Messenger contract deployed to subnet A at $example_messenger_a_contract_address" # Deploy the example messenger application on subnet B -example_messenger_b_deploy_result=$(forge create --private-key $user_private_key --constructor-args $registry_address_b \ - --rpc-url $subnet_b_url src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol:ExampleCrossChainMessenger) +example_messenger_b_deploy_result=$(forge create --private-key $user_private_key \ + --rpc-url $subnet_b_url src/CrossChainApplications/ExampleMessenger/ExampleCrossChainMessenger.sol:ExampleCrossChainMessenger --constructor-args $registry_address_b) example_messenger_b_contract_address=$(parseContractAddress "$example_messenger_b_deploy_result") echo "Example Messenger contract deployed to subnet B at $example_messenger_b_contract_address" From afc114e62455128d50e5aeaedde6055beac00e00 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Mon, 30 Oct 2023 16:49:03 +0000 Subject: [PATCH 80/80] update foundry version --- docker/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index c60b4b563..31012a85e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -36,13 +36,13 @@ ENV LANG en_US.utf8 # Install foundry from specific commit SHELL ["/bin/bash", "-c"] -RUN curl -L https://raw.githubusercontent.com/foundry-rs/foundry/70d00222c2ef74fc484b8d98c5705d131ab31871/foundryup/install > /tmp/foundry-install-script && \ - sed -i 's/\/foundry-rs\/foundry\/master\/foundryup/\/foundry-rs\/foundry\/70d00222c2ef74fc484b8d98c5705d131ab31871\/foundryup/g' /tmp/foundry-install-script && \ +RUN curl -L https://raw.githubusercontent.com/foundry-rs/foundry/037b3bc9cebd545fe3a4f05a32bf7efb82afdbd8/foundryup/install > /tmp/foundry-install-script && \ + sed -i 's/\/foundry-rs\/foundry\/master\/foundryup/\/foundry-rs\/foundry\/037b3bc9cebd545fe3a4f05a32bf7efb82afdbd8\/foundryup/g' /tmp/foundry-install-script && \ cat /tmp/foundry-install-script | bash && \ echo "export PATH=\"$PATH:/$HOME/.foundry/bin\"">> ~/.bashrc && \ source ~/.bashrc && \ export PATH=$PATH:$HOME/.foundry/bin:$HOME/.cargo/bin && \ - foundryup --version nightly-70d00222c2ef74fc484b8d98c5705d131ab31871 + foundryup --version nightly-037b3bc9cebd545fe3a4f05a32bf7efb82afdbd8 # Install python base58 decode library RUN apt-get update && \