From 3120b71a07becea12f7b8fbc0ba3b2b95b9b85f4 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Fri, 8 Sep 2023 05:22:30 +0000 Subject: [PATCH 01/22] apply getVerifiedWarpMessage and sourceChainID changes --- contracts/src/Teleporter/TeleporterMessenger.sol | 16 ++++++++-------- .../src/Teleporter/tests/MarkReceiptTests.t.sol | 12 ++++++------ .../tests/ReceiveCrossChainMessageTests.t.sol | 6 +++--- .../tests/RedeemRelayerRewardsTests.t.sol | 4 ++-- .../tests/TeleporterMessengerTest.t.sol | 6 +++--- subnet-evm | 2 +- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/contracts/src/Teleporter/TeleporterMessenger.sol b/contracts/src/Teleporter/TeleporterMessenger.sol index 28cb16519..2e6d045b9 100644 --- a/contracts/src/Teleporter/TeleporterMessenger.sol +++ b/contracts/src/Teleporter/TeleporterMessenger.sol @@ -251,7 +251,7 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { // Verify and parse the cross chain message included in the transaction access list // using the warp message precompile. (WarpMessage memory warpMessage, bool success) = WARP_MESSENGER - .getVerifiedWarpMessage(); + .getVerifiedWarpMessage(0); require(success, "Failed to verify or parse cross chain message."); // Only allow for messages to be received from the same address as this teleporter contract. @@ -282,7 +282,7 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { // Check the message has not been delivered before by checking that there is no relayer reward // address stored for it already. require( - relayerRewardAddresses[warpMessage.originChainID][ + relayerRewardAddresses[warpMessage.sourceChainID][ teleporterMessage.messageID ] == address(0), "Teleporter message previously delivered." @@ -298,14 +298,14 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { ); // Store the relayer reward address provided, effectively marking the message as received. - relayerRewardAddresses[warpMessage.originChainID][ + relayerRewardAddresses[warpMessage.sourceChainID][ teleporterMessage.messageID ] = relayerRewardAddress; // Execute the message. if (teleporterMessage.message.length > 0) { _handleInitialMessageExecution( - warpMessage.originChainID, + warpMessage.sourceChainID, teleporterMessage ); } @@ -317,7 +317,7 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { TeleporterMessageReceipt memory receipt = teleporterMessage .receipts[i]; _markReceipt( - warpMessage.originChainID, + warpMessage.sourceChainID, receipt.receivedMessageID, receipt.relayerRewardAddress ); @@ -327,11 +327,11 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { // to the origin of this message, we will clean up the receipt state. // If the receipts queue contract for this chain doesn't exist yet, create it now. ReceiptQueue receiptsQueue = outstandingReceipts[ - warpMessage.originChainID + warpMessage.sourceChainID ]; if (address(receiptsQueue) == address(0)) { receiptsQueue = new ReceiptQueue(); - outstandingReceipts[warpMessage.originChainID] = receiptsQueue; + outstandingReceipts[warpMessage.sourceChainID] = receiptsQueue; } receiptsQueue.enqueue( TeleporterMessageReceipt({ @@ -341,7 +341,7 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { ); emit ReceiveCrossChainMessage( - warpMessage.originChainID, + warpMessage.sourceChainID, teleporterMessage.messageID, teleporterMessage ); diff --git a/contracts/src/Teleporter/tests/MarkReceiptTests.t.sol b/contracts/src/Teleporter/tests/MarkReceiptTests.t.sol index d42d85107..6f39a2733 100644 --- a/contracts/src/Teleporter/tests/MarkReceiptTests.t.sol +++ b/contracts/src/Teleporter/tests/MarkReceiptTests.t.sol @@ -77,12 +77,12 @@ contract MarkReceiptTest is TeleporterMessengerTest { ); vm.mockCall( WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, ()), + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)), abi.encode(warpMessage, true) ); vm.expectCall( WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, ()) + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)) ); // Receive the mock message. @@ -152,12 +152,12 @@ contract MarkReceiptTest is TeleporterMessengerTest { ); vm.mockCall( WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, ()), + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)), abi.encode(warpMessage, true) ); vm.expectCall( WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, ()) + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)) ); // Receive the mock message. @@ -217,12 +217,12 @@ contract MarkReceiptTest is TeleporterMessengerTest { ); vm.mockCall( WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, ()), + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)), abi.encode(warpMessage, true) ); vm.expectCall( WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, ()) + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)) ); // Receive the mock message. diff --git a/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol b/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol index 64c46d399..4aa22f815 100644 --- a/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol +++ b/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol @@ -55,7 +55,7 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { function testNoValidMessage() public { // Mock the call to the warp precompile to get the message failing. WarpMessage memory emptyMessage = WarpMessage({ - originChainID: bytes32(0), + sourceChainID: bytes32(0), originSenderAddress: address(0), destinationChainID: bytes32(0), destinationAddress: address(0), @@ -63,12 +63,12 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { }); vm.mockCall( WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, ()), + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)), abi.encode(emptyMessage, false) ); vm.expectCall( WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, ()) + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)) ); vm.expectRevert("Failed to verify or parse cross chain message."); diff --git a/contracts/src/Teleporter/tests/RedeemRelayerRewardsTests.t.sol b/contracts/src/Teleporter/tests/RedeemRelayerRewardsTests.t.sol index cec5d8667..56a7ada97 100644 --- a/contracts/src/Teleporter/tests/RedeemRelayerRewardsTests.t.sol +++ b/contracts/src/Teleporter/tests/RedeemRelayerRewardsTests.t.sol @@ -128,12 +128,12 @@ contract RedeemRelayerRewardsTest is TeleporterMessengerTest { ); vm.mockCall( WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, ()), + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)), abi.encode(warpMessage, true) ); vm.expectCall( WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, ()) + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)) ); // Receive the mock message. diff --git a/contracts/src/Teleporter/tests/TeleporterMessengerTest.t.sol b/contracts/src/Teleporter/tests/TeleporterMessengerTest.t.sol index 2e3c668e4..49d13668a 100644 --- a/contracts/src/Teleporter/tests/TeleporterMessengerTest.t.sol +++ b/contracts/src/Teleporter/tests/TeleporterMessengerTest.t.sol @@ -135,12 +135,12 @@ contract TeleporterMessengerTest is Test { ) internal { vm.mockCall( WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, ()), + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)), abi.encode(warpMessage, true) ); vm.expectCall( WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, ()) + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)) ); } @@ -242,7 +242,7 @@ contract TeleporterMessengerTest is Test { ) internal view returns (WarpMessage memory) { return WarpMessage({ - originChainID: originChainID, + sourceChainID: originChainID, originSenderAddress: address(teleporterMessenger), destinationChainID: MOCK_BLOCK_CHAIN_ID, destinationAddress: address(teleporterMessenger), diff --git a/subnet-evm b/subnet-evm index 71e9f76aa..27e0ca9c1 160000 --- a/subnet-evm +++ b/subnet-evm @@ -1 +1 @@ -Subproject commit 71e9f76aa71a830016aa28f05486ac64dd88a353 +Subproject commit 27e0ca9c1e40a9abf3d21e5d1569851e540e8072 From 4174ab2350afb6ff6533ba8bb94072805ec138fd Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 20 Sep 2023 20:02:56 +0000 Subject: [PATCH 02/22] update subnet-evm commit to v0.5.6 --- go.work.sum | 44 +++++++++++++++++++++++++++++++++++++++++++- subnet-evm | 2 +- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/go.work.sum b/go.work.sum index 1cf9f391b..8555f9f7e 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= @@ -586,6 +588,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= @@ -635,7 +639,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= @@ -663,9 +666,15 @@ 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/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/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= @@ -689,24 +698,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= @@ -715,11 +741,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= @@ -732,13 +762,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= @@ -750,16 +784,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= @@ -767,6 +806,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= @@ -786,6 +826,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 27e0ca9c1..a05fc0b62 160000 --- a/subnet-evm +++ b/subnet-evm @@ -1 +1 @@ -Subproject commit 27e0ca9c1e40a9abf3d21e5d1569851e540e8072 +Subproject commit a05fc0b629272e604441c73e870a751a415327b2 From 2edfb9bf69d01cfe2665b0c201fe32765055146b Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 20 Sep 2023 22:22:45 +0000 Subject: [PATCH 03/22] update golang version and genesis template --- docker/Dockerfile | 4 +- docker/genesisTemplate.json | 90 ++++++++++++++++++------------------- go.mod | 6 +-- go.sum | 3 ++ 4 files changed, 51 insertions(+), 52 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 2667a2d73..a15c1aac8 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -22,8 +22,8 @@ RUN apt-get install -y wget curl git python3 make gcc build-essential # Install Golang RUN apt-get install -y bison -RUN wget https://go.dev/dl/go1.20.7.linux-${ARCH}.tar.gz -RUN rm -rf /usr/local/go && tar -C /usr/local -xzf go1.20.7.linux-${ARCH}.tar.gz +RUN wget https://go.dev/dl/go1.20.8.linux-${ARCH}.tar.gz +RUN rm -rf /usr/local/go && tar -C /usr/local -xzf go1.20.8.linux-${ARCH}.tar.gz ENV PATH $PATH:/usr/local/go/bin ENV GOPATH $HOME/go ENV GOROOT /usr/local/go diff --git a/docker/genesisTemplate.json b/docker/genesisTemplate.json index abe7200a5..7bfea80be 100644 --- a/docker/genesisTemplate.json +++ b/docker/genesisTemplate.json @@ -1,50 +1,46 @@ { - "config": { - "chainId": "", - "homesteadBlock": 0, - "eip150Block": 0, - "eip150Hash": "0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0", - "eip155Block": 0, - "eip158Block": 0, - "byzantiumBlock": 0, - "constantinopleBlock": 0, - "petersburgBlock": 0, - "istanbulBlock": 0, - "muirGlacierBlock": 0, - "subnetEVMTimestamp": 0, - "feeConfig": { - "gasLimit": 20000000, - "minBaseFee": 1000000000, - "targetGas": 100000000, - "baseFeeChangeDenominator": 48, - "minBlockGasCost": 0, - "maxBlockGasCost": 10000000, - "targetBlockRate": 2, - "blockGasCostStep": 500000 + "config": { + "chainId": "", + "homesteadBlock": 0, + "eip150Block": 0, + "eip150Hash": "0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0", + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 0, + "muirGlacierBlock": 0, + "feeConfig": { + "gasLimit": 20000000, + "minBaseFee": 1000000000, + "targetGas": 100000000, + "baseFeeChangeDenominator": 48, + "minBlockGasCost": 0, + "maxBlockGasCost": 10000000, + "targetBlockRate": 2, + "blockGasCostStep": 500000 + }, + "warpConfig": { + "blockTimestamp": 0 + } }, - "rewardManagerConfig": { - "blockTimestamp": 0, - "adminAddresses": [ - "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC" - ] + "alloc": { + "8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": { + "balance": "0x52B7D2DCC80CD2E4000000" + }, + "0x0Fa8EA536Be85F32724D57A37758761B86416123": { + "balance": "0x52B7D2DCC80CD2E4000000" + } }, - "warpConfig": { - "blockTimestamp": 0 - } - }, - "alloc": { - "8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": { - "balance": "0x52B7D2DCC80CD2E4000000" - } - }, - "nonce": "0x0", - "timestamp": "0x638F7000", - "extraData": "0x00", - "gasLimit": "0x1312D00", - "difficulty": "0x0", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "coinbase": "0x0000000000000000000000000000000000000000", - "number": "0x0", - "gasUsed": "0x0", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" -} \ No newline at end of file + "nonce": "0x0", + "timestamp": "0x0", + "extraData": "0x00", + "gasLimit": "0x1312D00", + "difficulty": "0x0", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000", + "number": "0x0", + "gasUsed": "0x0", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" +} diff --git a/go.mod b/go.mod index 8866428ca..c8d8a9d78 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,14 @@ module github.com/ava-labs/teleporter -go 1.18 +go 1.20 require ( - github.com/ava-labs/avalanchego v1.10.9 // indirect + github.com/ava-labs/avalanchego v1.10.10 // indirect github.com/supranational/blst v0.3.11 // indirect ) require ( - github.com/ava-labs/subnet-evm v0.5.4 + github.com/ava-labs/subnet-evm v0.5.6 github.com/ethereum/go-ethereum v1.12.0 ) diff --git a/go.sum b/go.sum index 04bef53a3..16359e671 100644 --- a/go.sum +++ b/go.sum @@ -44,8 +44,11 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/ava-labs/avalanchego v1.10.9 h1:qxhp3YoD2Wm/iIKP6Wb1isbkUPWmIrJxWgivDoL0obM= github.com/ava-labs/avalanchego v1.10.9/go.mod h1:C8R5uiltpc8MQ62ixxgODR+15mesWF0aAw3H+Qrl9Iw= +github.com/ava-labs/avalanchego v1.10.10/go.mod h1:6UA0nxxTvvpyuCbP2DSzx9+7uWQfQx9DPApK8JptLiE= github.com/ava-labs/subnet-evm v0.5.4 h1:4+UHva8rhGlvH4gDYpI0Lt6/J5ie1DqQa6kEmbebArI= github.com/ava-labs/subnet-evm v0.5.4/go.mod h1:PAyhfYnECzA17N62i7OAdKazjfSsN2l8KR5nOspg39I= +github.com/ava-labs/subnet-evm v0.5.6 h1:u+xBvEExOa362Up02hgSgeF+aqDona57whhRIeEIim8= +github.com/ava-labs/subnet-evm v0.5.6/go.mod h1:desGY3ghT+Ner+oqxeovwF37eM4dmMQbYZECONPQU9w= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= From 7ee3a098e43db4e38a16a138d4fba322d82f85bb Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 20 Sep 2023 22:24:31 +0000 Subject: [PATCH 04/22] reformat genesis template --- docker/genesisTemplate.json | 84 ++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/docker/genesisTemplate.json b/docker/genesisTemplate.json index 7bfea80be..98b93a8f3 100644 --- a/docker/genesisTemplate.json +++ b/docker/genesisTemplate.json @@ -1,46 +1,46 @@ { - "config": { - "chainId": "", - "homesteadBlock": 0, - "eip150Block": 0, - "eip150Hash": "0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0", - "eip155Block": 0, - "eip158Block": 0, - "byzantiumBlock": 0, - "constantinopleBlock": 0, - "petersburgBlock": 0, - "istanbulBlock": 0, - "muirGlacierBlock": 0, - "feeConfig": { - "gasLimit": 20000000, - "minBaseFee": 1000000000, - "targetGas": 100000000, - "baseFeeChangeDenominator": 48, - "minBlockGasCost": 0, - "maxBlockGasCost": 10000000, - "targetBlockRate": 2, - "blockGasCostStep": 500000 - }, - "warpConfig": { - "blockTimestamp": 0 - } + "config": { + "chainId": "", + "homesteadBlock": 0, + "eip150Block": 0, + "eip150Hash": "0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0", + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 0, + "muirGlacierBlock": 0, + "feeConfig": { + "gasLimit": 20000000, + "minBaseFee": 1000000000, + "targetGas": 100000000, + "baseFeeChangeDenominator": 48, + "minBlockGasCost": 0, + "maxBlockGasCost": 10000000, + "targetBlockRate": 2, + "blockGasCostStep": 500000 }, - "alloc": { - "8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": { - "balance": "0x52B7D2DCC80CD2E4000000" - }, - "0x0Fa8EA536Be85F32724D57A37758761B86416123": { - "balance": "0x52B7D2DCC80CD2E4000000" - } + "warpConfig": { + "blockTimestamp": 0 + } + }, + "alloc": { + "8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": { + "balance": "0x52B7D2DCC80CD2E4000000" }, - "nonce": "0x0", - "timestamp": "0x0", - "extraData": "0x00", - "gasLimit": "0x1312D00", - "difficulty": "0x0", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "coinbase": "0x0000000000000000000000000000000000000000", - "number": "0x0", - "gasUsed": "0x0", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0Fa8EA536Be85F32724D57A37758761B86416123": { + "balance": "0x52B7D2DCC80CD2E4000000" + } + }, + "nonce": "0x0", + "timestamp": "0x0", + "extraData": "0x00", + "gasLimit": "0x1312D00", + "difficulty": "0x0", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000", + "number": "0x0", + "gasUsed": "0x0", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" } From 33b8d4caebe2ca2ac85a864371e17c181e31abe0 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 20 Sep 2023 23:46:43 +0000 Subject: [PATCH 05/22] add dupgrade config to genesis template --- .gitignore | 1 + docker/genesisTemplate.json | 2 ++ go.sum | 5 +---- go.work.sum | 6 ++++++ 4 files changed, 10 insertions(+), 4 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/docker/genesisTemplate.json b/docker/genesisTemplate.json index 98b93a8f3..95545fb78 100644 --- a/docker/genesisTemplate.json +++ b/docker/genesisTemplate.json @@ -11,6 +11,8 @@ "petersburgBlock": 0, "istanbulBlock": 0, "muirGlacierBlock": 0, + "subnetEVMTimestamp": 0, + "dUpgradeTimestamp": 0, "feeConfig": { "gasLimit": 20000000, "minBaseFee": 1000000000, diff --git a/go.sum b/go.sum index 16359e671..c3fa7bc42 100644 --- a/go.sum +++ b/go.sum @@ -42,11 +42,8 @@ github.com/VictoriaMetrics/fastcache v1.10.0/go.mod h1:tjiYeEfYXCqacuvYw/7UoDIeJ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/ava-labs/avalanchego v1.10.9 h1:qxhp3YoD2Wm/iIKP6Wb1isbkUPWmIrJxWgivDoL0obM= -github.com/ava-labs/avalanchego v1.10.9/go.mod h1:C8R5uiltpc8MQ62ixxgODR+15mesWF0aAw3H+Qrl9Iw= +github.com/ava-labs/avalanchego v1.10.10 h1:EYX4LVotcfdtIQ0nJSBTcoisubx/Bzk2tM1aP3yiYiw= github.com/ava-labs/avalanchego v1.10.10/go.mod h1:6UA0nxxTvvpyuCbP2DSzx9+7uWQfQx9DPApK8JptLiE= -github.com/ava-labs/subnet-evm v0.5.4 h1:4+UHva8rhGlvH4gDYpI0Lt6/J5ie1DqQa6kEmbebArI= -github.com/ava-labs/subnet-evm v0.5.4/go.mod h1:PAyhfYnECzA17N62i7OAdKazjfSsN2l8KR5nOspg39I= github.com/ava-labs/subnet-evm v0.5.6 h1:u+xBvEExOa362Up02hgSgeF+aqDona57whhRIeEIim8= github.com/ava-labs/subnet-evm v0.5.6/go.mod h1:desGY3ghT+Ner+oqxeovwF37eM4dmMQbYZECONPQU9w= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= diff --git a/go.work.sum b/go.work.sum index 8555f9f7e..2d77868a0 100644 --- a/go.work.sum +++ b/go.work.sum @@ -550,6 +550,8 @@ 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 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= @@ -558,6 +560,8 @@ github.com/ava-labs/avalanchego v1.9.1-rc.3/go.mod h1:qQJugll8yY/YKiy/Eutjwjn/vS github.com/ava-labs/avalanchego v1.10.5-rc.1/go.mod h1:azK88lcF5jwcPSp//RKUh2VncmrZZUrKu998C7no4Ys= 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/avalanchego v1.10.10-rc.4/go.mod h1:BN97sZppDSvIMIfEjrLTjdPTFkGLkb0ISJHEcoxMMNk= +github.com/ava-labs/avalanchego v1.10.10 h1:EYX4LVotcfdtIQ0nJSBTcoisubx/Bzk2tM1aP3yiYiw= github.com/ava-labs/coreth v0.11.5-rc.0 h1:EQ4MVWFrG+gtqtTFgquL4yoZnCNA+kbMVGWAnsTMeBE= github.com/ava-labs/coreth v0.11.7-rc.0/go.mod h1:e7SuEq6g3+YWyNPiznJF6KnnAuc0HCXxiSshMNj52Sw= github.com/ava-labs/coreth v0.11.7-rc.3 h1:+GaXmcqzBDd6jFJcPrAQ/RKEFJlqCVcdTF/Q5T6woy4= @@ -566,6 +570,8 @@ github.com/ava-labs/coreth v0.11.8-rc.3 h1:pS+OTFPc9edcFuCJIQGn5TdyAZncT9Hhs9jCc github.com/ava-labs/coreth v0.11.8-rc.3/go.mod h1:pc44yvJD4jTPIwkPI64pUXyJDvQ/UAqkbmhXOx78PXA= 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/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 h1:EdxD90j5sClfL5Ngpz2TlnbnkNYdFPDXa0jDOjam65c= github.com/ava-labs/ledger-avalanche/go v0.0.0-20230105152938-00a24d05a8c7/go.mod h1:XhiXSrh90sHUbkERzaxEftCmUz53eCijshDLZ4fByVM= github.com/aws/aws-sdk-go-v2 v1.2.0 h1:BS+UYpbsElC82gB+2E2jiCBg36i8HlubTB/dO/moQ9c= From bd3656ff80c8de4fae1496222a1156faace1e366 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Fri, 22 Sep 2023 23:45:12 +0000 Subject: [PATCH 06/22] add index to receiveCrossChainMessage --- .gitignore | 1 - .../src/Teleporter/ITeleporterMessenger.sol | 8 ++- .../src/Teleporter/TeleporterMessenger.sol | 8 +-- .../HandleInitialMessageExecutionTests.t.sol | 30 +++++++---- .../Teleporter/tests/MarkReceiptTests.t.sol | 42 +++++---------- .../tests/ReceiveCrossChainMessageTests.t.sol | 51 ++++++++++--------- .../tests/RedeemRelayerRewardsTests.t.sol | 14 ++--- .../tests/RetryMessageExecutionTests.t.sol | 11 ++-- .../tests/TeleporterMessengerTest.t.sol | 16 +++--- docker/genesisTemplate.json | 3 -- 10 files changed, 89 insertions(+), 95 deletions(-) diff --git a/.gitignore b/.gitignore index 1860daa1f..fefdf3aaa 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,6 @@ subnetGenesis_* vars.sh NETWORK_READY NETWORK_RUNNING -.awm-relayer-storage/ # Raw Contract Deployment Transaction UniversalTeleporterDeployerTransaction.txt diff --git a/contracts/src/Teleporter/ITeleporterMessenger.sol b/contracts/src/Teleporter/ITeleporterMessenger.sol index 1248ab1b5..7682f2226 100644 --- a/contracts/src/Teleporter/ITeleporterMessenger.sol +++ b/contracts/src/Teleporter/ITeleporterMessenger.sol @@ -125,9 +125,13 @@ interface ITeleporterMessenger { /** * @dev Receives a cross chain message, and marks the `relayerRewardAddress` for fee reward for a successful delivery. * - * The message must be provided in the access list storage slots of the transaction, as is verified in the precompile predicate. + * The message specified by `index` must be provided in the access list storage slots of the transaction, + * and is verified in the precompile predicate. */ - function receiveCrossChainMessage(address relayerRewardAddress) external; + function receiveCrossChainMessage( + address relayerRewardAddress, + uint32 index + ) external; /** * @dev Retries the execution of a previously delivered message by verifying the payload matches diff --git a/contracts/src/Teleporter/TeleporterMessenger.sol b/contracts/src/Teleporter/TeleporterMessenger.sol index 2145204c1..b1795c45a 100644 --- a/contracts/src/Teleporter/TeleporterMessenger.sol +++ b/contracts/src/Teleporter/TeleporterMessenger.sol @@ -249,10 +249,11 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { * @dev See {ITeleporterMessenger-receiveCrossChainMessage} * * Emits {ReceiveCrossChainMessage} event. - * Re-entrancy is explicitly disallowed. One message is not able to receive another message. + * Re-entrancy is explicitly disallowed between receiving functions. One message is not able to receive another message. * Requirements: * * - `relayerRewardAddress` must not be the zero address. + * - `index` must specify a valid warp message in transaction's storage slots. * - Valid warp message provided in storage slots, and sender address matches the address of this contract. * - Warp message `destinationChainID` must match the `blockchainID` of this contract. * - Warp message `destinationAddress` must match the address of this contract. @@ -260,7 +261,8 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { * - Transaction was sent by an allowed relayer for corresponding teleporter message. */ function receiveCrossChainMessage( - address relayerRewardAddress + address relayerRewardAddress, + uint32 index ) external receiverNonReentrant { // The relayer reward address is not allowed to be the zero address because it is how we track // whether or not a message has been delivered. @@ -271,7 +273,7 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { // Verify and parse the cross chain message included in the transaction access list // using the warp message precompile. (WarpMessage memory warpMessage, bool success) = WARP_MESSENGER - .getVerifiedWarpMessage(0); + .getVerifiedWarpMessage(index); if (!success) { revert InvalidWarpMessage(); diff --git a/contracts/src/Teleporter/tests/HandleInitialMessageExecutionTests.t.sol b/contracts/src/Teleporter/tests/HandleInitialMessageExecutionTests.t.sol index 721c5be3c..6d88f5cec 100644 --- a/contracts/src/Teleporter/tests/HandleInitialMessageExecutionTests.t.sol +++ b/contracts/src/Teleporter/tests/HandleInitialMessageExecutionTests.t.sol @@ -93,7 +93,7 @@ contract SampleMessageReceiver is ITeleporterReceiver { ITeleporterMessenger messenger = ITeleporterMessenger( teleporterContract ); - messenger.receiveCrossChainMessage(address(42)); + messenger.receiveCrossChainMessage(address(42), 0); latestMessage = message; latestMessageSenderSubnetID = originChainID; latestMessageSenderAddress = originSenderAddress; @@ -134,11 +134,12 @@ contract HandleInitialMessageExecutionTest is TeleporterMessengerTest { ); // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage); + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); // Receive the message. teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS + DEFAULT_RELAYER_REWARD_ADDRESS, + 0 ); // Check that the message had the proper affect on the destination contract. @@ -185,12 +186,13 @@ contract HandleInitialMessageExecutionTest is TeleporterMessengerTest { ); // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage); + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); // Receive the message. vm.expectRevert(TeleporterMessenger.InsufficientGas.selector); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS + DEFAULT_RELAYER_REWARD_ADDRESS, + 0 ); } @@ -215,7 +217,7 @@ contract HandleInitialMessageExecutionTest is TeleporterMessengerTest { ); // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage); + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); // Receive the message - this does not revert because the recursive call // is considered a failed message execution, but the message itself is @@ -227,7 +229,8 @@ contract HandleInitialMessageExecutionTest is TeleporterMessengerTest { messageToReceive ); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS + DEFAULT_RELAYER_REWARD_ADDRESS, + 0 ); // Check that the message hash was stored in state and the message did not have any affect on the destination. @@ -241,7 +244,9 @@ contract HandleInitialMessageExecutionTest is TeleporterMessengerTest { ), DEFAULT_RELAYER_REWARD_ADDRESS ); - vm.expectRevert(TeleporterMessenger.MessageRetryExecutionFailed.selector); + vm.expectRevert( + TeleporterMessenger.MessageRetryExecutionFailed.selector + ); teleporterMessenger.retryMessageExecution( DEFAULT_ORIGIN_CHAIN_ID, messageToReceive @@ -269,7 +274,7 @@ contract HandleInitialMessageExecutionTest is TeleporterMessengerTest { ); // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage); + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); // Receive the message. vm.expectEmit(true, true, true, true, address(teleporterMessenger)); @@ -279,7 +284,8 @@ contract HandleInitialMessageExecutionTest is TeleporterMessengerTest { messageToReceive ); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS + DEFAULT_RELAYER_REWARD_ADDRESS, + 0 ); // Check that the message hash was stored in state and the message did not have any affect on the destination. @@ -293,7 +299,9 @@ contract HandleInitialMessageExecutionTest is TeleporterMessengerTest { ), DEFAULT_RELAYER_REWARD_ADDRESS ); - vm.expectRevert(TeleporterMessenger.MessageRetryExecutionFailed.selector); + vm.expectRevert( + TeleporterMessenger.MessageRetryExecutionFailed.selector + ); teleporterMessenger.retryMessageExecution( DEFAULT_ORIGIN_CHAIN_ID, messageToReceive diff --git a/contracts/src/Teleporter/tests/MarkReceiptTests.t.sol b/contracts/src/Teleporter/tests/MarkReceiptTests.t.sol index 6f39a2733..09c485791 100644 --- a/contracts/src/Teleporter/tests/MarkReceiptTests.t.sol +++ b/contracts/src/Teleporter/tests/MarkReceiptTests.t.sol @@ -75,20 +75,14 @@ contract MarkReceiptTest is TeleporterMessengerTest { address(teleporterMessenger), abi.encode(messageToReceive) ); - vm.mockCall( - WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)), - abi.encode(warpMessage, true) - ); - vm.expectCall( - WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)) - ); + + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); // Receive the mock message. address expectedRelayerRewardAddress = 0x93753a9eA4C9D6eeed9f64eA92E97ce1f5FBAeDe; teleporterMessenger.receiveCrossChainMessage( - expectedRelayerRewardAddress + expectedRelayerRewardAddress, + 0 ); // Check that the relayers have redeemable balances @@ -150,20 +144,14 @@ contract MarkReceiptTest is TeleporterMessengerTest { address(teleporterMessenger), abi.encode(messageToReceive) ); - vm.mockCall( - WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)), - abi.encode(warpMessage, true) - ); - vm.expectCall( - WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)) - ); + + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); // Receive the mock message. address expectedRelayerRewardAddress = 0x2F20537C2F5c57231866DE9D0CE33d0681a200D4; teleporterMessenger.receiveCrossChainMessage( - expectedRelayerRewardAddress + expectedRelayerRewardAddress, + 0 ); // Check that the message received is considered delivered, and that the relayer reward address is stored. @@ -215,20 +203,14 @@ contract MarkReceiptTest is TeleporterMessengerTest { address(teleporterMessenger), abi.encode(messageToReceive) ); - vm.mockCall( - WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)), - abi.encode(warpMessage, true) - ); - vm.expectCall( - WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)) - ); + + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); // Receive the mock message. address expectedRelayerRewardAddress = 0x6DAEF0D63ea44C801b655Fd97fe3804B9bFCC097; teleporterMessenger.receiveCrossChainMessage( - expectedRelayerRewardAddress + expectedRelayerRewardAddress, + 0 ); // Check that the relayer redeemable balances was only added once. diff --git a/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol b/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol index d66772b67..5c3f5faae 100644 --- a/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol +++ b/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol @@ -44,11 +44,12 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { ); // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage); + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); // Receive the message. teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS + DEFAULT_RELAYER_REWARD_ADDRESS, + 0 ); } @@ -61,18 +62,11 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { destinationAddress: address(0), payload: new bytes(0) }); - vm.mockCall( - WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)), - abi.encode(emptyMessage, false) - ); - vm.expectCall( - WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)) - ); + + _setUpSuccessGetVerifiedWarpMessageMock(emptyMessage, 0); vm.expectRevert(TeleporterMessenger.InvalidWarpMessage.selector); - teleporterMessenger.receiveCrossChainMessage(address(1)); + teleporterMessenger.receiveCrossChainMessage(address(1), 0); } function testInvalidOriginSenderAddress() public { @@ -91,11 +85,14 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { warpMessage.originSenderAddress = invalidSenderAddress; // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage); + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); - vm.expectRevert(TeleporterMessenger.InvalidOriginSenderAddress.selector); + vm.expectRevert( + TeleporterMessenger.InvalidOriginSenderAddress.selector + ); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS + DEFAULT_RELAYER_REWARD_ADDRESS, + 0 ); } @@ -117,11 +114,12 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { warpMessage.destinationChainID = invalidDestinationChainID; // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage); + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); vm.expectRevert(TeleporterMessenger.InvalidDestinationChainID.selector); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS + DEFAULT_RELAYER_REWARD_ADDRESS, + 0 ); } @@ -141,17 +139,20 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { warpMessage.destinationAddress = invalidDestinationAddress; // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage); + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); vm.expectRevert(TeleporterMessenger.InvalidDestinationAddress.selector); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS + DEFAULT_RELAYER_REWARD_ADDRESS, + 0 ); } function testInvalidRelayerAddress() public { - vm.expectRevert(TeleporterMessenger.InvalidRelayerRewardAddress.selector); - teleporterMessenger.receiveCrossChainMessage(address(0)); + vm.expectRevert( + TeleporterMessenger.InvalidRelayerRewardAddress.selector + ); + teleporterMessenger.receiveCrossChainMessage(address(0), 0); } function testMessageAlreadyReceived() public { @@ -161,7 +162,8 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { // Check you can't deliver it again. vm.expectRevert(TeleporterMessenger.MessageAlreadyDelivered.selector); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS + DEFAULT_RELAYER_REWARD_ADDRESS, + 0 ); } @@ -187,12 +189,13 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { ); // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage); + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); // Receive the message. vm.expectRevert(TeleporterMessenger.UnauthorizedRelayer.selector); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS + DEFAULT_RELAYER_REWARD_ADDRESS, + 0 ); } diff --git a/contracts/src/Teleporter/tests/RedeemRelayerRewardsTests.t.sol b/contracts/src/Teleporter/tests/RedeemRelayerRewardsTests.t.sol index 6545dfa9a..4b3a13a42 100644 --- a/contracts/src/Teleporter/tests/RedeemRelayerRewardsTests.t.sol +++ b/contracts/src/Teleporter/tests/RedeemRelayerRewardsTests.t.sol @@ -126,20 +126,14 @@ contract RedeemRelayerRewardsTest is TeleporterMessengerTest { address(teleporterMessenger), abi.encode(messageToReceive) ); - vm.mockCall( - WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)), - abi.encode(warpMessage, true) - ); - vm.expectCall( - WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)) - ); + + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); // Receive the mock message. address expectedRelayerRewardAddress = 0x93753a9eA4C9D6eeed9f64eA92E97ce1f5FBAeDe; teleporterMessenger.receiveCrossChainMessage( - expectedRelayerRewardAddress + expectedRelayerRewardAddress, + 0 ); // Check that the relayer has redeemable balance diff --git a/contracts/src/Teleporter/tests/RetryMessageExecutionTests.t.sol b/contracts/src/Teleporter/tests/RetryMessageExecutionTests.t.sol index e05c7ed42..8ed47df7a 100644 --- a/contracts/src/Teleporter/tests/RetryMessageExecutionTests.t.sol +++ b/contracts/src/Teleporter/tests/RetryMessageExecutionTests.t.sol @@ -86,7 +86,7 @@ contract FlakyMessageReceiver is ITeleporterReceiver { ITeleporterMessenger messenger = ITeleporterMessenger( teleporterContract ); - messenger.receiveCrossChainMessage(address(42)); + messenger.receiveCrossChainMessage(address(42), 0); latestMessage = message; latestMessageSenderSubnetID = originChainID; latestMessageSenderAddress = originSenderAddress; @@ -119,7 +119,9 @@ contract RetryMessageExecutionTest is TeleporterMessengerTest { ) = _receiveFailedMessage(false); // Now retry it in another block with an even timestamp so that it fails again. - vm.expectRevert(TeleporterMessenger.MessageRetryExecutionFailed.selector); + vm.expectRevert( + TeleporterMessenger.MessageRetryExecutionFailed.selector + ); teleporterMessenger.retryMessageExecution(originChainID, message); } @@ -236,7 +238,7 @@ contract RetryMessageExecutionTest is TeleporterMessengerTest { ); // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage); + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); // Receive the message in a block with an even height. // The message should be successfully received, but its execution should fail. @@ -248,7 +250,8 @@ contract RetryMessageExecutionTest is TeleporterMessengerTest { messageToReceive ); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS + DEFAULT_RELAYER_REWARD_ADDRESS, + 0 ); // Check that the message execution didn't have any effect, but diff --git a/contracts/src/Teleporter/tests/TeleporterMessengerTest.t.sol b/contracts/src/Teleporter/tests/TeleporterMessengerTest.t.sol index 49d13668a..c19d507ab 100644 --- a/contracts/src/Teleporter/tests/TeleporterMessengerTest.t.sol +++ b/contracts/src/Teleporter/tests/TeleporterMessengerTest.t.sol @@ -131,16 +131,17 @@ contract TeleporterMessengerTest is Test { } function _setUpSuccessGetVerifiedWarpMessageMock( - WarpMessage memory warpMessage + WarpMessage memory warpMessage, + uint32 index ) internal { vm.mockCall( WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)), + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (index)), abi.encode(warpMessage, true) ); vm.expectCall( WARP_PRECOMPILE_ADDRESS, - abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)) + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (index)) ); } @@ -166,10 +167,10 @@ contract TeleporterMessengerTest is Test { ); // We have to mock the precompile call so that it doesn't revert in the tests. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage); + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); // Receive the message. - teleporterMessenger.receiveCrossChainMessage(relayerRewardAddress); + teleporterMessenger.receiveCrossChainMessage(relayerRewardAddress, 0); } function _receiveMessageSentToEOA() @@ -193,7 +194,7 @@ contract TeleporterMessengerTest is Test { ); // We have to mock the precompile call so that it doesn't revert in the tests. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage); + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); // Mock there being no code at the destination address which will be called // when the message is executed. This mimics the default destination address being an EOA. @@ -207,7 +208,8 @@ contract TeleporterMessengerTest is Test { messageToReceive ); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS + DEFAULT_RELAYER_REWARD_ADDRESS, + 0 ); return ( diff --git a/docker/genesisTemplate.json b/docker/genesisTemplate.json index 95545fb78..cda8a1f43 100644 --- a/docker/genesisTemplate.json +++ b/docker/genesisTemplate.json @@ -30,9 +30,6 @@ "alloc": { "8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": { "balance": "0x52B7D2DCC80CD2E4000000" - }, - "0x0Fa8EA536Be85F32724D57A37758761B86416123": { - "balance": "0x52B7D2DCC80CD2E4000000" } }, "nonce": "0x0", From e496ee0817ce72cd1bc84d1d2ccd366164e6bc4c Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Fri, 22 Sep 2023 23:49:26 +0000 Subject: [PATCH 07/22] fix unit test --- .../tests/ReceiveCrossChainMessageTests.t.sol | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol b/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol index 5c3f5faae..f9afa84e6 100644 --- a/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol +++ b/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol @@ -63,7 +63,15 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { payload: new bytes(0) }); - _setUpSuccessGetVerifiedWarpMessageMock(emptyMessage, 0); + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)), + abi.encode(emptyMessage, false) + ); + vm.expectCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (0)) + ); vm.expectRevert(TeleporterMessenger.InvalidWarpMessage.selector); teleporterMessenger.receiveCrossChainMessage(address(1), 0); From e72ddb980f4c501fc3cdd327a4630dd62098e6b4 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Mon, 25 Sep 2023 23:12:41 -0700 Subject: [PATCH 08/22] test added buffer gas --- contracts/src/Teleporter/ITeleporterMessenger.abi | 1 + 1 file changed, 1 insertion(+) create mode 100644 contracts/src/Teleporter/ITeleporterMessenger.abi diff --git a/contracts/src/Teleporter/ITeleporterMessenger.abi b/contracts/src/Teleporter/ITeleporterMessenger.abi new file mode 100644 index 000000000..7625ac1c5 --- /dev/null +++ b/contracts/src/Teleporter/ITeleporterMessenger.abi @@ -0,0 +1 @@ +[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"destinationChainID","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"messageID","type":"uint256"},{"components":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"indexed":false,"internalType":"struct TeleporterFeeInfo","name":"updatedFeeInfo","type":"tuple"}],"name":"AddFeeAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"originChainID","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"messageID","type":"uint256"},{"components":[{"internalType":"uint256","name":"messageID","type":"uint256"},{"internalType":"address","name":"senderAddress","type":"address"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"requiredGasLimit","type":"uint256"},{"internalType":"address[]","name":"allowedRelayerAddresses","type":"address[]"},{"components":[{"internalType":"uint256","name":"receivedMessageID","type":"uint256"},{"internalType":"address","name":"relayerRewardAddress","type":"address"}],"internalType":"struct TeleporterMessageReceipt[]","name":"receipts","type":"tuple[]"},{"internalType":"bytes","name":"message","type":"bytes"}],"indexed":false,"internalType":"struct TeleporterMessage","name":"message","type":"tuple"}],"name":"FailedMessageExecution","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"originChainID","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"messageID","type":"uint256"}],"name":"MessageExecutionRetried","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"originChainID","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"messageID","type":"uint256"},{"components":[{"internalType":"uint256","name":"messageID","type":"uint256"},{"internalType":"address","name":"senderAddress","type":"address"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"requiredGasLimit","type":"uint256"},{"internalType":"address[]","name":"allowedRelayerAddresses","type":"address[]"},{"components":[{"internalType":"uint256","name":"receivedMessageID","type":"uint256"},{"internalType":"address","name":"relayerRewardAddress","type":"address"}],"internalType":"struct TeleporterMessageReceipt[]","name":"receipts","type":"tuple[]"},{"internalType":"bytes","name":"message","type":"bytes"}],"indexed":false,"internalType":"struct TeleporterMessage","name":"message","type":"tuple"}],"name":"ReceiveCrossChainMessage","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"destinationChainID","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"messageID","type":"uint256"},{"components":[{"internalType":"uint256","name":"messageID","type":"uint256"},{"internalType":"address","name":"senderAddress","type":"address"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"requiredGasLimit","type":"uint256"},{"internalType":"address[]","name":"allowedRelayerAddresses","type":"address[]"},{"components":[{"internalType":"uint256","name":"receivedMessageID","type":"uint256"},{"internalType":"address","name":"relayerRewardAddress","type":"address"}],"internalType":"struct TeleporterMessageReceipt[]","name":"receipts","type":"tuple[]"},{"internalType":"bytes","name":"message","type":"bytes"}],"indexed":false,"internalType":"struct TeleporterMessage","name":"message","type":"tuple"}],"name":"SendCrossChainMessage","type":"event"},{"inputs":[{"internalType":"bytes32","name":"destinationChainID","type":"bytes32"},{"internalType":"uint256","name":"messageID","type":"uint256"},{"internalType":"address","name":"feeContractAddress","type":"address"},{"internalType":"uint256","name":"additionalFeeAmount","type":"uint256"}],"name":"addFeeAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"relayer","type":"address"},{"internalType":"address","name":"feeAsset","type":"address"}],"name":"checkRelayerRewardAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"destinationChainID","type":"bytes32"},{"internalType":"uint256","name":"messageID","type":"uint256"}],"name":"getFeeInfo","outputs":[{"internalType":"address","name":"feeAsset","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"destinationChainID","type":"bytes32"},{"internalType":"uint256","name":"messageID","type":"uint256"}],"name":"getMessageHash","outputs":[{"internalType":"bytes32","name":"messageHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"originChainID","type":"bytes32"},{"internalType":"uint256","name":"messageID","type":"uint256"}],"name":"getRelayerRewardAddress","outputs":[{"internalType":"address","name":"relayerRewardAddress","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"originChainID","type":"bytes32"},{"internalType":"uint256","name":"messageID","type":"uint256"}],"name":"messageReceived","outputs":[{"internalType":"bool","name":"delivered","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"relayerRewardAddress","type":"address"},{"internalType":"uint32","name":"index","type":"uint32"}],"name":"receiveCrossChainMessage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"feeAsset","type":"address"}],"name":"redeemRelayerRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"originChainID","type":"bytes32"},{"components":[{"internalType":"uint256","name":"messageID","type":"uint256"},{"internalType":"address","name":"senderAddress","type":"address"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"requiredGasLimit","type":"uint256"},{"internalType":"address[]","name":"allowedRelayerAddresses","type":"address[]"},{"components":[{"internalType":"uint256","name":"receivedMessageID","type":"uint256"},{"internalType":"address","name":"relayerRewardAddress","type":"address"}],"internalType":"struct TeleporterMessageReceipt[]","name":"receipts","type":"tuple[]"},{"internalType":"bytes","name":"message","type":"bytes"}],"internalType":"struct TeleporterMessage","name":"message","type":"tuple"}],"name":"retryMessageExecution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"originChainID","type":"bytes32"},{"internalType":"uint256[]","name":"messageIDs","type":"uint256[]"},{"components":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct TeleporterFeeInfo","name":"feeInfo","type":"tuple"},{"internalType":"address[]","name":"allowedRelayerAddresses","type":"address[]"}],"name":"retryReceipts","outputs":[{"internalType":"uint256","name":"messageID","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"destinationChainID","type":"bytes32"},{"components":[{"internalType":"uint256","name":"messageID","type":"uint256"},{"internalType":"address","name":"senderAddress","type":"address"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"requiredGasLimit","type":"uint256"},{"internalType":"address[]","name":"allowedRelayerAddresses","type":"address[]"},{"components":[{"internalType":"uint256","name":"receivedMessageID","type":"uint256"},{"internalType":"address","name":"relayerRewardAddress","type":"address"}],"internalType":"struct TeleporterMessageReceipt[]","name":"receipts","type":"tuple[]"},{"internalType":"bytes","name":"message","type":"bytes"}],"internalType":"struct TeleporterMessage","name":"message","type":"tuple"}],"name":"retrySendCrossChainMessage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"destinationChainID","type":"bytes32"},{"internalType":"address","name":"destinationAddress","type":"address"},{"components":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct TeleporterFeeInfo","name":"feeInfo","type":"tuple"},{"internalType":"uint256","name":"requiredGasLimit","type":"uint256"},{"internalType":"address[]","name":"allowedRelayerAddresses","type":"address[]"},{"internalType":"bytes","name":"message","type":"bytes"}],"internalType":"struct TeleporterMessageInput","name":"messageInput","type":"tuple"}],"name":"sendCrossChainMessage","outputs":[{"internalType":"uint256","name":"messageID","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file From 93ec7bd311b5991527a430dc776b58151a1b5156 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Tue, 26 Sep 2023 09:59:48 -0700 Subject: [PATCH 09/22] add unit test for receive index --- .../tests/ReceiveCrossChainMessageTests.t.sol | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol b/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol index f9afa84e6..5991991ac 100644 --- a/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol +++ b/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol @@ -30,7 +30,7 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { // Construct the test message to be received. TeleporterMessage memory messageToReceive = TeleporterMessage({ - messageID: 42, + messageID: 1, senderAddress: address(this), destinationAddress: DEFAULT_DESTINATION_ADDRESS, requiredGasLimit: DEFAULT_REQUIRED_GAS_LIMIT, @@ -51,6 +51,20 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { DEFAULT_RELAYER_REWARD_ADDRESS, 0 ); + + // Receive at a different index + messageToReceive.messageID = 2; + warpMessage = _createDefaultWarpMessage( + DEFAULT_ORIGIN_CHAIN_ID, + abi.encode(messageToReceive) + ); + _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 3); + + // Receive the message. + teleporterMessenger.receiveCrossChainMessage( + DEFAULT_RELAYER_REWARD_ADDRESS, + 3 + ); } function testNoValidMessage() public { @@ -75,6 +89,20 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { vm.expectRevert(TeleporterMessenger.InvalidWarpMessage.selector); teleporterMessenger.receiveCrossChainMessage(address(1), 0); + + // Receive invalid message at index 3 + vm.mockCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (3)), + abi.encode(emptyMessage, false) + ); + vm.expectCall( + WARP_PRECOMPILE_ADDRESS, + abi.encodeCall(WarpMessenger.getVerifiedWarpMessage, (3)) + ); + + vm.expectRevert(TeleporterMessenger.InvalidWarpMessage.selector); + teleporterMessenger.receiveCrossChainMessage(address(1), 3); } function testInvalidOriginSenderAddress() public { From d6b1fe48e12103bd6dd54d9578f9bea3dd44eab5 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Tue, 26 Sep 2023 10:03:25 -0700 Subject: [PATCH 10/22] fix comment --- contracts/src/Teleporter/TeleporterMessenger.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/TeleporterMessenger.sol b/contracts/src/Teleporter/TeleporterMessenger.sol index b1795c45a..98a9227f1 100644 --- a/contracts/src/Teleporter/TeleporterMessenger.sol +++ b/contracts/src/Teleporter/TeleporterMessenger.sol @@ -253,7 +253,7 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { * Requirements: * * - `relayerRewardAddress` must not be the zero address. - * - `index` must specify a valid warp message in transaction's storage slots. + * - `index` must specify a valid warp message in the transaction's storage slots. * - Valid warp message provided in storage slots, and sender address matches the address of this contract. * - Warp message `destinationChainID` must match the `blockchainID` of this contract. * - Warp message `destinationAddress` must match the address of this contract. From 9118693eaa8f079cba04d9523a7a0d932fd98c35 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Tue, 26 Sep 2023 10:03:59 -0700 Subject: [PATCH 11/22] remove abi --- contracts/src/Teleporter/ITeleporterMessenger.abi | 1 - 1 file changed, 1 deletion(-) delete mode 100644 contracts/src/Teleporter/ITeleporterMessenger.abi diff --git a/contracts/src/Teleporter/ITeleporterMessenger.abi b/contracts/src/Teleporter/ITeleporterMessenger.abi deleted file mode 100644 index 7625ac1c5..000000000 --- a/contracts/src/Teleporter/ITeleporterMessenger.abi +++ /dev/null @@ -1 +0,0 @@ -[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"destinationChainID","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"messageID","type":"uint256"},{"components":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"indexed":false,"internalType":"struct TeleporterFeeInfo","name":"updatedFeeInfo","type":"tuple"}],"name":"AddFeeAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"originChainID","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"messageID","type":"uint256"},{"components":[{"internalType":"uint256","name":"messageID","type":"uint256"},{"internalType":"address","name":"senderAddress","type":"address"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"requiredGasLimit","type":"uint256"},{"internalType":"address[]","name":"allowedRelayerAddresses","type":"address[]"},{"components":[{"internalType":"uint256","name":"receivedMessageID","type":"uint256"},{"internalType":"address","name":"relayerRewardAddress","type":"address"}],"internalType":"struct TeleporterMessageReceipt[]","name":"receipts","type":"tuple[]"},{"internalType":"bytes","name":"message","type":"bytes"}],"indexed":false,"internalType":"struct TeleporterMessage","name":"message","type":"tuple"}],"name":"FailedMessageExecution","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"originChainID","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"messageID","type":"uint256"}],"name":"MessageExecutionRetried","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"originChainID","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"messageID","type":"uint256"},{"components":[{"internalType":"uint256","name":"messageID","type":"uint256"},{"internalType":"address","name":"senderAddress","type":"address"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"requiredGasLimit","type":"uint256"},{"internalType":"address[]","name":"allowedRelayerAddresses","type":"address[]"},{"components":[{"internalType":"uint256","name":"receivedMessageID","type":"uint256"},{"internalType":"address","name":"relayerRewardAddress","type":"address"}],"internalType":"struct TeleporterMessageReceipt[]","name":"receipts","type":"tuple[]"},{"internalType":"bytes","name":"message","type":"bytes"}],"indexed":false,"internalType":"struct TeleporterMessage","name":"message","type":"tuple"}],"name":"ReceiveCrossChainMessage","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"destinationChainID","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"messageID","type":"uint256"},{"components":[{"internalType":"uint256","name":"messageID","type":"uint256"},{"internalType":"address","name":"senderAddress","type":"address"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"requiredGasLimit","type":"uint256"},{"internalType":"address[]","name":"allowedRelayerAddresses","type":"address[]"},{"components":[{"internalType":"uint256","name":"receivedMessageID","type":"uint256"},{"internalType":"address","name":"relayerRewardAddress","type":"address"}],"internalType":"struct TeleporterMessageReceipt[]","name":"receipts","type":"tuple[]"},{"internalType":"bytes","name":"message","type":"bytes"}],"indexed":false,"internalType":"struct TeleporterMessage","name":"message","type":"tuple"}],"name":"SendCrossChainMessage","type":"event"},{"inputs":[{"internalType":"bytes32","name":"destinationChainID","type":"bytes32"},{"internalType":"uint256","name":"messageID","type":"uint256"},{"internalType":"address","name":"feeContractAddress","type":"address"},{"internalType":"uint256","name":"additionalFeeAmount","type":"uint256"}],"name":"addFeeAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"relayer","type":"address"},{"internalType":"address","name":"feeAsset","type":"address"}],"name":"checkRelayerRewardAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"destinationChainID","type":"bytes32"},{"internalType":"uint256","name":"messageID","type":"uint256"}],"name":"getFeeInfo","outputs":[{"internalType":"address","name":"feeAsset","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"destinationChainID","type":"bytes32"},{"internalType":"uint256","name":"messageID","type":"uint256"}],"name":"getMessageHash","outputs":[{"internalType":"bytes32","name":"messageHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"originChainID","type":"bytes32"},{"internalType":"uint256","name":"messageID","type":"uint256"}],"name":"getRelayerRewardAddress","outputs":[{"internalType":"address","name":"relayerRewardAddress","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"originChainID","type":"bytes32"},{"internalType":"uint256","name":"messageID","type":"uint256"}],"name":"messageReceived","outputs":[{"internalType":"bool","name":"delivered","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"relayerRewardAddress","type":"address"},{"internalType":"uint32","name":"index","type":"uint32"}],"name":"receiveCrossChainMessage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"feeAsset","type":"address"}],"name":"redeemRelayerRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"originChainID","type":"bytes32"},{"components":[{"internalType":"uint256","name":"messageID","type":"uint256"},{"internalType":"address","name":"senderAddress","type":"address"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"requiredGasLimit","type":"uint256"},{"internalType":"address[]","name":"allowedRelayerAddresses","type":"address[]"},{"components":[{"internalType":"uint256","name":"receivedMessageID","type":"uint256"},{"internalType":"address","name":"relayerRewardAddress","type":"address"}],"internalType":"struct TeleporterMessageReceipt[]","name":"receipts","type":"tuple[]"},{"internalType":"bytes","name":"message","type":"bytes"}],"internalType":"struct TeleporterMessage","name":"message","type":"tuple"}],"name":"retryMessageExecution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"originChainID","type":"bytes32"},{"internalType":"uint256[]","name":"messageIDs","type":"uint256[]"},{"components":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct TeleporterFeeInfo","name":"feeInfo","type":"tuple"},{"internalType":"address[]","name":"allowedRelayerAddresses","type":"address[]"}],"name":"retryReceipts","outputs":[{"internalType":"uint256","name":"messageID","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"destinationChainID","type":"bytes32"},{"components":[{"internalType":"uint256","name":"messageID","type":"uint256"},{"internalType":"address","name":"senderAddress","type":"address"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"requiredGasLimit","type":"uint256"},{"internalType":"address[]","name":"allowedRelayerAddresses","type":"address[]"},{"components":[{"internalType":"uint256","name":"receivedMessageID","type":"uint256"},{"internalType":"address","name":"relayerRewardAddress","type":"address"}],"internalType":"struct TeleporterMessageReceipt[]","name":"receipts","type":"tuple[]"},{"internalType":"bytes","name":"message","type":"bytes"}],"internalType":"struct TeleporterMessage","name":"message","type":"tuple"}],"name":"retrySendCrossChainMessage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"destinationChainID","type":"bytes32"},{"internalType":"address","name":"destinationAddress","type":"address"},{"components":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct TeleporterFeeInfo","name":"feeInfo","type":"tuple"},{"internalType":"uint256","name":"requiredGasLimit","type":"uint256"},{"internalType":"address[]","name":"allowedRelayerAddresses","type":"address[]"},{"internalType":"bytes","name":"message","type":"bytes"}],"internalType":"struct TeleporterMessageInput","name":"messageInput","type":"tuple"}],"name":"sendCrossChainMessage","outputs":[{"internalType":"uint256","name":"messageID","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file From 65b6110bce3eb843b1c10e025baac3b72ee80ef2 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Tue, 26 Sep 2023 10:53:37 -0700 Subject: [PATCH 12/22] update naming and parameter order --- .../src/Teleporter/ITeleporterMessenger.sol | 6 +-- .../src/Teleporter/TeleporterMessenger.sol | 8 ++-- .../HandleInitialMessageExecutionTests.t.sol | 26 +++++------ .../Teleporter/tests/MarkReceiptTests.t.sol | 18 ++++---- .../tests/ReceiveCrossChainMessageTests.t.sol | 46 +++++++++---------- .../tests/RedeemRelayerRewardsTests.t.sol | 6 +-- .../tests/RetryMessageExecutionTests.t.sol | 8 ++-- .../tests/TeleporterMessengerTest.t.sol | 14 +++--- 8 files changed, 66 insertions(+), 66 deletions(-) diff --git a/contracts/src/Teleporter/ITeleporterMessenger.sol b/contracts/src/Teleporter/ITeleporterMessenger.sol index 7682f2226..237ab3e4a 100644 --- a/contracts/src/Teleporter/ITeleporterMessenger.sol +++ b/contracts/src/Teleporter/ITeleporterMessenger.sol @@ -125,12 +125,12 @@ interface ITeleporterMessenger { /** * @dev Receives a cross chain message, and marks the `relayerRewardAddress` for fee reward for a successful delivery. * - * The message specified by `index` must be provided in the access list storage slots of the transaction, + * The message specified by `messageIndex` must be provided in the access list storage slots of the transaction, * and is verified in the precompile predicate. */ function receiveCrossChainMessage( - address relayerRewardAddress, - uint32 index + uint32 messageIndex, + address relayerRewardAddress ) external; /** diff --git a/contracts/src/Teleporter/TeleporterMessenger.sol b/contracts/src/Teleporter/TeleporterMessenger.sol index 98a9227f1..3394c7cb1 100644 --- a/contracts/src/Teleporter/TeleporterMessenger.sol +++ b/contracts/src/Teleporter/TeleporterMessenger.sol @@ -253,7 +253,7 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { * Requirements: * * - `relayerRewardAddress` must not be the zero address. - * - `index` must specify a valid warp message in the transaction's storage slots. + * - `messageIndex` must specify a valid warp message in the transaction's storage slots. * - Valid warp message provided in storage slots, and sender address matches the address of this contract. * - Warp message `destinationChainID` must match the `blockchainID` of this contract. * - Warp message `destinationAddress` must match the address of this contract. @@ -261,8 +261,8 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { * - Transaction was sent by an allowed relayer for corresponding teleporter message. */ function receiveCrossChainMessage( - address relayerRewardAddress, - uint32 index + uint32 messageIndex, + address relayerRewardAddress ) external receiverNonReentrant { // The relayer reward address is not allowed to be the zero address because it is how we track // whether or not a message has been delivered. @@ -273,7 +273,7 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { // Verify and parse the cross chain message included in the transaction access list // using the warp message precompile. (WarpMessage memory warpMessage, bool success) = WARP_MESSENGER - .getVerifiedWarpMessage(index); + .getVerifiedWarpMessage(messageIndex); if (!success) { revert InvalidWarpMessage(); diff --git a/contracts/src/Teleporter/tests/HandleInitialMessageExecutionTests.t.sol b/contracts/src/Teleporter/tests/HandleInitialMessageExecutionTests.t.sol index 6d88f5cec..25f9cb182 100644 --- a/contracts/src/Teleporter/tests/HandleInitialMessageExecutionTests.t.sol +++ b/contracts/src/Teleporter/tests/HandleInitialMessageExecutionTests.t.sol @@ -93,7 +93,7 @@ contract SampleMessageReceiver is ITeleporterReceiver { ITeleporterMessenger messenger = ITeleporterMessenger( teleporterContract ); - messenger.receiveCrossChainMessage(address(42), 0); + messenger.receiveCrossChainMessage(0, address(42)); latestMessage = message; latestMessageSenderSubnetID = originChainID; latestMessageSenderAddress = originSenderAddress; @@ -134,12 +134,12 @@ contract HandleInitialMessageExecutionTest is TeleporterMessengerTest { ); // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); // Receive the message. teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS, - 0 + 0, + DEFAULT_RELAYER_REWARD_ADDRESS ); // Check that the message had the proper affect on the destination contract. @@ -186,13 +186,13 @@ contract HandleInitialMessageExecutionTest is TeleporterMessengerTest { ); // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); // Receive the message. vm.expectRevert(TeleporterMessenger.InsufficientGas.selector); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS, - 0 + 0, + DEFAULT_RELAYER_REWARD_ADDRESS ); } @@ -217,7 +217,7 @@ contract HandleInitialMessageExecutionTest is TeleporterMessengerTest { ); // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); // Receive the message - this does not revert because the recursive call // is considered a failed message execution, but the message itself is @@ -229,8 +229,8 @@ contract HandleInitialMessageExecutionTest is TeleporterMessengerTest { messageToReceive ); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS, - 0 + 0, + DEFAULT_RELAYER_REWARD_ADDRESS ); // Check that the message hash was stored in state and the message did not have any affect on the destination. @@ -274,7 +274,7 @@ contract HandleInitialMessageExecutionTest is TeleporterMessengerTest { ); // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); // Receive the message. vm.expectEmit(true, true, true, true, address(teleporterMessenger)); @@ -284,8 +284,8 @@ contract HandleInitialMessageExecutionTest is TeleporterMessengerTest { messageToReceive ); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS, - 0 + 0, + DEFAULT_RELAYER_REWARD_ADDRESS ); // Check that the message hash was stored in state and the message did not have any affect on the destination. diff --git a/contracts/src/Teleporter/tests/MarkReceiptTests.t.sol b/contracts/src/Teleporter/tests/MarkReceiptTests.t.sol index 09c485791..d1a057232 100644 --- a/contracts/src/Teleporter/tests/MarkReceiptTests.t.sol +++ b/contracts/src/Teleporter/tests/MarkReceiptTests.t.sol @@ -76,13 +76,13 @@ contract MarkReceiptTest is TeleporterMessengerTest { abi.encode(messageToReceive) ); - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); // Receive the mock message. address expectedRelayerRewardAddress = 0x93753a9eA4C9D6eeed9f64eA92E97ce1f5FBAeDe; teleporterMessenger.receiveCrossChainMessage( - expectedRelayerRewardAddress, - 0 + 0, + expectedRelayerRewardAddress ); // Check that the relayers have redeemable balances @@ -145,13 +145,13 @@ contract MarkReceiptTest is TeleporterMessengerTest { abi.encode(messageToReceive) ); - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); // Receive the mock message. address expectedRelayerRewardAddress = 0x2F20537C2F5c57231866DE9D0CE33d0681a200D4; teleporterMessenger.receiveCrossChainMessage( - expectedRelayerRewardAddress, - 0 + 0, + expectedRelayerRewardAddress ); // Check that the message received is considered delivered, and that the relayer reward address is stored. @@ -204,13 +204,13 @@ contract MarkReceiptTest is TeleporterMessengerTest { abi.encode(messageToReceive) ); - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); // Receive the mock message. address expectedRelayerRewardAddress = 0x6DAEF0D63ea44C801b655Fd97fe3804B9bFCC097; teleporterMessenger.receiveCrossChainMessage( - expectedRelayerRewardAddress, - 0 + 0, + expectedRelayerRewardAddress ); // Check that the relayer redeemable balances was only added once. diff --git a/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol b/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol index 5991991ac..745f64f99 100644 --- a/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol +++ b/contracts/src/Teleporter/tests/ReceiveCrossChainMessageTests.t.sol @@ -44,12 +44,12 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { ); // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); // Receive the message. teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS, - 0 + 0, + DEFAULT_RELAYER_REWARD_ADDRESS ); // Receive at a different index @@ -58,12 +58,12 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { DEFAULT_ORIGIN_CHAIN_ID, abi.encode(messageToReceive) ); - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 3); + _setUpSuccessGetVerifiedWarpMessageMock(3, warpMessage); // Receive the message. teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS, - 3 + 3, + DEFAULT_RELAYER_REWARD_ADDRESS ); } @@ -88,7 +88,7 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { ); vm.expectRevert(TeleporterMessenger.InvalidWarpMessage.selector); - teleporterMessenger.receiveCrossChainMessage(address(1), 0); + teleporterMessenger.receiveCrossChainMessage(0, address(1)); // Receive invalid message at index 3 vm.mockCall( @@ -102,7 +102,7 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { ); vm.expectRevert(TeleporterMessenger.InvalidWarpMessage.selector); - teleporterMessenger.receiveCrossChainMessage(address(1), 3); + teleporterMessenger.receiveCrossChainMessage(3, address(1)); } function testInvalidOriginSenderAddress() public { @@ -121,14 +121,14 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { warpMessage.originSenderAddress = invalidSenderAddress; // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); vm.expectRevert( TeleporterMessenger.InvalidOriginSenderAddress.selector ); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS, - 0 + 0, + DEFAULT_RELAYER_REWARD_ADDRESS ); } @@ -150,12 +150,12 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { warpMessage.destinationChainID = invalidDestinationChainID; // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); vm.expectRevert(TeleporterMessenger.InvalidDestinationChainID.selector); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS, - 0 + 0, + DEFAULT_RELAYER_REWARD_ADDRESS ); } @@ -175,12 +175,12 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { warpMessage.destinationAddress = invalidDestinationAddress; // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); vm.expectRevert(TeleporterMessenger.InvalidDestinationAddress.selector); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS, - 0 + 0, + DEFAULT_RELAYER_REWARD_ADDRESS ); } @@ -188,7 +188,7 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { vm.expectRevert( TeleporterMessenger.InvalidRelayerRewardAddress.selector ); - teleporterMessenger.receiveCrossChainMessage(address(0), 0); + teleporterMessenger.receiveCrossChainMessage(0, address(0)); } function testMessageAlreadyReceived() public { @@ -198,8 +198,8 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { // Check you can't deliver it again. vm.expectRevert(TeleporterMessenger.MessageAlreadyDelivered.selector); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS, - 0 + 0, + DEFAULT_RELAYER_REWARD_ADDRESS ); } @@ -225,13 +225,13 @@ contract ReceiveCrossChainMessagedTest is TeleporterMessengerTest { ); // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); // Receive the message. vm.expectRevert(TeleporterMessenger.UnauthorizedRelayer.selector); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS, - 0 + 0, + DEFAULT_RELAYER_REWARD_ADDRESS ); } diff --git a/contracts/src/Teleporter/tests/RedeemRelayerRewardsTests.t.sol b/contracts/src/Teleporter/tests/RedeemRelayerRewardsTests.t.sol index 4b3a13a42..9a21ea9b9 100644 --- a/contracts/src/Teleporter/tests/RedeemRelayerRewardsTests.t.sol +++ b/contracts/src/Teleporter/tests/RedeemRelayerRewardsTests.t.sol @@ -127,13 +127,13 @@ contract RedeemRelayerRewardsTest is TeleporterMessengerTest { abi.encode(messageToReceive) ); - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); // Receive the mock message. address expectedRelayerRewardAddress = 0x93753a9eA4C9D6eeed9f64eA92E97ce1f5FBAeDe; teleporterMessenger.receiveCrossChainMessage( - expectedRelayerRewardAddress, - 0 + 0, + expectedRelayerRewardAddress ); // Check that the relayer has redeemable balance diff --git a/contracts/src/Teleporter/tests/RetryMessageExecutionTests.t.sol b/contracts/src/Teleporter/tests/RetryMessageExecutionTests.t.sol index 8ed47df7a..e55cfb16c 100644 --- a/contracts/src/Teleporter/tests/RetryMessageExecutionTests.t.sol +++ b/contracts/src/Teleporter/tests/RetryMessageExecutionTests.t.sol @@ -86,7 +86,7 @@ contract FlakyMessageReceiver is ITeleporterReceiver { ITeleporterMessenger messenger = ITeleporterMessenger( teleporterContract ); - messenger.receiveCrossChainMessage(address(42), 0); + messenger.receiveCrossChainMessage(0, address(42)); latestMessage = message; latestMessageSenderSubnetID = originChainID; latestMessageSenderAddress = originSenderAddress; @@ -238,7 +238,7 @@ contract RetryMessageExecutionTest is TeleporterMessengerTest { ); // Mock the call to the warp precompile to get the message. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); // Receive the message in a block with an even height. // The message should be successfully received, but its execution should fail. @@ -250,8 +250,8 @@ contract RetryMessageExecutionTest is TeleporterMessengerTest { messageToReceive ); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS, - 0 + 0, + DEFAULT_RELAYER_REWARD_ADDRESS ); // Check that the message execution didn't have any effect, but diff --git a/contracts/src/Teleporter/tests/TeleporterMessengerTest.t.sol b/contracts/src/Teleporter/tests/TeleporterMessengerTest.t.sol index c19d507ab..b9c620fbb 100644 --- a/contracts/src/Teleporter/tests/TeleporterMessengerTest.t.sol +++ b/contracts/src/Teleporter/tests/TeleporterMessengerTest.t.sol @@ -131,8 +131,8 @@ contract TeleporterMessengerTest is Test { } function _setUpSuccessGetVerifiedWarpMessageMock( - WarpMessage memory warpMessage, - uint32 index + uint32 index, + WarpMessage memory warpMessage ) internal { vm.mockCall( WARP_PRECOMPILE_ADDRESS, @@ -167,10 +167,10 @@ contract TeleporterMessengerTest is Test { ); // We have to mock the precompile call so that it doesn't revert in the tests. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); // Receive the message. - teleporterMessenger.receiveCrossChainMessage(relayerRewardAddress, 0); + teleporterMessenger.receiveCrossChainMessage(0, relayerRewardAddress); } function _receiveMessageSentToEOA() @@ -194,7 +194,7 @@ contract TeleporterMessengerTest is Test { ); // We have to mock the precompile call so that it doesn't revert in the tests. - _setUpSuccessGetVerifiedWarpMessageMock(warpMessage, 0); + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); // Mock there being no code at the destination address which will be called // when the message is executed. This mimics the default destination address being an EOA. @@ -208,8 +208,8 @@ contract TeleporterMessengerTest is Test { messageToReceive ); teleporterMessenger.receiveCrossChainMessage( - DEFAULT_RELAYER_REWARD_ADDRESS, - 0 + 0, + DEFAULT_RELAYER_REWARD_ADDRESS ); return ( From 00fc76a6bdaf7ffbd1906cdd6a95e70e83533d65 Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Tue, 26 Sep 2023 11:23:11 -0700 Subject: [PATCH 13/22] Update contracts/src/Teleporter/ITeleporterMessenger.sol Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- contracts/src/Teleporter/ITeleporterMessenger.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/Teleporter/ITeleporterMessenger.sol b/contracts/src/Teleporter/ITeleporterMessenger.sol index 237ab3e4a..87653afd6 100644 --- a/contracts/src/Teleporter/ITeleporterMessenger.sol +++ b/contracts/src/Teleporter/ITeleporterMessenger.sol @@ -125,7 +125,7 @@ interface ITeleporterMessenger { /** * @dev Receives a cross chain message, and marks the `relayerRewardAddress` for fee reward for a successful delivery. * - * The message specified by `messageIndex` must be provided in the access list storage slots of the transaction, + * The message specified by `messageIndex` must be provided at that index in the access list storage slots of the transaction, * and is verified in the precompile predicate. */ function receiveCrossChainMessage( From a52b2b93a1fc98a15ad0a137169564b986b377b6 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Tue, 26 Sep 2023 21:52:01 +0000 Subject: [PATCH 14/22] basic block hash receiver --- .../ITeleporterBlockHashReceiver.sol | 30 +++++++++++ .../TeleporterBlockHashReceiver.sol | 50 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 contracts/src/Teleporter/ITeleporterBlockHashReceiver.sol create mode 100644 contracts/src/Teleporter/TeleporterBlockHashReceiver.sol diff --git a/contracts/src/Teleporter/ITeleporterBlockHashReceiver.sol b/contracts/src/Teleporter/ITeleporterBlockHashReceiver.sol new file mode 100644 index 000000000..87a6779b5 --- /dev/null +++ b/contracts/src/Teleporter/ITeleporterBlockHashReceiver.sol @@ -0,0 +1,30 @@ +// (c) 2023, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +// SPDX-License-Identifier: Ecosystem + +pragma solidity 0.8.18; + +/** + * @dev Interface that describes functionalities for receiving block hashes from other chains. + */ +interface ITeleporterBlockHashReceiver { + /** + * @dev Emitted when a block hash is successfully received. + */ + event ReceiveBlockHash( + bytes32 indexed originChainID, + bytes32 indexed blockHash + ); + + /** + * @dev Receives a block hash from another chain. + * + * The message specified by `messageIndex` must be provided at that index in the access list storage slots of the transaction, + * and is verified in the precompile predicate. + */ + function receiveCrossChainMessage( + uint32 messageIndex, + bytes32 sourceChainID + ) external; +} \ No newline at end of file diff --git a/contracts/src/Teleporter/TeleporterBlockHashReceiver.sol b/contracts/src/Teleporter/TeleporterBlockHashReceiver.sol new file mode 100644 index 000000000..91b7b498c --- /dev/null +++ b/contracts/src/Teleporter/TeleporterBlockHashReceiver.sol @@ -0,0 +1,50 @@ +// (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 "@subnet-evm-contracts/interfaces/IWarpMessenger.sol"; +import "./ReentrancyGuards.sol"; +import "./ITeleporterBlockHashReceiver.sol"; + +/** + * @dev Implementation of the {ITeleporterBlockHashReceiver} interface. + * + * This implementation is used to receive block hashes from other chains using the WarpMessenger precompile + */ +contract TeleporterBlockHashReceiver is ITeleporterBlockHashReceiver, ReentrancyGuards { + WarpMessenger public constant WARP_MESSENGER = + WarpMessenger(0x0200000000000000000000000000000000000005); + + error InvalidWarpBlockHash(); + error UnexpectedSourceChainID(); + + /** + * @dev See {ITeleporterBlockHashReceiver-receiveCrossChainMessage} + * + * Emits a {ReceiveBlockHash} event when a block hash is verified.. + */ + function receiveCrossChainMessage( + uint32 messageIndex, + bytes32 sourceChainID + ) external receiverNonReentrant { + // Verify and parse the block hash payload included in the transaction access list + // using the warp message precompile. + (WarpBlockHash memory warpBlockHash, bool success) = WARP_MESSENGER + .getVerifiedWarpBlockHash(messageIndex); + + if (!success) { + revert InvalidWarpBlockHash(); + } + if (warpBlockHash.sourceChainID != sourceChainID) { + revert UnexpectedSourceChainID(); + } + + emit ReceiveBlockHash( + warpBlockHash.sourceChainID, + warpBlockHash.blockHash + ); + } +} \ No newline at end of file From c08725fa0c66d587d352a148c67480655c3d7770 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Wed, 27 Sep 2023 21:34:46 +0000 Subject: [PATCH 15/22] block hash go binding --- .../teleporter_block_hash.go | 386 ++++++++++++++++++ 1 file changed, 386 insertions(+) create mode 100644 abis/go/teleporter-block-hash/teleporter_block_hash.go diff --git a/abis/go/teleporter-block-hash/teleporter_block_hash.go b/abis/go/teleporter-block-hash/teleporter_block_hash.go new file mode 100644 index 000000000..78f01f33f --- /dev/null +++ b/abis/go/teleporter-block-hash/teleporter_block_hash.go @@ -0,0 +1,386 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package teleporter_block_hash + +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 +) + +// TeleporterBlockHashMetaData contains all meta data concerning the TeleporterBlockHash contract. +var TeleporterBlockHashMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"InvalidWarpBlockHash\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ReceiverReentrancy\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SenderReentrancy\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UnexpectedSourceChainID\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"WARP_MESSENGER\",\"outputs\":[{\"internalType\":\"contractWarpMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"messageIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"sourceChainID\",\"type\":\"bytes32\"}],\"name\":\"receiveCrossChainMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// TeleporterBlockHashABI is the input ABI used to generate the binding from. +// Deprecated: Use TeleporterBlockHashMetaData.ABI instead. +var TeleporterBlockHashABI = TeleporterBlockHashMetaData.ABI + +// TeleporterBlockHash is an auto generated Go binding around an Ethereum contract. +type TeleporterBlockHash struct { + TeleporterBlockHashCaller // Read-only binding to the contract + TeleporterBlockHashTransactor // Write-only binding to the contract + TeleporterBlockHashFilterer // Log filterer for contract events +} + +// TeleporterBlockHashCaller is an auto generated read-only Go binding around an Ethereum contract. +type TeleporterBlockHashCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TeleporterBlockHashTransactor is an auto generated write-only Go binding around an Ethereum contract. +type TeleporterBlockHashTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TeleporterBlockHashFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type TeleporterBlockHashFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TeleporterBlockHashSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type TeleporterBlockHashSession struct { + Contract *TeleporterBlockHash // 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 +} + +// TeleporterBlockHashCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type TeleporterBlockHashCallerSession struct { + Contract *TeleporterBlockHashCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// TeleporterBlockHashTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type TeleporterBlockHashTransactorSession struct { + Contract *TeleporterBlockHashTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// TeleporterBlockHashRaw is an auto generated low-level Go binding around an Ethereum contract. +type TeleporterBlockHashRaw struct { + Contract *TeleporterBlockHash // Generic contract binding to access the raw methods on +} + +// TeleporterBlockHashCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type TeleporterBlockHashCallerRaw struct { + Contract *TeleporterBlockHashCaller // Generic read-only contract binding to access the raw methods on +} + +// TeleporterBlockHashTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type TeleporterBlockHashTransactorRaw struct { + Contract *TeleporterBlockHashTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewTeleporterBlockHash creates a new instance of TeleporterBlockHash, bound to a specific deployed contract. +func NewTeleporterBlockHash(address common.Address, backend bind.ContractBackend) (*TeleporterBlockHash, error) { + contract, err := bindTeleporterBlockHash(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &TeleporterBlockHash{TeleporterBlockHashCaller: TeleporterBlockHashCaller{contract: contract}, TeleporterBlockHashTransactor: TeleporterBlockHashTransactor{contract: contract}, TeleporterBlockHashFilterer: TeleporterBlockHashFilterer{contract: contract}}, nil +} + +// NewTeleporterBlockHashCaller creates a new read-only instance of TeleporterBlockHash, bound to a specific deployed contract. +func NewTeleporterBlockHashCaller(address common.Address, caller bind.ContractCaller) (*TeleporterBlockHashCaller, error) { + contract, err := bindTeleporterBlockHash(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &TeleporterBlockHashCaller{contract: contract}, nil +} + +// NewTeleporterBlockHashTransactor creates a new write-only instance of TeleporterBlockHash, bound to a specific deployed contract. +func NewTeleporterBlockHashTransactor(address common.Address, transactor bind.ContractTransactor) (*TeleporterBlockHashTransactor, error) { + contract, err := bindTeleporterBlockHash(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &TeleporterBlockHashTransactor{contract: contract}, nil +} + +// NewTeleporterBlockHashFilterer creates a new log filterer instance of TeleporterBlockHash, bound to a specific deployed contract. +func NewTeleporterBlockHashFilterer(address common.Address, filterer bind.ContractFilterer) (*TeleporterBlockHashFilterer, error) { + contract, err := bindTeleporterBlockHash(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &TeleporterBlockHashFilterer{contract: contract}, nil +} + +// bindTeleporterBlockHash binds a generic wrapper to an already deployed contract. +func bindTeleporterBlockHash(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := TeleporterBlockHashMetaData.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 (_TeleporterBlockHash *TeleporterBlockHashRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _TeleporterBlockHash.Contract.TeleporterBlockHashCaller.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 (_TeleporterBlockHash *TeleporterBlockHashRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TeleporterBlockHash.Contract.TeleporterBlockHashTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_TeleporterBlockHash *TeleporterBlockHashRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _TeleporterBlockHash.Contract.TeleporterBlockHashTransactor.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 (_TeleporterBlockHash *TeleporterBlockHashCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _TeleporterBlockHash.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 (_TeleporterBlockHash *TeleporterBlockHashTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TeleporterBlockHash.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_TeleporterBlockHash *TeleporterBlockHashTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _TeleporterBlockHash.Contract.contract.Transact(opts, method, params...) +} + +// WARPMESSENGER is a free data retrieval call binding the contract method 0xb771b3bc. +// +// Solidity: function WARP_MESSENGER() view returns(address) +func (_TeleporterBlockHash *TeleporterBlockHashCaller) WARPMESSENGER(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _TeleporterBlockHash.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 (_TeleporterBlockHash *TeleporterBlockHashSession) WARPMESSENGER() (common.Address, error) { + return _TeleporterBlockHash.Contract.WARPMESSENGER(&_TeleporterBlockHash.CallOpts) +} + +// WARPMESSENGER is a free data retrieval call binding the contract method 0xb771b3bc. +// +// Solidity: function WARP_MESSENGER() view returns(address) +func (_TeleporterBlockHash *TeleporterBlockHashCallerSession) WARPMESSENGER() (common.Address, error) { + return _TeleporterBlockHash.Contract.WARPMESSENGER(&_TeleporterBlockHash.CallOpts) +} + +// ReceiveCrossChainMessage is a paid mutator transaction binding the contract method 0xd791465a. +// +// Solidity: function receiveCrossChainMessage(uint32 messageIndex, bytes32 sourceChainID) returns() +func (_TeleporterBlockHash *TeleporterBlockHashTransactor) ReceiveCrossChainMessage(opts *bind.TransactOpts, messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { + return _TeleporterBlockHash.contract.Transact(opts, "receiveCrossChainMessage", messageIndex, sourceChainID) +} + +// ReceiveCrossChainMessage is a paid mutator transaction binding the contract method 0xd791465a. +// +// Solidity: function receiveCrossChainMessage(uint32 messageIndex, bytes32 sourceChainID) returns() +func (_TeleporterBlockHash *TeleporterBlockHashSession) ReceiveCrossChainMessage(messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { + return _TeleporterBlockHash.Contract.ReceiveCrossChainMessage(&_TeleporterBlockHash.TransactOpts, messageIndex, sourceChainID) +} + +// ReceiveCrossChainMessage is a paid mutator transaction binding the contract method 0xd791465a. +// +// Solidity: function receiveCrossChainMessage(uint32 messageIndex, bytes32 sourceChainID) returns() +func (_TeleporterBlockHash *TeleporterBlockHashTransactorSession) ReceiveCrossChainMessage(messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { + return _TeleporterBlockHash.Contract.ReceiveCrossChainMessage(&_TeleporterBlockHash.TransactOpts, messageIndex, sourceChainID) +} + +// TeleporterBlockHashReceiveBlockHashIterator is returned from FilterReceiveBlockHash and is used to iterate over the raw logs and unpacked data for ReceiveBlockHash events raised by the TeleporterBlockHash contract. +type TeleporterBlockHashReceiveBlockHashIterator struct { + Event *TeleporterBlockHashReceiveBlockHash // 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 *TeleporterBlockHashReceiveBlockHashIterator) 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(TeleporterBlockHashReceiveBlockHash) + 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(TeleporterBlockHashReceiveBlockHash) + 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 *TeleporterBlockHashReceiveBlockHashIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *TeleporterBlockHashReceiveBlockHashIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// TeleporterBlockHashReceiveBlockHash represents a ReceiveBlockHash event raised by the TeleporterBlockHash contract. +type TeleporterBlockHashReceiveBlockHash struct { + OriginChainID [32]byte + BlockHash [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterReceiveBlockHash is a free log retrieval operation binding the contract event 0x7770e5f72465e9b05c8076c3f2eac70898abe6a84f0259307d127c13e2a1a4e4. +// +// Solidity: event ReceiveBlockHash(bytes32 indexed originChainID, bytes32 indexed blockHash) +func (_TeleporterBlockHash *TeleporterBlockHashFilterer) FilterReceiveBlockHash(opts *bind.FilterOpts, originChainID [][32]byte, blockHash [][32]byte) (*TeleporterBlockHashReceiveBlockHashIterator, error) { + + var originChainIDRule []interface{} + for _, originChainIDItem := range originChainID { + originChainIDRule = append(originChainIDRule, originChainIDItem) + } + var blockHashRule []interface{} + for _, blockHashItem := range blockHash { + blockHashRule = append(blockHashRule, blockHashItem) + } + + logs, sub, err := _TeleporterBlockHash.contract.FilterLogs(opts, "ReceiveBlockHash", originChainIDRule, blockHashRule) + if err != nil { + return nil, err + } + return &TeleporterBlockHashReceiveBlockHashIterator{contract: _TeleporterBlockHash.contract, event: "ReceiveBlockHash", logs: logs, sub: sub}, nil +} + +// WatchReceiveBlockHash is a free log subscription operation binding the contract event 0x7770e5f72465e9b05c8076c3f2eac70898abe6a84f0259307d127c13e2a1a4e4. +// +// Solidity: event ReceiveBlockHash(bytes32 indexed originChainID, bytes32 indexed blockHash) +func (_TeleporterBlockHash *TeleporterBlockHashFilterer) WatchReceiveBlockHash(opts *bind.WatchOpts, sink chan<- *TeleporterBlockHashReceiveBlockHash, originChainID [][32]byte, blockHash [][32]byte) (event.Subscription, error) { + + var originChainIDRule []interface{} + for _, originChainIDItem := range originChainID { + originChainIDRule = append(originChainIDRule, originChainIDItem) + } + var blockHashRule []interface{} + for _, blockHashItem := range blockHash { + blockHashRule = append(blockHashRule, blockHashItem) + } + + logs, sub, err := _TeleporterBlockHash.contract.WatchLogs(opts, "ReceiveBlockHash", originChainIDRule, blockHashRule) + 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(TeleporterBlockHashReceiveBlockHash) + if err := _TeleporterBlockHash.contract.UnpackLog(event, "ReceiveBlockHash", 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 +} + +// ParseReceiveBlockHash is a log parse operation binding the contract event 0x7770e5f72465e9b05c8076c3f2eac70898abe6a84f0259307d127c13e2a1a4e4. +// +// Solidity: event ReceiveBlockHash(bytes32 indexed originChainID, bytes32 indexed blockHash) +func (_TeleporterBlockHash *TeleporterBlockHashFilterer) ParseReceiveBlockHash(log types.Log) (*TeleporterBlockHashReceiveBlockHash, error) { + event := new(TeleporterBlockHashReceiveBlockHash) + if err := _TeleporterBlockHash.contract.UnpackLog(event, "ReceiveBlockHash", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} From 43ad4b3620afd8fe26318c9abc7f822555a758fb Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Thu, 28 Sep 2023 14:25:15 +0000 Subject: [PATCH 16/22] block hash packing --- .../teleporter_block_hash.go | 26 +++++++++---------- .../teleporter_block_hash_packing.go | 21 +++++++++++++++ .../ITeleporterBlockHashReceiver.sol | 2 +- .../TeleporterBlockHashReceiver.sol | 2 +- 4 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 abis/go/teleporter-block-hash/teleporter_block_hash_packing.go diff --git a/abis/go/teleporter-block-hash/teleporter_block_hash.go b/abis/go/teleporter-block-hash/teleporter_block_hash.go index 78f01f33f..9623ecae5 100644 --- a/abis/go/teleporter-block-hash/teleporter_block_hash.go +++ b/abis/go/teleporter-block-hash/teleporter_block_hash.go @@ -31,7 +31,7 @@ var ( // TeleporterBlockHashMetaData contains all meta data concerning the TeleporterBlockHash contract. var TeleporterBlockHashMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"name\":\"InvalidWarpBlockHash\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ReceiverReentrancy\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SenderReentrancy\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UnexpectedSourceChainID\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"WARP_MESSENGER\",\"outputs\":[{\"internalType\":\"contractWarpMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"messageIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"sourceChainID\",\"type\":\"bytes32\"}],\"name\":\"receiveCrossChainMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[],\"name\":\"InvalidWarpBlockHash\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ReceiverReentrancy\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SenderReentrancy\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UnexpectedSourceChainID\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"WARP_MESSENGER\",\"outputs\":[{\"internalType\":\"contractWarpMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"messageIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"sourceChainID\",\"type\":\"bytes32\"}],\"name\":\"receiveBlockHash\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // TeleporterBlockHashABI is the input ABI used to generate the binding from. @@ -211,25 +211,25 @@ func (_TeleporterBlockHash *TeleporterBlockHashCallerSession) WARPMESSENGER() (c return _TeleporterBlockHash.Contract.WARPMESSENGER(&_TeleporterBlockHash.CallOpts) } -// ReceiveCrossChainMessage is a paid mutator transaction binding the contract method 0xd791465a. +// ReceiveBlockHash is a paid mutator transaction binding the contract method 0x30b52559. // -// Solidity: function receiveCrossChainMessage(uint32 messageIndex, bytes32 sourceChainID) returns() -func (_TeleporterBlockHash *TeleporterBlockHashTransactor) ReceiveCrossChainMessage(opts *bind.TransactOpts, messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { - return _TeleporterBlockHash.contract.Transact(opts, "receiveCrossChainMessage", messageIndex, sourceChainID) +// Solidity: function receiveBlockHash(uint32 messageIndex, bytes32 sourceChainID) returns() +func (_TeleporterBlockHash *TeleporterBlockHashTransactor) ReceiveBlockHash(opts *bind.TransactOpts, messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { + return _TeleporterBlockHash.contract.Transact(opts, "receiveBlockHash", messageIndex, sourceChainID) } -// ReceiveCrossChainMessage is a paid mutator transaction binding the contract method 0xd791465a. +// ReceiveBlockHash is a paid mutator transaction binding the contract method 0x30b52559. // -// Solidity: function receiveCrossChainMessage(uint32 messageIndex, bytes32 sourceChainID) returns() -func (_TeleporterBlockHash *TeleporterBlockHashSession) ReceiveCrossChainMessage(messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { - return _TeleporterBlockHash.Contract.ReceiveCrossChainMessage(&_TeleporterBlockHash.TransactOpts, messageIndex, sourceChainID) +// Solidity: function receiveBlockHash(uint32 messageIndex, bytes32 sourceChainID) returns() +func (_TeleporterBlockHash *TeleporterBlockHashSession) ReceiveBlockHash(messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { + return _TeleporterBlockHash.Contract.ReceiveBlockHash(&_TeleporterBlockHash.TransactOpts, messageIndex, sourceChainID) } -// ReceiveCrossChainMessage is a paid mutator transaction binding the contract method 0xd791465a. +// ReceiveBlockHash is a paid mutator transaction binding the contract method 0x30b52559. // -// Solidity: function receiveCrossChainMessage(uint32 messageIndex, bytes32 sourceChainID) returns() -func (_TeleporterBlockHash *TeleporterBlockHashTransactorSession) ReceiveCrossChainMessage(messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { - return _TeleporterBlockHash.Contract.ReceiveCrossChainMessage(&_TeleporterBlockHash.TransactOpts, messageIndex, sourceChainID) +// Solidity: function receiveBlockHash(uint32 messageIndex, bytes32 sourceChainID) returns() +func (_TeleporterBlockHash *TeleporterBlockHashTransactorSession) ReceiveBlockHash(messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { + return _TeleporterBlockHash.Contract.ReceiveBlockHash(&_TeleporterBlockHash.TransactOpts, messageIndex, sourceChainID) } // TeleporterBlockHashReceiveBlockHashIterator is returned from FilterReceiveBlockHash and is used to iterate over the raw logs and unpacked data for ReceiveBlockHash events raised by the TeleporterBlockHash contract. diff --git a/abis/go/teleporter-block-hash/teleporter_block_hash_packing.go b/abis/go/teleporter-block-hash/teleporter_block_hash_packing.go new file mode 100644 index 000000000..91c5615a5 --- /dev/null +++ b/abis/go/teleporter-block-hash/teleporter_block_hash_packing.go @@ -0,0 +1,21 @@ +package teleporter_block_hash + +import "github.com/ava-labs/avalanchego/ids" + +// ReceiveBlockHashInput is the input to receiveBlockHash call +// in the contract deployed on the destination chain +// - messageIndex: specifies the warp message in the transaction's storage slots. +// - +type ReceiveBlockHashInput struct { + MessageIndex uint32 `json:"messageIndex"` + SourceChainID ids.ID `json:"sourceChainID"` +} + +// Pack packs a ReceiveCrossChainMessageInput to form a call to the receiveCrossChainMessage function +func PackReceiveBlockHash(inputStruct ReceiveBlockHashInput) ([]byte, error) { + abi, err := TeleporterBlockHashMetaData.GetAbi() + if err != nil { + return nil, err + } + return abi.Pack("receiveBlockHash", inputStruct.MessageIndex, inputStruct.SourceChainID) +} diff --git a/contracts/src/Teleporter/ITeleporterBlockHashReceiver.sol b/contracts/src/Teleporter/ITeleporterBlockHashReceiver.sol index 87a6779b5..af453371c 100644 --- a/contracts/src/Teleporter/ITeleporterBlockHashReceiver.sol +++ b/contracts/src/Teleporter/ITeleporterBlockHashReceiver.sol @@ -23,7 +23,7 @@ interface ITeleporterBlockHashReceiver { * The message specified by `messageIndex` must be provided at that index in the access list storage slots of the transaction, * and is verified in the precompile predicate. */ - function receiveCrossChainMessage( + function receiveBlockHash( uint32 messageIndex, bytes32 sourceChainID ) external; diff --git a/contracts/src/Teleporter/TeleporterBlockHashReceiver.sol b/contracts/src/Teleporter/TeleporterBlockHashReceiver.sol index 91b7b498c..87331a77d 100644 --- a/contracts/src/Teleporter/TeleporterBlockHashReceiver.sol +++ b/contracts/src/Teleporter/TeleporterBlockHashReceiver.sol @@ -26,7 +26,7 @@ contract TeleporterBlockHashReceiver is ITeleporterBlockHashReceiver, Reentrancy * * Emits a {ReceiveBlockHash} event when a block hash is verified.. */ - function receiveCrossChainMessage( + function receiveBlockHash( uint32 messageIndex, bytes32 sourceChainID ) external receiverNonReentrant { From 9b7af3f98ce4cc6fa21fca630a6875434b85ba80 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Thu, 5 Oct 2023 19:33:06 +0000 Subject: [PATCH 17/22] cleanup var --- tests/utils/utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/utils/utils.go b/tests/utils/utils.go index 669d681c4..20872d867 100644 --- a/tests/utils/utils.go +++ b/tests/utils/utils.go @@ -78,9 +78,9 @@ func SendTransactionAndWaitForAcceptance( tx *types.Transaction) *types.Receipt { newHeads := make(chan *types.Header, 1) - subA, err := wsClient.SubscribeNewHead(ctx, newHeads) + sub, err := wsClient.SubscribeNewHead(ctx, newHeads) Expect(err).Should(BeNil()) - defer subA.Unsubscribe() + defer sub.Unsubscribe() err = wsClient.SendTransaction(ctx, tx) Expect(err).Should(BeNil()) From a8e949bd37c97fc5d5c696d03a7c8b285f8ad6b7 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Thu, 5 Oct 2023 19:41:59 +0000 Subject: [PATCH 18/22] block hash receiver abigen --- .../TeleporterBlockHashReceiver.go | 386 ++++++++++++++++++ .../packing.go} | 4 +- .../teleporter_block_hash.go | 386 ------------------ scripts/abi_go_bindings.sh | 2 +- 4 files changed, 389 insertions(+), 389 deletions(-) create mode 100644 abis/TeleporterBlockHashReceiver/TeleporterBlockHashReceiver.go rename abis/{go/teleporter-block-hash/teleporter_block_hash_packing.go => TeleporterBlockHashReceiver/packing.go} (87%) delete mode 100644 abis/go/teleporter-block-hash/teleporter_block_hash.go diff --git a/abis/TeleporterBlockHashReceiver/TeleporterBlockHashReceiver.go b/abis/TeleporterBlockHashReceiver/TeleporterBlockHashReceiver.go new file mode 100644 index 000000000..de033b4e7 --- /dev/null +++ b/abis/TeleporterBlockHashReceiver/TeleporterBlockHashReceiver.go @@ -0,0 +1,386 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package teleporterblockhashreceiver + +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 +) + +// TeleporterblockhashreceiverMetaData contains all meta data concerning the Teleporterblockhashreceiver contract. +var TeleporterblockhashreceiverMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"InvalidWarpBlockHash\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ReceiverReentrancy\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SenderReentrancy\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UnexpectedSourceChainID\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"WARP_MESSENGER\",\"outputs\":[{\"internalType\":\"contractWarpMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"messageIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"sourceChainID\",\"type\":\"bytes32\"}],\"name\":\"receiveBlockHash\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// TeleporterblockhashreceiverABI is the input ABI used to generate the binding from. +// Deprecated: Use TeleporterblockhashreceiverMetaData.ABI instead. +var TeleporterblockhashreceiverABI = TeleporterblockhashreceiverMetaData.ABI + +// Teleporterblockhashreceiver is an auto generated Go binding around an Ethereum contract. +type Teleporterblockhashreceiver struct { + TeleporterblockhashreceiverCaller // Read-only binding to the contract + TeleporterblockhashreceiverTransactor // Write-only binding to the contract + TeleporterblockhashreceiverFilterer // Log filterer for contract events +} + +// TeleporterblockhashreceiverCaller is an auto generated read-only Go binding around an Ethereum contract. +type TeleporterblockhashreceiverCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TeleporterblockhashreceiverTransactor is an auto generated write-only Go binding around an Ethereum contract. +type TeleporterblockhashreceiverTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TeleporterblockhashreceiverFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type TeleporterblockhashreceiverFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TeleporterblockhashreceiverSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type TeleporterblockhashreceiverSession struct { + Contract *Teleporterblockhashreceiver // 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 +} + +// TeleporterblockhashreceiverCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type TeleporterblockhashreceiverCallerSession struct { + Contract *TeleporterblockhashreceiverCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// TeleporterblockhashreceiverTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type TeleporterblockhashreceiverTransactorSession struct { + Contract *TeleporterblockhashreceiverTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// TeleporterblockhashreceiverRaw is an auto generated low-level Go binding around an Ethereum contract. +type TeleporterblockhashreceiverRaw struct { + Contract *Teleporterblockhashreceiver // Generic contract binding to access the raw methods on +} + +// TeleporterblockhashreceiverCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type TeleporterblockhashreceiverCallerRaw struct { + Contract *TeleporterblockhashreceiverCaller // Generic read-only contract binding to access the raw methods on +} + +// TeleporterblockhashreceiverTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type TeleporterblockhashreceiverTransactorRaw struct { + Contract *TeleporterblockhashreceiverTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewTeleporterblockhashreceiver creates a new instance of Teleporterblockhashreceiver, bound to a specific deployed contract. +func NewTeleporterblockhashreceiver(address common.Address, backend bind.ContractBackend) (*Teleporterblockhashreceiver, error) { + contract, err := bindTeleporterblockhashreceiver(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Teleporterblockhashreceiver{TeleporterblockhashreceiverCaller: TeleporterblockhashreceiverCaller{contract: contract}, TeleporterblockhashreceiverTransactor: TeleporterblockhashreceiverTransactor{contract: contract}, TeleporterblockhashreceiverFilterer: TeleporterblockhashreceiverFilterer{contract: contract}}, nil +} + +// NewTeleporterblockhashreceiverCaller creates a new read-only instance of Teleporterblockhashreceiver, bound to a specific deployed contract. +func NewTeleporterblockhashreceiverCaller(address common.Address, caller bind.ContractCaller) (*TeleporterblockhashreceiverCaller, error) { + contract, err := bindTeleporterblockhashreceiver(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &TeleporterblockhashreceiverCaller{contract: contract}, nil +} + +// NewTeleporterblockhashreceiverTransactor creates a new write-only instance of Teleporterblockhashreceiver, bound to a specific deployed contract. +func NewTeleporterblockhashreceiverTransactor(address common.Address, transactor bind.ContractTransactor) (*TeleporterblockhashreceiverTransactor, error) { + contract, err := bindTeleporterblockhashreceiver(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &TeleporterblockhashreceiverTransactor{contract: contract}, nil +} + +// NewTeleporterblockhashreceiverFilterer creates a new log filterer instance of Teleporterblockhashreceiver, bound to a specific deployed contract. +func NewTeleporterblockhashreceiverFilterer(address common.Address, filterer bind.ContractFilterer) (*TeleporterblockhashreceiverFilterer, error) { + contract, err := bindTeleporterblockhashreceiver(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &TeleporterblockhashreceiverFilterer{contract: contract}, nil +} + +// bindTeleporterblockhashreceiver binds a generic wrapper to an already deployed contract. +func bindTeleporterblockhashreceiver(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := TeleporterblockhashreceiverMetaData.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 (_Teleporterblockhashreceiver *TeleporterblockhashreceiverRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Teleporterblockhashreceiver.Contract.TeleporterblockhashreceiverCaller.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 (_Teleporterblockhashreceiver *TeleporterblockhashreceiverRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Teleporterblockhashreceiver.Contract.TeleporterblockhashreceiverTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Teleporterblockhashreceiver *TeleporterblockhashreceiverRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Teleporterblockhashreceiver.Contract.TeleporterblockhashreceiverTransactor.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 (_Teleporterblockhashreceiver *TeleporterblockhashreceiverCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Teleporterblockhashreceiver.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 (_Teleporterblockhashreceiver *TeleporterblockhashreceiverTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Teleporterblockhashreceiver.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Teleporterblockhashreceiver *TeleporterblockhashreceiverTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Teleporterblockhashreceiver.Contract.contract.Transact(opts, method, params...) +} + +// WARPMESSENGER is a free data retrieval call binding the contract method 0xb771b3bc. +// +// Solidity: function WARP_MESSENGER() view returns(address) +func (_Teleporterblockhashreceiver *TeleporterblockhashreceiverCaller) WARPMESSENGER(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Teleporterblockhashreceiver.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 (_Teleporterblockhashreceiver *TeleporterblockhashreceiverSession) WARPMESSENGER() (common.Address, error) { + return _Teleporterblockhashreceiver.Contract.WARPMESSENGER(&_Teleporterblockhashreceiver.CallOpts) +} + +// WARPMESSENGER is a free data retrieval call binding the contract method 0xb771b3bc. +// +// Solidity: function WARP_MESSENGER() view returns(address) +func (_Teleporterblockhashreceiver *TeleporterblockhashreceiverCallerSession) WARPMESSENGER() (common.Address, error) { + return _Teleporterblockhashreceiver.Contract.WARPMESSENGER(&_Teleporterblockhashreceiver.CallOpts) +} + +// ReceiveBlockHash is a paid mutator transaction binding the contract method 0x30b52559. +// +// Solidity: function receiveBlockHash(uint32 messageIndex, bytes32 sourceChainID) returns() +func (_Teleporterblockhashreceiver *TeleporterblockhashreceiverTransactor) ReceiveBlockHash(opts *bind.TransactOpts, messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { + return _Teleporterblockhashreceiver.contract.Transact(opts, "receiveBlockHash", messageIndex, sourceChainID) +} + +// ReceiveBlockHash is a paid mutator transaction binding the contract method 0x30b52559. +// +// Solidity: function receiveBlockHash(uint32 messageIndex, bytes32 sourceChainID) returns() +func (_Teleporterblockhashreceiver *TeleporterblockhashreceiverSession) ReceiveBlockHash(messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { + return _Teleporterblockhashreceiver.Contract.ReceiveBlockHash(&_Teleporterblockhashreceiver.TransactOpts, messageIndex, sourceChainID) +} + +// ReceiveBlockHash is a paid mutator transaction binding the contract method 0x30b52559. +// +// Solidity: function receiveBlockHash(uint32 messageIndex, bytes32 sourceChainID) returns() +func (_Teleporterblockhashreceiver *TeleporterblockhashreceiverTransactorSession) ReceiveBlockHash(messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { + return _Teleporterblockhashreceiver.Contract.ReceiveBlockHash(&_Teleporterblockhashreceiver.TransactOpts, messageIndex, sourceChainID) +} + +// TeleporterblockhashreceiverReceiveBlockHashIterator is returned from FilterReceiveBlockHash and is used to iterate over the raw logs and unpacked data for ReceiveBlockHash events raised by the Teleporterblockhashreceiver contract. +type TeleporterblockhashreceiverReceiveBlockHashIterator struct { + Event *TeleporterblockhashreceiverReceiveBlockHash // 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 *TeleporterblockhashreceiverReceiveBlockHashIterator) 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(TeleporterblockhashreceiverReceiveBlockHash) + 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(TeleporterblockhashreceiverReceiveBlockHash) + 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 *TeleporterblockhashreceiverReceiveBlockHashIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *TeleporterblockhashreceiverReceiveBlockHashIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// TeleporterblockhashreceiverReceiveBlockHash represents a ReceiveBlockHash event raised by the Teleporterblockhashreceiver contract. +type TeleporterblockhashreceiverReceiveBlockHash struct { + OriginChainID [32]byte + BlockHash [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterReceiveBlockHash is a free log retrieval operation binding the contract event 0x7770e5f72465e9b05c8076c3f2eac70898abe6a84f0259307d127c13e2a1a4e4. +// +// Solidity: event ReceiveBlockHash(bytes32 indexed originChainID, bytes32 indexed blockHash) +func (_Teleporterblockhashreceiver *TeleporterblockhashreceiverFilterer) FilterReceiveBlockHash(opts *bind.FilterOpts, originChainID [][32]byte, blockHash [][32]byte) (*TeleporterblockhashreceiverReceiveBlockHashIterator, error) { + + var originChainIDRule []interface{} + for _, originChainIDItem := range originChainID { + originChainIDRule = append(originChainIDRule, originChainIDItem) + } + var blockHashRule []interface{} + for _, blockHashItem := range blockHash { + blockHashRule = append(blockHashRule, blockHashItem) + } + + logs, sub, err := _Teleporterblockhashreceiver.contract.FilterLogs(opts, "ReceiveBlockHash", originChainIDRule, blockHashRule) + if err != nil { + return nil, err + } + return &TeleporterblockhashreceiverReceiveBlockHashIterator{contract: _Teleporterblockhashreceiver.contract, event: "ReceiveBlockHash", logs: logs, sub: sub}, nil +} + +// WatchReceiveBlockHash is a free log subscription operation binding the contract event 0x7770e5f72465e9b05c8076c3f2eac70898abe6a84f0259307d127c13e2a1a4e4. +// +// Solidity: event ReceiveBlockHash(bytes32 indexed originChainID, bytes32 indexed blockHash) +func (_Teleporterblockhashreceiver *TeleporterblockhashreceiverFilterer) WatchReceiveBlockHash(opts *bind.WatchOpts, sink chan<- *TeleporterblockhashreceiverReceiveBlockHash, originChainID [][32]byte, blockHash [][32]byte) (event.Subscription, error) { + + var originChainIDRule []interface{} + for _, originChainIDItem := range originChainID { + originChainIDRule = append(originChainIDRule, originChainIDItem) + } + var blockHashRule []interface{} + for _, blockHashItem := range blockHash { + blockHashRule = append(blockHashRule, blockHashItem) + } + + logs, sub, err := _Teleporterblockhashreceiver.contract.WatchLogs(opts, "ReceiveBlockHash", originChainIDRule, blockHashRule) + 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(TeleporterblockhashreceiverReceiveBlockHash) + if err := _Teleporterblockhashreceiver.contract.UnpackLog(event, "ReceiveBlockHash", 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 +} + +// ParseReceiveBlockHash is a log parse operation binding the contract event 0x7770e5f72465e9b05c8076c3f2eac70898abe6a84f0259307d127c13e2a1a4e4. +// +// Solidity: event ReceiveBlockHash(bytes32 indexed originChainID, bytes32 indexed blockHash) +func (_Teleporterblockhashreceiver *TeleporterblockhashreceiverFilterer) ParseReceiveBlockHash(log types.Log) (*TeleporterblockhashreceiverReceiveBlockHash, error) { + event := new(TeleporterblockhashreceiverReceiveBlockHash) + if err := _Teleporterblockhashreceiver.contract.UnpackLog(event, "ReceiveBlockHash", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/abis/go/teleporter-block-hash/teleporter_block_hash_packing.go b/abis/TeleporterBlockHashReceiver/packing.go similarity index 87% rename from abis/go/teleporter-block-hash/teleporter_block_hash_packing.go rename to abis/TeleporterBlockHashReceiver/packing.go index 91c5615a5..16120e5a9 100644 --- a/abis/go/teleporter-block-hash/teleporter_block_hash_packing.go +++ b/abis/TeleporterBlockHashReceiver/packing.go @@ -1,4 +1,4 @@ -package teleporter_block_hash +package teleporterblockhashreceiver import "github.com/ava-labs/avalanchego/ids" @@ -13,7 +13,7 @@ type ReceiveBlockHashInput struct { // Pack packs a ReceiveCrossChainMessageInput to form a call to the receiveCrossChainMessage function func PackReceiveBlockHash(inputStruct ReceiveBlockHashInput) ([]byte, error) { - abi, err := TeleporterBlockHashMetaData.GetAbi() + abi, err := TeleporterblockhashreceiverMetaData.GetAbi() if err != nil { return nil, err } diff --git a/abis/go/teleporter-block-hash/teleporter_block_hash.go b/abis/go/teleporter-block-hash/teleporter_block_hash.go deleted file mode 100644 index 9623ecae5..000000000 --- a/abis/go/teleporter-block-hash/teleporter_block_hash.go +++ /dev/null @@ -1,386 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package teleporter_block_hash - -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 -) - -// TeleporterBlockHashMetaData contains all meta data concerning the TeleporterBlockHash contract. -var TeleporterBlockHashMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"name\":\"InvalidWarpBlockHash\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ReceiverReentrancy\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SenderReentrancy\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UnexpectedSourceChainID\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"WARP_MESSENGER\",\"outputs\":[{\"internalType\":\"contractWarpMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"messageIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"sourceChainID\",\"type\":\"bytes32\"}],\"name\":\"receiveBlockHash\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", -} - -// TeleporterBlockHashABI is the input ABI used to generate the binding from. -// Deprecated: Use TeleporterBlockHashMetaData.ABI instead. -var TeleporterBlockHashABI = TeleporterBlockHashMetaData.ABI - -// TeleporterBlockHash is an auto generated Go binding around an Ethereum contract. -type TeleporterBlockHash struct { - TeleporterBlockHashCaller // Read-only binding to the contract - TeleporterBlockHashTransactor // Write-only binding to the contract - TeleporterBlockHashFilterer // Log filterer for contract events -} - -// TeleporterBlockHashCaller is an auto generated read-only Go binding around an Ethereum contract. -type TeleporterBlockHashCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// TeleporterBlockHashTransactor is an auto generated write-only Go binding around an Ethereum contract. -type TeleporterBlockHashTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// TeleporterBlockHashFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type TeleporterBlockHashFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// TeleporterBlockHashSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type TeleporterBlockHashSession struct { - Contract *TeleporterBlockHash // 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 -} - -// TeleporterBlockHashCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type TeleporterBlockHashCallerSession struct { - Contract *TeleporterBlockHashCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// TeleporterBlockHashTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type TeleporterBlockHashTransactorSession struct { - Contract *TeleporterBlockHashTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// TeleporterBlockHashRaw is an auto generated low-level Go binding around an Ethereum contract. -type TeleporterBlockHashRaw struct { - Contract *TeleporterBlockHash // Generic contract binding to access the raw methods on -} - -// TeleporterBlockHashCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type TeleporterBlockHashCallerRaw struct { - Contract *TeleporterBlockHashCaller // Generic read-only contract binding to access the raw methods on -} - -// TeleporterBlockHashTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type TeleporterBlockHashTransactorRaw struct { - Contract *TeleporterBlockHashTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewTeleporterBlockHash creates a new instance of TeleporterBlockHash, bound to a specific deployed contract. -func NewTeleporterBlockHash(address common.Address, backend bind.ContractBackend) (*TeleporterBlockHash, error) { - contract, err := bindTeleporterBlockHash(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &TeleporterBlockHash{TeleporterBlockHashCaller: TeleporterBlockHashCaller{contract: contract}, TeleporterBlockHashTransactor: TeleporterBlockHashTransactor{contract: contract}, TeleporterBlockHashFilterer: TeleporterBlockHashFilterer{contract: contract}}, nil -} - -// NewTeleporterBlockHashCaller creates a new read-only instance of TeleporterBlockHash, bound to a specific deployed contract. -func NewTeleporterBlockHashCaller(address common.Address, caller bind.ContractCaller) (*TeleporterBlockHashCaller, error) { - contract, err := bindTeleporterBlockHash(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &TeleporterBlockHashCaller{contract: contract}, nil -} - -// NewTeleporterBlockHashTransactor creates a new write-only instance of TeleporterBlockHash, bound to a specific deployed contract. -func NewTeleporterBlockHashTransactor(address common.Address, transactor bind.ContractTransactor) (*TeleporterBlockHashTransactor, error) { - contract, err := bindTeleporterBlockHash(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &TeleporterBlockHashTransactor{contract: contract}, nil -} - -// NewTeleporterBlockHashFilterer creates a new log filterer instance of TeleporterBlockHash, bound to a specific deployed contract. -func NewTeleporterBlockHashFilterer(address common.Address, filterer bind.ContractFilterer) (*TeleporterBlockHashFilterer, error) { - contract, err := bindTeleporterBlockHash(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &TeleporterBlockHashFilterer{contract: contract}, nil -} - -// bindTeleporterBlockHash binds a generic wrapper to an already deployed contract. -func bindTeleporterBlockHash(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := TeleporterBlockHashMetaData.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 (_TeleporterBlockHash *TeleporterBlockHashRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _TeleporterBlockHash.Contract.TeleporterBlockHashCaller.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 (_TeleporterBlockHash *TeleporterBlockHashRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _TeleporterBlockHash.Contract.TeleporterBlockHashTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_TeleporterBlockHash *TeleporterBlockHashRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _TeleporterBlockHash.Contract.TeleporterBlockHashTransactor.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 (_TeleporterBlockHash *TeleporterBlockHashCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _TeleporterBlockHash.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 (_TeleporterBlockHash *TeleporterBlockHashTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _TeleporterBlockHash.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_TeleporterBlockHash *TeleporterBlockHashTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _TeleporterBlockHash.Contract.contract.Transact(opts, method, params...) -} - -// WARPMESSENGER is a free data retrieval call binding the contract method 0xb771b3bc. -// -// Solidity: function WARP_MESSENGER() view returns(address) -func (_TeleporterBlockHash *TeleporterBlockHashCaller) WARPMESSENGER(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _TeleporterBlockHash.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 (_TeleporterBlockHash *TeleporterBlockHashSession) WARPMESSENGER() (common.Address, error) { - return _TeleporterBlockHash.Contract.WARPMESSENGER(&_TeleporterBlockHash.CallOpts) -} - -// WARPMESSENGER is a free data retrieval call binding the contract method 0xb771b3bc. -// -// Solidity: function WARP_MESSENGER() view returns(address) -func (_TeleporterBlockHash *TeleporterBlockHashCallerSession) WARPMESSENGER() (common.Address, error) { - return _TeleporterBlockHash.Contract.WARPMESSENGER(&_TeleporterBlockHash.CallOpts) -} - -// ReceiveBlockHash is a paid mutator transaction binding the contract method 0x30b52559. -// -// Solidity: function receiveBlockHash(uint32 messageIndex, bytes32 sourceChainID) returns() -func (_TeleporterBlockHash *TeleporterBlockHashTransactor) ReceiveBlockHash(opts *bind.TransactOpts, messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { - return _TeleporterBlockHash.contract.Transact(opts, "receiveBlockHash", messageIndex, sourceChainID) -} - -// ReceiveBlockHash is a paid mutator transaction binding the contract method 0x30b52559. -// -// Solidity: function receiveBlockHash(uint32 messageIndex, bytes32 sourceChainID) returns() -func (_TeleporterBlockHash *TeleporterBlockHashSession) ReceiveBlockHash(messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { - return _TeleporterBlockHash.Contract.ReceiveBlockHash(&_TeleporterBlockHash.TransactOpts, messageIndex, sourceChainID) -} - -// ReceiveBlockHash is a paid mutator transaction binding the contract method 0x30b52559. -// -// Solidity: function receiveBlockHash(uint32 messageIndex, bytes32 sourceChainID) returns() -func (_TeleporterBlockHash *TeleporterBlockHashTransactorSession) ReceiveBlockHash(messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { - return _TeleporterBlockHash.Contract.ReceiveBlockHash(&_TeleporterBlockHash.TransactOpts, messageIndex, sourceChainID) -} - -// TeleporterBlockHashReceiveBlockHashIterator is returned from FilterReceiveBlockHash and is used to iterate over the raw logs and unpacked data for ReceiveBlockHash events raised by the TeleporterBlockHash contract. -type TeleporterBlockHashReceiveBlockHashIterator struct { - Event *TeleporterBlockHashReceiveBlockHash // 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 *TeleporterBlockHashReceiveBlockHashIterator) 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(TeleporterBlockHashReceiveBlockHash) - 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(TeleporterBlockHashReceiveBlockHash) - 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 *TeleporterBlockHashReceiveBlockHashIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *TeleporterBlockHashReceiveBlockHashIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// TeleporterBlockHashReceiveBlockHash represents a ReceiveBlockHash event raised by the TeleporterBlockHash contract. -type TeleporterBlockHashReceiveBlockHash struct { - OriginChainID [32]byte - BlockHash [32]byte - Raw types.Log // Blockchain specific contextual infos -} - -// FilterReceiveBlockHash is a free log retrieval operation binding the contract event 0x7770e5f72465e9b05c8076c3f2eac70898abe6a84f0259307d127c13e2a1a4e4. -// -// Solidity: event ReceiveBlockHash(bytes32 indexed originChainID, bytes32 indexed blockHash) -func (_TeleporterBlockHash *TeleporterBlockHashFilterer) FilterReceiveBlockHash(opts *bind.FilterOpts, originChainID [][32]byte, blockHash [][32]byte) (*TeleporterBlockHashReceiveBlockHashIterator, error) { - - var originChainIDRule []interface{} - for _, originChainIDItem := range originChainID { - originChainIDRule = append(originChainIDRule, originChainIDItem) - } - var blockHashRule []interface{} - for _, blockHashItem := range blockHash { - blockHashRule = append(blockHashRule, blockHashItem) - } - - logs, sub, err := _TeleporterBlockHash.contract.FilterLogs(opts, "ReceiveBlockHash", originChainIDRule, blockHashRule) - if err != nil { - return nil, err - } - return &TeleporterBlockHashReceiveBlockHashIterator{contract: _TeleporterBlockHash.contract, event: "ReceiveBlockHash", logs: logs, sub: sub}, nil -} - -// WatchReceiveBlockHash is a free log subscription operation binding the contract event 0x7770e5f72465e9b05c8076c3f2eac70898abe6a84f0259307d127c13e2a1a4e4. -// -// Solidity: event ReceiveBlockHash(bytes32 indexed originChainID, bytes32 indexed blockHash) -func (_TeleporterBlockHash *TeleporterBlockHashFilterer) WatchReceiveBlockHash(opts *bind.WatchOpts, sink chan<- *TeleporterBlockHashReceiveBlockHash, originChainID [][32]byte, blockHash [][32]byte) (event.Subscription, error) { - - var originChainIDRule []interface{} - for _, originChainIDItem := range originChainID { - originChainIDRule = append(originChainIDRule, originChainIDItem) - } - var blockHashRule []interface{} - for _, blockHashItem := range blockHash { - blockHashRule = append(blockHashRule, blockHashItem) - } - - logs, sub, err := _TeleporterBlockHash.contract.WatchLogs(opts, "ReceiveBlockHash", originChainIDRule, blockHashRule) - 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(TeleporterBlockHashReceiveBlockHash) - if err := _TeleporterBlockHash.contract.UnpackLog(event, "ReceiveBlockHash", 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 -} - -// ParseReceiveBlockHash is a log parse operation binding the contract event 0x7770e5f72465e9b05c8076c3f2eac70898abe6a84f0259307d127c13e2a1a4e4. -// -// Solidity: event ReceiveBlockHash(bytes32 indexed originChainID, bytes32 indexed blockHash) -func (_TeleporterBlockHash *TeleporterBlockHashFilterer) ParseReceiveBlockHash(log types.Log) (*TeleporterBlockHashReceiveBlockHash, error) { - event := new(TeleporterBlockHashReceiveBlockHash) - if err := _TeleporterBlockHash.contract.UnpackLog(event, "ReceiveBlockHash", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/scripts/abi_go_bindings.sh b/scripts/abi_go_bindings.sh index bf50569d1..edadf0397 100755 --- a/scripts/abi_go_bindings.sh +++ b/scripts/abi_go_bindings.sh @@ -13,7 +13,7 @@ TELEPORTER_PATH=$( cd .. && pwd ) -DEFAULT_CONTRACT_LIST="TeleporterMessenger ERC20Bridge ExampleCrossChainMessenger BlockHashPublisher BlockHashReceiver BridgeToken" +DEFAULT_CONTRACT_LIST="TeleporterMessenger TeleporterBlockHashReceiver ERC20Bridge ExampleCrossChainMessenger BlockHashPublisher BlockHashReceiver BridgeToken" CONTRACT_LIST= HELP= From 0810228e758d398029900b292a12278e7a74ce5c Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Fri, 13 Oct 2023 20:35:57 +0000 Subject: [PATCH 19/22] set up third test subnet --- tests/utils/network_setup.go | 67 +++++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/tests/utils/network_setup.go b/tests/utils/network_setup.go index 1ee6b16f3..94c2d4a20 100644 --- a/tests/utils/network_setup.go +++ b/tests/utils/network_setup.go @@ -27,15 +27,15 @@ const ( ) var ( - teleporterContractAddress common.Address - subnetA, subnetB ids.ID - blockchainIDA, blockchainIDB ids.ID - chainANodeURIs, chainBNodeURIs []string - fundedAddress = common.HexToAddress("0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC") - fundedKey *ecdsa.PrivateKey - chainAWSClient, chainBWSClient ethclient.Client - chainAWSURI, chainBWSURI string - chainAIDInt, chainBIDInt *big.Int + teleporterContractAddress common.Address + subnetA, subnetB, subnetC ids.ID + blockchainIDA, blockchainIDB, blockchainIDC ids.ID + chainANodeURIs, chainBNodeURIs, chainCNodeURIs []string + fundedAddress = common.HexToAddress("0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC") + fundedKey *ecdsa.PrivateKey + chainAWSClient, chainBWSClient, chainCWSClient ethclient.Client + chainAWSURI, chainBWSURI, chainCWSURI string + chainAIDInt, chainBIDInt, chainCIDInt *big.Int // Internal vars only used to set up the local network anrConfig = runner.NewDefaultANRConfig() @@ -60,6 +60,7 @@ func GetSubnetsInfo() []SubnetTestInfo { return []SubnetTestInfo{ GetSubnetATestInfo(), GetSubnetBTestInfo(), + GetSubnetCTestInfo(), } } @@ -83,6 +84,16 @@ func GetSubnetBTestInfo() SubnetTestInfo { ChainIDInt: big.NewInt(0).Set(chainBIDInt), } } +func GetSubnetCTestInfo() SubnetTestInfo { + return SubnetTestInfo{ + SubnetID: subnetC, + BlockchainID: blockchainIDC, + ChainNodeURIs: chainCNodeURIs, + ChainWSClient: chainCWSClient, + ChainWSURI: chainCWSURI, + ChainIDInt: big.NewInt(0).Set(chainCIDInt), + } +} func GetTeleporterContractAddress() common.Address { return teleporterContractAddress } @@ -100,15 +111,18 @@ func SetupNetwork(warpGenesisFile string) { ctx := context.Background() var err error - // Name 10 new validators (which should have BLS key registered) + // Name 15 new validators (which should have BLS key registered) subnetANodeNames := []string{} subnetBNodeNames := []string{} - for i := 1; i <= 10; i++ { + subnetCNodeNames := []string{} + for i := 1; i <= 15; i++ { n := fmt.Sprintf("node%d-bls", i) if i <= 5 { subnetANodeNames = append(subnetANodeNames, n) - } else { + } else if i <= 10 { subnetBNodeNames = append(subnetBNodeNames, n) + } else { + subnetCNodeNames = append(subnetCNodeNames, n) } } f, err := os.CreateTemp(os.TempDir(), "config.json") @@ -146,6 +160,15 @@ func SetupNetwork(warpGenesisFile string) { Participants: subnetBNodeNames, }, }, + { + VmName: evm.IDStr, + Genesis: warpGenesisFile, + ChainConfig: warpChainConfigPath, + SubnetSpec: &rpcpb.SubnetSpec{ + SubnetConfig: "", + Participants: subnetCNodeNames, + }, + }, }, ) Expect(err).Should(BeNil()) @@ -155,10 +178,11 @@ func SetupNetwork(warpGenesisFile string) { Expect(err).Should(BeNil()) SetupProposerVM(ctx, fundedKey, manager, 0) SetupProposerVM(ctx, fundedKey, manager, 1) + SetupProposerVM(ctx, fundedKey, manager, 2) // Set up subnet URIs subnetIDs := manager.GetSubnets() - Expect(len(subnetIDs)).Should(Equal(2)) + Expect(len(subnetIDs)).Should(Equal(3)) subnetA = subnetIDs[0] subnetADetails, ok := manager.GetSubnet(subnetA) @@ -174,12 +198,21 @@ func SetupNetwork(warpGenesisFile string) { blockchainIDB = subnetBDetails.BlockchainID chainBNodeURIs = append(chainBNodeURIs, subnetBDetails.ValidatorURIs...) + subnetC = subnetIDs[2] + subnetCDetails, ok := manager.GetSubnet(subnetC) + Expect(ok).Should(BeTrue()) + Expect(len(subnetCDetails.ValidatorURIs)).Should(Equal(5)) + blockchainIDC = subnetCDetails.BlockchainID + chainCNodeURIs = append(chainCNodeURIs, subnetCDetails.ValidatorURIs...) + log.Info( "Created URIs for subnets", "chainAURIs", chainANodeURIs, "chainBURIs", chainBNodeURIs, + "chainCURIs", chainCNodeURIs, "blockchainIDA", blockchainIDA, "blockchainIDB", blockchainIDB, + "blockchainIDC", blockchainIDC, ) chainAWSURI := HttpToWebsocketURI(chainANodeURIs[0], blockchainIDA.String()) @@ -198,6 +231,14 @@ func SetupNetwork(warpGenesisFile string) { chainBIDInt, err = chainBWSClient.ChainID(context.Background()) Expect(err).Should(BeNil()) + chainCWSURI := HttpToWebsocketURI(chainCNodeURIs[0], blockchainIDC.String()) + log.Info("Creating ethclient for blockchainC", "wsURI", chainCWSURI) + chainCWSClient, err = ethclient.Dial(chainCWSURI) + Expect(err).Should(BeNil()) + + chainCIDInt, err = chainCWSClient.ChainID(context.Background()) + Expect(err).Should(BeNil()) + log.Info("Finished setting up e2e test subnet variables") } From cc3978f0cc4e1193a395d6cc7aa8eb7b43579d9e Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Thu, 19 Oct 2023 21:30:11 +0000 Subject: [PATCH 20/22] cleanup --- contracts/src/.solhint.json | 1 + .../Teleporter/ITeleporterBlockHashReceiver.sol | 3 +-- .../Teleporter/TeleporterBlockHashReceiver.sol | 15 +++------------ 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/contracts/src/.solhint.json b/contracts/src/.solhint.json index 457ab6485..e6c60007f 100644 --- a/contracts/src/.solhint.json +++ b/contracts/src/.solhint.json @@ -17,6 +17,7 @@ } ], "reason-string": ["off"], + "custom-errors": "off", "ordering": "warn", "immutable-vars-naming": [ "warn", diff --git a/contracts/src/Teleporter/ITeleporterBlockHashReceiver.sol b/contracts/src/Teleporter/ITeleporterBlockHashReceiver.sol index af453371c..a63d02dc9 100644 --- a/contracts/src/Teleporter/ITeleporterBlockHashReceiver.sol +++ b/contracts/src/Teleporter/ITeleporterBlockHashReceiver.sol @@ -24,7 +24,6 @@ interface ITeleporterBlockHashReceiver { * and is verified in the precompile predicate. */ function receiveBlockHash( - uint32 messageIndex, - bytes32 sourceChainID + uint32 messageIndex ) external; } \ No newline at end of file diff --git a/contracts/src/Teleporter/TeleporterBlockHashReceiver.sol b/contracts/src/Teleporter/TeleporterBlockHashReceiver.sol index 87331a77d..8a546da97 100644 --- a/contracts/src/Teleporter/TeleporterBlockHashReceiver.sol +++ b/contracts/src/Teleporter/TeleporterBlockHashReceiver.sol @@ -18,29 +18,20 @@ contract TeleporterBlockHashReceiver is ITeleporterBlockHashReceiver, Reentrancy WarpMessenger public constant WARP_MESSENGER = WarpMessenger(0x0200000000000000000000000000000000000005); - error InvalidWarpBlockHash(); - error UnexpectedSourceChainID(); - /** - * @dev See {ITeleporterBlockHashReceiver-receiveCrossChainMessage} + * @dev See {ITeleporterBlockHashReceiver-receiveBlockHash} * * Emits a {ReceiveBlockHash} event when a block hash is verified.. */ function receiveBlockHash( - uint32 messageIndex, - bytes32 sourceChainID + uint32 messageIndex ) external receiverNonReentrant { // Verify and parse the block hash payload included in the transaction access list // using the warp message precompile. (WarpBlockHash memory warpBlockHash, bool success) = WARP_MESSENGER .getVerifiedWarpBlockHash(messageIndex); - if (!success) { - revert InvalidWarpBlockHash(); - } - if (warpBlockHash.sourceChainID != sourceChainID) { - revert UnexpectedSourceChainID(); - } + require(success, "TeleporterBlockHashReceiver: invalid warp message"); emit ReceiveBlockHash( warpBlockHash.sourceChainID, From d5b8203b495296945de0be3a01b580b53649c169 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Thu, 19 Oct 2023 21:35:04 +0000 Subject: [PATCH 21/22] update binding --- .../TeleporterBlockHashReceiver.go | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/abi-bindings/Teleporter/TeleporterBlockHashReceiver/TeleporterBlockHashReceiver.go b/abi-bindings/Teleporter/TeleporterBlockHashReceiver/TeleporterBlockHashReceiver.go index a47907dbe..18ec4775c 100644 --- a/abi-bindings/Teleporter/TeleporterBlockHashReceiver/TeleporterBlockHashReceiver.go +++ b/abi-bindings/Teleporter/TeleporterBlockHashReceiver/TeleporterBlockHashReceiver.go @@ -31,7 +31,7 @@ var ( // TeleporterBlockHashReceiverMetaData contains all meta data concerning the TeleporterBlockHashReceiver contract. var TeleporterBlockHashReceiverMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"name\":\"InvalidWarpBlockHash\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ReceiverReentrancy\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SenderReentrancy\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UnexpectedSourceChainID\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"WARP_MESSENGER\",\"outputs\":[{\"internalType\":\"contractWarpMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"messageIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"sourceChainID\",\"type\":\"bytes32\"}],\"name\":\"receiveBlockHash\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[],\"name\":\"ReceiverReentrancy\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SenderReentrancy\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originChainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"name\":\"ReceiveBlockHash\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"WARP_MESSENGER\",\"outputs\":[{\"internalType\":\"contractWarpMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"messageIndex\",\"type\":\"uint32\"}],\"name\":\"receiveBlockHash\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // TeleporterBlockHashReceiverABI is the input ABI used to generate the binding from. @@ -211,25 +211,25 @@ func (_TeleporterBlockHashReceiver *TeleporterBlockHashReceiverCallerSession) WA return _TeleporterBlockHashReceiver.Contract.WARPMESSENGER(&_TeleporterBlockHashReceiver.CallOpts) } -// ReceiveBlockHash is a paid mutator transaction binding the contract method 0x30b52559. +// ReceiveBlockHash is a paid mutator transaction binding the contract method 0x303bb425. // -// Solidity: function receiveBlockHash(uint32 messageIndex, bytes32 sourceChainID) returns() -func (_TeleporterBlockHashReceiver *TeleporterBlockHashReceiverTransactor) ReceiveBlockHash(opts *bind.TransactOpts, messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { - return _TeleporterBlockHashReceiver.contract.Transact(opts, "receiveBlockHash", messageIndex, sourceChainID) +// Solidity: function receiveBlockHash(uint32 messageIndex) returns() +func (_TeleporterBlockHashReceiver *TeleporterBlockHashReceiverTransactor) ReceiveBlockHash(opts *bind.TransactOpts, messageIndex uint32) (*types.Transaction, error) { + return _TeleporterBlockHashReceiver.contract.Transact(opts, "receiveBlockHash", messageIndex) } -// ReceiveBlockHash is a paid mutator transaction binding the contract method 0x30b52559. +// ReceiveBlockHash is a paid mutator transaction binding the contract method 0x303bb425. // -// Solidity: function receiveBlockHash(uint32 messageIndex, bytes32 sourceChainID) returns() -func (_TeleporterBlockHashReceiver *TeleporterBlockHashReceiverSession) ReceiveBlockHash(messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { - return _TeleporterBlockHashReceiver.Contract.ReceiveBlockHash(&_TeleporterBlockHashReceiver.TransactOpts, messageIndex, sourceChainID) +// Solidity: function receiveBlockHash(uint32 messageIndex) returns() +func (_TeleporterBlockHashReceiver *TeleporterBlockHashReceiverSession) ReceiveBlockHash(messageIndex uint32) (*types.Transaction, error) { + return _TeleporterBlockHashReceiver.Contract.ReceiveBlockHash(&_TeleporterBlockHashReceiver.TransactOpts, messageIndex) } -// ReceiveBlockHash is a paid mutator transaction binding the contract method 0x30b52559. +// ReceiveBlockHash is a paid mutator transaction binding the contract method 0x303bb425. // -// Solidity: function receiveBlockHash(uint32 messageIndex, bytes32 sourceChainID) returns() -func (_TeleporterBlockHashReceiver *TeleporterBlockHashReceiverTransactorSession) ReceiveBlockHash(messageIndex uint32, sourceChainID [32]byte) (*types.Transaction, error) { - return _TeleporterBlockHashReceiver.Contract.ReceiveBlockHash(&_TeleporterBlockHashReceiver.TransactOpts, messageIndex, sourceChainID) +// Solidity: function receiveBlockHash(uint32 messageIndex) returns() +func (_TeleporterBlockHashReceiver *TeleporterBlockHashReceiverTransactorSession) ReceiveBlockHash(messageIndex uint32) (*types.Transaction, error) { + return _TeleporterBlockHashReceiver.Contract.ReceiveBlockHash(&_TeleporterBlockHashReceiver.TransactOpts, messageIndex) } // TeleporterBlockHashReceiverReceiveBlockHashIterator is returned from FilterReceiveBlockHash and is used to iterate over the raw logs and unpacked data for ReceiveBlockHash events raised by the TeleporterBlockHashReceiver contract. From 050fbd0d69926595627a1bbe5784af194a68a203 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Thu, 19 Oct 2023 21:37:26 +0000 Subject: [PATCH 22/22] update pack function --- .../TeleporterBlockHashReceiver/packing.go | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/abi-bindings/Teleporter/TeleporterBlockHashReceiver/packing.go b/abi-bindings/Teleporter/TeleporterBlockHashReceiver/packing.go index 8cca0491d..f848be224 100644 --- a/abi-bindings/Teleporter/TeleporterBlockHashReceiver/packing.go +++ b/abi-bindings/Teleporter/TeleporterBlockHashReceiver/packing.go @@ -1,21 +1,10 @@ package teleporterblockhashreceiver -import "github.com/ava-labs/avalanchego/ids" - -// ReceiveBlockHashInput is the input to receiveBlockHash call -// in the contract deployed on the destination chain -// - messageIndex: specifies the warp message in the transaction's storage slots. -// - -type ReceiveBlockHashInput struct { - MessageIndex uint32 `json:"messageIndex"` - SourceChainID ids.ID `json:"sourceChainID"` -} - // Pack packs a ReceiveCrossChainMessageInput to form a call to the receiveCrossChainMessage function -func PackReceiveBlockHash(inputStruct ReceiveBlockHashInput) ([]byte, error) { +func PackReceiveBlockHash(messageIndex uint32) ([]byte, error) { abi, err := TeleporterBlockHashReceiverMetaData.GetAbi() if err != nil { return nil, err } - return abi.Pack("receiveBlockHash", inputStruct.MessageIndex, inputStruct.SourceChainID) + return abi.Pack("receiveBlockHash", messageIndex) }