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

dex: fold Positions into the price indexes #4564

Merged
merged 1 commit into from
Jun 13, 2024
Merged

Conversation

erwanor
Copy link
Member

@erwanor erwanor commented Jun 5, 2024

Describe your changes

This PR:

  • fold Position records into the DEX price indexes
  • remove extra hashing of positions (to compute Ids)
  • adds a migration script to population the nonconsensus idx

Checklist before requesting a review

  • If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason:

    This is consensus breaking, AND requires a migration.

@erwanor erwanor added A-dex Area: Relates to the dex migration A pull request that contains a migration consensus-breaking breaking change to execution of on-chain data labels Jun 6, 2024
@erwanor erwanor requested review from hdevalence and zbuc June 6, 2024 21:37
@erwanor erwanor self-assigned this Jun 6, 2024
@erwanor erwanor added this to the Sprint 8 milestone Jun 6, 2024
@erwanor
Copy link
Member Author

erwanor commented Jun 8, 2024

There's an interesting idea about using the pb type for asset id to short-circuit an expensive field element serialization. But if we do it, that will be in a different PR.

@erwanor erwanor marked this pull request as ready for review June 8, 2024 13:15
@zbuc zbuc self-requested a review June 10, 2024 21:34
@conorsch
Copy link
Contributor

Heads up, we've got conflicts with #4567 & #4596 now. I recommend we land #4596 and then work on rebasing this PR to accommodate.

@conorsch
Copy link
Contributor

OK, I believe we're unblocked to rebase this one now. Sorry we missed an opportunity to coordinate more closely on starting the Testnet78 migration. @erwanor could you handle the rebase since you know the logic best? Then I'll circle back to test the migration end to end as part of final review.

@conorsch conorsch self-requested a review June 12, 2024 22:27
Copy link
Contributor

@conorsch conorsch left a comment

Choose a reason for hiding this comment

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

Has conflicts due to Testnet78 migration added recently, oops. Requesting rebase resolution, then will test as part of review.

@erwanor erwanor force-pushed the erwan/nv_indexes_lookup branch 2 times, most recently from ea38bf1 to 67f8546 Compare June 13, 2024 16:49
@erwanor
Copy link
Member Author

erwanor commented Jun 13, 2024

I have tested this manually, and rebased onto main.

@conorsch
Copy link
Contributor

Tested this by setting up a devnet on v0.77.2, opening an LP on the pair penumbra:test_usd, and confirming I can swap out of it:

❯ pcli --home ~/.local/share/pcli-devnet q dex all-positions
Scanning blocks from last sync height 1745 to latest height 1745
[0s] ██████████████████████████████████████████████████       0/0       0/s ETA: 0s
 ID                                                                State    Fee  Sell Price    Reserves
 plpid1xs8dxcp22k7cw9adkqaya5lvvqyv5spwqfemj7kxjam40y6rt2fqms4f8p  opened  0bps   1penumbra  95test_usd
 └──────────────────────────────────────────────────────────────▶          0bps   1test_usd   5penumbra

Then, after voting for a halt and applying the migration, the position is still visible, and I can still swap into it, seeing the balance updated:

❯ pcli --home ~/.local/share/pcli-devnet tx swap 45penumbra --into test_usd
Scanning blocks from last sync height 1911 to latest height 1911
[0s] ██████████████████████████████████████████████████       0/0       0/s ETA: 0s
building transaction [3 actions, 3 proofs]...
finished proving in 0.566 seconds [3 actions, 3 proofs, 2377 bytes]
broadcasting transaction and awaiting confirmation...
transaction broadcast successfully: b75ecd4cfe2a414913d8a698c9e3a16a93d67ab353426deead6e9e68762703dc
transaction confirmed and detected: b75ecd4cfe2a414913d8a698c9e3a16a93d67ab353426deead6e9e68762703dc @ height 1912
Swap submitted and batch confirmed!
You will receive outputs of 45test_usd and 0penumbra. Claiming now...
building transaction [1 actions, 1 proofs]...
finished proving in 0.495 seconds [1 actions, 1 proofs, 585 bytes]
broadcasting transaction and awaiting confirmation...
transaction broadcast successfully: 1163bcceb238b4b805b58123c7cf1beb9a5a46924404f0d04ba77651cdfc4b2a
transaction confirmed and detected: 1163bcceb238b4b805b58123c7cf1beb9a5a46924404f0d04ba77651cdfc4b2a

❯ cargo run -q --release --bin pcli -- --home ~/.local/share/pcli-devnet/ q dex all-positions
Scanning blocks from last sync height 1914 to latest height 1914
[0s] ██████████████████████████████████████████████████       0/0       0/s ETA: 0s
ID                                                                State    Fee  Sell Price    Reserves
plpid1xs8dxcp22k7cw9adkqaya5lvvqyv5spwqfemj7kxjam40y6rt2fqms4f8p  opened  0bps   1penumbra  50test_usd
└──────────────────────────────────────────────────────────────▶          0bps   1test_usd  50penumbra

That looks right to me! One more migration to write toward 78.

@conorsch conorsch merged commit b584c26 into main Jun 13, 2024
16 checks passed
@conorsch conorsch deleted the erwan/nv_indexes_lookup branch June 13, 2024 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dex Area: Relates to the dex consensus-breaking breaking change to execution of on-chain data migration A pull request that contains a migration
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants