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

Build legacy multisig transaction programatically #583

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

LGLO
Copy link
Contributor

@LGLO LGLO commented Mar 18, 2025

Pros:

  • it would be easier to keep this test if genesis utxo changes

Cons:

  • costs many lines of code and still requires updating genesis utxo buried in applied scripts

@LGLO LGLO marked this pull request as ready for review March 20, 2025 05:36
@AmbientTea
Copy link
Contributor

still requires updating genesis utxo buried in applied scripts

can't we also programmatically apply the utxo?

@LGLO
Copy link
Contributor Author

LGLO commented Mar 20, 2025

still requires updating genesis utxo buried in applied scripts

can't we also programmatically apply the utxo?

We could by copy-pasting some code from csl module here or by making some pub(crate) functions/structs pub. WDYT?

@kpinter-iohk
Copy link
Contributor

kpinter-iohk commented Mar 20, 2025

csl (and plutus_scripts for that matter) should be in their own crate (crates?) as they have useful things. I'm pretty sure it happened more than once that I wanted to use something from them and ended up having to copy-paste it. If you look at those modules they are pretty generic and would even make sense outside of PC (they do reference PC in comments or one error message but nothing relevant).


let mut witness_set = TransactionWitnessSet::new();
let mut plutus_scripts = PlutusScripts::new();
let applied_version_oracle_script = hex!("590cbf0100003332323233223232323232323233223232323232323232323233223232323232323232232323232322225335323232323233353232325333573466e1d200000213322122233002005004375a6ae84004dd71aba1357440022a666ae68cdc3a40040042664424446600200a0086eb4d5d08009bae357426ae8800454ccd5cd19b87480100084c84888c00c010dd69aba1001130314901035054310035573c0046aae74004dd50039191919299a998082481174552524f522d56455253494f4e2d504f4c4943592d3037003303422533500110332213235003223500122225333500210072153500522350172233532335005233500425333573466e3c0080045400c40b880b88cd401080b894ccd5cd19b8f00200115003102e153350032153350022133500223350022335002233500223303000200120312335002203123303000200122203122233500420312225333573466e1c01800c54ccd5cd19b8700500213302c00400110331033102c153350012102c102c133044225335001100e22132533500321350012253353302c00201c153353302c333027010502048810e56657273696f6e206f7261636c6500480084cd41200d0010401040104004c010004c8cd4104004108c094014403084020c010004c080c07cc04cdd619801180091000a40002a66a660229201174552524f522d56455253494f4e2d504f4c4943592d3038005335330342253350011033221325333573466e24ccc050c078cc01cd4c0c800c880052002500d4890e56657273696f6e206f7261636c65004800040044cd40d40e0004c010004c0a4c04cdd619801180091000a4008203844203a266022921174552524f522d56455253494f4e2d504f4c4943592d3039003300e500800a101b101b5302c002502a50042232533533010491174552524f522d56455253494f4e2d504f4c4943592d303100300c302a302930123758660026a6058660026a605801244002900011000a40002a66a6601e9201174552524f522d56455253494f4e2d504f4c4943592d30320033005003002133010491174552524f522d56455253494f4e2d504f4c4943592d3033005004101a101a502a2253353300e491174552524f522d56455253494f4e2d504f4c4943592d30340033004002001153353300f491174552524f522d56455253494f4e2d504f4c4943592d3035003300c500600813300f4901174552524f522d56455253494f4e2d504f4c4943592d30360050031019101913300f33300a30143233502835302900122001480214009400d2210e56657273696f6e206f7261636c65004800888cc0c0894cd400440bc884c8d400c88894ccd40084014854cd4008854d401888d404888cd4c8cd40148cd401094ccd5cd19b8f00200115003102920292335004202925333573466e3c0080045400c40a454cd400c854cd400884cd40088cd40088cd40088cd40088cc0ac00800480b08cd400880b08cc0ac0080048880b0888cd401080b08894ccd5cd19b8700600315333573466e1c0140084cc09c01000440b840b8409c54cd40048409c409c4cc0fc894cd40044034884c94cd400c84d4004894cd4cc09c00806454cd4cc0b403406054cd4cc09cccc088045406d2210e56657273696f6e206f7261636c6500480084cd410c0bc0104010401040104004c010004c8cd40f00040f4c080018402c401884018c010004c068c8c068c040dd619a8149a981500091000a4008a006266a04a6a604c0064400290000a99aa99a9a981299a8121a981280111000a400444a66a0022a042442a66a0022a666ae68cdc3a4000008260480042a046442a04a4260426eb80045407c840044c0a92401164552524f522d4f5241434c452d504f4c4943592d313000301a003102a1302949010350543500302722533500110102215333573466ebc024008404c4c01000488c8c8c94cd4c94cd4c8cc0b4894cd400454088884d4008894ccd5cd19b8f002007130270011300600300253353302c225335001102b2213235003223500122225333500210072153350022133039225335001100b2213253350032135001225335330210024810054ccd5cd19b8748008ccc07003406d2210e56657273696f6e206f7261636c6500133503d009004100410041001300400132335036001037301a0021008210083004001300e3232323302f225335001100322133502f00230040010023012300d37586600c6004440029000180818061bac33005300122001480094c094cc010cc098800400920001302a491194552524f522d56455253494f4e2d43555252454e43592d30310022153350011002221302e491194552524f522d56455253494f4e2d43555252454e43592d3031002130210011501f3233301e75ca03a002660066a6048660066604a4002002900011000a401042a66a00220264426a00444a66a0062666ae68cdc4800a400002e03044203220246aae78004dd50012810111191981491299a8008a40004426a00444a666ae68cdc78010048980380089803001802181411299a8008a40004426a00444a666ae68cdc780100388008980300191299a80089812001110a99a8008801110981400311299a8008806899ab9c00200c30212233335573e0024042466a0406ae84008c00cd5d100124c44666ae68cdc380100080500491999999aba4001250142501423232333002375800800244a6646aa66a6666660020064400c400a400a46036002400a42603600220084266600c00600a44a66a666666008004440124010401040104603c00242666012004603c246600200a00444014200e4444446666666ae900188c8cc01cd55ce8009aab9e001375400e4600a6eac01c8c010dd6003918019bad00723002375c00e0542006a02a4446666aae7c00c800c8cc008d5d08021aba2004023250142501401f301e225335001101d22133501e300f0023004001301d225335001101c22133501d0023004001301c225335001101b22133501c0023004001233300e75ca01a00244666ae68cdc7801000802001891001091000980b91299a800880b11099a80b8011802000980b11299a800880a91099a80b18040011802000980a91299a800880a11099a80a8011802000980a11299a800880991099a80a1802801180200091919192999ab9a3370e90000010999109198008018011919192999ab9a3370e90000010999109198008018011919192999ab9a3370e900000109bae35742002260369201035054310035573c0046aae74004dd51aba1001375a6ae84d5d10008980c2481035054310035573c0046aae74004dd51aba10013005357426ae880044c055241035054310035573c0046aae74004dd500091919192999ab9a3370e9000001099191999911109199980080280200180118039aba100333300a75ca0126ae84008c8c8c94ccd5cd19b87480000084488800c54ccd5cd19b87480080084c84888c004010dd71aba100115333573466e1d20040021321222300200435742002260329201035054310035573c0046aae74004dd51aba10013300875c6ae84d5d10009aba200135744002260289201035054310035573c0046aae74004dd500091919192999ab9a3370e90000010991991091980080180118009aba10023300623232325333573466e1d200000213212230020033005357420022a666ae68cdc3a400400426466644424466600200a0080066eb4d5d08011bad357420026eb4d5d09aba200135744002260309201035054310035573c0046aae74004dd50009aba1357440044646464a666ae68cdc3a400000426424460040066eb8d5d08008a999ab9a3370e900100109909118008019bae357420022602e921035054310035573c0046aae74004dd500089809a49035054310035573c0046aae74004dd5000911919192999ab9a3370e90010010a8040a999ab9a3370e90000010980498029aba1001130134901035054310035573c0046aae74004dd5000899800bae75a4464460046eac004c04088cccd55cf800900811919a8081980798031aab9d001300535573c00260086ae8800cd5d0801008909118010018891000980591299a800880511099a8058011802000980511299a800880491099a8050011802000980491299a800880411099a80499a8029a980300111000a4000600800226444a666ae68cdc4000a4000260129210350543600133003001002300822253350011300949103505437002215333573466e1d20000041002133005337020089001000919198021aab9d0013233004200100135573c0026ea80048c88c008004c01c88cccd55cf8009003919a80318021aba10023003357440049311091980080180109100109109119800802001919319ab9c001002120012323001001223300330020020014c012bd8799fd8799f5820f8fbe7316561e57de9ecd1c86ee8f8b512a314ba86499ba9a584bfa8fe2edc8dff00ff004c0129d8799fd87a9f581c7eccc25232d07fdc848d7b653465fc6c23a32d8dfb266181ecd26f0fffd87a80ff0001");
Copy link
Contributor

Choose a reason for hiding this comment

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

Any thoughts on putting blobs like that in external files and including them via include_str or include_bytes (depending on how the content is stored in the file obviously) ?

Not a major concern but something like the following seems appealing:

let applied_version_oracle_script = !include_bytes("./applied_version_oracle_script.bin")
plutus_scripts.add(&PlutusScript::new_v2(applied_version_oracle_script.to_vec()));

Maybe I'm ignoring some downsides though? WDYT?

Copy link
Contributor Author

@LGLO LGLO Mar 20, 2025

Choose a reason for hiding this comment

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

There is a question if we want to use applied script or we prefer to apply parameters to the base script in a programatic manner. In the latter case we can import it use raw_scripts::VERSION_ORACLE_POLICY

I think it it worth trying to include it from some other file.

@@ -210,15 +216,75 @@ async fn update_legacy_governance() {
let client = Cli::default();
let container = client.run(image);
let client = initialize(&container).await;
let legacy_init_governance_tx = hex!("84a900d9010281825820f8fbe7316561e57de9ecd1c86ee8f8b512a314ba86499ba9a584bfa8fe2edc8d000182a400581d707eccc25232d07fdc848d7b653465fc6c23a32d8dfb266181ecd26f0f01821a0032a3aca1581cab81fe48f392989bd215f9fdc25ece3335a248696b2a64abc1acb595a14e56657273696f6e206f7261636c6501028201d81858229f1820581cab81fe48f392989bd215f9fdc25ece3335a248696b2a64abc1acb595ff03d8185901db82025901d65901d30100003323322323232323322323232222323232532323355333573466e20cc8c8c88c008004c058894cd4004400c884cc018008c010004c04488004c04088008c01000400840304034403c4c02d24010350543500300d37586ae84008dd69aba1357440026eb0014c040894cd400440448c884c8cd40514cd4c00cc04cc030dd6198009a9803998009a980380411000a40004400290080a400429000180300119112999ab9a33710002900009807a490350543600133003001002301522253350011300f49103505437002215333573466e1d20000041002133005337020089001000980991299a8008806910a999ab9a3371e00a6eb800840404c0100048c8cc8848cc00400c008d55ce80098031aab9e00137540026016446666aae7c00480348cd4030d5d080118019aba2002498c02888cccd55cf8009006119a8059aba100230033574400493119319ab9c00100512200212200130062233335573e0024010466a00e6eb8d5d080118019aba20020031200123300122337000040029000180191299a800880211099a802801180200089100109109119800802001919180080091198019801001000a61239f9f581ce8c300330fe315531ca89d4a2e7d0c80211bc70b473b1ed4979dff2bff01ff000182581d60e8c300330fe315531ca89d4a2e7d0c80211bc70b473b1ed4979dff2b1a3b61e903021a00063d5109a1581cab81fe48f392989bd215f9fdc25ece3335a248696b2a64abc1acb595a14e56657273696f6e206f7261636c65010b5820bb4035b9ede213192640b6e68ddea7d6c42ad664a9b4d1fbff04b52193cec1ae0dd9010281825820f8fbe7316561e57de9ecd1c86ee8f8b512a314ba86499ba9a584bfa8fe2edc8d040ed9010281581ce8c300330fe315531ca89d4a2e7d0c80211bc70b473b1ed4979dff2b1082581d60e8c300330fe315531ca89d4a2e7d0c80211bc70b473b1ed4979dff2b1b006a8e81df3a2cc6111a00095bfaa300d9010281825820fc014cb5f071f5d6a36cb5a7e5f168c86555989445a23d4abec33d280f71aca4584089d9dfaddfa820868d23f27a8344c711507b95c117c76862a191c2484ba364814db7cc196f2b98de4f40ac6069effa115c2d4f9781744ef3cc4f141e82c3e40c06d9010281590cc2590cbf0100003332323233223232323232323233223232323232323232323233223232323232323232232323232322225335323232323233353232325333573466e1d200000213322122233002005004375a6ae84004dd71aba1357440022a666ae68cdc3a40040042664424446600200a0086eb4d5d08009bae357426ae8800454ccd5cd19b87480100084c84888c00c010dd69aba1001130314901035054310035573c0046aae74004dd50039191919299a998082481174552524f522d56455253494f4e2d504f4c4943592d3037003303422533500110332213235003223500122225333500210072153500522350172233532335005233500425333573466e3c0080045400c40b880b88cd401080b894ccd5cd19b8f00200115003102e153350032153350022133500223350022335002233500223303000200120312335002203123303000200122203122233500420312225333573466e1c01800c54ccd5cd19b8700500213302c00400110331033102c153350012102c102c133044225335001100e22132533500321350012253353302c00201c153353302c333027010502048810e56657273696f6e206f7261636c6500480084cd41200d0010401040104004c010004c8cd4104004108c094014403084020c010004c080c07cc04cdd619801180091000a40002a66a660229201174552524f522d56455253494f4e2d504f4c4943592d3038005335330342253350011033221325333573466e24ccc050c078cc01cd4c0c800c880052002500d4890e56657273696f6e206f7261636c65004800040044cd40d40e0004c010004c0a4c04cdd619801180091000a4008203844203a266022921174552524f522d56455253494f4e2d504f4c4943592d3039003300e500800a101b101b5302c002502a50042232533533010491174552524f522d56455253494f4e2d504f4c4943592d303100300c302a302930123758660026a6058660026a605801244002900011000a40002a66a6601e9201174552524f522d56455253494f4e2d504f4c4943592d30320033005003002133010491174552524f522d56455253494f4e2d504f4c4943592d3033005004101a101a502a2253353300e491174552524f522d56455253494f4e2d504f4c4943592d30340033004002001153353300f491174552524f522d56455253494f4e2d504f4c4943592d3035003300c500600813300f4901174552524f522d56455253494f4e2d504f4c4943592d30360050031019101913300f33300a30143233502835302900122001480214009400d2210e56657273696f6e206f7261636c65004800888cc0c0894cd400440bc884c8d400c88894ccd40084014854cd4008854d401888d404888cd4c8cd40148cd401094ccd5cd19b8f00200115003102920292335004202925333573466e3c0080045400c40a454cd400c854cd400884cd40088cd40088cd40088cd40088cc0ac00800480b08cd400880b08cc0ac0080048880b0888cd401080b08894ccd5cd19b8700600315333573466e1c0140084cc09c01000440b840b8409c54cd40048409c409c4cc0fc894cd40044034884c94cd400c84d4004894cd4cc09c00806454cd4cc0b403406054cd4cc09cccc088045406d2210e56657273696f6e206f7261636c6500480084cd410c0bc0104010401040104004c010004c8cd40f00040f4c080018402c401884018c010004c068c8c068c040dd619a8149a981500091000a4008a006266a04a6a604c0064400290000a99aa99a9a981299a8121a981280111000a400444a66a0022a042442a66a0022a666ae68cdc3a4000008260480042a046442a04a4260426eb80045407c840044c0a92401164552524f522d4f5241434c452d504f4c4943592d313000301a003102a1302949010350543500302722533500110102215333573466ebc024008404c4c01000488c8c8c94cd4c94cd4c8cc0b4894cd400454088884d4008894ccd5cd19b8f002007130270011300600300253353302c225335001102b2213235003223500122225333500210072153350022133039225335001100b2213253350032135001225335330210024810054ccd5cd19b8748008ccc07003406d2210e56657273696f6e206f7261636c6500133503d009004100410041001300400132335036001037301a0021008210083004001300e3232323302f225335001100322133502f00230040010023012300d37586600c6004440029000180818061bac33005300122001480094c094cc010cc098800400920001302a491194552524f522d56455253494f4e2d43555252454e43592d30310022153350011002221302e491194552524f522d56455253494f4e2d43555252454e43592d3031002130210011501f3233301e75ca03a002660066a6048660066604a4002002900011000a401042a66a00220264426a00444a66a0062666ae68cdc4800a400002e03044203220246aae78004dd50012810111191981491299a8008a40004426a00444a666ae68cdc78010048980380089803001802181411299a8008a40004426a00444a666ae68cdc780100388008980300191299a80089812001110a99a8008801110981400311299a8008806899ab9c00200c30212233335573e0024042466a0406ae84008c00cd5d100124c44666ae68cdc380100080500491999999aba4001250142501423232333002375800800244a6646aa66a6666660020064400c400a400a46036002400a42603600220084266600c00600a44a66a666666008004440124010401040104603c00242666012004603c246600200a00444014200e4444446666666ae900188c8cc01cd55ce8009aab9e001375400e4600a6eac01c8c010dd6003918019bad00723002375c00e0542006a02a4446666aae7c00c800c8cc008d5d08021aba2004023250142501401f301e225335001101d22133501e300f0023004001301d225335001101c22133501d0023004001301c225335001101b22133501c0023004001233300e75ca01a00244666ae68cdc7801000802001891001091000980b91299a800880b11099a80b8011802000980b11299a800880a91099a80b18040011802000980a91299a800880a11099a80a8011802000980a11299a800880991099a80a1802801180200091919192999ab9a3370e90000010999109198008018011919192999ab9a3370e90000010999109198008018011919192999ab9a3370e900000109bae35742002260369201035054310035573c0046aae74004dd51aba1001375a6ae84d5d10008980c2481035054310035573c0046aae74004dd51aba10013005357426ae880044c055241035054310035573c0046aae74004dd500091919192999ab9a3370e9000001099191999911109199980080280200180118039aba100333300a75ca0126ae84008c8c8c94ccd5cd19b87480000084488800c54ccd5cd19b87480080084c84888c004010dd71aba100115333573466e1d20040021321222300200435742002260329201035054310035573c0046aae74004dd51aba10013300875c6ae84d5d10009aba200135744002260289201035054310035573c0046aae74004dd500091919192999ab9a3370e90000010991991091980080180118009aba10023300623232325333573466e1d200000213212230020033005357420022a666ae68cdc3a400400426466644424466600200a0080066eb4d5d08011bad357420026eb4d5d09aba200135744002260309201035054310035573c0046aae74004dd50009aba1357440044646464a666ae68cdc3a400000426424460040066eb8d5d08008a999ab9a3370e900100109909118008019bae357420022602e921035054310035573c0046aae74004dd500089809a49035054310035573c0046aae74004dd5000911919192999ab9a3370e90010010a8040a999ab9a3370e90000010980498029aba1001130134901035054310035573c0046aae74004dd5000899800bae75a4464460046eac004c04088cccd55cf800900811919a8081980798031aab9d001300535573c00260086ae8800cd5d0801008909118010018891000980591299a800880511099a8058011802000980511299a800880491099a8050011802000980491299a800880411099a80499a8029a980300111000a4000600800226444a666ae68cdc4000a4000260129210350543600133003001002300822253350011300949103505437002215333573466e1d20000041002133005337020089001000919198021aab9d0013233004200100135573c0026ea80048c88c008004c01c88cccd55cf8009003919a80318021aba10023003357440049311091980080180109100109109119800802001919319ab9c001002120012323001001223300330020020014c012bd8799fd8799f5820f8fbe7316561e57de9ecd1c86ee8f8b512a314ba86499ba9a584bfa8fe2edc8dff00ff004c0129d8799fd87a9f581c7eccc25232d07fdc848d7b653465fc6c23a32d8dfb266181ecd26f0fffd87a80ff000105a182010082d8799f1820581c08b95138e16a062fa8d623a2b1beebd59c06210f3d33690580733e73ff821a000c0cfa1a0db12739f5f6");

let genesis_utxo =
Copy link
Contributor

Choose a reason for hiding this comment

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

There is quite a lot going on in this test - I wonder if it would be feasible to maybe extract some pieces and get a bit closer to the common structure of setup / "action" / assertion?

let something = setup_something();
let whatever = build_whatever();

let result = run_upsert_d_param(...)

assert!(result, ...)

Might help to make it clearer what is being asserted? WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course, but this is polishing. The main question for this draft was if it is worth to build this programatically.

@LGLO
Copy link
Contributor Author

LGLO commented Mar 20, 2025

csl (and plutus_scripts for that matter) should be in their own crate (crates?) as they have useful things. I'm pretty sure it happened more than once that I wanted to use something from them and ended up having to copy-paste it. If you look at those modules they are pretty generic and would even make sense outside of PC (they do reference PC in comments or one error message but nothing relevant).

I don't think so. We take only offchain code needs into account there and we also take advantage of having things there usually pub(crate).
Especially csl is a set of offchain needs regarding mostly CSL and also our Ogmios implementation. I don't think we are in business of providing (and if we are, we lack workforce) general purpose improvements to CSL.

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.

5 participants