-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
Pallet::<T, I>::deposit_event(Event::OrderReward( | ||
lane_id, | ||
message_nonce, | ||
reward_item.clone(), | ||
)); |
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.
I'm not sure whether we should deposit event in this function(slash_and_calculate_rewards) or at the end of pay_relayers_rewards?
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.
If deposit this event at the end of pay_relayers_rewards
, you may need to remove the RewardBook
and iterate the whole RewardItems
. I prefer the current way.
fn add_reward_item(&mut self, item: RewardItem<T::AccountId, BalanceOf<T, I>>) { | ||
if let Some((id, reward)) = item.to_slot_relayer { | ||
self.assigned_relayers_sum | ||
.entry(id) | ||
.and_modify(|r| *r = r.saturating_add(reward)) | ||
.or_insert(reward); | ||
} | ||
|
||
if let Some(reward) = item.to_treasury { | ||
self.treasury_sum = self.treasury_sum.saturating_add(reward); | ||
} | ||
|
||
if let Some((id, reward)) = item.to_message_relayer { | ||
self.deliver_sum | ||
.entry(id) | ||
.and_modify(|r| *r = r.saturating_add(reward)) | ||
.or_insert(reward); | ||
} | ||
|
||
if let Some((_id, reward)) = item.to_confirm_relayer { | ||
self.confirm_sum = self.confirm_sum.saturating_add(reward); | ||
} | ||
} |
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.
Another way would be directly iterate though RewardItem and calculate the value wanted. RewardBook can be removed then.
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.
We can do this. Store the reward item in something like HashMap and iterate it in the pay_relayers_rewards
. But I think the reward book is easier to read and understand.
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.
My feelings from my point as a reviewer, RewardBook is unnecessary concept and removing it will be simpler.
I'm going to merge this and review this discussion in separate issue because its blocking other release tasks.
@JayJay1024 Can these events meet your requirement? |
yeah these two events seems to meet the requirement |
@hackfisher Please take a review again. I plan to do companions this afternoon and introduce this change to the |
* Refactor the total reward cal * Code Clean * Fix test * Add OrderCreated event * Self review * Update comment * Update OrderCreate event to include relayers * Fix review
* Companion for 96, fix benchmark * Check order capacity when relayer enroll (#93) * Add check logic * Update test file * Add necessary reward event (#89) * Refactor the total reward cal * Code Clean * Fix test * Add OrderCreated event * Self review * Update comment * Update OrderCreate event to include relayers * Fix review
* Companion for 96, fix benchmark * Check order capacity when relayer enroll (#93) * Add check logic * Update test file * Add necessary reward event (#89) * Refactor the total reward cal * Code Clean * Fix test * Add OrderCreated event * Self review * Update comment * Update OrderCreate event to include relayers * Fix review
* Companion for 96, fix benchmark * Check order capacity when relayer enroll (#93) * Add check logic * Update test file * Add necessary reward event (#89) * Refactor the total reward cal * Code Clean * Fix test * Add OrderCreated event * Self review * Update comment * Update OrderCreate event to include relayers * Fix review
* Refactor the total reward cal * Code Clean * Fix test * Add OrderCreated event * Self review * Update comment * Update OrderCreate event to include relayers * Fix review
* Refactor the total reward cal * Code Clean * Fix test * Add OrderCreated event * Self review * Update comment * Update OrderCreate event to include relayers * Fix review
* Refactor the total reward cal * Code Clean * Fix test * Add OrderCreated event * Self review * Update comment * Update OrderCreate event to include relayers * Fix review # Conflicts: # modules/fee-market/src/s2s/payment.rs # modules/fee-market/src/tests.rs
* Refactor the total reward cal * Code Clean * Fix test * Add OrderCreated event * Self review * Update comment * Update OrderCreate event to include relayers * Fix review
* Update market after order is created or comfirmed (#94) * Update order capacity * FIX CI * Update comment * Redesign fee market payment (#169) * Add basic solution * Refactor Slash Report * Refactor Slash Report 2 * Add other changes * Add tests * Self review * Rename to `message_and_confirm_reward` * Rename to `previous_relayers` * Rename to AssignedRelayer * Add more comments * Add more comments * Add new reward implementation * Rename and clean the code, needs more test * Add more docs here * Prepare for tests * Fix broken tests * Refactor * Rename * Remove RewardBook * Self review * Save one storage * Try fix ci * Handle Zero `CollateralPerOrder` (#176) * Companion 189 for darwinia-parachain (#194) * Update fee-market terminology (#192) (#199) * Support pangolin <> pangolin parachain alpha bridge (#190) * Cherry-pick #201 to `darwinia-parachain` (#203) * Del useless related to fee calculation (#201) * Delete estimate_delivery_transaction * Delete transaction_payment * Delete MessageTransaction * Code clean * Fix compile * Anchor polkadot-v0.9.27 * remove unused import * Fix test problem (#172) * fix ci * Add necessary reward event (#89) * Refactor the total reward cal * Code Clean * Fix test * Add OrderCreated event * Self review * Update comment * Update OrderCreate event to include relayers * Fix review * Enhance dispatch module (#121) * rm shift session manager pallet and clean useless imports (#128) * `Pre-dispatch` validate for main branch (#130) * Adjust the traits * Try fix compile * Fix tests * Code clean * Avoid duplicate evm transact fees (#136) * cherry pick #137 (#140) * cherry pick #137 * pick #141 Co-authored-by: bear <boundless.forest@outlook.com> * Drop error in `pre_dispatch` (#152) (#153) * Migrate to new s2s bridge (#149) * Add client-darwinia/client-crab/client-crab-parachain * Update CI * rever substrate commit * fix compile * remove transactional * Fix * Bump finality-grandpa to v0.16.0 * fix wrong import * make change follow paritytech/substrate#11415 * Add runtime-common to workspace and try fix test * Make changes follow paritytech/substrate#10242 * Code clean * More ci check * Remove integrity Co-authored-by: bear <boundless.forest@outlook.com> * Companion for #155 (#157) * Update market after order is created or comfirmed (#94) * Update order capacity * FIX CI * Update comment * Redesign fee market payment (#169) * Add basic solution * Refactor Slash Report * Refactor Slash Report 2 * Add other changes * Add tests * Self review * Rename to `message_and_confirm_reward` * Rename to `previous_relayers` * Rename to AssignedRelayer * Add more comments * Add more comments * Add new reward implementation * Rename and clean the code, needs more test * Add more docs here * Prepare for tests * Fix broken tests * Refactor * Rename * Remove RewardBook * Self review * Save one storage * Try fix ci * Handle Zero `CollateralPerOrder` (#176) * Update Fee market docs (#178) * Update doc * Update example * Move to `dev-dependencies` (#182) * Sync part.1 (#184) * Remove fee relates (#186) * Sync missing changes from different branches (#191) * Support pangolin <> pangolin parachain alpha bridge (#190) * Integrate `fee-market` to `FromThisChainMessageVerifier` (#189) * Run ignored crate * Fix tests * Add features * Fix compile * Update fee-market terminology (#192) * Del useless related to fee calculation (#201) * Delete estimate_delivery_transaction * Delete transaction_payment * Delete MessageTransaction * Code clean * master > polkadot-v0.9.27 * roll back bp-parachain Co-authored-by: bear <boundless.forest@outlook.com> Co-authored-by: Xavier Lau <xavier@inv.cafe> Co-authored-by: Aki Wu <aki.wu@itering.com> Co-authored-by: HackFisher <denny.wang@itering.io> Co-authored-by: HackFisher <hackfisher@gmail.com> Co-authored-by: fewensa <37804932+fewensa@users.noreply.github.com>
Add two events to support Apps presentation easily: