node icon indicating copy to clipboard operation
node copied to clipboard

refactor: create BaseClient and BaseSigner struct to group common data of EVM client/signer and Bitcoin client/signer

Open ws4charlie opened this issue 1 year ago • 2 comments

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 avatar May 07 '24 04:05 ws4charlie

Would Doge require a different signer implementation from Bitcoin?

lumtis avatar May 08 '24 17:05 lumtis

Would Doge require a different signer implementation from Bitcoin?

Yeah. It will be a separate/different implementation.

ws4charlie avatar May 09 '24 15:05 ws4charlie