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

CLI deployment of Wst using Blockfrost #44

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Conversation

amirmrad
Copy link
Collaborator

@amirmrad amirmrad commented Jan 6, 2025

No description provided.

@amirmrad amirmrad changed the base branch from main to j-mueller/issue-35/debug-mode January 6, 2025 13:22
Base automatically changed from j-mueller/issue-35/debug-mode to main January 6, 2025 19:13
@amirmrad amirmrad requested a review from j-mueller January 10, 2025 16:28
@amirmrad amirmrad marked this pull request as ready for review January 10, 2025 16:28
@@ -250,41 +264,31 @@ registerAlwaysSucceedsStakingCert = failOnError $ do
BuildTx.addConwayStakeCredentialRegistrationCertificate cred (pp ^. Ledger.ppKeyDepositL)
void (tryBalanceAndSubmit mempty Wallet.w1 txBody TrailingChange [])

-- TODO: registration to be moved to the endpoints
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will it fail if we attempt to register a 2nd time?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe so. Should we handle it?

txBody <- BuildTx.execBuildTxT $ do
BuildTx.addStakeScriptWitness credMinting transferMintingScript ()
BuildTx.addConwayStakeCredentialRegistrationCertificate credMinting (pp ^. Ledger.ppKeyDepositL)
-- pp <- fmap C.unLedgerProtocolParameters queryProtocolParameters
Copy link
Collaborator

Choose a reason for hiding this comment

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

Commented out code

let root = DirectoryScriptRoot txi target
(tx, _) <- Env.withEnv $ Env.withOperator opEnv $ Env.withDirectoryFor root $ Env.withTransferFromOperator
$ Env.balanceTxEnv_
$ BuildTx.mintProtocolParams
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks nice 👍

@@ -0,0 +1 @@

Copy link
Collaborator

Choose a reason for hiding this comment

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

empty file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops!

blacklistMintingScript :: ScriptTarget -> C.Hash C.PaymentKey -> C.PlutusScript C.PlutusScriptV3
blacklistMintingScript target cred =
let script = Scripts.tryCompile target $ mkPermissionedMinting # pdata (pconstant $ transPubKeyHash cred)
let script = Scripts.tryCompile target $ mkPermissionedMinting # pforgetData (pdata (pconstant "blacklist minting" :: ClosedTerm PByteString)) # pdata (pconstant $ transPubKeyHash cred)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the different between "permissioned" minting / spending and "blacklist" minting / spending? If it's just nominal, why do we need both?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No difference really, just though I'd nonce them differently to avoid confusions as it took me a while to debug as there were spending scripts, minting policies and stake scripts that had the same hash.

@j-mueller
Copy link
Collaborator

The missing ToSchema instance can be added to Wst.Orphans() (should be pretty straightforward as it's just a Text value)

@@ -131,6 +135,13 @@ insertBlacklistNode cred blacklistNodes = Utils.inBabbage @era $ do
opPkh <- asks (fst . Env.bteOperator . Env.operatorEnv)
addRequiredSignature opPkh

spendBlacklistOutput :: forall era env m. (MonadReader env m, Env.HasOperatorEnv era env, Env.HasTransferLogicEnv env, C.IsBabbageBasedEra era, C.HasScriptLanguageInEra C.PlutusScriptV3 era, MonadBuildTx era m) => C.TxIn -> m ()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is currently unused in the endpoints. I only needed it to remove a duplicate blacklist node I accidentally pushed on preview. We could later cleanup the interface and add an endpoint if need be.

addConwayStakeCredentialCertificate credMinting
addConwayStakeCredentialCertificate credSpending
addConwayStakeCredentialCertificate credSeizeSpending
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Registration step for transfer script was missing issuer spend (seize) stake script

@@ -216,7 +216,17 @@ seizeCredentialAssetsTx :: forall era env m.
seizeCredentialAssetsTx sanctionedCred = do
opPkh <- asks (fst . Env.bteOperator . Env.operatorEnv)
directory <- Query.registryNodes @era
seizeTxo <- head <$> Query.userProgrammableOutputs sanctionedCred
let getTxOutValue (C.TxOut _a v _d _r) = v
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just selects the UTxO with the largest non ada asset quantities ignoring the asset names.
To seize all utxos the endpoints must be repeatedly called until NoTokensToSeize is returned.

@@ -130,7 +131,8 @@ queryBlacklistedNodes _ (SerialiseAddress addr) = do
. P.fromBuiltin
. blnKey
. uDatum
Env.withEnv $ Env.withTransfer transferLogic (fmap (fmap getHash) (Query.blacklistNodes @era))
nonHeadNodes (P.fromBuiltin . blnKey . uDatum -> hsh) = hsh /= ""
Env.withEnv $ Env.withTransfer transferLogic (fmap getHash . filter nonHeadNodes <$> (Query.blacklistNodes @era))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Desezialization would fail in the case of the head node with an empty payment credential

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants