-
Notifications
You must be signed in to change notification settings - Fork 19
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
Move Rate Limiter #113
base: movement
Are you sure you want to change the base?
Move Rate Limiter #113
Conversation
Thanks for this, @Primata Got this test failure with
Putting in draft until all unit tests pass. Also needs to be clearly aligned with MIP-58, ideally with reviews from Research team, before merging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Move unit tests and E2E Move tests pass ✅
- LGTM for testing, with a note that a proper MIP and review from Research is needed for the entire rate limiter before considering this ready for production.
@andygolay This Rate Limiting implementation is already specified in MIP-58 https://github.com/movementlabsxyz/MIP/blob/161ed87aba691992b83f7d3fb1641d58bd5fe352/MIP/mip-58/README.md The new suggestions and updates are to be laid out in a new MIP-74. The review and approval of that MIP don't block this from being merged. This is so that we can deploy this initial version of the Native Bridge MIP-58 to Bardock and unblock front end testing. cc. @Primata |
Right, sounds like we're on the same page about this being fine to merge for front end testing. MIP-58 mentions rate limiting but it doesn't seem totally clear nor is it consistent with this implementation from what I can tell. For example MIP-58 mentions, "Single-sided rate limiting, Rate limiting should be implemented on the L1 and maps each day to a budget, for each direction." Maybe I'm misunderstanding the wording or implementation. But here we have rate limiting implemented on the L2. So that's a big difference. Likewise there's no mention of the denominator in MIP-58, despite it being an important factor in the implementation. That said, yes I agree this is good for testing. And look forward to a more fully-fleshed out and aligned spec and revisiting when it comes time to integrate everything. I haven't been able to focus on it as I'm occupied with operations tasks and want to be sure to prioritize those. I don't want to downplay this progress but rather emphasize that it's still in my opinion an early iteration that needs more formal input and consideration before being deemed production-ready (which it sounds like we agree on). I already approved, LGTM to merge once we get another approval. |
@andygolay MIP-74 now requests that rate limit is applied symmetrical. The circumstances have changed compared to the HTLC-type bridge. The idea boils down to
Consequently,
There may be dispute as to how the rate limits are set.. For example does the insurance fund need to be on both chains (target chain for either direction, i.e. L1->L2 and L2->L1) or is it sufficient to be on one chain, as the Governance Operator is supposed to be aware of both chains, e.g. through the Informer. |
MIP-58 wasn't for the HTLC bridge. For the most part, discussion of the rate limiting specification details is probably best kept to the relevant MIP itself. My point in my approving comment on this PR was that this code should be considered an early iteration, for testing, while a proper MIP for rate limiting, eg MIP-74, is worked out. Then the code on both sides should be inspected to be sure that it actually implements the MIP. Hopefully we all agree on that; I don't see it as a particularly controversial or objectionable stance. I already approved this PR. All that needs to happen here is for someone else to review and approve it, then it can be merged. I don't think we should get into the weeds about the design in the PR conversation, but rather in MIP conversation. |
|
||
## Function `risk_denominator` | ||
|
||
Retrieves the current risk denominator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the risk denominator? i assume it is the reaction time or window.
you could provide the equation context here (rate_limit=....)
let current_budget = smart_table::borrow_mut_with_default(&mut table.inner, day, 0); | ||
smart_table::upsert(&mut table.inner, day, *current_budget + amount); | ||
let rate_limit = coin::balance<AptosCoin>(insurance_fund) / risk_denominator; | ||
assert!(*smart_table::borrow(&table.inner, day) < rate_limit, ERATE_LIMIT_EXCEEDED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be an error in the units
the left value is a budget unit, whereas rate_limit is a budget/time-unit (here max_budget/day) ..
for example one_day_budget = rate_limit * 1 (days)
however the budget can be consumed within a risk_period, which could be 8 hours, 24hours, 48 hours, etc.
maybe we should approach this different:
- window = risk_denominator ( = reaction time )
- budget_for_window = insurance_fund
- assert ( current_budget + amount < budget_for_window )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The window length of budgets probably may or even will change. specifically the Governance Operator may set the window to e.g. 8 hours, which means in a first approach (without moving window) the max_budget would reset after the new window time (8 hours)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some comments
@andygolay I agree that higher level design discussions should happen at the MIP. I was providing context and addressing your comment for your convenience. :) |
The MIP context should be given in the PR description. If anything we should be encouraging PR authors to do that, in my opinion. I think if you look through the discussion, you'll see there's an abundance of confusion about which MIP this PR is even meant to address. I hope pushing code like this without linking to an MIP is a practice we can avoid going forward, in favor of proper software engineering practices. |
Description
Rate Limits the Relayer capability of calling complete_bridge_transfer based on an insurance fund address, similar to the bridge counterparty on Solidity. movementlabsxyz/movement#836
How Has This Been Tested?
Mirrors testing of rate limit on Solidity but without fuzzing
Key Areas to Review
Test coverage
Type of Change
Which Components or Systems Does This Change Impact?
Checklist