-
Notifications
You must be signed in to change notification settings - Fork 16
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
query protocol-parameters: use ledger JSON encoding, not API one #758
Conversation
3486a52
to
3e7aae3
Compare
$ writeLazyByteStringOutput mOutFile' $ encodePretty $ fromLedgerPParams sbe pparams | ||
$ writeLazyByteStringOutput mOutFile' | ||
$ shelleyBasedEraConstraints sbe | ||
$ encodePretty pparams |
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 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.
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.
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.
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.
@carbolymer> actually there are multiple usages of the API JSON encoding:
- In
build-estimate
: https://github.com/IntersectMBO/cardano-cli/blob/main/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs#L286 - In
build-raw
(the one you pointed out) - In
calculate-min-fee
: https://github.com/IntersectMBO/cardano-cli/blob/main/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs#L1261 - 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.
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.
sure, also those are really important. let me compile the cli for testing...
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.
@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.
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.
@gitmachtl> is there a way I can reproduce your tests myself? So that then I can investigate how to fix the issues in autonomy.
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.
@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.
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.
@smelc yes, we should only use one encoding, so in this case ledger's.
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 |
@smelc check afterwards with @mkoura if it's not breaking cardano-node-tests too. |
d073319
to
f54073c
Compare
3931011
to
1bad372
Compare
@gitmachtl> can you give this PR a new round of testing? |
@smelc yea, will do it over the weekend, thx. |
1bad372
to
c9a7471
Compare
@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. |
@smelc ok, babbage era also looks good 👍 |
Thanks @gitmachtl for the feedback 🙏 |
c9a7471
to
f71d11b
Compare
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.
LGTM! Feel free to merge as long as @gitmachtl is happy.
f71d11b
to
87134c3
Compare
@Jimbo4350 i am happy 😄 |
Changelog
Context
How to trust this PR
cardano-node
's tests ran on this PR: Test of cardano-cli/pull/758 - CI only cardano-node#5839cardano-node
's PR: https://github.com/IntersectMBO/cardano-node/pull/5839/filesChecklist