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 Mainchain, Sidechain and BaseRecoveryManager class and declare functions #9164

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

Comments

@ishantiw
Copy link
Member

ishantiw commented Nov 29, 2023

Description

Create BaseRecoveryManager class and declare functions

abstract class BaseRecoveryManager {
	private _stateRecoveryDB: Database;
	private _apiClient: APIClient;
	private config: Config;
	private _queryKeys: Map<chainID, queryKey[]>;
	private _mainchainClient: APIClient;
	public _sidechainClientMap: Map<chainID, SidechainClient>

	constructor({ config, chainID, stateRecoveryDB }) {
		this._stateRecoveryDB = stateRecoveryDB;
		this.config = config;
		this._sidechainClientMap = new Map();
	}

	public load() {}

	public unload() {}

	// Add a client
	public addSideChainClient(chainID, connectionURL) {
		const sidechainClient = new SidechainClient((chainID, connectionURL);
		this._sidechainClientMap.set(chainID, sidechainClient);
	}

	// add key for state recovery based on the chain and add it to client.addQueryKeyForInclusionProof
	public addKeyForStateRecovery(chainID, queryKey) {}

	// this is common to both mainchain and sidechain; gets information from DB stored by clients
	public triggerStateRecovery(chainID, queryKey) {
// calls private method `computeStateRecoveryParams ` which computes all the params stored in the messageRecoveryDB
       }
	
      // This method will be called once a recovery was done successfully and we need to update all the inclusionProofs
    public updateInclusionProofs(chainID, queryKey) {}

	// Clean mechanism will include checking last certificate height of the sidechain on mainchain
    public cleanup()
}

class MainchainRecoveryManager extends BaseRecoveryManager {
	private _messageRecoveryDB: Database;

	constructor({ config, chainID, stateRecoveryDB, messageRecoveryDB, sidechainChainID }) {
		super({ config, chainID, stateRecoveryDB });
		this._messageRecoveryDB = messageRecoveryDB;
	}

	// saves CCMs and inclusion proof on the mainchain on every new block
	public enableMessageRecovery() {}

	// creates tx
	public triggerMessageRecovery(chainID){
		// calls private method `computeMessageRecoveryParams ` which computes all the params stored in the messageRecoveryDB
	}

// creates tx
	public triggerInitMessageRecovery(chainID){
		// calls private method `computeInitMessageRecoveryParams ` which computes all the params stored in the messageRecoveryDB
	}

      public cleanup()
}

class SidechainRecoveryManager extends BaseRecoveryManager {
	private _mainchainClient: APIClient;

	constructor({ config, chainID, stateRecoveryDB, mainchainClient }) {
		super({ config, chainID, stateRecoveryDB });
		this._mainchainClient = mainchainClient;
	}

	// Only init state recovery is extra command as compared to BaseRecoveryManager
	// we can call mainchainClient to build the params
	public triggerInitStateRecovery(chainID, queryKey){
// calls private method `computeInitStateRecoveryParams ` which computes all the params stored in the StateRecoveryDB
       }
    
      public cleanup()
}
  • Implement logic for addSideChainClient and addKeyForStateRecovery

Acceptance Criteria

  • Should have all the interfaces present
  • Should have all the unit tests present for addSideChainClient and addKeyForStateRecovery
@Madhulearn Madhulearn modified the milestone: Sprint 110 Dec 4, 2023
@ishantiw ishantiw changed the title Create BaseRecoveryManager class and declare functions Create Mainchain, Sidechain and BaseRecoveryManager class and declare functions 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

2 participants