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

Implement transaction balancing (prototype) #19

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

Conversation

ajuggler
Copy link
Contributor

Objective: implement transaction balancing algorithm.

@ajuggler ajuggler self-assigned this Aug 30, 2024
@ajuggler ajuggler linked an issue Aug 30, 2024 that may be closed by this pull request
@ajuggler
Copy link
Contributor Author

ajuggler commented Aug 30, 2024

The purpose of last commit is to clarify/exemplify the requirements of task Implement transaction balancing algorithm. Also, we want clarify whether cardano-cli's command calculate-min-required-utxo already implements what we need.

With modifications in last commit, automatic balancing depending on inputs is already achieved in the context of the plonk verifier example. Besides the transaction to be balanced, the inputs are as follows:

  • In '01-init-transaction.sh', relevant inputs are serialized scripts plonkVerifier.plutus and forwardingMint.plutus.
  • In '02-transfer-transaction.sh', relevant input is datum datumPlonk.cbor.
  • In '03-minting-transaction.sh', relevant input are policyid + tokenname for plonkVerifier and verification input, respectively, and proof.

I guess that, for tokenname, we would want to use a generic example so as to avoid computation of input.

@ajuggler
Copy link
Contributor Author

Shell script compute-min-fee estimates the minFee for executing symbolicVerifer on a given set of data inputs (txInfoInputs, txInfoReferenceInputs, txInfoOutputs and txInfoValidRange) recorded in file inputs.json. Estimation is based on linear model constructed with aid of plutus scripts pubInput and symbolicVerifierBench1 (file PubInput.hs).

@ajuggler
Copy link
Contributor Author

Relevant directory is /benchs/bench-emptycircuit, which contains a README summarizing the test so far.

@ajuggler
Copy link
Contributor Author

Note that tautologyVerificationBytes was defined with "emptyCircuit":

mempty {acOutput = V.empty} :: ArithmeticCircuit Fr (Vector 1) (Vector 0)

@ajuggler
Copy link
Contributor Author

To test tautologyVerificationBytes, simply execute

cabal run bench-emptycircuit

(Active directory is irrelevant.)

@ajuggler
Copy link
Contributor Author

ajuggler commented Nov 19, 2024

Follow instructions in README.

Terminal output:

antonio:e2e-test$ ./symbolic-balancing/02-balancing-parse-input.sh 
Input UTxO from Alice:

Right [TxInInfo {txInInfoOutRef = TxOutRef {txOutRefId = 3070244ef4b70034b0813b0b2f07efe1b67f50c2dc0be21d5051ff23e24c47e1, txOutRefIdx = 1}, txInInfoResolved = TxOut {txOutAddress = Address {addressCredential = PubKeyCredential 1f82ba7c394aeb23bf09ad26d85c2c4d3f808e98f4bcfffa198f7e68, addressStakingCredential = Nothing}, txOutValue = Value {getValue = Map {unMap = [(,Map {unMap = [("",975033708)]})]}}, txOutDatum = NoOutputDatum, txOutReferenceScript = Nothing}}]

Input UTxO from SymbolicVerifier:

Right [TxInInfo {txInInfoOutRef = TxOutRef {txOutRefId = 3070244ef4b70034b0813b0b2f07efe1b67f50c2dc0be21d5051ff23e24c47e1, txOutRefIdx = 0}, txInInfoResolved = TxOut {txOutAddress = Address {addressCredential = ScriptCredential bd14d681443a1edf890c296c488c35c8ef25de5cd85e3f3add385e82, addressStakingCredential = Nothing}, txOutValue = Value {getValue = Map {unMap = [(,Map {unMap = [("",10000000)]})]}}, txOutDatum = OutputDatum (Datum {getDatum = Constr 0 []}), txOutReferenceScript = Nothing}}]

Data:

List [Constr 0 [Constr 0 [B "0p$N\244\183\NUL4\176\129;\v/\a\239\225\182\DELP\194\220\v\226\GSPQ\255#\226LG\225",I 1],Constr 0 [Constr 0 [Constr 0 [B "\US\130\186|9J\235#\191\t\173&\216\\,M?\128\142\152\244\188\255\250\EM\143~h"],Constr 1 []],Map [(B "",Map [(B "",I 975033708)])],Constr 0 [],Constr 1 []]],Constr 0 [Constr 0 [B "0p$N\244\183\NUL4\176\129;\v/\a\239\225\182\DELP\194\220\v\226\GSPQ\255#\226LG\225",I 0],Constr 0 [Constr 0 [Constr 1 [B "\189\DC4\214\129D:\RS\223\137\f)lH\140\&5\200\239%\222\\\216^?:\221\&8^\130"],Constr 1 []],Map [(B "",Map [(B "",I 10000000)])],Constr 2 [Constr 0 []],Constr 1 []]]]

Serialised data:

"\159\216y\159\216y\159X 0p$N\244\183\NUL4\176\129;\v/\a\239\225\182\DELP\194\220\v\226\GSPQ\255#\226LG\225\SOH\255\216y\159\216y\159\216y\159X\FS\US\130\186|9J\235#\191\t\173&\216\\,M?\128\142\152\244\188\255\250\EM\143~h\255\216z\128\255\161@\161@\SUB:\GS\213l\216y\128\216z\128\255\255\216y\159\216y\159X 0p$N\244\183\NUL4\176\129;\v/\a\239\225\182\DELP\194\220\v\226\GSPQ\255#\226LG\225\NUL\255\216y\159\216y\159\216z\159X\FS\189\DC4\214\129D:\RS\223\137\f)lH\140\&5\200\239%\222\\\216^?:\221\&8^\130\255\216z\128\255\161@\161@\SUB\NUL\152\150\128\216{\159\216y\128\255\216z\128\255\255\255"

Verifier's input: F 21353937139332672587613110998586736437186355074714830484134924746314

Generating proof...

Retrieving funds from Symbolic [exec units]...

Estimated transaction fee: Coin 653377

@ajuggler
Copy link
Contributor Author

ajuggler commented Dec 4, 2024

Balancing prototype, with validator untypedPlonkVerifierTx', now works as expected. To test code, follow instructions in README.

@ajuggler ajuggler changed the title Implement transaction balancing Implement transaction balancing (prototype) Dec 4, 2024
@ajuggler ajuggler linked an issue Dec 4, 2024 that may be closed by this pull request
@ajuggler ajuggler marked this pull request as ready for review December 4, 2024 14:48
@ajuggler ajuggler requested a review from vlasin December 4, 2024 14:48
@vlasin vlasin requested a review from zlonast December 5, 2024 06:11
@zlonast zlonast self-requested a review December 12, 2024 07:55
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.

Transaction balancing algorithm prototype
3 participants