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

feat(applying): certificate and native script validation for ShelleyMA #510

Merged
merged 8 commits into from
Sep 23, 2024

Conversation

sterraf
Copy link
Contributor

@sterraf sterraf commented Aug 26, 2024

This PR implements checks for

  • the execution of native scripts; and
  • validity of certificates;

for ShelleyMA. This also required a revision of check_preservation_of_value to take care of pool deposits and the like. (The implementation of native scripts has also been been tested at Alonzo, but will be included in a future PR).

I tried to follow the specs for the Shelley and Mary ledgers. In order to do this, I implemented (with guidance by Gadea) some of the relevant types that describe the “states” related by the different transition relations governing the ledger (see utils.rs); v.g. DState records key delegations and pointers, etc.

Breaking change

In order to make use of the new checks, validate_shelley_ma_tx (and hence validate, which has been renamed to validate_txs and takes a list of transactions) must maintain (and modify) those states, and hence the type signature differs from the original one.

API

The original (mutable) state must be preserved before checking a tx (e.g. at Dolos) with validate_txs:

let mut buf_state: CertState = state.clone();
match validate_txs(..., &buf_state) {
	Ok(()) => state = buf_state,
	Err(error) =>  // handle error,
};

This is because the buffer state will end up inconsistent in case of a validation error.

Tests

Eight new unit tests (four positive and four negative) were added.

@scarmuega scarmuega merged commit 07b7451 into txpipe:main Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants