-
Notifications
You must be signed in to change notification settings - Fork 213
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
Add transaction expiry slot for pending transactions #1879
Conversation
19d373c
to
b2830bc
Compare
8775410
to
3c6f96d
Compare
b43d675
to
86273d4
Compare
b21f9d8
to
25374a2
Compare
8c998f0
to
a76ae7e
Compare
2792944
to
aef0bdc
Compare
bors try |
tryBuild succeeded: |
, expectField #expiresAt (`shouldSatisfy` isJust) | ||
] | ||
|
||
-- This stuff would be easier with Control.Lens... |
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.
Are we tracking that in a technical debt ticket 🤔 ?
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.
No, because I sent a message about this to slack, and got exactly 0 replies.
let sl = sinceBlock ^. #absoluteSlotNumber . #getApiT | ||
|
||
-- The expected expiry slot (adds the hardcoded default ttl) | ||
let ttl = sl + SlotNo 7200 |
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.
Should we perhaps expose that default "magic number" ? Or at least, have it behind a named constant in the integration DSL so that we do not duplicate it all over the place.
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.
OK done.
lib/core/src/Cardano/Wallet.hs
Outdated
@@ -840,6 +840,7 @@ restoreBlocks ctx wid blocks nodeTip = db & \DBLayer{..} -> mapExceptT atomicall | |||
let k = gp ^. #getEpochStability | |||
let localTip = currentTip $ NE.last cps | |||
|
|||
updatePendingTx (PrimaryKey wid) (view #slotNo localTip) |
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.
update
feels a bit general here. When reading this, my first thought is "update what?". What about using a more specific qualifier like: "discardNowExpiredTx" or, whatever you'd come up with ?
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.
updatePendingTxForExpiry
@@ -1332,9 +1333,11 @@ mkApiTransactionFromInfo ti (TransactionInfo txid ins outs ws meta depth txtime | |||
case meta ^. #status of | |||
Pending -> #pendingSince | |||
InLedger -> #insertedAt | |||
Expired -> #pendingSince |
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.
Shall we perhaps use yet-another-field for tracking the time since which the transaction has expired?
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 "pending_since" is the correct field. The time at which the transaction expired is in "expires_at".
So both times are captured for expired 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.
Fair enough!
data ApiSlotReference = ApiSlotReference | ||
{ time :: !UTCTime | ||
, absoluteSlotNumber :: !(ApiT SlotNo) | ||
} deriving (Eq, Generic, Show) |
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.
What about including also the epoch and slot within epoch to be consistent with other time references? We use:
data ApiTimeReference = ApiTimeReference
{ time :: !UTCTime
, block :: !ApiBlockReference
} deriving (Eq, Generic, Show)
data ApiBlockReference = ApiBlockReference
{ epochNumber :: !(ApiT EpochNo)
, slotNumber :: !(ApiT SlotInEpoch)
, height :: !(Quantity "block" Natural)
, absoluteSlotNumber :: !(ApiT SlotNo)
} deriving (Eq, Generic, Show)
Although indeed, the TTL is about slots and not blocks so the height don't make much sense. The other however do. So I'd suggest to have something along the lines of:
data ApiTimeReferenceBySlot = ApiTimeReferenceBySlot
{ time :: !UTCTime
, slot :: !ApiSlotReference
} deriving (Eq, Generic, Show)
data ApiSlotReference = ApiBlockReference
{ epochNumber :: !(ApiT EpochNo)
, slotNumber :: !(ApiT SlotInEpoch)
, absoluteSlotNumber :: !(ApiT SlotNo)
} deriving (Eq, Generic, Show)
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.
Not only is TTL about slots, but it's about slots in the future -- which cannot have a block height.
OK I have added epoch and slot numbers.
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.
For consistency, It'd be better to have them nested under a slot
field, don't you think 🤔 ?
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 maybe - I am going to straighten out the types a bit (without changing existing API fields).
minUTxOValue :: Natural | ||
minUTxOValue = 1_000_000 | ||
|
||
-- | Wallet server's chosen transaction TTL value (in slots) when none is given. | ||
defaultTxTTL :: SlotNo | ||
defaultTxTTL = 7200 |
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.
👍
data ApiSlotReference = ApiSlotReference | ||
{ time :: !UTCTime | ||
, absoluteSlotNumber :: !(ApiT SlotNo) | ||
} deriving (Eq, Generic, Show) |
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.
For consistency, It'd be better to have them nested under a slot
field, don't you think 🤔 ?
@@ -174,6 +175,9 @@ newDBLayer timeInterpreter = do | |||
Pending Tx | |||
-----------------------------------------------------------------------} | |||
|
|||
, updatePendingTxForExpiry = \pk tip -> ExceptT $ do | |||
alterDB errNoSuchWallet db (mUpdatePendingTx pk tip) |
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.
👍
@KtorZ I made the API types more consistent (last 2 commits). ApiBlockReference is just ApiSlotReference with block information added. ApiNetworkTip is replaced with ApiSlotReference. The end result is that all references to a slot/time look the same in the API. The Haskell API types have SlotId and block info nested rather than inline. I hope in future that we can change the swagger spec to match. But for now there are some non-generic Aeson instances to maintain backwards compatibility. |
ApiBlockReference is just ApiSlotReference with block information added -- block references gain slot info. ApiNetworkTip is replaced with ApiSlotReference -- so it gains a "time" field. The Haskell API types have SlotId and block info nested rather than inline. I hope in future that we can change the swagger spec to match. But for now there are some non-generic Aeson instances to maintain backwards compatibility.
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.
Nice work!
I pointed that out in my review from yesterday which I apparently didn't submit :| ... I agree that having one flat and the other nested is sort of inconsistent and I'd very much prefer getting rid of this inconsistency but its also neat-picking at this stage. So happy to move forward with that one. |
bors merge |
Build succeeded: |
2235: Fix extra-source-files not containing files used by TH r=hasufell a=hasufell 2239: WIP: Bump version from 2020.9.30 to 2020.10.13 r=KtorZ a=jonathanknowles <!-- Short optional summary --> Compatible with [`jormungandr@v0.9.0`](https://github.com/input-output-hk/jormungandr/releases/tag/v0.9.0) and [`cardano-node@1.21.1`](https://github.com/input-output-hk/cardano-node/releases/tag/1.21.1). ## New Features - Adds the ability for users to select their own SMASH servers for stakepool listings. (#2214) - Adds transaction expiry slots for pending transactions. (#1879) ## Improvements - Adds a 100-wallet scenario to the latency benchmark. (#2223) - Adds an executable `shelley-test-cluster` which starts an integration test cluster that includes faucets. (#2178) - Extends `isOurs` to return the derivation path of an address. (#2219) ## Resolved Issues - Make pool garbage collection handle an unknown current epoch. (#2203) - Fixes incorrect mainnet network parameters returned from API. (#2226) ## Known Issues **_This section is a work in progress._** - Wallet restoration status reported incorrectly on mainnet. ([ADP-483](https://jira.iohk.io/browse/ADP-483)) ## Documentation <!-- A snapshot of the documentation at the time of releasing. --> Cardano (cardano-node) | ITN (Jörmungandr) --- | --- [API Documentation](https://input-output-hk.github.io/cardano-wallet/api/v2020-10-13) | [API Documentation](https://input-output-hk.github.io/cardano-wallet/api/v2020-10-13) [CLI Manual](https://github.com/input-output-hk/cardano-wallet/wiki/Wallet-command-line-interface/f71ecb7ece3deaec5bf60f4a4beea1d3950e0d46) | [CLI Manual](https://github.com/input-output-hk/cardano-wallet/wiki/Wallet-command-line-interface-jormungandr/f71ecb7ece3deaec5bf60f4a4beea1d3950e0d46) [Docker Manual](https://github.com/input-output-hk/cardano-wallet/wiki/Docker/f71ecb7ece3deaec5bf60f4a4beea1d3950e0d46) | [Docker Manual](https://github.com/input-output-hk/cardano-wallet/wiki/Docker-jormungandr/f71ecb7ece3deaec5bf60f4a4beea1d3950e0d46) ## Installation Instructions ### Cardano (cardano-node) 1. Install [`cardano-node@1.21.1`](https://github.com/input-output-hk/cardano-node/releases/tag/1.21.1). 2. Download the provided `cardano-wallet` for your platform, and uncompress it in a directory that is on your `$PATH`, e.g. `/usr/local/bin`. Or `%PATH%` on Windows. 4. Start `cardano-wallet --help` and see available parameters. #### Docker Pull from DockerHub and verify the version matches 2020.10.13. ``` $ docker pull inputoutput/cardano-wallet:2020.10.13 $ docker run --rm inputoutput/cardano-wallet:2020.10.13 version ``` ### ITN (jormungandr) 1. Install [`jormungandr@v0.9.0`](https://github.com/input-output-hk/jormungandr/releases/tag/v0.9.0). 2. Download the provided `cardano-wallet-jormungandr` for your platform, and uncompress it in a directory that is on your `$PATH`, e.g. `/usr/local/bin`. Or `%PATH%` on Windows. 3. (optional) Install the bash/zsh auto-completion script according to the [jormungandr cli manual](https://github.com/input-output-hk/cardano-wallet/wiki/Wallet-Command-Line-Interface/{{JORM_CLI_WIKI_COMMIT}}) 4. Start `cardano-wallet --help` and see available parameters. #### Docker Pull from DockerHub and verify the version matches 2020.10.13 ``` $ docker pull inputoutput/cardano-wallet:2020.10.13-jormungandr $ docker run --rm inputoutput/cardano-wallet:2020.10.13-jormungandr version ``` ## Signatures <!-- Signatures of people responsible for the release --> Name | Role | Approval --- | --- | ---: Matthias Benkort @KtorZ | Technical Team Lead | ⌛ Piotr Stachyra @piotr-iohk | QA Engineer | ⌛ Tatyana Valkevych @tatyanavych | Release Manager | ⌛ Co-authored-by: Julian Ospald <julian.ospald@iohk.io> Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io> Co-authored-by: Jonathan Knowles <jonathan.knowles@iohk.io> Co-authored-by: IOHK <devops+stack-project@iohk.io>
Issue Number
Relates to ADP-93 / #1838.
Overview