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

✨ Allow deleting contracts #800

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

✨ Allow deleting contracts #800

wants to merge 2 commits into from

Conversation

wraitii
Copy link
Member

@wraitii wraitii commented Feb 18, 2025

No description provided.

Copy link

codecov bot commented Feb 18, 2025

Codecov Report

Attention: Patch coverage is 89.94253% with 35 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/node_state.rs 89.06% 27 Missing ⚠️
crates/contracts/uuid-tld/src/lib.rs 75.00% 2 Missing ⚠️
crates/hyle-model/src/contract.rs 88.88% 2 Missing ⚠️
crates/client-sdk/src/helpers.rs 0.00% 1 Missing ⚠️
crates/contract-sdk/src/guest.rs 0.00% 1 Missing ⚠️
crates/hyle-verifiers/src/noir_utils.rs 0.00% 1 Missing ⚠️
src/node_state/hyle_tld.rs 98.41% 1 Missing ⚠️
Files with missing lines Coverage Δ
crates/contract-sdk/src/lib.rs 57.25% <ø> (ø)
crates/contract-sdk/src/utils.rs 73.17% <100.00%> (ø)
crates/hyle-model/src/block.rs 78.16% <ø> (ø)
crates/hyle-model/src/node/data_availability.rs 77.77% <100.00%> (+0.63%) ⬆️
crates/hyle-verifiers/src/lib.rs 13.79% <ø> (ø)
src/indexer.rs 81.84% <100.00%> (ø)
src/mempool/verifiers.rs 56.48% <100.00%> (ø)
crates/client-sdk/src/helpers.rs 31.57% <0.00%> (ø)
crates/contract-sdk/src/guest.rs 58.33% <0.00%> (ø)
crates/hyle-verifiers/src/noir_utils.rs 0.00% <0.00%> (ø)
... and 4 more

@@ -43,7 +43,7 @@ macro_rules! info {
}
}

pub type RunResult<T> = Result<(String, T, Vec<RegisterContractEffect>), String>;
pub type RunResult<T> = Result<(String, T, Vec<RegisterContractEffect>, Vec<ContractName>), String>;
Copy link
Contributor

Choose a reason for hiding this comment

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

je trouve que ce type devient de moins en moins lisible... pas le sujet de refacto dans cette PR, mais faudra changer pour un truc un chouille plus "explicite", ou proposer un builder pattern "RunResultBuilder" avec des helpers explicite (e.g. .with_registered_contracts() ,.with_removed_contracts() ...)

Copy link
Member Author

Choose a reason for hiding this comment

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

Bonne idée mais je ferais plus tard effectivement, en attendant je reswitch sur un seul Vec qui aidera

})
}

fn handle_delete_blob(
Copy link
Contributor

Choose a reason for hiding this comment

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

là j'ai l'impression que n'importe qui peut delete n'importe quel contrat non ? Comment fonctionne le "droit" de delete ?

#[derive(
Debug, Serialize, Deserialize, Default, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize,
)]
pub struct DeleteContractAction {
Copy link
Contributor

Choose a reason for hiding this comment

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

un bout de RustDoc sur cette struct serait bien, pour avoir qqpart l'explication de comment on l'utilise / comment les "droits de suppression" sont gérés (s'ils le sont).

Peut-être de même avoir un bout de doc qqpart sur le register de contract pour expliquer comment on update un contrat ? (ok pour faire ça dans une autre PR)

Copy link
Member Author

Choose a reason for hiding this comment

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

En soit ça c'est purement la spec du contrat hyle TLD, c'est réutilisable par d'autres mais pas forcément lié à comment l'utiliser.
Je vais quand même rajouter un peu de doc.

Comment on lines 495 to 496
contracts: &HashMap<ContractName, Contract>,
current_contracts: BTreeMap<ContractName, Contract>,
current_contracts: BTreeMap<ContractName, ContractSideEffect>,
Copy link
Contributor

Choose a reason for hiding this comment

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

note: je comprends pas bien la diff entre "contracts" et "current_contracts", à voir si on trouve un meilleur naming

Copy link
Member Author

Choose a reason for hiding this comment

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

current_contracts c'est la version "en cours de settlement", tandis que contracts c'est la version actuellement storée dans node-state (et donc non mutable).
Le 'mieux' serait d'avoir une version Copy-on-write smart du truc. Peut ptet le wrapper dans un type en attendant.

// Recursion end-case: we succesfully settled all prior blobs, so success.
let Some(current_blob) = blob_iter.next() else {
return Some((current_contracts, blob_proof_output_indices, true));
return Some(Ok(SettlementResult {
contracts_changes: current_contracts,
Copy link
Contributor

Choose a reason for hiding this comment

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

en référence à mon commentaire précédent, peut-être que "contract_changes" est plus adapté comme nom de paramètre ?

Copy link
Member Author

Choose a reason for hiding this comment

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

vrai

return match handle_blob_for_hyle_tld(contracts, &current_contracts, &current_blob.blob)
{
Ok(HyleTldOutput::Register(contract)) => {
let mut us = current_contracts.clone();
Copy link
Contributor

Choose a reason for hiding this comment

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

chaud pour éviter les abbréviations comme "us" au maximum 🙏

Copy link
Contributor

Choose a reason for hiding this comment

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

je pense que tu utilises des abbréviations pour limiter la taille de la ligne, mais je pense que c'est pas un bon pattern, et qu'on devrait plutôt chercher à moins nester nos fonctions, qu'à raccourcir le nom de nos variables ^^

Copy link
Member Author

@wraitii wraitii Feb 19, 2025

Choose a reason for hiding this comment

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

Non là c'est "us" parce que mmmh je sais plus si c'était pour updated_states ou si c'était us au sens ma version haha (genre us vs them comme les branches git)

@wraitii wraitii force-pushed the feat/delete_contracts branch 2 times, most recently from c7a2ad5 to 61c71f0 Compare February 20, 2025 10:46
@wraitii wraitii marked this pull request as ready for review February 20, 2025 17:08
@wraitii wraitii force-pushed the feat/delete_contracts branch from 7728b9f to b64b196 Compare February 21, 2025 16:48
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.

2 participants