Skip to content

Commit

Permalink
hot fix TooManyPendingMessages (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
hujw77 committed Sep 14, 2022
1 parent d60700f commit 9953f24
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 20 deletions.
6 changes: 3 additions & 3 deletions contracts/bridge/bin/addr/test/bsctest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"FeeMarketProxy": "0x86F9206Ce70372A85C0a43c8F11ade4eCCD5E4D0",
"POSALightClient": "0xA7343a00a6aDA616F9035fF41D552331c1c60F6b",
"DarwiniaLightClientProxy": "0x03FC3E2D3eF934432Ee796699295a10D6dB5F1dE",
"DarwiniaMessageVerifier": "0xEF9CFb1065C1CC0115892F66006361d42A7D1706",
"OutboundLane": "0x301Fe278aAFe42d1E2edCA4B62c1D67B088671De",
"InboundLane": "0x4Ee0d401f713D86C5aBe24feA762099CFEb17913"
"DarwiniaMessageVerifier": "0x051f4B222a5f99031A25cd7334bdc3bAdB9A0B60",
"OutboundLane": "0x5F0dA02f792C9f4Cb862Dc07309B89CF7eEF9c26",
"InboundLane": "0xEFacaafbfbEa2f681E890Ca9AF24650128536B67"
}
}
6 changes: 3 additions & 3 deletions contracts/bridge/bin/addr/test/goerli.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"FeeMarketProxy": "0x380244554a9C51f0CCaFec90A2766B0C8b698a4a",
"POSALightClient": "0x91Fef68AcC7B1d3202F4882a3c16D5577e15d10e",
"DarwiniaLightClientProxy": "0x82afDD48E3a06672c7C87A6742eC14d1088f6eF7",
"DarwiniaMessageVerifier": "0x2aA80A61FFbce5429E054782fa81355a70261bD4",
"OutboundLane": "0x0E27e673b1398FB189C2d516775E1195AF665e1E",
"InboundLane": "0x2b99f13A2a9dC1570Ab423BB8fA8577755AcD77B"
"DarwiniaMessageVerifier": "0x82d5dD3B81a031a69B3405f409D71110213cf343",
"OutboundLane": "0xc4D1b94BF5a277da43d0D0762Ce52Fd0b81039df",
"InboundLane": "0xFD89b82eCd642C2b171a6619A851B5f0500aab86"
}
}
16 changes: 8 additions & 8 deletions contracts/bridge/bin/addr/test/pangoro.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
"BeaconLightClient": "0x957972BD5F7f385e366e1ce607D6E8058b532c3d",
"ExecutionLayer": "0x0542bFECbdab27A03A447C9fF6e34dA319849D91",
"EthereumExecutionLayerProxy": "0x3F58e8Cf0DE243f978834e11e0CC419670FCe6d8",
"EthereumStorageVerifier": "0x815596fF53c02A0c782ADbE158c07a1A6878B8f5",
"OutboundLane": "0x90302800b3509e56f4F611c69D2d144a43a5cfE7",
"InboundLane": "0x39539c494dA9b97dD716e167f9cBF25438fe72d0",
"LaneMessageCommitter": "0xeB9e7B56Dc3B45a0FdE1bAF63d6A74586D41aee3"
"EthereumStorageVerifier": "0x3217F36AE34aCA2CE60d218af8F47d29101204a8",
"OutboundLane": "0x654FE7E51eCA910800Df4E1fA8F2CD8Fb1aFEc4A",
"InboundLane": "0x20c3b4a6Cb3319d14ffB0C2d4C7b035f16C4B7D3",
"LaneMessageCommitter": "0x1559Bf123D300f244ABdA95aefDA14F54C37B9B6"
},
"bsctest": {
"FeeMarket": "0x20F35D3f622b537dff77E99b0aD15f4a24926051",
"FeeMarketProxy": "0x4ca59Ec46543E10De53C97332B8fe656e7a22878",
"BSCLightClient": "0xd3686C9a2Ff3Fa3dc24E2ab157f58B2d567A295e",
"BSCLightClientProxy": "0x6c74a72444048A8588dEBeb749Ee60DB842aD90f",
"BSCStorageVerifier": "0xC14031cF5cA3876f32B8Dc8f0F3Bfc0EC0DCb3c4",
"OutboundLane": "0x257B832F80E70b34349e38ad50167C60B15676e5",
"InboundLane": "0x005CaCd7608302d9F64199Bd79b85d112617fE0A",
"LaneMessageCommitter": "0x71d18878F49d3a40f605baBbD81c24045fcB524a"
"BSCStorageVerifier": "0x23c2e12caaE858f1cc7a4B3d1499C6881C86839b",
"OutboundLane": "0x445A92e8dB20095a1755f4BE32E21E529E942E62",
"InboundLane": "0x062f87ae9eCAd31398C0cF5Ef269feb9050b9DF6",
"LaneMessageCommitter": "0x75774D78306a847F5CFc7630F37Bd4ed649784B3"
}
}
8 changes: 4 additions & 4 deletions contracts/bridge/bin/migrate-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eo pipefail

export MODE=test

# . $(dirname $0)/migrate/test/fee/pangoro-1.sh
. $(dirname $0)/migrate/test/fee/pangoro-2.sh
# . $(dirname $0)/migrate/test/fee/goerli.sh
# . $(dirname $0)/migrate/test/fee/bsctest.sh
. $(dirname $0)/migrate/test/msg/pangoro-1.sh
. $(dirname $0)/migrate/test/msg/pangoro-2.sh
. $(dirname $0)/migrate/test/msg/goerli.sh
. $(dirname $0)/migrate/test/msg/bsctest.sh
2 changes: 1 addition & 1 deletion contracts/bridge/flat/OutboundLane.f.sol
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ contract OutboundLane is IOutboundLane, OutboundLaneVerifier, TargetChain, Sourc
/// @param encoded The calldata which encoded by ABI Encoding
/// @return encoded_key Encoded message key
function send_message(address target, bytes calldata encoded) external payable override returns (uint256 encoded_key) {
require(outboundLaneNonce.latest_generated_nonce - outboundLaneNonce.latest_received_nonce <= MAX_PENDING_MESSAGES, "TooManyPendingMessages");
require(outboundLaneNonce.latest_generated_nonce - outboundLaneNonce.latest_received_nonce < MAX_PENDING_MESSAGES, "TooManyPendingMessages");
require(outboundLaneNonce.latest_generated_nonce < type(uint64).max, "Overflow");
require(encoded.length <= MAX_CALLDATA_LENGTH, "TooLargeCalldata");

Expand Down
2 changes: 1 addition & 1 deletion contracts/bridge/src/message/OutboundLane.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ contract OutboundLane is IOutboundLane, OutboundLaneVerifier, TargetChain, Sourc
/// @param encoded The calldata which encoded by ABI Encoding
/// @return encoded_key Encoded message key
function send_message(address target, bytes calldata encoded) external payable override returns (uint256 encoded_key) {
require(outboundLaneNonce.latest_generated_nonce - outboundLaneNonce.latest_received_nonce <= MAX_PENDING_MESSAGES, "TooManyPendingMessages");
require(outboundLaneNonce.latest_generated_nonce - outboundLaneNonce.latest_received_nonce < MAX_PENDING_MESSAGES, "TooManyPendingMessages");
require(outboundLaneNonce.latest_generated_nonce < type(uint64).max, "Overflow");
require(encoded.length <= MAX_CALLDATA_LENGTH, "TooLargeCalldata");

Expand Down
8 changes: 8 additions & 0 deletions contracts/bridge/src/test/message/OutboundLane.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ contract OutboundLaneTest is DSTest, SourceChain, TargetChain {
assertEq(hash(payload), 0xf68a7103167104b132a65ee29f46cb238d61f3ca1813cc87155928bab0af5ac1);
}

function testFail_too_many_pending_messages() public {
address target = address(1);
bytes memory encoded = abi.encodeWithSignature("foo()");
for (uint i=0; i<21; i++) {
perform_send_message(target, encoded);
}
}

function test_send_message() public {
address target = address(1);
bytes memory encoded = abi.encodeWithSignature("foo()");
Expand Down

0 comments on commit 9953f24

Please sign in to comment.