Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Create Base, Mainchain and Sidechain RecoveryClient classes #9167

Open
Tracked by #6919
ishantiw opened this issue Nov 29, 2023 · 0 comments
Open
Tracked by #6919

Create Base, Mainchain and Sidechain RecoveryClient classes #9167

ishantiw opened this issue Nov 29, 2023 · 0 comments

Comments

@ishantiw
Copy link
Contributor

ishantiw commented Nov 29, 2023

Description

  • Create SidechainRecoveryClient class
abstract class BaseRecoveryClient {
	private _apiClient!: apiClient.APIClient;
	private _queryKeys!: Set<string>;

	public connect(_connectionObj: ConnectionObj) {
		// check for mode of connection and use connectionString to connect to the relevant client
	}
	public async getInclusionProof(_keys: string[]) {
		// Call RPC to get inclusionProof and return in appropriate format
		// await this._apiClient.invoke('state_prove', {});
	}
	public addQueryKeyForInclusionProof(queryKey: string) {
		this._queryKeys.add(queryKey);
	}

	public collectInclusionProofs() {
		// subscribe to chain_newBlock event and on every new block query the client with all the proofs
		this._apiClient.subscribe('chain_newBlock', _ => {
			this.getInclusionProof([...this._queryKeys.values()]);
			// save proof for each key in stateRecoveryDB with key { sidechainID+queryKey }
		});
	}

	public removeQueryKey(queryKey: string) {
		this._queryKeys.delete(queryKey);
	}

	// Based on finalized height and last certificate on the other chain delete irrelevant recovery data
	public cleanupStateRecoveryData() {}

	// Disconnect client and release resources
	public disconnectClient() {}
}

class MainchainRecoveryClient extends BaseRecoveryClient {
	// Collect new CCMs from the on-chain events
	// Collect inclusionProofs for the sidechain outbox for the CCMs: This part is done by calling addQueryKeyForInclusionProof from the manager class
	public collectCCMsAndProofs() {
		// collect CCMs on every newBlock and by calling getEvents for the block height and save them in messageRecoveryDB
	}

	// Based on finalized height and last certificate on the other chain delete irrelevant message recovery data
	public cleanupMessageRecoveryData() {}
}

class SidechainRecoveryClient extends BaseRecoveryClient {}

Acceptance Criteria

  • Should have all the method definition
  • Should have all the unit tests for the implemented methods
@ishantiw ishantiw changed the title Create SidechainRecoveryClient class Create Base, Mainchain and Sidechain RecoveryClient classes Dec 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant