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

[EPIC] Minimal viable ledger #6

Open
2 tasks
scarmuega opened this issue Mar 26, 2024 · 1 comment
Open
2 tasks

[EPIC] Minimal viable ledger #6

scarmuega opened this issue Mar 26, 2024 · 1 comment

Comments

@scarmuega
Copy link
Contributor

scarmuega commented Mar 26, 2024

Tasks

Scope/Acceptance Criteria

  • Keep track of protocol parameters from a initial configuration & protocol updates tracked from chain-synchronization

    • We mostly need what is sufficient to provide useful feedback when validating transaction on submission, at least:
      • Fee (constant + coefficient)
      • maxValueSize
      • minUtxoDepositCoefficient / minUtxoDepositConstant
      • maxTransactionSize
      • stakeCredentialDeposit
      • collateralPercentage
      • maxCollateralInputs
      • maxExecutionUnits
      • (to be completed as identified)
  • At this point, UTxO-tracking is not required, but a nice-to-have. If times allow, we may consider it for this phase otherwise it will be reviewed more carefully in the next.

@micahkendall
Copy link

micahkendall commented Jun 10, 2024

This could be developed as an emulator like this, allowing efficient rust-based contract testing, and then you could generalise it for the ledger purposes.

For your list of useful feedback when validating transaction, this may be useful, which summarises a number of rules:

  • Verify Witnesses: Ensure that all witnesses in the transaction are valid.
  • Correct Count of Scripts and Vkeys: Check that the transaction has the correct number of scripts and vkeys.
  • Stake Key Registration: If the transaction involves a stake key registration, ensure that the stake key is not already registered.
  • Withdrawals: If the transaction involves withdrawals, ensure that the withdrawal amount matches the actual reward balance (in babbage, zero should be valid).
  • Validity Interval: Check that the transaction's validity interval is within the slot range.
  • Input Existence: Check that all inputs in the transaction exist and have not been spent.
  • Script Refs: For each input, check if it has a script ref and handle it accordingly.
  • Collateral Inputs: Check that all collateral inputs only contain vkeys.
  • Required Signers: Check that all required signers are included in the transaction.
  • Mint Witnesses: Check that all mint witnesses are included in the transaction.
  • Cert Witnesses: Check that all cert witnesses are included in the transaction.
  • Input Witnesses: Check that all input witnesses are included in the transaction.
  • Check Consumed Witnesses: Check that all witnesses have been consumed.
  • Apply Transitions: Apply the necessary transitions to the ledger, mempool, withdrawal requests, cert requests, and outputs, create outputs and consume datum hashes: For each output, create a new unspent output and consume the datum hash.
  • UTXO: Check that the transaction's outputs are valid. Fee checking, minSize, ada /= 0, Alonzo.validateOutputTooBigUTxO,
  • Fee Checking: Ensure that the transaction fee is not too small. See the fee calculator in tx builder.
  • Collateral Checking: Check that the collateral inputs are valid. Collateral should be UTxOs where all are held by pubkeys such that the sum of the collateral minus the collateral return is greater than the minimum collateral fee for the transaction.
    • Understanding collateral balancing: if the tx fails, instead of consuming inputs and producing outputs, you consume collateral inputs and produce 1 output (the collateral return), this is
  • Disjoint RefInputs: Ensure that there is no intersection between the input set of a transaction and the reference input set of a transaction. I.e no reference inputs may be spent.
  • Outputs Too Small: Check that all outputs of the transaction are not too small. See size calculation in tx builder, use the min size parameter from protocol params.
  • Other UTxO Transition Rules: Check other transition rules for the UTXO.
  • PPUP: Run the PPUP rule before script evaluation. Note from micah: not fully understood.
  • Expect Scripts To Pass: Ensure that all scripts pass. Simple enough, requires an 'Evaluator' to be attached to the emulator (see tx class).
  • Valid field matters for scripts/collateral: Check that the valid field is true for scripts and collateral.
    • The valid field tells you whether the tx should be passed as a collateral forfeit or if the tx should succeed.
    • I believe when the valid field is true, even if the tx fails, the node will reject it, but a malicious node could accept and propagate it.
  • Babbage Missing Scripts: Check for missing scripts according to the Babbage rules. Reference scripts get counted for free, in conway the constitution script is given for free, others need to be included in witnesses.
  • Scripts Well Formed: Ensure that all scripts are well-formed.
  • Check scripts needed: Check that all needed scripts are provided.
  • Missing Script Witnesses: Check for missing script witnesses.
  • Extraneous Script Witness: No unnecessary scripts may be attached to the transaction.
  • Failed Babbage Scripts: Validate failed Babbage scripts.
  • Outside Forecast: Validate that the transaction is bounded within the forecast (start <-> ttl).
  • Inputs Is Not Empty Set: Validate that the inputs are not an empty set.
  • Value Conserved: Validate that the value is conserved (inputs + withdrawals = outputs + fee + mint && collateral inputs = collateral outputs + collateral fee). See getPitch() from tx builder.
  • ADA is not minted: Ensure that ADA is not minted.
  • Output Too Big: Validate that the output is not too big.
  • Output Boot AddrAttrs Too Big: Validate that the output boot address attributes are not too big.
  • Correct Network Id: Validate that the correct network ID is used.
  • Network for Withdrawals: Validate the network for withdrawals.
  • Size of Tx: Validate the size of the transaction.
  • Consumed Exunits: Validate the consumed exunits.
  • Number of Collateral Inputs: Validate the number of collateral inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🏗 In progress
Development

No branches or pull requests

4 participants