-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rate Limit Bridge #836
Comments
Blocking Lock event shouldn't be done this way:
|
"In time" meaning before the timelock has expired, or something else? I was thinking that the front-end could simple be notified. that the contract has been locked. We could instead, do a lock for |
I think the contract should reject the initiate_tranfer when the limit is reached. There are different possibilities to indicate to the contract to reject initial_transfer. The contract can do the calculus but it needs to be very strict in time or we indicate a number of blocks. The other way is the relayer detects that the limit has been reached and calls the contract to put it in a locked mode. |
The scenario can be:
|
So some |
Have two options to present here:
Second option is a little bit cheaper in average (it will be more expensive for users that bridge during a reset) but it's on average cheaper. function _rateLimitIncoming(uint256 amount) internal {
(uint256 year, uint256 month, uint256 day) = block.timestamp.timestampToDate();
incomingRateLimitBudget[year][month][day] += amount;
require(incomingRateLimitBudget[year][month][day] <= incomingRateLimit, IncomingRateLimitExceeded());
} function _rateLimitIncoming(uint256 amount) internal {
_resetTime();
incomingRateLimitBudget += amount;
require(incomingRateLimitBudget <= outboundRateLimit, IncomingRateLimitExceeded());
}
function _resetTime() internal {
if (block.timestamp - lastReset >= 1 days) {
lastReset = block.timestamp;
outboundRateLimitBudget = 0;
incomingRateLimitBudget = 0;
}
} reset after time passed
daily record
Wondering what would be better or if there are any logical issues with any of those. Implementations under https://github.com/movementlabsxyz/movement/tree/primata/rate-limiter |
Option 1 is better, in my opinion; it's clearer to track the time durations (useful for auditing or analysing historical data) and its more fair to all users. Option 1 is more expensive yes, but the additional cost seems justified for the added precision and fairness. And, its marginally higher. |
Between the above options, I like option 1. However, there appears to still be a risk of large amounts of downtime for the bridge, if a few big transfers go through and use up the daily budget quickly. Is there a plan already for rate-limiting more granularly individual wallets, IP addresses, and/ or starting off with some limit to the amount per transfer? |
I wouldn't consider this a risk, but the rate-limiter simple doing its job. For safety's sake we want to limit the bridge by volume for a given time period. If it gets used up quickly, then its functioning as intended and it is safely controlling flow of volume and traffic. We just need to set a large enough volume so that we allow the level of activity we expect within 24 hours. |
Summary
We need to limit the bridge's operations for initial deployment, this is to secure regular flow, safety and maintainability. It is also to ensure we can always recover from an internal exploit (relayer liveness no longer a threat due to refund call restrictions).
We want to limit the amount of transfers possible within a 24h period by volume. This volume amount must be equal to the max amount we can mint on demand.
NB. Implementing this at the relayer level is for initial deployment, after this we want to implement this at the contract level via an upgrade with a governing body would be able to vote on proposals to rate limit, that is the volume and the time period.
The text was updated successfully, but these errors were encountered: