signersvc

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package signersvc implements the SignerSvc of the Kwil reward system. It simply fetches the new Epoch from Kwil network and verify&sign it, then upload the signature back to the Kwil network. Each bridgeSigner targets one registered erc20 Reward instance.

Index

Constants

View Source
const (
	EthNetworkMainnet = 1
	EthNetworkSepolia = 11155111
)

Variables

View Source
var (
	AddressMulticall3 = common.HexToAddress("0xcA11bde05977b3631167028862bE2a173976CA11")
)

Functions

func IsMulticall3Deployed

func IsMulticall3Deployed(chainID uint64, blockNumber *big.Int) bool

func NewSignerClient

func NewSignerClient(chainID string, db DB, call engineCall, bcast txBcast, nodeApp nodeApp) *signerClient

func StateFilePath

func StateFilePath(dir string) string

StateFilePath returns the state file.

func ToSlicePtr

func ToSlicePtr[T any](collection []T) []*T

Types

type DB

type DB interface {
	sql.ReadTxMaker
	sql.DelayedReadTxMaker
}

type Epoch

type Epoch struct {
	ID             *types.UUID
	StartHeight    int64
	StartTimestamp int64
	EndHeight      int64
	RewardRoot     []byte
	RewardAmount   *types.Decimal
	EndBlockHash   []byte
	Confirmed      bool
	Voters         []string
	VoteNonces     []int64
	VoteSignatures [][]byte
}

type EpochReward

type EpochReward struct {
	Recipient string
	Amount    string
}

type RewardInstanceInfo

type RewardInstanceInfo struct {
	Chain       string
	Escrow      string
	EpochPeriod string
	Erc20       string
	Decimals    int64
	Balance     *types.Decimal
	Synced      bool
	SyncedAt    int64
	Enabled     bool
}

type Safe

type Safe struct {
	// contains filtered or unexported fields
}

func NewSafe

func NewSafe(rpc string, addr string) (*Safe, error)

func NewSafeFromEscrow

func NewSafeFromEscrow(rpc string, escrowAddr string) (*Safe, error)

type ServiceMgr

type ServiceMgr struct {
	// contains filtered or unexported fields
}

ServiceMgr manages multiple bridgeSigner instances running in parallel.

func NewServiceMgr

func NewServiceMgr(
	chainID string,
	db DB,
	call engineCall,
	bcast txBcast,
	nodeApp nodeApp,
	cfg config.ERC20BridgeConfig,
	state *State,
	logger log.Logger) *ServiceMgr

func (*ServiceMgr) Start

func (m *ServiceMgr) Start(ctx context.Context) error

Start runs all rewardSigners. It returns error if there are issues initializing the bridgeSigner; no errors are returned after the bridgeSigner is running.

type State

type State struct {
	// contains filtered or unexported fields
}

State is a naive kv impl used by bridgeSigner.

func LoadStateFromFile

func LoadStateFromFile(stateFile string) (*State, error)

LoadStateFromFile load the state from a file.

func NewMemState

func NewMemState() *State

func NewTmpState

func NewTmpState() *State

func (*State) LastVote

func (s *State) LastVote(target string) *voteRecord

func (*State) UpdateLastVote

func (s *State) UpdateLastVote(target string, newVote *voteRecord) error

UpdateLastVote updates the latest vote record, and syncs the changes to disk.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳