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

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
Member

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 join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant