-
Notifications
You must be signed in to change notification settings - Fork 17
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
Process Dutch auction NFT metadata in the block processor #1015
Conversation
@@ -52,10 +56,16 @@ interface QueryClientProps { | |||
stakingTokenMetadata: Metadata; | |||
} | |||
|
|||
const blankTxSource = new CommitmentSource({ | |||
const BLANK_TX_SOURCE = new CommitmentSource({ |
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.
Just a rename to make it clear that this is a never-changing constant
source: { case: 'transaction', value: { id: new Uint8Array() } }, | ||
}); | ||
|
||
const POSITION_STATES: PositionState[] = [ |
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.
Sort of the same here — extracting this constant from inside of a function, where it was being defined on every function call despite never changing.
@@ -361,45 +371,66 @@ export class BlockProcessor implements BlockProcessorInterface { | |||
return spentNullifiers; | |||
} | |||
|
|||
private async identifyLpNftPositions(txs: Transaction[]) { |
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.
You'll probably want to review the rest of this file with "Hide whitespace" turned on. In short, I:
- created a new
processTransactions
method that iterates over each transaction, then each action of each transaction, and callsthis.identifyAuctionNfts()
andthis.identifyLpNftPositions()
on each action. - created a new
identifyAuctioNfts()
method that saves auction NFT metadata when it appears. - modified
identifyLpNftPositions()
to process individual actions, rather than processing an array of transactions.
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.
this a great design choice as it's extensible to other metadata-related processing we'll need to do in the future!
@@ -73,21 +83,32 @@ mod test_helpers { | |||
|
|||
use super::*; | |||
|
|||
pub fn get_metadata_for(display_denom: &str) -> Metadata { | |||
pub fn get_metadata_for(display_denom: &str, base_denom_is_display_denom: bool) -> Metadata { |
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.
This is just a test helper. Auction NFTs only have one denom unit, so the base denom is the same as the display denom. So I added this arg to this function so that I can generate the right type of metadata for auction NFTs as well.
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.
smooth brain question: is it ever the case that a base denom is not the display denom?
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.
Yeah — the display denom is the one you see in the UI (e.g., "penumbra") but the base denom is the smallest possible unit (e.g., "upenumbra"). Usually they're different, just like US dollars and cents are different, but auction NFTs apparently only have a single denom unit — which makes sense, since you'll never hold more than 1 NFT for a given auction.
698e062
to
be1d9e5
Compare
@@ -101,7 +101,7 @@ impl ActionList { | |||
for value in self.balance().provided() { | |||
self.change_outputs.insert( | |||
value.asset_id, | |||
OutputPlan::new(&mut OsRng, value, change_address), | |||
OutputPlan::new(&mut OsRng, value, change_address.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 think I saw something about removing Copy
from Address
, this would explain why it's moved all the sudden
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.
Anyway, cloning is the right thing to do here. LGTM.
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.
yeah was getting lot of these copy errors too without cloning
@@ -73,21 +83,32 @@ mod test_helpers { | |||
|
|||
use super::*; | |||
|
|||
pub fn get_metadata_for(display_denom: &str) -> Metadata { | |||
pub fn get_metadata_for(display_denom: &str, base_denom_is_display_denom: bool) -> Metadata { |
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.
smooth brain question: is it ever the case that a base denom is not the display denom?
const auctionId = getAuctionId(action.value.description); | ||
const metadata = getAuctionNftMetadata( | ||
auctionId, | ||
// Always a sequence number of 0 when starting a Dutch auction |
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.
👍
} else if (action.case === 'actionDutchAuctionEnd' && action.value.auctionId) { | ||
const metadata = getAuctionNftMetadata( | ||
action.value.auctionId, | ||
// Always a sequence number of 1 when ending a Dutch auction |
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.
👍
} | ||
/** | ||
* @todo Handle `actionDutchAuctionWithdraw`, and figure out how to | ||
* determine the sequence number if there have been multiple withdrawals. |
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 think one way to do that is to structure the Action['action']
with a sequence number, rather than adding it ex-post in this method, unsure
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.
Cool, thanks, added a link to this comment in the ticket (#1020)
@@ -361,45 +371,66 @@ export class BlockProcessor implements BlockProcessorInterface { | |||
return spentNullifiers; | |||
} | |||
|
|||
private async identifyLpNftPositions(txs: Transaction[]) { |
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.
this a great design choice as it's extensible to other metadata-related processing we'll need to do in the future!
@@ -261,7 +271,7 @@ export class BlockProcessor implements BlockProcessorInterface { | |||
// - detect LpNft position opens | |||
// - generate all possible position state metadata | |||
// - update idb | |||
await this.identifyLpNftPositions(blockTx); |
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.
can we update the description above processTransactions(blockTx)
to accurately describe this function? Can we also move these existing comments to identifyLpNftPositions()
and add comments to identifyAuctionNfts()
.
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.
Whoops, good catch — fixed.
penumbra-stake = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.73.0", package = "penumbra-stake", default-features = false } | ||
penumbra-tct = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.73.0", package = "penumbra-tct" } | ||
penumbra-transaction = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.73.0", package = "penumbra-transaction", default-features = false } | ||
# TODO: Use `tag` instead of `rev` once auctions land in a tagged release of |
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.
👍
@@ -101,7 +101,7 @@ impl ActionList { | |||
for value in self.balance().provided() { | |||
self.change_outputs.insert( | |||
value.asset_id, | |||
OutputPlan::new(&mut OsRng, value, change_address), | |||
OutputPlan::new(&mut OsRng, value, change_address.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.
yeah was getting lot of these copy errors too without cloning
we're currently only saving the auction metadata to the can you create a separate issue in the tracking issue for that builds on this? ie. creating a auction state table which stores the auction id and note commitment?
|
The functionality seems to be all here, LGTM! |
As part of #942, I've made a massive branch with a ton of changes to the Dutch auction UI. To make the review process more manageable, I'm breaking the changes into smaller atomic PRs.
This PR modifies the block processor to identify Dutch auctions, and save their NFTs' metadata to the database when it encounters them. Future PRs will build on top of this.