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

refactor: create base Observer and Signer struct to group common data of EVM observer/signer and Bitcoin observer/signer #2126

Closed
Tracked by #1611
ws4charlie opened this issue May 7, 2024 · 2 comments · Fixed by #2359
Assignees
Labels
code-quality Code quality improvement zetaclient Issues related to ZetaClient

Comments

@ws4charlie
Copy link
Contributor

Describe the Issue

  • The EVM client and Bitcoin client structs have common data fields which can be grouped into a BaseClient struct. BaseClient can then be reused by EVM client, Bitcoin client and future chain clients (e.g., DogeClient) by exposing unified methods.
  • The EVM signer and Bitcoin signer structs have common data fields which can be grouped into a BaseSigner struct. BaseSigner can then be reused by EVM client, Bitcoin client and future chain clients (e.g., DogeSigner) by exposing unified methods.
  • The commonly used loggers can also form a BaseClientLog struct and be reused by future chain clients.

Expected Outcome


// BaseClientLog is the base logger for external chain client
type BaseClientLog struct {
	// Chain is the parent logger for the chain
	Chain zerolog.Logger

	// Inbound is the logger for incoming transactions
	Inbound zerolog.Logger

	// Outbound is the logger for outgoing transactions
	Outbound zerolog.Logger

	// GasPrice is the logger for gas prices
	GasPrice zerolog.Logger

	// Compliance is the logger for compliance checks
	Compliance zerolog.Logger
}

// BaseClient is the base client struct for external chain client
type BaseClient struct {
	// the external chain
	chain chains.Chain

	// the external chain's parameters
	chainParams observertypes.ChainParams

	// tss signer
	tss interfaces.TSSSigner

	// zetacore bridge
	bridge interfaces.ZetaCoreBridger

	// zetacore context
	coreContext *corecontext.ZetaCoreContext

	// the latest block height of external chain
	lastBlock uint64

	// the last successfully scanned block height
	lastBlockScanned uint64

	// lru cache for blocks
	blockCache *lru.Cache

	// client db for persistency
	db *gorm.DB

	// stop channel
	stop chan struct{}

	// telemetry server
	ts *metrics.TelemetryServer
}


// BaseSigner is the base signer struct for external chain signer
type BaseSigner struct {
	// the external chain
	chain chains.Chain

	tssSigner interfaces.TSSSigner

	// the loggers
	logger           zerolog.Logger
	loggerCompliance zerolog.Logger

	// zetacore context
	coreContext *corecontext.ZetaCoreContext

	// telemetry server
	ts *metrics.TelemetryServer
}
@ws4charlie ws4charlie self-assigned this May 7, 2024
@lumtis lumtis added the zetaclient Issues related to ZetaClient label May 7, 2024
@ws4charlie ws4charlie added the code-quality Code quality improvement label May 7, 2024
@lumtis
Copy link
Member

lumtis commented May 8, 2024

Would Doge require a different signer implementation from Bitcoin?

@ws4charlie
Copy link
Contributor Author

Would Doge require a different signer implementation from Bitcoin?

Yeah. It will be a separate/different implementation.

@ws4charlie ws4charlie changed the title refactor: create BaseClient and BaseSigner struct to group common data of EVM client/signer and Bitcoin client/signer refactor: create base Observer and Signer struct to group common data of EVM observer/signer and Bitcoin observer/signer Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-quality Code quality improvement zetaclient Issues related to ZetaClient
Projects
None yet
2 participants