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

[FEATURE] - Avoid Redundant ACL Computation in _initializeFinalityState #463

Closed
trungnotchung opened this issue Feb 13, 2025 · 0 comments · Fixed by #474
Closed

[FEATURE] - Avoid Redundant ACL Computation in _initializeFinalityState #463

trungnotchung opened this issue Feb 13, 2025 · 0 comments · Fixed by #474
Assignees
Labels
feature New feature or request

Comments

@trungnotchung
Copy link
Member

trungnotchung commented Feb 13, 2025

Problem Description

The method _initializeFinalityState(hash: Hash) currently recomputes the ACL even though the ACL might have already been computed and stored in the codebase.

// initialize the attestation store for the given vertex hash
	private _initializeFinalityState(hash: Hash) {
		if (!this.acl || !this.originalObjectACL) {
			throw new Error("ObjectACL is undefined");
		}
		const fetchedState = this.aclStates.get(hash);
		if (fetchedState !== undefined) {
			const state = cloneDeep(fetchedState);
			const acl = cloneDeep(this.originalObjectACL);

			for (const entry of state.state) {
				acl[entry.key] = entry.value;
			}
			// signer set equals writer set
			this.finalityStore.initializeState(hash, acl.query_getFinalitySigners());
		}
	}

cloneDeep operations are costly, and this function runs every time _initializeFinalityState is called when a new vertex is added to the hash graph. This results in unnecessary recomputation and inefficiency.

Proposed Solution

Instead of recomputing ACL every time, modify _initializeFinalityState to directly accept a precomputed acl

Implementation PR

No response

Reference Issues

No response

Unresolved questions

No response

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant