node
node copied to clipboard
refactor: create BaseClient and BaseSigner struct to group common data of EVM client/signer and Bitcoin client/signer
Describe the Issue
- The EVM client and Bitcoin client structs have common data fields which can be grouped into a
BaseClientstruct.BaseClientcan 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
BaseSignerstruct.BaseSignercan 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
BaseClientLogstruct 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
}
Would Doge require a different signer implementation from Bitcoin?
Would Doge require a different signer implementation from Bitcoin?
Yeah. It will be a separate/different implementation.