@layerzerolabs/lz-evm-v1-0.7 2.3.7 → 2.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/contracts/RelayerV2.sol +19 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/contracts/RelayerV2.sol
CHANGED
|
@@ -97,9 +97,13 @@ contract RelayerV2 is ReentrancyGuard, OwnableUpgradeable, Proxied, ILayerZeroRe
|
|
|
97
97
|
|
|
98
98
|
uint256 public nativeDecimalsRate;
|
|
99
99
|
|
|
100
|
-
RateLimiter.Info public limiter;
|
|
100
|
+
RateLimiter.Info public limiter; // deprecated
|
|
101
101
|
|
|
102
|
-
event RateLimiterSet(uint64 capacity, uint64 rate);
|
|
102
|
+
event RateLimiterSet(uint64 capacity, uint64 rate); // deprecated
|
|
103
|
+
|
|
104
|
+
mapping(address => bool) public limiterWhitelist; // if true, sender bypasses rate limits
|
|
105
|
+
mapping(uint16 => RateLimiter.Info) public limiters;
|
|
106
|
+
event DstRateLimiterSet(uint16 dstChain, uint64 capacity, uint64 rate);
|
|
103
107
|
|
|
104
108
|
// owner is always approved
|
|
105
109
|
modifier onlyApproved() {
|
|
@@ -148,6 +152,9 @@ contract RelayerV2 is ReentrancyGuard, OwnableUpgradeable, Proxied, ILayerZeroRe
|
|
|
148
152
|
|
|
149
153
|
//----------------------------------------------------------------------------------
|
|
150
154
|
// onlyApproved
|
|
155
|
+
function setLimiterWhitelist(address _addr, bool _skipRateLimits) external onlyApproved {
|
|
156
|
+
limiterWhitelist[_addr] = _skipRateLimits;
|
|
157
|
+
}
|
|
151
158
|
|
|
152
159
|
function setDstPrice(uint16 _chainId, uint128 _dstPriceRatio, uint128 _dstGasPriceInWei) external onlyApproved {
|
|
153
160
|
// No longer used: Write prices in PriceFeed.
|
|
@@ -192,10 +199,11 @@ contract RelayerV2 is ReentrancyGuard, OwnableUpgradeable, Proxied, ILayerZeroRe
|
|
|
192
199
|
|
|
193
200
|
//----------------------------------------------------------------------------------
|
|
194
201
|
// onlyOwner
|
|
195
|
-
function configRateLimiter(uint64 _capacity, uint64 _rate) external onlyOwner {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
202
|
+
function configRateLimiter(uint16 _dstChainId, uint64 _capacity, uint64 _rate) external onlyOwner {
|
|
203
|
+
RateLimiter.Info storage dstLimiter = limiters[_dstChainId];
|
|
204
|
+
dstLimiter.setCapacity(_capacity);
|
|
205
|
+
dstLimiter.setRate(_rate);
|
|
206
|
+
emit DstRateLimiterSet(_dstChainId, _capacity, _rate);
|
|
199
207
|
}
|
|
200
208
|
|
|
201
209
|
function setApprovedAddress(address _relayerAddress, bool _approve) public onlyOwner {
|
|
@@ -313,9 +321,12 @@ contract RelayerV2 is ReentrancyGuard, OwnableUpgradeable, Proxied, ILayerZeroRe
|
|
|
313
321
|
uint _payloadSize,
|
|
314
322
|
bytes calldata _adapterParams
|
|
315
323
|
) external override returns (uint fee) {
|
|
316
|
-
if (_dstChainId >= 10000
|
|
324
|
+
if (_dstChainId >= 10000) {
|
|
325
|
+
RateLimiter.Info storage dstLimiter = limiters[_dstChainId];
|
|
317
326
|
// sandbox or testnet
|
|
318
|
-
|
|
327
|
+
if (!limiterWhitelist[_userApplication] && dstLimiter.capacity > 0) {
|
|
328
|
+
dstLimiter.tryConsume(10000);
|
|
329
|
+
}
|
|
319
330
|
}
|
|
320
331
|
|
|
321
332
|
require(msg.sender == address(uln), "Relayer: invalid uln");
|