Custom relay strategy#1198
Conversation
…-common into feemarket-strategy
|
|
svyatonik
left a comment
There was a problem hiding this comment.
The reason of this change is to ease process of adding new strategy, right? So now we have altruistic and rational, you need to add 3rd, but it requires forking messages-relay, right? If not - please explain :) If so, then idea seems good to me.
I've left some comments - one issue with accumulators && couple of design suggestions.
|
Yes, it is, we want to add another strategy to our bridger. |
|
@svyatonik changed to follow your suggestions |
There was a problem hiding this comment.
There are two types of checks in this loop - hard and soft. You can't violate hard checks in any strategy - i.e. if target chain weight has max transaction size set to 1MB, it means that you can't deliver 2MB of messages in a single tx. That's the 'hard' limit. The 'soft' limit is defined by the strategy. So I'd expect *_strategy.rs files to only contain soft checks. Hard checks must be done at the upper level and stay the same for all strategies.
That said, I expect altruistic_strategy.rs to only have something like return true or return <something-that-says-Im-ready-to-deliver-all-nonces> in its only method. And the rational_strategy.rs should only have checks related to rewards/losses. Is it possible to fix that, please?
There was a problem hiding this comment.
I changed it. can be reviewed.
There was a problem hiding this comment.
Oh, sorry, This is still wrong, please wait. let me fix it
There was a problem hiding this comment.
I don't know if there is a better solution, there is currently a big struct
svyatonik
left a comment
There was a problem hiding this comment.
Thanks! I'll take a look in next few days - the change is non-trivial && I'll need to review it in details.
46c85ad to
c1f3372
Compare
svyatonik
left a comment
There was a problem hiding this comment.
The code seems to be correct - I'll do a brief run before approving + merging, though :)
Couple of comments:
- there are multiple warnings in the clippy + fmt jobs for this PR. They're introduced here - please fix it. I can't hit merge until everything is green :)
- the
MixStrategyis very similar to what've beenDefaultStrategyin the very beginning :) It looks like a code that links two implementations - enum-based old and trait-based new. I'd prefer to haveAltruisticStrategy+RationalStrategyonly; - big structs that are passed between strategies. I've suggested strategies to have some context for their own fields. Like
total_costandtotal_rewardfields of theRelayerReferencestruct are only used by theRationalStrategy. They're never touched by theAltruisticStrategyand they're never read or updated by thatEnforcementStrategy. So it isn't clear when I look at all these strategies code - who's responsible for updating these fields and how they're related to selecting nonces.
Re (2) and (3) - we may add a separate issue for that and fix it in later PRs if you're blocked on this one.
|
About 2 Maybe we can remove About 3. merge selected_reward and total_reward |
|
All tests and code format fixed. |
* Add relayer strategy * Add default relayer strategy * default relayer strategy * expose relayer strategy * fix compile * fix compile * docs * Rename Relayer to Relay, keep RelayerDecide * split `DefaultRelayerStrategy` into `AltruisticRelayerStrategy` and `RationalRelayerStrategy` * Remove relayer mode * Remove unused import * Rename `RelayerStrategy` to `RelayStrategy` * Add missing docs * clippy * clippy * clippy * clippy * Revert `relayer_mode` and add `MixStrategy` * Add `EnforcementStrategy` * fix bug and simplify relay strategy * Update message_lane_loop.rs * Update messages_target.rs * clippy * clippy * clippy * clippy * clippy * clippy * clippy * fix test * fix test * test test test fix test
* Add relayer strategy * Add default relayer strategy * default relayer strategy * expose relayer strategy * fix compile * fix compile * docs * Rename Relayer to Relay, keep RelayerDecide * split `DefaultRelayerStrategy` into `AltruisticRelayerStrategy` and `RationalRelayerStrategy` * Remove relayer mode * Remove unused import * Rename `RelayerStrategy` to `RelayStrategy` * Add missing docs * clippy * clippy * clippy * clippy * Revert `relayer_mode` and add `MixStrategy` * Add `EnforcementStrategy` * fix bug and simplify relay strategy * Update message_lane_loop.rs * Update messages_target.rs * clippy * clippy * clippy * clippy * clippy * clippy * clippy * fix test * fix test * test test test fix test
Help all bridgers implement their own relay strategy