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

query protocol-parameters: use ledger JSON encoding, not API one #758

Merged
merged 2 commits into from
May 28, 2024

Conversation

smelc
Copy link
Contributor

@smelc smelc commented May 13, 2024

Changelog

- description: |
    query protocol-parameters: use ledger JSON encoding, not API one
# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
  - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  # - refactoring    # QoL changes
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

How to trust this PR

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • Self-reviewed the diff

@smelc smelc force-pushed the smelc/write-protocol-parameters-use-ledger-encoding branch from 3486a52 to 3e7aae3 Compare May 13, 2024 12:01
@smelc smelc marked this pull request as ready for review May 13, 2024 12:02
$ writeLazyByteStringOutput mOutFile' $ encodePretty $ fromLedgerPParams sbe pparams
$ writeLazyByteStringOutput mOutFile'
$ shelleyBasedEraConstraints sbe
$ encodePretty pparams
Copy link
Contributor

Choose a reason for hiding this comment

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

What about this TODO: https://github.com/IntersectMBO/cardano-cli/blob/main/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs#L506
Are we able to round-trip i.e. read the parameters into the transaction build after your change? Afair there was a testnet test for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Notes to myself:

  • On one hand, transaction build doesn't read the parameters by using the CLI's code: it requests them from the node
  • On the other hand, transaction build-raw does read parameters from the command line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@carbolymer> actually there are multiple usages of the API JSON encoding:

  1. In build-estimate: https://github.com/IntersectMBO/cardano-cli/blob/main/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs#L286
  2. In build-raw (the one you pointed out)
  3. In calculate-min-fee: https://github.com/IntersectMBO/cardano-cli/blob/main/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs#L1261
  4. In calculate-min-value: https://github.com/IntersectMBO/cardano-cli/blob/main/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs#L1342

Should we change all of them?

@gitmachtl> would you be able to test this change before we merge it? I'm afraid we are not the best ones to test this change exhaustively.

Copy link
Contributor

Choose a reason for hiding this comment

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

sure, also those are really important. let me compile the cli for testing...

Copy link
Contributor

@gitmachtl gitmachtl May 13, 2024

Choose a reason for hiding this comment

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

@smelc so first issue i see is, that cli is complaining about the missing parameter key "minUTxOValue" not found

so the parameters with null value that were sorted out are causing an issue here. cli expects at least that the key is in there.

afaik only those parameters are automatically "trimmed" out right now:

    "decentralization": null,
    "extraPraosEntropy": null,
    "minUTxOValue": null,

not sure if "decentralization" and "extraPraosEntropy" are actually ever read back for some processes? if not, only the "minUTxoValue" one is an issue. that parameter was only used pre babbage era, so would it be an option to only read that in if the used era expects it? utxoCostPerWord is also not present anymore in latest eras. but was used before, that might also be an issue during bootstrap phase to get thru the eras.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gitmachtl> is there a way I can reproduce your tests myself? So that then I can investigate how to fix the issues in autonomy.

Copy link
Contributor

@gitmachtl gitmachtl May 14, 2024

Choose a reason for hiding this comment

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

@smelc Sure, you can simply copy&paste those lines on the cli.

dummyTx='{"type":"Unwitnessed Tx ConwayEra","description":"Ledger Cddl Format","cborHex":"84a400d901028182582090ebfd31ec657d52eecf489871ecabefdce3753877aee7ee9e3200bd55fba9b800018282581d6052e63f22c5107ed776b70f7b92248b02552fd08f3e747bc745099441821a002f9d38ac581c01a7db2a2a897c4a84ca4b75b17281df80cc8607413644d21a9e020da14b73746172666f726765313002581c01c2435381c8362192bce939c002a99ce79c7bb7ba399cc55e2af07da14b73746172666f726765373901581c02f917e4ebe2f3474a713ec76e45e51f1ac72d5b053624d3ee124c12a14a73746172666f7267653201581c07e346cdcb11cff8048cf9ae2166a54c3324cf09b04c7554d6e94391a14b73746172666f726765373301581c0b6f1f1220140053fe1a9e44f4d77c12a5909f599970cd9b65e638e6a14b73746172666f726765343301581c0f28da1e6892acb5973ec68aab4e4718fec8761673e9d725343d97a9a14b73746172666f726765393701581c10ccfab9710c68068f3cd2bc86a96420c97b6d363a68b9232097b86aa14b73746172666f726765383801581c11b6c9e65d8e1e1bd51743a8599bfc8d70e1b1ccebb8902e32538c55a14b73746172666f726765313201581c12df514d7cd52225e39a7fe27ee0652dd2f1bfab05139deadda2a7caa14b73746172666f726765383901581c14deabc3a38365004e31a8a865a425e187fe4776e84c626c2c822344a148373536376130363301581cb2e796da6ef0fc4b427ca94f400691f22c949ed09ddd61592611e015a14b73746172666f726765343201581ce6911f8b6bae62fc20b96e55131bbf189334baab80d07f2964ca3b6da14a73746172666f726765300382581d6052e63f22c5107ed776b70f7b92248b02552fd08f3e747bc7450994411b000000058503a08a021a00030d40031a01ba9424a0f5f6"}'

protocolParametersJSON=$(cardano-cli conway query protocol-parameters)

cardano-cli conway transaction calculate-min-fee --tx-body-file <(echo ${dummyTx}) --protocol-params-file <(echo ${protocolParametersJSON}) --witness-count 1 --reference-script-size 0

Error: "Error in $: key \"extraPraosEntropy\" not found"

So the cli complains about the missing extrapraosEntropy parameter. To simulate the presence of the extraPraosEntropy we can do:

protocolParametersJSON=$(./cardano-cli conway query protocol-parameters | jq -r ". += {\"extraPraosEntropy\": null}")

cardano-cli conway transaction calculate-min-fee --tx-body-file <(echo ${dummyTx}) --protocol-params-file <(echo ${protocolParametersJSON}) --witness-count 1 --reference-script-size 0

Error: "Error in $: key \"minUTxOValue\" not found"

Now its complaining about the missing minUTxOVallue

If we also add this with the null value again, the fee calculation works:

protocolParametersJSON=$(./cardano-cli conway query protocol-parameters | jq -r ". += {\"extraPraosEntropy\": null, \"minUTxOValue\": null}")

cardano-cli conway transaction calculate-min-fee --tx-body-file <(echo ${dummyTx}) --protocol-params-file <(echo ${protocolParametersJSON}) --witness-count 1 --reference-script-size 0

189173 Lovelace

Same errors are for the calculate-min-required-utxo function.

Copy link
Contributor

Choose a reason for hiding this comment

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

@smelc yes, we should only use one encoding, so in this case ledger's.

@smelc
Copy link
Contributor Author

smelc commented May 15, 2024

Work happening at https://github.com/IntersectMBO/cardano-cli/commits/smelc/8.22.0.0-backport-write-protocol-parameters-use-ledger-encoding/

I will bring the commits to this PR when I'm done. I need to work on 8.22.0.0 to more easily test that with cardano-node master.

@carbolymer
Copy link
Contributor

carbolymer commented May 16, 2024

@smelc check afterwards with @mkoura if it's not breaking cardano-node-tests too.

@smelc smelc changed the base branch from main to smelc/remove-UnwitnessedCliFormattedTxBody-constructor-v2 May 16, 2024 15:45
@smelc smelc force-pushed the smelc/write-protocol-parameters-use-ledger-encoding branch from d073319 to f54073c Compare May 16, 2024 15:45
Base automatically changed from smelc/remove-UnwitnessedCliFormattedTxBody-constructor-v2 to main May 17, 2024 06:55
@smelc smelc force-pushed the smelc/write-protocol-parameters-use-ledger-encoding branch 2 times, most recently from 3931011 to 1bad372 Compare May 17, 2024 09:42
@smelc
Copy link
Contributor Author

smelc commented May 17, 2024

@gitmachtl> can you give this PR a new round of testing?

@gitmachtl
Copy link
Contributor

@gitmachtl> can you give this PR a new round of testing?

@smelc yea, will do it over the weekend, thx.

@smelc smelc force-pushed the smelc/write-protocol-parameters-use-ledger-encoding branch from 1bad372 to c9a7471 Compare May 17, 2024 12:40
@smelc smelc marked this pull request as ready for review May 17, 2024 14:10
@gitmachtl
Copy link
Contributor

gitmachtl commented May 19, 2024

@gitmachtl> can you give this PR a new round of testing?

@smelc looking good. did test the min-fee calculation, min-utxo calculation, made transactions via build-raw and ran the new build-estimate command with the new protocol-parameter version. 👍 but i only tested in conway era. have to redo it also in babbage era.

@gitmachtl
Copy link
Contributor

@smelc ok, babbage era also looks good 👍

@smelc
Copy link
Contributor Author

smelc commented May 21, 2024

Thanks @gitmachtl for the feedback 🙏

@smelc smelc force-pushed the smelc/write-protocol-parameters-use-ledger-encoding branch from c9a7471 to f71d11b Compare May 21, 2024 09:12
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

LGTM! Feel free to merge as long as @gitmachtl is happy.

@smelc smelc force-pushed the smelc/write-protocol-parameters-use-ledger-encoding branch from f71d11b to 87134c3 Compare May 28, 2024 11:19
@gitmachtl
Copy link
Contributor

LGTM! Feel free to merge as long as @gitmachtl is happy.

@Jimbo4350 i am happy 😄

@smelc smelc enabled auto-merge May 28, 2024 12:21
@smelc smelc disabled auto-merge May 28, 2024 12:21
@smelc smelc merged commit b08f10c into main May 28, 2024
14 of 15 checks passed
@smelc smelc deleted the smelc/write-protocol-parameters-use-ledger-encoding branch May 28, 2024 12:21
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.

query protocol-parameters does not show params introduced in Conway
4 participants