Skip to content
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

Improve On_demand_assigner events #4339

Merged
merged 7 commits into from
May 28, 2024
Merged

Conversation

bolajahmad
Copy link
Contributor

@bolajahmad bolajahmad commented Apr 30, 2024

title: Improving on_demand_assigner emitted events

doc:

  • audience: Rutime User
    description: OnDemandOrderPlaced event that is useful for indexers to save data related to on demand orders. Check discussion here.

Closes #4254

crates: [ 'runtime-parachain]

Copy link
Member

@eskimor eskimor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Left a few nits and triggered CI for you. Please remove unrelated formatting changes as well.

Copy link
Contributor

@Overkillus Overkillus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bolajahmad o/

Always happy to have some external contributors so if you need any help please feel free to ping me.

I think there is a small misunderstanding so let me clear it up:

Eskimor:

SpotTrafficSet This value will be largely useless for people, maybe we should have a SpotPriceSet?

@bolajahmad :

SpotTrafficSet is used in the update_spot_traffic call. What is the intended effect of changing the EventName to SpotPriceSet, especilly if the resulting event has the same arguments?

I assume that Eskimor meant not only renaming that event but also changing what it actually represents (to be in-line with the new name). The new event should represent the actual SpotPrice instead of the Traffic component. It seems that this might be much more useful for users.

Notice that if both SpotPriceSet as proposed by Eskimor and OnDemandOrderPlaced have the spot price then in case of an order being made we would get a double event with the same thing. This might not be undesirable IMO.

TODO:

  • rename SpotTrafficSet to SpotPriceSet
  • After updating traffic calculate spot price and deposit it in that new SpotPriceSet event

@eskimor I'm not sure if I agree with:

Issue SpotTrafficSet ... only if price changed without an order getting placed.

First of all I assume you meant SpotPriceSet otherwise it seems inconsistent with what you said earlier.

Issue here is that SpotPrice can also change when orders are placed so someone could easily follow this event thinking he has the most up to date spot price which would be false if we emit it only when price changed without an order getting placed.

I suggest always emitting this spot price update (traffic goes down due to no orders or orders boost the price up). Then we can either drop the spot price from the OnDemandOrderPlaced event or simply have it in both places for absolute clarity.

Cargo.lock Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of formatting nits. We use nightly fmt cargo +nightly fmt --all. Feel free to run locally and see the changes yourself.

For more details feel free to read this: https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/STYLE_GUIDE.md

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running the cargo +nightly fmt --all worked but some of the formatting remained inconsistent with the styleguide example.

I'll try to run it while paying more attention if there's an issue

polkadot/runtime/parachains/src/assigner_on_demand/mod.rs Outdated Show resolved Hide resolved
@Overkillus Overkillus added C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. T8-polkadot This PR/Issue is related to/affects the Polkadot network. labels May 21, 2024
@Overkillus
Copy link
Contributor

Overkillus commented May 21, 2024

Hey @bolajahmad

Thanks for fixing it! Seems we are nearly good to go and the only item missing is the PRdoc. I see that you've added it into the description of that PR but what you need to do is put it in a file in this folder: prdoc (link)

Name it pr_4339.prdoc and use the same description items as the ones you have above. I added an extra SpotPriceSet clarification and removed the link:

# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Improving on_demand_assigner emitted events

doc:
  - audience: Runtime User
    description: |
      Registering OnDemandOrderPlaced event that is useful for indexers to save data related to on demand orders. Adds SpotPriceSet as a new event to monitor on-demand spot prices. It updates whenever the price changes due to traffic.

crates:
  - name: polkadot-runtime-parachains
    bump: minor

Once you get that done we can do a final review and merge 🚀

@eskimor
Copy link
Member

eskimor commented May 27, 2024

bot fmt

@command-bot
Copy link

command-bot bot commented May 27, 2024

@eskimor https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6311702 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh". Check out https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 4-df4e7789-5cee-4a66-870b-a2e74161ab43 to cancel this command or bot cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented May 27, 2024

@eskimor Command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh" has finished. Result: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6311702 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6311702/artifacts/download.

@eskimor
Copy link
Member

eskimor commented May 28, 2024

bot fmt

@command-bot
Copy link

command-bot bot commented May 28, 2024

@eskimor https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6324500 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh". Check out https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 1-20a2ab59-fbb2-4a44-86b0-9f81c975e04f to cancel this command or bot cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented May 28, 2024

@eskimor Command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh" has finished. Result: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6324500 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6324500/artifacts/download.

Copy link
Member

@eskimor eskimor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to get the remaining formatting inconsistencies fixed. Other than that looks good.

@eskimor eskimor added this pull request to the merge queue May 28, 2024
Merged via the queue into paritytech:master with commit 650b124 May 28, 2024
154 of 157 checks passed
Comment on lines -371 to +374
/// An order was placed at some spot price amount.
OnDemandOrderPlaced { para_id: ParaId, spot_price: BalanceOf<T> },
/// The value of the spot traffic multiplier changed.
SpotTrafficSet { traffic: FixedU128 },
/// An order was placed at some spot price amount by orderer ordered_by
OnDemandOrderPlaced { para_id: ParaId, spot_price: BalanceOf<T>, ordered_by: T::AccountId },
/// The value of the spot price has likely changed
SpotPriceSet { spot_price: BalanceOf<T> },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be problematic as you're changing the formats of the existing events here. As events from the previous block are reset after the runtime upgrade but before running any hooks, event storage must always be compatible. So, technically, this part needs more care.

Buuuut, given that, IIUC,

  1. OnDemandOrderPlaced was never deposited by the previous version of the code, and
  2. SpotPriceSet internal representation is the same, as BalanceOf<T> coincides with FixedU128 in all the current use cases,

it may be safe to leave it as is.

That said, some more research is needed on how safe it is.

CC @liamaharon @bkchr

ordian added a commit that referenced this pull request May 30, 2024
* master: (93 commits)
  Fix broken windows build (#4636)
  Beefy client generic on aduthority Id (#1816)
  pallet-staking: Put tests behind `cfg(debug_assertions)` (#4620)
  Broker new price adapter (#4521)
  Change `XcmDryRunApi::dry_run_extrinsic` to take a call instead (#4621)
  Update README.md (#4623)
  Publish `chain-spec-builder` (#4518)
  Add omni bencher & chain-spec-builder bins to release (#4557)
  Moves runtime macro out of experimental flag (#4249)
  Filter workspace dependencies in the templates (#4599)
  parachain-inherent: Make `para_id` more prominent (#4555)
  Add metric to measure the time it takes to gather enough assignments (#4587)
  Improve On_demand_assigner events (#4339)
  Conditional `required` checks (#4544)
  [CI] Deny adding git deps (#4572)
  [subsytem-bench] Remove redundant banchmark_name param (#4540)
  Add availability-recovery from systematic chunks (#1644)
  Remove workspace lints from templates (#4598)
  `sc-chain-spec`: deprecated code removed (#4410)
  [subsystem-benchmarks] Add statement-distribution benchmarks (#3863)
  ...
girazoki pushed a commit to moondance-labs/polkadot-sdk that referenced this pull request May 30, 2024
title: Improving `on_demand_assigner` emitted events

doc:
  - audience: Rutime User
description: OnDemandOrderPlaced event that is useful for indexers to
save data related to on demand orders. Check [discussion
here](https://substrate.stackexchange.com/questions/11366/ondemandassignmentprovider-ondemandorderplaced-event-was-removed/11389#11389).

Closes paritytech#4254 

crates: [ 'runtime-parachain]

---------

Co-authored-by: Maciej <maciej.zyszkiewicz@parity.io>
hitchhooker pushed a commit to ibp-network/polkadot-sdk that referenced this pull request Jun 5, 2024
title: Improving `on_demand_assigner` emitted events

doc:
  - audience: Rutime User
description: OnDemandOrderPlaced event that is useful for indexers to
save data related to on demand orders. Check [discussion
here](https://substrate.stackexchange.com/questions/11366/ondemandassignmentprovider-ondemandorderplaced-event-was-removed/11389#11389).

Closes paritytech#4254 

crates: [ 'runtime-parachain]

---------

Co-authored-by: Maciej <maciej.zyszkiewicz@parity.io>
TarekkMA pushed a commit to moonbeam-foundation/polkadot-sdk that referenced this pull request Aug 2, 2024
title: Improving `on_demand_assigner` emitted events

doc:
  - audience: Rutime User
description: OnDemandOrderPlaced event that is useful for indexers to
save data related to on demand orders. Check [discussion
here](https://substrate.stackexchange.com/questions/11366/ondemandassignmentprovider-ondemandorderplaced-event-was-removed/11389#11389).

Closes paritytech#4254 

crates: [ 'runtime-parachain]

---------

Co-authored-by: Maciej <maciej.zyszkiewicz@parity.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. T8-polkadot This PR/Issue is related to/affects the Polkadot network.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

on-demand: Improve/fix events
4 participants