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

AbortTx inlcuding some plutus validation #90

Merged
merged 39 commits into from
Oct 14, 2021

Conversation

ch1bo
Copy link
Collaborator

@ch1bo ch1bo commented Sep 22, 2021

No description provided.

@ch1bo
Copy link
Collaborator Author

ch1bo commented Sep 22, 2021

Obviously fails on error "where is this coming from?" and this is where this work stream ought to continue

@abailly-iohk abailly-iohk force-pushed the ch1bo/aborttx-plutus-validation branch 2 times, most recently from 1697621 to 2c0f2dd Compare September 23, 2021 15:58
@ch1bo ch1bo force-pushed the master branch 4 times, most recently from 942d809 to a37319c Compare September 24, 2021 21:19
ch1bo and others added 23 commits October 12, 2021 14:25
This is not covering creation of the 'TxInfo' / 'ScriptContext' so will
never work for non-trivial validators
Of course the init tx would not validate using the Initial validator,
rather commit or abort txs should be checked against that
The abortTx would try to spend an input which is governed by the initial
validator.
Seems that the Plutus ValidatorHash contains a different hash than
produced by `hashScript` of the ledger. Or the serialization of
`initialScript` is wrong. Work around to see if it runs.
This avoids use of 'ValidatorHash' et al and uses only 'Script' to
serialize it into a ledger 'Script era' and take it from there.
To build correct transactions for the on-chain protocol we need to
construct or provide datumhashes with the correct datums, but these
datums are only available from previous transactions' data so we must
keep state while observing the chain.
This commit only adds the needed machinery but tests aren't passing
and state is not really used yet.
This is needed in order to provide a seed TxIn to the Init
transaction and of course to be able to sign transactions later on.
Because it does not have any combination we always observe it which
does not make sense right now.
TODO: Add JSON instances for the log messages
Unit test for AbortTx is currently failing because the script raises
an error which is not easily traced. Need to see if I can get more
info by executing the script directly in Plutus.
Constructing the state machine requires a token which is more
complicated to build.
The redeemers are indexed to the input they apply to, assuming the
inputs are sorted by (TxId, TxIx), so we cannot naively use a counter
to build those. The rdptr function retrieves the correct index for the
pointer.
For some unknown reason this makes unit test pass even though the validator actually
does nothing but returns True
There is a bug in the way we observe transaction hence it's possible
to observe both an inittx and an  abortx given the same
ValidatedTx.
abailly-iohk and others added 12 commits October 12, 2021 14:26
This is not satisfactory but is a stop-gap solution while we take
some time to think again about what are the right criteria to
distinguish all transaction types from each other.
Still one test of aborttx failing due to failing validator
Following upgrade, castPoint does not work anymore so I ended up
manually unwrapping the hash representations to get what I needed.
The Plutus documentation is actually wrong, serialising scripts and
datums for consumption by cardano-cli requires specific conversion
functions and not only the generic `serialiseToTextEnvelope` one
After upgrading to more recent Plutus version, validatorHash is in
sync with hashScript from the ledger API so we can use it directly to
compute dependencies.
@abailly-iohk abailly-iohk force-pushed the ch1bo/aborttx-plutus-validation branch from 6971aff to 7ff91c0 Compare October 13, 2021 05:28
Upgrade to GHC 8.10.7 and newer haskell.nix
Some tests are still failing
* Replace the use of externally supplied cardano-node and cardano-cli
  executables by build-tool-depends dependencies, like other integration
  tests.
* Adapt configuration for Alonzo
@github-actions
Copy link

github-actions bot commented Oct 13, 2021

Unit Test Results

    4 files  ±0    62 suites  ±0   4m 15s ⏱️ +18s
171 tests ±0  168 ✔️ ±0  3 💤 ±0  0 ±0 

Results for commit df918e1. ± Comparison against base commit 242b266.

This pull request removes 5 and adds 5 tests. Note that renamed tests count towards both.
Hydra.Chain.Direct ‑ publishes init tx and observes it also
Hydra.Chain.Direct.Tx ‑ observeTx . constructTx roundtrip
Hydra.Chain.Direct.Tx/initTx ‑ can construct & serialize unsigned initTx
Hydra.Chain.Direct.Tx/initTx ‑ contains some datums
Hydra.Chain.Direct.Tx/initTx ‑ distributes participation tokens (expected failure)
Hydra.Chain.Direct ‑ can init and abort a head given nothing has been committed
Hydra.Chain.Direct.Tx/abortTx ‑ transaction size below limit
Hydra.Chain.Direct.Tx/abortTx ‑ updates on-chain state to 'Final' given state is Initial
Hydra.Chain.Direct.Tx/abortTx ‑ validates against 'head' script in haskell (unlimited budget)
Hydra.Chain.Direct.Tx/initTx ‑ updates on-chain state to 'Initial' given state is closed

♻️ This comment has been updated with latest results.

@abailly-iohk abailly-iohk merged commit 6ff282a into master Oct 14, 2021
@abailly-iohk abailly-iohk deleted the ch1bo/aborttx-plutus-validation branch October 14, 2021 07:40
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.

3 participants