-
Notifications
You must be signed in to change notification settings - Fork 217
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
Withdrawals as part of core and API transactions #1892
Conversation
_ <- Sqlite.step query | ||
Sqlite.finalize query | ||
ColumnPresent -> | ||
traceWith tr $ MsgManualMigrationNotNeeded field |
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 originally started adding the withdrawal to the TxMeta
table but I reverted and went for a new table instead since it behaves much more like current TxIn and TxOut. I however kept this refactor as I thought it wouldn't hurt 😊
txWithdrawalAccount W.ChimericAccount sql=account | ||
|
||
Primary txWithdrawalTxId txWithdrawalAccount | ||
deriving Show Generic |
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.
Interesting stuff actually here ☝️
, withdrawals | ||
:: !(Map ChimericAccount Coin) | ||
-- ^ Withdrawals (of funds from a registered reward account) embedded in | ||
-- a transaction. The order does not matter. |
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.
And here 👆
Right a | ||
where | ||
msg = TextDecodingError | ||
"Unable to decode stake-address: not a well-formed address." |
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'll add a roundtrip test for these instances.
@@ -911,9 +983,6 @@ instance Buildable addr => Buildable (ConnectionId addr) where | |||
instance Buildable LocalAddress where | |||
build (LocalAddress p) = build p | |||
|
|||
instance Buildable W.ChimericAccount where | |||
build (W.ChimericAccount addr) = hexF addr |
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.
Found this little orphan 🙃 ... No longer needed since it's define in the core package next to its relevant type declaration.
- amount | ||
properties: | ||
stake_address: *stakeAddress | ||
amount: *amount |
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.
Here, I've chosen not to represent withdrawals as a key:value map in the API because it would otherwise be a key:value map where all keys are pretty much unknown by the client 😶 ... wallet clients aren't typically aware of what their stake address is, so having something like:
{ "stake_addr1sjck9mdmfyhzvjhydcjllgj9vjvl522w0573ncustrrr2rg7h9azg4cyqd36yyd48t5ut72hgld0fg2x": 42 }
Would make it quite hard for them to inspect the content of that value ^^"... Hence, in the API, I am turning the Map
we have internally into a list of object with a stake_address
and amount
properties.
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, sound decision
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.
Was thinking before how absent withdrawals are going to be represented: either by 0-length array or by making withdrawals
in ApiTransaction
not required... Why the first option is better?
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.
It'll be a 0-length array.
, status :: !(ApiT TxStatus) | ||
} deriving (Eq, Generic, Show) | ||
|
||
data ApiWithdrawal n = ApiWithdrawal |
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.
👍
, mapMaybe fromShelleyDelegationCert (toList certs) | ||
, mapMaybe fromShelleyRegistrationCert (toList certs) | ||
) | ||
|
||
fromShelleyWdrl :: SL.Wdrl TPraosStandardCrypto -> Map W.ChimericAccount W.Coin |
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.
👍
@@ -387,15 +387,15 @@ computeTxSize proxy action cs = | |||
|
|||
dummyKeyHashRaw = BS.pack (replicate 28 0) | |||
|
|||
withdrawals = mkWithdrawals | |||
wdrls = mkWithdrawals |
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.
frankly speaking like more previous naming, but understand the probable rationale (80-line styling)
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, I usually try to keep naming consistent with the surrounding context.
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.
LGTM! would be good not to forget _decodeStakeAddress . _encodeStakeAddress
roundtrip. Also some changes are needed in /build/cardano-wallet/lib/core/test/bench/db/Main.hs:408
but it is no surprise when changes in such a core place are made.
a64f033
to
a40b93e
Compare
bors r+ |
Canceled |
bors r+ |
1892: Withdrawals as part of core and API transactions r=KtorZ a=KtorZ # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> #1881 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - 589609e 📍 **factor out common code in database migration** Turns out that adding column is a pretty common and straighfordward migration. I originally intended to add a new column to the TxMeta table, hence the refactor. In the end, I've used a different table for withdrawals, but the refactor is still worth it as it is IMO. - e9e516c 📍 **add withdrawals to API & core transaction data types** Still to be done: withdrawals must be discovered when processing blocks - ff58489 📍 **upgrade Byron & Jormungandr compatibility code with empty withdrawals** Withdrawals are only a thing in Shelley, so for this targets, we can safely replace them by empty lists - 533b787 📍 **wire withdrawals in Shelley compatibility code** Here, we extract withdrawals directly from the TxBody, the conversion is straightforward - e2e6fbb 📍 **include withdrawals where relevant in test and arbitrary generators** - 4b6eaba 📍 **add withdrawals to the API Swagger specification** We represent them as a list and not a key:value map with stake address as key because clients typically don't know the stake address associated with their wallet, so it'd be quite impractical for them to access this data if returned as a map... # Comments <!-- Additional comments or screenshots to attach if any -->⚠️ Sorry, the PR spans over many files because I needed to add a new class constraints `DecodeStakeAddress` which goes side-by-side with the current `DecodeAddress`. <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> 1895: hydra: Prevent caching of shelley integration test failures r=KtorZ a=rvl ### Issue Number Not sure. ### Overview This change causes integration tests to be re-run whenever the git revision changes, even if everything else is identical. Since these tests tend to fail a lot, we don't want to cache false failures. Also increase the minimum severity for integration test logging, because debug level produces quite a lot of output. Co-authored-by: KtorZ <[email protected]> Co-authored-by: IOHK <[email protected]> Co-authored-by: Rodney Lorrimar <[email protected]>
Build failed (retrying...) |
ab7bb2b
to
c947ed4
Compare
Canceled |
c947ed4
to
d344780
Compare
Still to be done: withdrawals must be discovered when processing blocks
Withdrawals are only a thing in Shelley, so for this targets, we can safely replace them by empty lists
Here, we extract withdrawals directly from the TxBody, the conversion is straightforward
We represent them as a list and not a key:value map with stake address as key because clients typically don't know the stake address associated with their wallet, so it'd be quite impractical for them to access this data if returned as a map...
…eturned from the API
This is a 'any' sort of filter, such that it returns any transaction where there's at least one withdrawal matching the criteria. The use-case is typically to ask for all transactions where there's a min withdrawal of 1, such that we get the entire withdrawal history
675d507
to
3dd7257
Compare
bors r+ |
1892: Withdrawals as part of core and API transactions r=KtorZ a=KtorZ # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> #1881 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - 74abe1c 📍 **add withdrawals to API & core transaction data types** Still to be done: withdrawals must be discovered when processing blocks - 0211c5c 📍 **upgrade Byron & Jormungandr compatibility code with empty withdrawals** Withdrawals are only a thing in Shelley, so for this targets, we can safely replace them by empty lists - 861a792 📍 **wire withdrawals in Shelley compatibility code** Here, we extract withdrawals directly from the TxBody, the conversion is straightforward - c36f23a 📍 **include withdrawals where relevant in test and arbitrary generators** - 9f6738e 📍 **add withdrawals to the API Swagger specification** We represent them as a list and not a key:value map with stake address as key because clients typically don't know the stake address associated with their wallet, so it'd be quite impractical for them to access this data if returned as a map... - e7fcedb 📍 **add roundtrip tests for stake address and show that withdrawals are returned from the API** - 00c2d69 📍 **Add stake address constraints to Jormungandr and Byron** - 533b772 📍 **add 'minWithdrawal' query parameter to the swagger specification** - 07a0f23 📍 **extend transaction API to allow filtering by minimal withdrawals amount** This is a 'any' sort of filter, such that it returns any transaction where there's at least one withdrawal matching the criteria. The use-case is typically to ask for all transactions where there's a min withdrawal of 1, such that we get the entire withdrawal history - 3dd7257 📍 **review integration and unit tests, add additional checks to cover withdrawals** # Comments <!-- Additional comments or screenshots to attach if any -->⚠️ Sorry, the PR spans over many files because I needed to add a new class constraints `DecodeStakeAddress` which goes side-by-side with the current `DecodeAddress`. <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: KtorZ <[email protected]>
Canceled |
bors r+ |
Build succeeded |
Issue Number
#1881
Overview
74abe1c
📍 add withdrawals to API & core transaction data types
Still to be done: withdrawals must be discovered when processing blocks
0211c5c
📍 upgrade Byron & Jormungandr compatibility code with empty withdrawals
Withdrawals are only a thing in Shelley, so for this targets, we can safely replace them by empty lists
861a792
📍 wire withdrawals in Shelley compatibility code
Here, we extract withdrawals directly from the TxBody, the conversion is straightforward
c36f23a
📍 include withdrawals where relevant in test and arbitrary generators
9f6738e
📍 add withdrawals to the API Swagger specification
We represent them as a list and not a key:value map with stake address as key because clients typically don't know the stake address associated with their wallet, so it'd be quite impractical for them to access this data if returned as a map...
e7fcedb
📍 add roundtrip tests for stake address and show that withdrawals are returned from the API
00c2d69
📍 Add stake address constraints to Jormungandr and Byron
533b772
📍 add 'minWithdrawal' query parameter to the swagger specification
07a0f23
📍 extend transaction API to allow filtering by minimal withdrawals amount
This is a 'any' sort of filter, such that it returns any transaction where there's at least one withdrawal matching the criteria. The use-case is typically to ask for all transactions where there's a min withdrawal of 1, such that we get the entire withdrawal history
3dd7257
📍 review integration and unit tests, add additional checks to cover withdrawals
Comments
DecodeStakeAddress
which goes side-by-side with the currentDecodeAddress
.