-
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
Diverse witnesses in shelley #1849
Diverse witnesses in shelley #1849
Conversation
let n = fromIntegral (natVal $ Proxy @(EntropySize mw)) `div` 8 | ||
bytes <- BS.pack <$> vector n | ||
let ent = unsafeMkEntropy @(EntropySize mw) bytes | ||
return $ entropyToMnemonic ent |
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.
Why not simply use genEntropy
with EntropySize mw
to get the right number of bytes?
pure $ mkByronWitness pm sigData ks | ||
pure | ||
( Tx (Hash sigData) (second coin <$> ownedIns) outs | ||
, SealedTx $ CBOR.toStrictByteString $ CBOR.encodeSignedTx tx witnesses |
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 don't think this is right. This is how transaction were serialized in Byron, but in Shelley, they are following a different scheme. Therefore, we should serialize transaction using the new shelley methods; only the witnesses are different!
6c90fca
to
919f096
Compare
(k, pwd) <- lookupPrivateKey keyFrom addr | ||
pure $ mkByronWitness unsigned pm (getRawKey k, pwd) | ||
pure $ SL.WitnessSet mempty mempty bootstrapWits | ||
<> mkExtraWits unsigned --- TO_DO - this is needed? |
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 one is maybe not needed - I do not know at this moment
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.
Yes, if extra witnesses are needed for certificates or whatnot, they end up here
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, but in byron transactions it should not happen to my best knowledge, right?
919f096
to
2d46562
Compare
where | ||
credential = Hash.UnsafeHash $ L8.toStrict chaff | ||
addrAttr = Byron.mkAttributes $ Byron.AddrAttributes | ||
(Just $ Byron.HDAddressPayload (bloatChaff keyLen)) |
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.
Why keyLen
here 🤔 ? The HDAddressPayload is a ChaChaPoly digest + nonce that totals 28 bytes + 2 bytes because it's CBOR-encoded. I believe the keyLen
is 32 bytes here so it's probably not a bit deal, but that is quite misleading and error-prone.
More importantly, there's only a HDPayload for /Byron/ type of addresses, Icarus do not.
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.
addressed here 1209bca
credential = Hash.UnsafeHash $ L8.toStrict chaff | ||
addrAttr = Byron.mkAttributes $ Byron.AddrAttributes | ||
(Just $ Byron.HDAddressPayload (bloatChaff keyLen)) | ||
(toByronNetworkMagic mainnetMagic) |
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.
mainnet is hard-coded here which is sort of wrong because mainnet addresses don't embed any discrimination attribute whereas testnet address do. So there's a significant size variation between the two.
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.
suggestion: rely on the proxy
above to know whether mainnet or testnet is needed. See also: fromNetworkDiscriminant
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 I retrieve protocolMagic easily from proxy? 🤔
I have above (I agree it was quick hack) :
763 toByronNetworkMagic :: W.ProtocolMagic -> Byron.NetworkMagic
764 toByronNetworkMagic pm@(W.ProtocolMagic magic) =
765 if pm == W.mainnetMagic then
766 Byron.NetworkMainOrStage
767 else
768 Byron.NetworkTestnet (fromIntegral magic)
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.
In theory they should match indeed.
let signingKey = Crypto.SigningKey prv | ||
bytes = xprvToBytes prv | ||
addrAttr = Byron.mkAttributes $ Byron.AddrAttributes | ||
(Just $ Byron.HDAddressPayload bytes) |
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 don't think we should send the user's private key over in a witness!
The HDAddressPayload corresponds to the encrypted derivation path that is present only on Byron-Random addresses. I assume that what we needs here is:
a) To pass down the corresponding address to mkByronWitness
b) Have a function in the Compatibility module to convert an Address
into a AddrAttributes
. We have all the information we need in the Address already.
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.
have a try to deliver proper solution in 72c70d0
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.
The witness for Byron needs to be corrected, in particular the HD payload needs to be inferred from the address!
2d46562
to
1ef9f16
Compare
(k, pwd) <- lookupPrivateKey keyFrom addr | ||
pure $ mkShelleyWitness unsigned (getRawKey k, pwd) | ||
|
||
let withdrawalsWits |
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 was first wondering: why not factor out fmap Set.fromList $ forM (CS.inputs cs) $ \(_, TxOut addr _)
from both cases, and just differentiate on the witness construction?
Then I see withdrawalsWits
are only in the TxWitnessShelleyUTxO
case. Wouldn't it technically be possible (at least for people using cardano-wallet as a library) to spend both byron funds and withdrawals? Would it not be as well to construct withdrawalsWits
in both cases then?
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.
that's good question - I have also this in the back of my head. I planned to have working byron/icarus tx...and then in the next PR check this possibility
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.
to spend both byron funds and withdrawals?
Technically yes, but not with the wallet, because there are no withdrawals coming with our definition of Byron wallets.
Doing to crypto takes time here, and the coin selection algorithm do estimate fee quite many times in the process. So instead, it's better to use dummy values.
The context fee estimator is showing its limit. It has actually become quite annoying to maintain two separate fee estimator. We should stop using this fee estimator and rely on the API instead. For now, I am manually adding margins necessary to account for Byron witnesses that are more expensive. Min and Max depends on whether we are making the transaction from an `Icarus` or `Random`. Fortunately, the API estimates this correctly!
ac35bb6
to
28a2f9f
Compare
bors try |
tryBuild succeeded |
(Link.getWallet @'Byron wByron) Default Empty | ||
expectField | ||
(#balance . #available) | ||
(`shouldBe` Quantity (faucetAmt - feeEstMax - amt)) ra2 |
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.
👍
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.
👍
bors r+ |
1847: Track Stakepool Retirements in the DB r=jonathanknowles a=jonathanknowles # Related Issues #1815 #1816 #1817 #1819 #1880 # Overview This PR: - [x] Extends the pool DB schema to make it possible to store: - [x] retirement certificates. - [x] the _order_ of publication of certificates _within the same block_, for both registration and retirement certificates. This is necessary, as the intra-block order is _significant_.<br><br> - [x] Adds the `PoolLifeCycleStatus` type, which indicates the current lifecycle stage of a pool. There are currently _three_ possibilities: 1. `NotRegistered` (indicates that a pool has never been registered) 2. `Registered` (indicates that a pool has been registered but _not_ retired) (provides a registration certificate) 3. `RegisteredAndRetired` (indicates that a pool has been registered _and_ retired) (provides both a registration and a retirement certificate)<br><br> - [x] Adds the `readPoolLifeCycleStatus` function to the pool DB layer, making it possible to determine the current lifecycle status of a pool. - [x] Updates the `retirement` field of `ApiStakePool` with live information. # Property Tests This PR adds property tests to ensure that: - [x] the `determinePoolLifeCycleStatus` function respects the correct order of precedence for registration and retirement certificates: - for a given pool, a registration certificate always _supercedes_ a prior retirement certificate. - for a given pool, a retirement certificate always _augments_ the latest registration certificate. - [x] `readPoolLifeCycleStatus` queries work correctly in the presence of blocks containing multiple certificates for the same pool. - [x] database rollback works correctly in the presence of retirement certificates. # Future Work A **_future_** PR will add integration tests to ensure that: - retiring a pool eventually results in a correct update to the `retirement` field of `ApiStakePool`, when read through the `ListStakePools` operation. - retiring and then re-registering a pool clears the `retirement` field. See QA section of #1819. 1849: Diverse witnesses in shelley r=paweljakubas a=paweljakubas # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> #1844 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - [x] I have added WitnessTag - [x] I have added impl of mkTx for Byron/Icarus wtinesses - [x] I have added unit tests verifying decodeTx for Byron/Icarus witnesses - [x] I have updated fee estimation - [x] I have added integration tests illustrating the case # Comments <!-- Additional comments or screenshots to attach if any --> <!-- 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 --> 1887: Rename our SlotNo to SlotInEpoch r=Anviking a=Anviking # Issue Number #1868 <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - [x] Renamed `SlotNo` to `SlotInEpoch` (for consistency with other components) # Comments - `W.SlotNo` == `Cardano.SlotInEpoch` /= `Cardano.SlotNo` ``` Epoch 0 1 2 3 4 SlotNo* 0 1 2 3 4 5 6 7 8 9 SlotInEpoch 0 1 0 1 0 1 0 1 0 1 ``` *) I.e. the one defined in cardano-base and used in ourobouros-consensus. <!-- Additional comments or screenshots to attach if any --> <!-- 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: Jonathan Knowles <[email protected]> Co-authored-by: Pawel Jakubas <[email protected]> Co-authored-by: IOHK <[email protected]> Co-authored-by: KtorZ <[email protected]> Co-authored-by: Johannes Lund <[email protected]>
Build failed (retrying...) |
1849: Diverse witnesses in shelley r=paweljakubas a=paweljakubas # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> #1844 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - [x] I have added WitnessTag - [x] I have added impl of mkTx for Byron/Icarus wtinesses - [x] I have added unit tests verifying decodeTx for Byron/Icarus witnesses - [x] I have updated fee estimation - [x] I have added integration tests illustrating the case # Comments <!-- Additional comments or screenshots to attach if any --> <!-- 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 --> 1887: Rename our SlotNo to SlotInEpoch r=Anviking a=Anviking # Issue Number #1868 <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - [x] Renamed `SlotNo` to `SlotInEpoch` (for consistency with other components) # Comments - `W.SlotNo` == `Cardano.SlotInEpoch` /= `Cardano.SlotNo` ``` Epoch 0 1 2 3 4 SlotNo* 0 1 2 3 4 5 6 7 8 9 SlotInEpoch 0 1 0 1 0 1 0 1 0 1 ``` *) I.e. the one defined in cardano-base and used in ourobouros-consensus. <!-- Additional comments or screenshots to attach if any --> <!-- 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: Pawel Jakubas <[email protected]> Co-authored-by: IOHK <[email protected]> Co-authored-by: KtorZ <[email protected]> Co-authored-by: Johannes Lund <[email protected]>
Build failed (retrying...) |
Build succeeded |
Issue Number
#1844
Overview
Comments