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

Add possibility to query local node to load protocol parameters - transaction build #5054

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

carbolymer
Copy link
Contributor

@carbolymer carbolymer commented Apr 4, 2023

This PR adds possibility to query local node for protocol parameters for transaction build command. This is a first part of implementation for #5052.

@carbolymer carbolymer force-pushed the mgalazyn/feature/read-protocol-params-from-node branch 3 times, most recently from 62079cf to 3b33373 Compare April 7, 2023 15:18
@carbolymer carbolymer changed the title #5052 Add possibility to query local node to load protocol parameters Add possibility to query local node to load protocol parameters - transaction build Apr 7, 2023
@carbolymer carbolymer marked this pull request as ready for review April 7, 2023 15:21
@newhoggy
Copy link
Contributor

newhoggy commented Apr 7, 2023

Might be good to demonstrate the change does what is intended somehow. For example in tests, or at least running the command manually and verifying results and pasting them in the PR.

@carbolymer carbolymer force-pushed the mgalazyn/feature/read-protocol-params-from-node branch from 2713502 to 6044cc2 Compare April 14, 2023 15:52
@@ -469,6 +470,11 @@ renderGenesisCmd cmd =
-- Shelley CLI flag/option data types
--

data ProtocolParamsSource
= ProtocolParamsFromFile !ProtocolParamsFile
| ProtocolParamsQueryNode !NetworkId !AnyConsensusModeParams
Copy link
Contributor

@Jimbo4350 Jimbo4350 Apr 14, 2023

Choose a reason for hiding this comment

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

The issue with this type is, in the situation where we want to query the node for the protocol parameters, we already have NetworkId and AnyConsensusModeParams values available to us.

@@ -323,14 +323,14 @@ runTxBuildCmd
-> TxMetadataJsonSchema
-> [ScriptFile]
-> [MetadataFile]
-> Maybe ProtocolParamsFile
-> Maybe ProtocolParamsSource
Copy link
Contributor

Choose a reason for hiding this comment

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

So I think what you want to do here is change Maybe ProtocolParamsFile to ProtocolParamsSource. In the case of Maybe ProtocolParamsFile the Nothing case corresponded to querying the node for the ProtocolParameters value.

TxInCount
TxOutCount
TxShelleyWitnessCount
TxByronWitnessCount
| TxCalculateMinRequiredUTxO
AnyCardanoEra
ProtocolParamsFile
ProtocolParamsSource
Copy link
Contributor

Choose a reason for hiding this comment

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

The problem here is TxCalculateMinRequiredUTxO is an offline cli command i.e does not necessitate having a running node in the background.

@@ -238,14 +239,14 @@ data TransactionCmd
| TxCalculateMinFee
TxBodyFile
(Maybe NetworkId)
ProtocolParamsFile
ProtocolParamsSource
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise here, this is an offline command.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can't use ProtocolParamsSource here because it's an offline command i.e you do not have to run a node to use it.

@@ -185,7 +186,7 @@ data TransactionCmd
[ScriptFile]
-- ^ Auxiliary scripts
[MetadataFile]
(Maybe ProtocolParamsFile)
(Maybe ProtocolParamsSource)
Copy link
Contributor

Choose a reason for hiding this comment

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

build-raw is also an offline cli command

Copy link
Contributor

Choose a reason for hiding this comment

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

You can't use ProtocolParamsSource here because it's an offline command i.e you do not have to run a node to use it.

@@ -361,8 +361,8 @@ runTxBuildCmd
scripts <- firstExceptT ShelleyTxCmdScriptFileError $
mapM (readFileScriptInAnyLang . unScriptFile) scriptFiles
txAuxScripts <- hoistEither $ first ShelleyTxCmdAuxScriptsValidationError $ validateTxAuxScripts cEra scripts
mpparams <- forM mProtocolParamsFile $ \ppf ->
firstExceptT ShelleyTxCmdProtocolParamsError (readProtocolParameters ppf)
mpparams <- forM mProtocolParamsSource $ \pps ->
Copy link
Contributor

Choose a reason for hiding this comment

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

This has already been deprecated and we already query the node for the ProtocolParameters: https://github.com/input-output-hk/cardano-node/blob/master/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs#L651

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. mpparams isn't used anywhere further.

@github-actions
Copy link

github-actions bot commented Jun 2, 2023

This PR is stale because it has been open 45 days with no activity.

@github-actions github-actions bot added the Stale label Jun 2, 2023
@@ -238,14 +239,14 @@ data TransactionCmd
| TxCalculateMinFee
TxBodyFile
(Maybe NetworkId)
ProtocolParamsFile
ProtocolParamsSource
Copy link
Contributor

Choose a reason for hiding this comment

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

You can't use ProtocolParamsSource here because it's an offline command i.e you do not have to run a node to use it.

@@ -185,7 +186,7 @@ data TransactionCmd
[ScriptFile]
-- ^ Auxiliary scripts
[MetadataFile]
(Maybe ProtocolParamsFile)
(Maybe ProtocolParamsSource)
Copy link
Contributor

Choose a reason for hiding this comment

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

You can't use ProtocolParamsSource here because it's an offline command i.e you do not have to run a node to use it.

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

Successfully merging this pull request may close these issues.

readProtocolParametersSourceSpec should be able to retrieve the ProtocolParameters by querying local node
3 participants