node

package
v0.0.0-...-348f794 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 65 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestnetLightecNetwork        = "testnet"
	TestnetBtcOperatorAddress    = "tb1qmfsjae6yxtt8kc3cre84rkraa5nyw35nzmx87t85z30f8auy0mnqhtuey4"
	TestnetBtcLockScript         = "0020da612ee74432d67b62381e4f51d87ded2647469316cc7f2cf4145e93f7847ee6"
	TestnetBtcMultiSig           = "" /* 210-byte string literal not displayed */
	TestnetEthZkBridgeAddress    = "0x9C83D62f524d589da2ED538F5F59225880B680D1"
	TestnetEthZkBtcAddress       = "0x71198dD1689eBc01A7664ce7c0d5b1f62DF2b378"
	TestnetEthUtxoManagerAddress = "0xc5eC55Ba3764c09eD28598465D534e313A0EEe34"
	TestnetEthBtcTxVerifyAddress = "0xC96685Eb518Df9959E326326d72b5234b78c2d30"
	TestnetFeePoolAddr           = "0xd69aec9e9a434aa6B0a9BCC9B4D01154fc907253"
	TestnetOasisSignerAddr       = "0x78131d6524C04F986e82Cd222a6ABcBf8f9D9Dc1"
	TestnetIcpPublicKey          = "0x02b4ca925faa4e78c292c080254121299a778e990dd52061fb6d5dd01ef9db56f2"
	TestnetGenesisRoot           = "0x603499eb68150e861ef759463fa901add0987d1af340c925e1701a10b9c21165"
	TestnetBlockSingerId         = "xdqo6-dqaaa-aaaal-qsqva-cai"
	TestnetIcpTxSingerId         = "n6pke-yqaaa-aaaah-arona-cai"
)
View Source
const (
	LightecNetwork        = "mainnet"
	BtcOperatorAddress    = "bc1qcwc08898aseahq2e5920m9395py3jjtm2xnt0s90slqra7cry2dq2xv9uq"
	BtcLockScript         = "0020c3b0f39ca7ec33db8159a154fd9625a04919497b51a6b7c0af87c03efb03229a"
	BtcMultiSig           = "" /* 210-byte string literal not displayed */
	EthZkBridgeAddress    = "0xF90966fd006a5B18Cb0E3A0568226010CED426FD"
	EthZkBtcAddress       = "0x199CC8f0ac008Bdc8cF0B1CCd5187F84E168C4D2"
	EthUtxoManagerAddress = "0x205a1E85C7d4d0fcd4344335120181aB5e796562"
	EthBtcTxVerifyAddress = "0x1F0f891fB88287091DFc6225038336207374ec79"
	FeePoolAddr           = "0x7be6F1ECac63c8562Da8fF769347c45fc4590bFb"
	OasisSignerAddr       = "0xA81Fc99DBC654D68513B8C1475aFeC3B5d76496e"
	IcpPublicKey          = "03183007b9afcfa519871885380d4dfd1144269d8050ec2a51992065af2a87d3df"
	GenesisRoot           = "52bbd8287d0e455ce6cd732fa8a5f003e2ad82fd0ed3a59516f9ae1642f1b182"
	BlockSingerId         = "xdqo6-dqaaa-aaaal-qsqva-cai"
	IcpTxSingerId         = "wlkxr-hqaaa-aaaad-aaxaa-cai"

	DepositTopic    = "0xd063609fea0cb9b8a1b53a4fbf0e659c270b3bc99eab08dcc7f4433b4937e074" // the UTXOAdded event from the UTXO Manager contract
	RedeemTopic     = "0x379299efe6911678ce0f23cfce13a7c61a5b2c1723f583f9217b6ee0887b3ef4" // the CreateRedeemUnsignedTx event from the zkBTC bridge contract
	UpdateUtxoTopic = "0x5d6cc5c33e60ae274f09159956ae8fd20271c63c95b9004445271437b335ed6e" // the ChangeUTXOUpdated event from the UTXO Manager contract

)
View Source
const (
	BtcScanTime = 5 * time.Minute
	EthScanTime = 3 * time.Minute
	// MigrateProto operator migrate address
	MigrateProto = "6a141234560000000000000000000000000000000000"
	// MinDepositValue deposit min value
	MinDepositValue = float64(0.00021000) // 21000 sats

	// 1: the first production version (2025.7) @gnark v0.12;
	// 2: Ethereum Fusaka + gnark 0.14
	GeneratorVersion = 2

	NodeVersion          = "1.0.0"
	RpcRegisterName      = "zkbtc"
	BitcoinNetwork       = "bitcoin"
	EthereumNetwork      = "ethereum"
	BitcoinAgentName     = "bitcoinAgent"
	EthereumAgentName    = "ethereumAgent"
	BeaconAgentName      = "beaconAgent"
	BtcLiteCacheHeight   = 24 * 6 * 45
	ProofExpired         = 5 * time.Hour
	BtcClientCacheHeight = 100
)
View Source
const (
	SecretKeyId = "secretKey"
)

Variables

View Source
var SgxServerUrl []string = []string{""} // todo

Functions

func BeaconBlockHeaderToSlotAndRoot

func BeaconBlockHeaderToSlotAndRoot(header *structs.BeaconBlockHeader) (uint64, []byte, error)

func BtcToSat

func BtcToSat(value float64) int64

func DbTxMinerReward

func DbTxMinerReward(txId string) []byte

func DbValue

func DbValue(a string) string

func DoTask

func DoTask(name string, fn func() error, exit chan os.Signal)

func DoTimerTask

func DoTimerTask(name string, interval time.Duration, fn func() error, exit chan os.Signal, notifies ...chan *Notify)

func FileKeyToIndex

func FileKeyToIndex(fileKey store.FileKey) (uint64, uint64, uint64, error)

func GenRequestData

func GenRequestData(p *Prepared, reqType common.ProofType, fIndex, sIndex uint64, hash string, prefix uint64, isCp bool) (interface{}, bool, error)

func LowercaseFirstLetter

func LowercaseFirstLetter(s string) string

func NewCacheState

func NewCacheState() *cache

func NewFetchId

func NewFetchId(updateType FetchType, index uint64) string

func NewLocalWorker

func NewLocalWorker(btcSetupDir, ethSetupDir, dataDir, wid string, maxNums, cacheCap int) (rpc.IWorker, error)

func NewRat

func NewRat() *big.Rat

func PrintPanicStack

func PrintPanicStack(extras ...interface{})

func RsToSignature

func RsToSignature(sig string) ([]byte, error)

func TxHeightKeyToTxId

func TxHeightKeyToTxId(key []byte) (string, error)

func TxIdIsEmpty

func TxIdIsEmpty(txId [32]byte) bool

func UUID

func UUID() string

func WorkerGenProof

func WorkerGenProof(worker rpc.IWorker, req *common.ProofRequest) ([]*common.ProofResponse, error)

Types

type ArrayQueue

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

todo

func NewArrayQueue

func NewArrayQueue(sortFn func(a, b *common.ProofRequest) bool) *ArrayQueue

func (*ArrayQueue) Filter

func (q *ArrayQueue) Filter(fn func(value *common.ProofRequest) bool) []*common.ProofRequest

func (*ArrayQueue) Len

func (q *ArrayQueue) Len() int

func (*ArrayQueue) List

func (q *ArrayQueue) List() []*common.ProofRequest

func (*ArrayQueue) Pop

func (q *ArrayQueue) Pop() (*common.ProofRequest, bool)

func (*ArrayQueue) PopFn

func (q *ArrayQueue) PopFn(fn func(req *common.ProofRequest) bool) (*common.ProofRequest, bool)

func (*ArrayQueue) Push

func (q *ArrayQueue) Push(value *common.ProofRequest)

func (*ArrayQueue) Remove

func (q *ArrayQueue) Remove(fn func(value *common.ProofRequest) bool) []*common.ProofRequest

type BtcClient

type BtcClient struct {
	IClient btcproverClient.IClient
	// contains filtered or unexported fields
}

BtcClient why exists this client, because btc_provers use btcproverClient.IClient to get block header,it`s maybe get forked chain data

func NewBtcClient

func NewBtcClient(client btcproverClient.IClient, store store.IStore, btClient *bitcoin.Client, initHeight int64) *BtcClient

func (*BtcClient) GetBlock

func (c *BtcClient) GetBlock(hash string) (*btcjson.GetBlockVerboseResult, error)

func (*BtcClient) GetBlockHash

func (c *BtcClient) GetBlockHash(height int64) (*chainhash.Hash, error)

func (*BtcClient) GetHeaderByHash

func (c *BtcClient) GetHeaderByHash(hash *chainhash.Hash) (string, error)

func (*BtcClient) GetHeaderByHashStr

func (c *BtcClient) GetHeaderByHashStr(hash string) (string, error)

func (*BtcClient) GetHeaderByHeight

func (c *BtcClient) GetHeaderByHeight(height int64) (string, error)

func (*BtcClient) SetInitHeight

func (c *BtcClient) SetInitHeight(height int64)

type BtcFilter

type BtcFilter struct {
	OperatorAddr  string
	LockScript    string
	MultiSigScrip string
	// contains filtered or unexported fields
}

func NewBtcAddrFilter

func NewBtcAddrFilter(operator, lockScript, multisig string, minDepositValue float64, txMode common.TxMode) *BtcFilter

func (*BtcFilter) Deposit

func (b *BtcFilter) Deposit(outputs []btcjson.Vout) bool

func (*BtcFilter) GetMinDepositValue

func (b *BtcFilter) GetMinDepositValue() float64

func (*BtcFilter) Migrate

func (b *BtcFilter) Migrate(outputs []btcjson.Vout) bool

func (*BtcFilter) Redeem

func (b *BtcFilter) Redeem(inputs []btcjson.Vin) bool

type ChainFork

type ChainFork struct {
	ForkHeight uint64
	Chain      common.ChainType
	Timestamp  int64
}

type ChainIndex

type ChainIndex struct {
	Genesis uint64
	Start   uint64
	End     uint64
	Step    uint64
	PreStep uint64
}

func BlockChainPlan

func BlockChainPlan(start, height uint64, skip ...bool) []ChainIndex

func BlockDepthPlan

func BlockDepthPlan(prefix, start, end uint64, skip ...bool) []ChainIndex

func BlockUpperIndex

func BlockUpperIndex(start, end uint64, skip ...bool) []ChainIndex

BlockUpperIndex one upper round plan

type ChainStore

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

func NewChainStore

func NewChainStore(store store.IStore) *ChainStore

func (*ChainStore) BtcDeleteData

func (cs *ChainStore) BtcDeleteData(height uint64) error

func (*ChainStore) BtcSaveData

func (cs *ChainStore) BtcSaveData(height uint64, depositTxs, redeemTxes []*DbTx) error

func (*ChainStore) Compact

func (cs *ChainStore) Compact(start, limit []byte) error

func (*ChainStore) DelBtcClientCache

func (cs *ChainStore) DelBtcClientCache(height uint64) error

func (*ChainStore) DelDbProof

func (cs *ChainStore) DelDbProof(txId string) error

func (*ChainStore) DeleteAddrTxPrefix

func (cs *ChainStore) DeleteAddrTxPrefix(addr string, txType common.TxType, hash string) error

func (*ChainStore) DeleteAddrTxesPrefix

func (cs *ChainStore) DeleteAddrTxesPrefix(txIds []string) error

func (*ChainStore) DeleteBtcTxHeight

func (cs *ChainStore) DeleteBtcTxHeight(height uint64, txIds []string) error

func (*ChainStore) DeleteBtcTxParam

func (cs *ChainStore) DeleteBtcTxParam(txId string) error

func (*ChainStore) DeleteDbProof

func (cs *ChainStore) DeleteDbProof(txIds []string) error

func (*ChainStore) DeleteDbTxes

func (cs *ChainStore) DeleteDbTxes(txId []string) error

func (*ChainStore) DeleteDbUnGenProofs

func (cs *ChainStore) DeleteDbUnGenProofs(chainType common.ChainType, txIds []string) error

func (*ChainStore) DeleteDestHash

func (cs *ChainStore) DeleteDestHash(txIds []string) error

func (*ChainStore) DeleteEthTxHeight

func (cs *ChainStore) DeleteEthTxHeight(height uint64, txIds []string) error

func (*ChainStore) DeletePendingRequest

func (cs *ChainStore) DeletePendingRequest(proofId string) error

func (*ChainStore) DeleteProofResponse

func (cs *ChainStore) DeleteProofResponse(requestId string) error

func (*ChainStore) DeleteRedeemSotCache

func (cs *ChainStore) DeleteRedeemSotCache(txSlot, finalizeSlot uint64, hash string) error

func (*ChainStore) DeleteTxProved

func (cs *ChainStore) DeleteTxProved(txIds []string) error

func (*ChainStore) DeleteUnGenProof

func (cs *ChainStore) DeleteUnGenProof(chainType common.ChainType, txIds ...string) error

func (*ChainStore) DeleteUnSubmitTx

func (cs *ChainStore) DeleteUnSubmitTx(hash string) error

func (*ChainStore) EthDeleteData

func (cs *ChainStore) EthDeleteData(height uint64) error

func (*ChainStore) EthSaveData

func (cs *ChainStore) EthSaveData(beginHeight, endHeight uint64, depositTxes, redeemTxes, updateUtxoTxes []*DbTx) error

func (*ChainStore) GetDestHash

func (cs *ChainStore) GetDestHash(key string) (string, bool, error)

func (*ChainStore) ReadAllMiners

func (cs *ChainStore) ReadAllMiners() ([]string, error)

func (*ChainStore) ReadAllPendingRequests

func (cs *ChainStore) ReadAllPendingRequests() ([]*common.ProofRequest, error)

func (*ChainStore) ReadAllProofResponse

func (cs *ChainStore) ReadAllProofResponse() ([]*common.SubmitProof, error)

func (*ChainStore) ReadBitcoinHash

func (cs *ChainStore) ReadBitcoinHash(height uint64) (string, bool, error)

func (*ChainStore) ReadBlockHeader

func (cs *ChainStore) ReadBlockHeader(hash string) (string, bool, error)

func (*ChainStore) ReadBtcBlock

func (cs *ChainStore) ReadBtcBlock(hash string) (string, bool, error)

func (*ChainStore) ReadBtcHeaderHash

func (cs *ChainStore) ReadBtcHeaderHash(start, end uint64) ([]string, error)

func (*ChainStore) ReadBtcHeight

func (cs *ChainStore) ReadBtcHeight() (uint64, bool, error)

func (*ChainStore) ReadBtcTx

func (cs *ChainStore) ReadBtcTx(hash string) (*DbTx, bool, error)

func (*ChainStore) ReadBtcTxHeight

func (cs *ChainStore) ReadBtcTxHeight(height uint64) ([]string, error)

func (*ChainStore) ReadBtcTxParam

func (cs *ChainStore) ReadBtcTxParam(txId string) (*common.ProofRequest, bool)

func (*ChainStore) ReadChainForks

func (cs *ChainStore) ReadChainForks(chain string) ([]*ChainFork, error)

func (*ChainStore) ReadCheckpoint

func (cs *ChainStore) ReadCheckpoint(height uint64) (string, bool, error)

func (*ChainStore) ReadCheckpointHash

func (cs *ChainStore) ReadCheckpointHash(txId string) (string, bool, error)

func (*ChainStore) ReadDbProof

func (cs *ChainStore) ReadDbProof(txId string) (DbProof, error)

func (*ChainStore) ReadDbTxes

func (cs *ChainStore) ReadDbTxes(txId string) ([]*DbTx, error)

func (*ChainStore) ReadDbUnGenProof

func (cs *ChainStore) ReadDbUnGenProof(chainType common.ChainType, txId string) (*DbUnGenProof, bool, error)

func (*ChainStore) ReadDestHash

func (cs *ChainStore) ReadDestHash(key string) (string, error)

func (*ChainStore) ReadEthTxHeight

func (cs *ChainStore) ReadEthTxHeight(height uint64) ([]string, error)

func (*ChainStore) ReadEthereumHeight

func (cs *ChainStore) ReadEthereumHeight() (uint64, bool, error)

func (*ChainStore) ReadIcpSignature

func (cs *ChainStore) ReadIcpSignature(height uint64) (DbIcpSignature, bool, error)

func (*ChainStore) ReadLatestBeaconSlot

func (cs *ChainStore) ReadLatestBeaconSlot() (uint64, bool, error)

func (*ChainStore) ReadLatestCheckPoint

func (cs *ChainStore) ReadLatestCheckPoint() (uint64, bool, error)

func (*ChainStore) ReadMaxGasPrice

func (cs *ChainStore) ReadMaxGasPrice() (uint64, bool, error)

func (*ChainStore) ReadMinerPower

func (cs *ChainStore) ReadMinerPower(addr string) (*DbMiner, error)

func (*ChainStore) ReadNonce

func (cs *ChainStore) ReadNonce(network, addr string) (uint64, bool, error)

func (*ChainStore) ReadRedeemTx

func (cs *ChainStore) ReadRedeemTx(txId string) (*DbTx, bool, error)

func (*ChainStore) ReadSlotByHeight

func (cs *ChainStore) ReadSlotByHeight(number uint64) (uint64, bool, error)

func (*ChainStore) ReadSubmitMaxValue

func (cs *ChainStore) ReadSubmitMaxValue() (uint64, bool, error)

func (*ChainStore) ReadSubmitMinValue

func (cs *ChainStore) ReadSubmitMinValue() (uint64, bool, error)

func (*ChainStore) ReadTxIdsByAddr

func (cs *ChainStore) ReadTxIdsByAddr(txType common.TxType, addr string) ([]string, error)

func (*ChainStore) ReadTxProved

func (cs *ChainStore) ReadTxProved(txId string) (bool, error)

func (*ChainStore) ReadUnGenProofs

func (cs *ChainStore) ReadUnGenProofs(chainType common.ChainType) ([]*DbUnGenProof, error)

func (*ChainStore) ReadUnSubmitTxs

func (cs *ChainStore) ReadUnSubmitTxs() ([]DbUnSubmitTx, error)

func (*ChainStore) ReadUpdateCpTx

func (cs *ChainStore) ReadUpdateCpTx() (*DbTx, bool)

func (*ChainStore) ReadUpdateUtxoDest

func (cs *ChainStore) ReadUpdateUtxoDest(hash string) (string, bool, error)

func (*ChainStore) ReadWorkerId

func (cs *ChainStore) ReadWorkerId() (string, bool, error)

func (*ChainStore) ReadZkParamVerify

func (cs *ChainStore) ReadZkParamVerify() (bool, error)

func (*ChainStore) UpdateProof

func (cs *ChainStore) UpdateProof(txId string, proof string, proofType common.ProofType, status common.ProofStatus) error

func (*ChainStore) UpdateProofStatus

func (cs *ChainStore) UpdateProofStatus(txId string, proofType common.ProofType, status common.ProofStatus) error

func (*ChainStore) WriteAddrPrefixTx

func (cs *ChainStore) WriteAddrPrefixTx(txes []*DbTx) error

func (*ChainStore) WriteBeaconSlot

func (cs *ChainStore) WriteBeaconSlot(number, slot uint64) error

func (*ChainStore) WriteBitcoinHash

func (cs *ChainStore) WriteBitcoinHash(height uint64, hash string) error

func (*ChainStore) WriteBlockHeader

func (cs *ChainStore) WriteBlockHeader(hash string, header string) error

func (*ChainStore) WriteBtcBlock

func (cs *ChainStore) WriteBtcBlock(hash string, block string) error

func (*ChainStore) WriteBtcHeight

func (cs *ChainStore) WriteBtcHeight(height uint64) error

func (*ChainStore) WriteBtcTxHeight

func (cs *ChainStore) WriteBtcTxHeight(height uint64, txIds []string) error

func (*ChainStore) WriteBtcTxParam

func (cs *ChainStore) WriteBtcTxParam(txId string, param interface{}) error

func (*ChainStore) WriteChainFork

func (cs *ChainStore) WriteChainFork(chain string, forkInfo *ChainFork) error

func (*ChainStore) WriteCheckpoint

func (cs *ChainStore) WriteCheckpoint(height uint64, hash string) error

func (*ChainStore) WriteDbProof

func (cs *ChainStore) WriteDbProof(txes ...DbProof) error

func (*ChainStore) WriteDbTxes

func (cs *ChainStore) WriteDbTxes(txes ...*DbTx) error

func (*ChainStore) WriteDestHash

func (cs *ChainStore) WriteDestHash(key, value string) error

func (*ChainStore) WriteEthTxHeight

func (cs *ChainStore) WriteEthTxHeight(height uint64, dbTxIds []string) error

func (*ChainStore) WriteEthereumHeight

func (cs *ChainStore) WriteEthereumHeight(height uint64) error

func (*ChainStore) WriteFinalityUpdateSlot

func (cs *ChainStore) WriteFinalityUpdateSlot(finalizeSlot uint64) error

func (*ChainStore) WriteIcpSignature

func (cs *ChainStore) WriteIcpSignature(height uint64, value DbIcpSignature) error

func (*ChainStore) WriteLatestBeaconSlot

func (cs *ChainStore) WriteLatestBeaconSlot(slot uint64) error

func (*ChainStore) WriteLatestCheckpoint

func (cs *ChainStore) WriteLatestCheckpoint(height uint64) error

func (*ChainStore) WriteMaxGasPrice

func (cs *ChainStore) WriteMaxGasPrice(price uint64) error

func (*ChainStore) WriteMiner

func (cs *ChainStore) WriteMiner(addr string) error

func (*ChainStore) WriteMinerPower

func (cs *ChainStore) WriteMinerPower(addr string, power, timestamp uint64) error

func (*ChainStore) WriteNonce

func (cs *ChainStore) WriteNonce(network, addr string, nonce uint64) error

func (*ChainStore) WritePendingRequest

func (cs *ChainStore) WritePendingRequest(proofId string, request *common.ProofRequest) error

func (*ChainStore) WriteProofResponse

func (cs *ChainStore) WriteProofResponse(resp *common.SubmitProof) error

func (*ChainStore) WriteSubmitMaxValue

func (cs *ChainStore) WriteSubmitMaxValue(value uint64) error

func (*ChainStore) WriteSubmitMinValue

func (cs *ChainStore) WriteSubmitMinValue(value uint64) error

func (*ChainStore) WriteTxFinalizedSlot

func (cs *ChainStore) WriteTxFinalizedSlot(txSlot uint64, tx *DbUnGenProof) error

func (*ChainStore) WriteTxIdsByAddr

func (cs *ChainStore) WriteTxIdsByAddr(addr string, txes []DbTx) error

func (*ChainStore) WriteTxProved

func (cs *ChainStore) WriteTxProved(txIds []string, status bool) error

func (*ChainStore) WriteTxSlot

func (cs *ChainStore) WriteTxSlot(txSlot uint64, tx *DbUnGenProof) error

func (*ChainStore) WriteUnGenProof

func (cs *ChainStore) WriteUnGenProof(chain common.ChainType, list ...*DbUnGenProof) error

func (*ChainStore) WriteUnSubmitTx

func (cs *ChainStore) WriteUnSubmitTx(txes ...DbUnSubmitTx) error

func (*ChainStore) WriteUpdateUtxoDest

func (cs *ChainStore) WriteUpdateUtxoDest(hash, dest string) error

func (*ChainStore) WriteWorkerId

func (cs *ChainStore) WriteWorkerId(id string) error

func (*ChainStore) WriteZkParamVerify

func (cs *ChainStore) WriteZkParamVerify(verify bool) error

type Config

type Config struct {
	RunConfig
	BtcOperatorAddr       string        `json:"btcOperatorAddr"`
	BtcLockScript         string        `json:"btcLockScript"`
	GenesisSyncPeriod     uint64        `json:"genesisPeriod"`
	ZkBridgeAddr          string        `json:"zkBridgeAddr"`
	ZkBtcAddr             string        `json:"zkBtcAddr"`
	UtxoManagerAddr       string        `json:"utxoManagerAddr"`
	OasisSignerAddress    string        `json:"oasisSignerAddress"`
	IcpTxSingerAddress    string        `json:"icpTxSingerAddress"`
	IcpBlockSignerAddress string        `json:"icpBlockSignerAddress"`
	BtcTxVerifyAddr       string        `json:"txVerifyAddr"`
	EthAddrFilter         *EthFilter    `json:"ethAddrFilter"`
	BtcFilter             *BtcFilter    `json:"btcFilter"`
	EthScanTime           time.Duration `json:"ethScanTime"`
	BtcScanTime           time.Duration `json:"btcScanTime"`
	Debug                 bool
}

func NewConfig

func NewConfig(cfg RunConfig) (Config, error)

type Daemon

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

func NewDaemon

func NewDaemon(cfg Config) (*Daemon, error)

func (*Daemon) Close

func (d *Daemon) Close()

func (*Daemon) Init

func (d *Daemon) Init() error

func (*Daemon) Run

func (d *Daemon) Run() error

type DbIcpSignature

type DbIcpSignature struct {
	Signature string
	Hash      string
	Height    uint64
}

type DbMiner

type DbMiner struct {
	Miner     string
	Power     uint64
	Timestamp uint64
}

type DbProof

type DbProof struct {
	TxHash    string           `json:"txId"`
	ProofType common.ProofType `json:"type"`
	Status    int              `json:"status"`
	Proof     string           `json:"Proof"`
}

type DbTx

type DbTx struct {
	Height       uint64
	TxIndex      uint
	Hash         string
	BlockHash    string
	BlockTime    uint64
	TxType       common.TxType
	ChainType    common.ChainType
	ProofType    common.ProofType
	Proved       bool
	Amount       int64
	GenProofNums int

	// bitcoin chain
	EthAddr string

	// ethereum chain
	LogIndex  uint
	UtxoId    string
	UtxoIndex int64
	Sender    string
	Receiver  string

	TxSlot        uint64 `cbor:"omitzero"`
	FinalizedSlot uint64 `cbor:"omitzero"`

	// for btc
	CheckPointHeight uint64
	LatestHeight     uint64
	CpMinDepth       uint64
	SigSigned        bool // this flag is NOT read any where for now, turn its semantic to "SigNeeded"
}

func NewDepositBtcTx

func NewDepositBtcTx(height, txIndex, blockTime uint64, txId, ethAddr string, amount int64, proofed bool) *DbTx

func NewDepositEthTx

func NewDepositEthTx(height uint64, txIndex, logIndex uint, txHash, sender, utxoId string, utxoIndex, amount int64, blockTime uint64) *DbTx

func NewMigrateBtcTx

func NewMigrateBtcTx(height, txIndex, blockTime uint64, txId string, amount int64, proofed bool) *DbTx

func NewRedeemBtcTx

func NewRedeemBtcTx(height, txIndex, blockTime uint64, txId string, amount int64, proofed bool) *DbTx

func NewRedeemEthTx

func NewRedeemEthTx(height uint64, txIndex, logIndex uint, txHash, sender, btcTxId string, amount int64, blockTime uint64) *DbTx

func NewUpdateUtxoTx

func NewUpdateUtxoTx(height uint64, txIndex, logIndex uint, txHash, utxoId string, utxoIndex, amount int64, blockTime uint64) *DbTx

func (*DbTx) GenReset

func (t *DbTx) GenReset()

type DbUnGenProof

type DbUnGenProof struct {
	Hash      string
	ProofType common.ProofType
	ChainType common.ChainType
	Height    uint64
	TxIndex   uint
	Amount    uint64
}

type DbUnSubmitTx

type DbUnSubmitTx struct {
	Hash        string
	ProofType   common.ProofType
	Proof       string
	Timestamp   int64
	ConfirmHash string //
	Status      int
}

func NewDbUnSubmitTx

func NewDbUnSubmitTx(hash, proof string, proofType common.ProofType) DbUnSubmitTx

type DownloadStatus

type DownloadStatus int

type EthFilter

type EthFilter struct {
	UtxoManagerAddr string `json:"depositAddr"`
	ZkbtcBridgeAddr string `json:"redeemAddr"`

	DepositTxTopic  string `json:"depositTxTopic"`
	RedeemTxTopic   string `json:"redeemTxTopic"`
	UpdateUtxoTopic string `json:"updateUtxoTopic"`

	BtcLockScript string `json:"btcLockScript"`
	// contains filtered or unexported fields
}

func NewEthAddrFilter

func NewEthAddrFilter(btcLockScript, utxoManagerAddr, zkbtcBridgeAddr string,
	depositTxTopic, redeemTxTopic, updateUtxoTopic string,
	txMode common.TxMode) *EthFilter

func (*EthFilter) DepositTx

func (e *EthFilter) DepositTx(addr, topic string) bool

func (*EthFilter) FilterLogs

func (e *EthFilter) FilterLogs() (logFilters []string, topicFilters []string)

func (*EthFilter) MigrateTx

func (e *EthFilter) MigrateTx(outs []*wire.TxOut) bool

func (*EthFilter) RedeemTx

func (e *EthFilter) RedeemTx(addr, topic string) bool

func (*EthFilter) UpdateUtxo

func (e *EthFilter) UpdateUtxo(addr, topic string) bool

type Fetch

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

func NewFetch

func NewFetch(client beacon.IMultiBeacon, store store.IStore, fileStore *FileStorage, genesisSlot uint64, update, finalityUpate chan *Notify) (*Fetch, error)

func (*Fetch) Bootstrap

func (f *Fetch) Bootstrap()

func (*Fetch) CheckFinalityUpdate

func (f *Fetch) CheckFinalityUpdate(period uint64, finalityUpdate *common.LightClientFinalityUpdateEvent) (bool, error)

func (*Fetch) CheckLightClientUpdate

func (f *Fetch) CheckLightClientUpdate(period uint64, update *common.LightClientUpdateResponse) (bool, error)

func (*Fetch) Close

func (f *Fetch) Close() error

func (*Fetch) FinalityUpdate

func (f *Fetch) FinalityUpdate() error

func (*Fetch) GetFinalityUpdate

func (f *Fetch) GetFinalityUpdate() error

func (*Fetch) GetLightClientUpdate

func (f *Fetch) GetLightClientUpdate(period uint64)

func (*Fetch) Init

func (f *Fetch) Init() error

func (*Fetch) LightClientUpdate

func (f *Fetch) LightClientUpdate() error

func (*Fetch) StoreLatestPeriod

func (f *Fetch) StoreLatestPeriod() error

type FetchRequest

type FetchRequest struct {
	UpdateType FetchType
	Status     DownloadStatus
	// contains filtered or unexported fields
}

type FetchResponse

type FetchResponse struct {
	FetchId    string
	Index      uint64
	UpdateType FetchType
	// contains filtered or unexported fields
}

func NewFetchResponse

func NewFetchResponse(updateType FetchType, index uint64, data interface{}) *FetchResponse

func (*FetchResponse) Id

func (f *FetchResponse) Id() string

type FetchType

type FetchType int
const (
	GenesisUpdateType FetchType = iota + 1
	PeriodUpdateType
	FinalityUpdateType
)

func (FetchType) String

func (ft FetchType) String() string

type FileStorage

type FileStorage struct {
	RootPath string
	FileMaps *sync.Map // store.Table -> store.IFileStore
	// contains filtered or unexported fields
}

func NewFileStorage

func NewFileStorage(path string, genesisSlot, btcGenesisHeight uint64, tables ...store.Table) (*FileStorage, error)

func (*FileStorage) BtcBaseIndexes

func (fs *FileStorage) BtcBaseIndexes(start, height uint64) ([]uint64, error)

func (*FileStorage) BtcChainIndex

func (fs *FileStorage) BtcChainIndex(height uint64) (uint64, bool, error)

func (*FileStorage) BtcDepthIndex

func (fs *FileStorage) BtcDepthIndex(cpHeight, genesis, height uint64) (uint64, bool, error)

func (*FileStorage) BtcMiddleIndexes

func (fs *FileStorage) BtcMiddleIndexes(start, height uint64) ([]Index, error)

func (*FileStorage) CheckFinalityUpdate

func (fs *FileStorage) CheckFinalityUpdate(slot uint64) (bool, error)

func (*FileStorage) CheckObj

func (fs *FileStorage) CheckObj(table store.Table, key store.FileKey) (bool, error)

func (*FileStorage) CheckProof

func (fs *FileStorage) CheckProof(key StoreKey) (bool, error)

func (*FileStorage) CheckUpdate

func (fs *FileStorage) CheckUpdate(period uint64) (bool, error)

func (*FileStorage) Clear

func (fs *FileStorage) Clear() error

func (*FileStorage) CurrentBtcChainIndex

func (fs *FileStorage) CurrentBtcChainIndex() (*ChainIndex, bool, error)

func (*FileStorage) CurrentBtcCpDepthIndex

func (fs *FileStorage) CurrentBtcCpDepthIndex(cpHeight uint64) (*ChainIndex, bool, error)

func (*FileStorage) DelProof

func (fs *FileStorage) DelProof(key StoreKey) error

func (*FileStorage) FileStore

func (fs *FileStorage) FileStore(key StoreKey, create ...bool) (store.IFileStore, bool)

func (*FileStorage) FindBtcChainProof

func (fs *FileStorage) FindBtcChainProof(height uint64) (*WrapStorageProof, bool, error)

func (*FileStorage) FindDepthProof

func (fs *FileStorage) FindDepthProof(prefix, height uint64) (*WrapStorageProof, bool, error)

func (*FileStorage) GenOuterIndexes

func (fs *FileStorage) GenOuterIndexes() ([]uint64, error)

func (*FileStorage) Get

func (fs *FileStorage) Get(table store.Table, value interface{}, key ...interface{}) (bool, error)

func (*FileStorage) GetBackendRedeemProof

func (fs *FileStorage) GetBackendRedeemProof(txHash string) (*StoreProof, bool, error)

func (*FileStorage) GetBeaconHeaderProof

func (fs *FileStorage) GetBeaconHeaderProof(start, end uint64) (*StoreProof, bool, error)

func (*FileStorage) GetBhfProof

func (fs *FileStorage) GetBhfProof(period uint64) (*StoreProof, bool, error)

func (*FileStorage) GetBtcBaseProof

func (fs *FileStorage) GetBtcBaseProof(start, end uint64) (*StoreProof, bool, error)

func (*FileStorage) GetBtcBulkProof

func (fs *FileStorage) GetBtcBulkProof(index, end uint64) (*StoreProof, bool, error)

func (*FileStorage) GetBtcMiddleProof

func (fs *FileStorage) GetBtcMiddleProof(start, end uint64) (*StoreProof, bool, error)

func (*FileStorage) GetBtcTimestampProof

func (fs *FileStorage) GetBtcTimestampProof(txHeight, latestHeight uint64) (*StoreProof, bool, error)

func (*FileStorage) GetBtcUpperProof

func (fs *FileStorage) GetBtcUpperProof(start, end uint64) (*StoreProof, bool, error)

func (*FileStorage) GetDutyProof

func (fs *FileStorage) GetDutyProof(period uint64) (*StoreProof, bool, error)

func (*FileStorage) GetFileStore

func (fs *FileStorage) GetFileStore(table store.Table) (store.IFileStore, bool)

func (*FileStorage) GetFinalityUpdate

func (fs *FileStorage) GetFinalityUpdate(slot uint64, value interface{}) (bool, error)

func (*FileStorage) GetGenesisPeriod

func (fs *FileStorage) GetGenesisPeriod() uint64

func (*FileStorage) GetLatestFinalizedSlot

func (fs *FileStorage) GetLatestFinalizedSlot() (uint64, bool, error)

func (*FileStorage) GetLatestPeriod

func (fs *FileStorage) GetLatestPeriod() (uint64, bool, error)

func (*FileStorage) GetObj

func (fs *FileStorage) GetObj(table store.Table, key store.FileKey, value interface{}) (bool, error)

func (*FileStorage) GetOuterProof

func (fs *FileStorage) GetOuterProof(period uint64) (*StoreProof, bool, error)

func (*FileStorage) GetProof

func (fs *FileStorage) GetProof(key StoreKey) (*StoreProof, bool, error)

func (*FileStorage) GetRecursiveProof

func (fs *FileStorage) GetRecursiveProof(period uint64) (*StoreProof, bool, error)

func (*FileStorage) GetRedeemProof

func (fs *FileStorage) GetRedeemProof(txHash string) (*StoreProof, bool, error)

func (*FileStorage) GetRootPath

func (fs *FileStorage) GetRootPath() string

func (*FileStorage) GetSgxRedeemProof

func (fs *FileStorage) GetSgxRedeemProof(hash string) (*StoreProof, bool, error)

func (*FileStorage) GetSubFileStore

func (fs *FileStorage) GetSubFileStore(table, sub store.Table, create ...bool) (store.IFileStore, bool)

func (*FileStorage) GetSyncInnerProof

func (fs *FileStorage) GetSyncInnerProof(period, index uint64) (*StoreProof, bool, error)

func (*FileStorage) GetTxFinalizedSlot

func (fs *FileStorage) GetTxFinalizedSlot(txSlot uint64) (uint64, bool, error)

func (*FileStorage) GetTxProof

func (fs *FileStorage) GetTxProof(txHash string) (*StoreProof, bool, error)

func (*FileStorage) GetUnitProof

func (fs *FileStorage) GetUnitProof(period uint64) (*StoreProof, bool, error)

func (*FileStorage) GetUpdate

func (fs *FileStorage) GetUpdate(period uint64, value interface{}) (bool, error)

func (*FileStorage) NeedDutyIndexes

func (fs *FileStorage) NeedDutyIndexes() ([]uint64, error)

func (*FileStorage) NeedGenUnitProofIndexes

func (fs *FileStorage) NeedGenUnitProofIndexes() ([]uint64, error)

func (*FileStorage) NeedUpdateIndexes

func (fs *FileStorage) NeedUpdateIndexes() ([]uint64, error)

func (*FileStorage) RemoveBtcProof

func (fs *FileStorage) RemoveBtcProof(height uint64) error

func (*FileStorage) StoreErrorFinalityUpdate

func (fs *FileStorage) StoreErrorFinalityUpdate(key string, data interface{}) error

func (*FileStorage) StoreFinalityUpdate

func (fs *FileStorage) StoreFinalityUpdate(slot uint64, data interface{}) error

func (*FileStorage) StoreLatestFinalizedSlot

func (fs *FileStorage) StoreLatestFinalizedSlot(slot uint64) error

func (*FileStorage) StoreLatestPeriod

func (fs *FileStorage) StoreLatestPeriod(period uint64) error

func (*FileStorage) StoreObj

func (fs *FileStorage) StoreObj(table store.Table, key store.FileKey, value interface{}) error

func (*FileStorage) StoreProof

func (fs *FileStorage) StoreProof(key StoreKey, proof, witness []byte) error

func (*FileStorage) StoreRequest

func (fs *FileStorage) StoreRequest(req *common.ProofRequest, extraIds ...string) error

func (*FileStorage) StoreUpdate

func (fs *FileStorage) StoreUpdate(period uint64, value interface{}) error

func (*FileStorage) SyncComInnerIndexes

func (fs *FileStorage) SyncComInnerIndexes() ([]Index, error)

type Handler

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

func NewHandler

func NewHandler(txManager *TxManager, manager IManager, ethReScan, btcReScan chan *ReScnSignal, store store.IStore, fileStore *FileStorage, exitCh chan os.Signal,
	btcClient *bitcoin.Client, proverClient btcproverClient.IClient, miner, network string) *Handler

func (*Handler) AddP2pPeer

func (h *Handler) AddP2pPeer(addr string) (string, error)

func (*Handler) AddWorker

func (h *Handler) AddWorker(endpoint string, max int) (string, error)

func (*Handler) AutoSubmitMaxValue

func (h *Handler) AutoSubmitMaxValue(max uint64) (string, error)

func (*Handler) AutoSubmitMinValue

func (h *Handler) AutoSubmitMinValue(min uint64) (string, error)

func (*Handler) GetZkProofTask

func (h *Handler) GetZkProofTask(request common.TaskRequest) (*common.TaskResponse, error)

func (*Handler) MinerInfo

func (h *Handler) MinerInfo() ([]*rpc.MinerInfo, error)

func (*Handler) PendingTask

func (h *Handler) PendingTask() ([]*rpc.ProofTask, error)

func (*Handler) ProofInfo

func (h *Handler) ProofInfo(txIds []string) ([]rpc.ProofInfo, error)

func (*Handler) ReScan

func (h *Handler) ReScan(height uint64, chain string) error

func (*Handler) RemoveUnGenProof

func (h *Handler) RemoveUnGenProof(hash string) (string, error)

func (*Handler) RemoveUnSubmitTx

func (h *Handler) RemoveUnSubmitTx(hash string) (string, error)

func (*Handler) SetGasPrice

func (h *Handler) SetGasPrice(gasPrice uint64) (string, error)

func (*Handler) Stop

func (h *Handler) Stop() error

func (*Handler) SubmitProof

func (h *Handler) SubmitProof(req *common.SubmitProof) (string, error)

func (*Handler) Transaction

func (h *Handler) Transaction(txHash string) ([]*rpc.Transaction, error)

func (*Handler) Transactions

func (h *Handler) Transactions(txIds []string) ([]*rpc.Transaction, error)

func (*Handler) TransactionsByHeight

func (h *Handler) TransactionsByHeight(height uint64, network string) ([]string, error)

func (*Handler) Version

func (h *Handler) Version() (rpc.NodeInfo, error)

type IAgent

type IAgent interface {
	ScanBlock() error
	ReScan(height uint64) error
	ProofResponse(resp *common.ProofResponse) error
	Init() error
	CheckState() error
	Close() error
	Name() string
}

func NewBitcoinAgent

func NewBitcoinAgent(cfg Config, store store.IStore, btcProverClient *BtcClient, btcClient *bitcoin.Client, ethClient *ethereum.Client,
	dfinityClient *dfinity.Client, txManager *TxManager, chainFork chan *ChainFork, fileStore *FileStorage) (IAgent, error)

func NewEthereumAgent

func NewEthereumAgent(cfg Config, fileStore *FileStorage, store store.IStore, btcClient *bitcoin.Client,
	ethClient *ethrpc.Client, task *TxManager, chainFork chan *ChainFork) (IAgent, error)

type IFetch

type IFetch interface {
	Init() error
	Bootstrap()
	FinalityUpdate() error
	LightClientUpdate() error
	Close() error
}

type IManager

type IManager interface {
	IScheduler
	Init() error
	PendingProofRequest() []*common.ProofRequest
	CheckState() error
	GetProofRequest(proofTypes []common.ProofType) (*common.ProofRequest, bool, error)
	ReceiveProofs(submitProof *common.SubmitProof) error
	LibP2pMessage(msg *p2p.Msg) error
	MinerPower() error
	AddP2pPeer(addr string) error
	ChainFork(signal *ChainFork) error
	EthNotify() chan *Notify
	BtcNotify() chan *Notify
	BeaconNotify() chan *Notify
	Close() error
}

func NewManager

func NewManager(minerAddr string, libP2p *p2p.LibP2p, icpClient *dfinity.Client, btcClient *bitcoin.Client, ethClient *ethereum.Client, beaconClient *beacon.Client, prep *Prepared,
	btcProofResp, ethProofResp, syncCommitteeProofResp chan *common.ProofResponse, store store.IStore, fileStore *FileStorage,
	btcNotify, ethNotify, beaconNotify chan *Notify) (IManager, error)

type IScheduler

type IScheduler interface {
	CheckBtcState() error
	CheckEthState() error
	CheckCpUpdate() error
	CheckPreBtcState() error
	CheckBeaconState() error
	UpdateBtcCp() error
	StoreCompact() error
}

type Index

type Index struct {
	Prefix uint64
	Start  uint64
	End    uint64
}

type KeyStore

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

func NewKeyStore

func NewKeyStore(privateKey string) (*KeyStore, error)

func (*KeyStore) CheckPermission

func (k *KeyStore) CheckPermission(method string) (rpc.Permission, error)

func (*KeyStore) EthAddress

func (k *KeyStore) EthAddress() string

func (*KeyStore) GetPrivateKey

func (k *KeyStore) GetPrivateKey() ([]byte, error)

func (*KeyStore) VerifyJwt

func (k *KeyStore) VerifyJwt(token string) (*rpc.CustomClaims, error)

type LocalWorker

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

func (*LocalWorker) AddReqNum

func (w *LocalWorker) AddReqNum()

func (*LocalWorker) BackendRedeemProof

func (w *LocalWorker) BackendRedeemProof(req *rpc.RedeemRequest) (*rpc.RedeemResponse, error)

func (*LocalWorker) BlockHeaderFinalityProve

func (w *LocalWorker) BlockHeaderFinalityProve(req *rpc.BlockHeaderFinalityRequest) (*rpc.BlockHeaderFinalityResponse, error)

func (*LocalWorker) BlockHeaderProve

func (w *LocalWorker) BlockHeaderProve(req *rpc.BlockHeaderRequest) (*rpc.BlockHeaderResponse, error)

func (*LocalWorker) BtcBaseProve

func (w *LocalWorker) BtcBaseProve(req *rpc.BtcBaseRequest) (*rpc.ProofResponse, error)

func (*LocalWorker) BtcBulkProve

func (w *LocalWorker) BtcBulkProve(req *rpc.BtcBulkRequest) (*rpc.BtcBulkResponse, error)

func (*LocalWorker) BtcChainProve

func (w *LocalWorker) BtcChainProve(req *rpc.BtcChainRequest) (*rpc.ProofResponse, error)

func (*LocalWorker) BtcChangeProve

func (w *LocalWorker) BtcChangeProve(req *rpc.BtcChangeRequest) (*rpc.ProofResponse, error)

func (*LocalWorker) BtcDepositProve

func (w *LocalWorker) BtcDepositProve(req *rpc.BtcDepositRequest) (*rpc.ProofResponse, error)

func (*LocalWorker) BtcDepthRecursiveProve

func (w *LocalWorker) BtcDepthRecursiveProve(req *rpc.BtcDepthRecursiveRequest) (*rpc.ProofResponse, error)

func (*LocalWorker) BtcDuperRecursiveProve

func (w *LocalWorker) BtcDuperRecursiveProve(req *rpc.BtcDuperRecursiveRequest) (*rpc.ProofResponse, error)

func (*LocalWorker) BtcMiddleProve

func (w *LocalWorker) BtcMiddleProve(req *rpc.BtcMiddleRequest) (*rpc.ProofResponse, error)

func (*LocalWorker) BtcTimestamp

func (w *LocalWorker) BtcTimestamp(req *rpc.BtcTimestampRequest) (*rpc.ProofResponse, error)

func (*LocalWorker) BtcUpperProve

func (w *LocalWorker) BtcUpperProve(req *rpc.BtcUpperRequest) (*rpc.ProofResponse, error)

func (*LocalWorker) Close

func (w *LocalWorker) Close() error

func (*LocalWorker) CurrentNums

func (w *LocalWorker) CurrentNums() int

func (*LocalWorker) DelReqNum

func (w *LocalWorker) DelReqNum()

func (*LocalWorker) Id

func (w *LocalWorker) Id() string

func (*LocalWorker) MaxNums

func (w *LocalWorker) MaxNums() int

func (*LocalWorker) ProofInfo

func (w *LocalWorker) ProofInfo(proofId string) (rpc.ProofInfo, error)

func (*LocalWorker) RedeemProof

func (w *LocalWorker) RedeemProof(req *rpc.RedeemRequest) (*rpc.RedeemResponse, error)

func (*LocalWorker) SupportProofType

func (w *LocalWorker) SupportProofType() []common.ProofType

func (*LocalWorker) SyncCommDutyProve

func (w *LocalWorker) SyncCommDutyProve(req rpc.SyncCommDutyRequest) (*rpc.SyncCommDutyResponse, error)

func (*LocalWorker) SyncCommInner

func (w *LocalWorker) SyncCommInner(req *rpc.SyncCommInnerRequest) (*rpc.ProofResponse, error)

func (*LocalWorker) SyncCommOuter

func (w *LocalWorker) SyncCommOuter(req *rpc.SyncCommOuterRequest) (*rpc.ProofResponse, error)

func (*LocalWorker) SyncCommitUnitProve

func (w *LocalWorker) SyncCommitUnitProve(req rpc.SyncCommUnitsRequest) (*rpc.SyncCommUnitsResponse, error)

func (*LocalWorker) TxInEth2Prove

type Memguard

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

func NewMemguard

func NewMemguard() *Memguard

func (*Memguard) Check

func (m *Memguard) Check(key string) bool

func (*Memguard) Close

func (m *Memguard) Close()

func (*Memguard) Delete

func (m *Memguard) Delete(key string)

func (*Memguard) Load

func (m *Memguard) Load(key string) ([]byte, error)

func (*Memguard) Store

func (m *Memguard) Store(key string, value []byte)

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore(store store.IStore) *MemoryStore

func (*MemoryStore) FindFinalityUpdateNearestSlot

func (s *MemoryStore) FindFinalityUpdateNearestSlot(txSlot uint64) (uint64, bool, error)

func (*MemoryStore) WriteFinalityUpdateSlot

func (s *MemoryStore) WriteFinalityUpdateSlot(slot uint64) error

type MinerPower

type MinerPower struct {
	Address    string
	Power      uint64
	CreateTime time.Time
}

func NewMinerPower

func NewMinerPower(address string, power uint64, createTime time.Time) *MinerPower

func (*MinerPower) AddConstant

func (m *MinerPower) AddConstant(constant uint64)

func (*MinerPower) AvgConstantPerHour

func (m *MinerPower) AvgConstantPerHour() float64

type Mode

type Mode string
const (
	LiteMode Mode = "lite"
	FullMode Mode = "full"
)

type Notify

type Notify struct {
}

type PendingQueue

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

func NewPendingQueue

func NewPendingQueue() *PendingQueue

func (*PendingQueue) Add

func (q *PendingQueue) Add(key string, value *common.ProofRequest)

func (*PendingQueue) Delete

func (q *PendingQueue) Delete(key string)

func (*PendingQueue) Get

func (q *PendingQueue) Get(key string) (*common.ProofRequest, bool)

func (*PendingQueue) Iterator

func (q *PendingQueue) Iterator(fn func(value *common.ProofRequest) bool) []*common.ProofRequest

type Prepared

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

func NewPreparedData

func NewPreparedData(filestore *FileStorage, store store.IStore, genesisSlot, btcGenesisHeight uint64, proverClient *BtcClient, btcClient *btcrpc.Client,
	ethClient *ethrpc.Client, apiClient *apiclient.Client, beaconClient *beacon.Client, minerAddr, network string, scNewRecursive bool) (*Prepared, error)

func (*Prepared) GetBeaconHeaderId

func (p *Prepared) GetBeaconHeaderId(start, end uint64) ([]byte, []byte, error)

func (*Prepared) GetBhfUpdateRequest

func (p *Prepared) GetBhfUpdateRequest(finalizedSlot uint64) (*rpc.BlockHeaderFinalityRequest, bool, error)

func (*Prepared) GetBlockHeaderRequest

func (p *Prepared) GetBlockHeaderRequest(txSlot, finalizedSlot uint64) (*rpc.BlockHeaderRequest, bool, error)

func (*Prepared) GetBtcBaseRequest

func (p *Prepared) GetBtcBaseRequest(start, end uint64) (*rpc.BtcBaseRequest, bool, error)

func (*Prepared) GetBtcBulkRequest

func (p *Prepared) GetBtcBulkRequest(start, end, prefix uint64) (*rpc.BtcBulkRequest, error)

func (*Prepared) GetBtcChangeRequest

func (p *Prepared) GetBtcChangeRequest(hash string) (*rpc.BtcChangeRequest, bool, error)

func (*Prepared) GetBtcDepositRequest

func (p *Prepared) GetBtcDepositRequest(hash string) (*rpc.BtcDepositRequest, bool, error)

func (*Prepared) GetBtcDepthRecursiveRequest

func (p *Prepared) GetBtcDepthRecursiveRequest(prefix, start, end uint64, isCp bool) (*rpc.BtcDepthRecursiveRequest, bool, error)

func (*Prepared) GetBtcDuperRecursiveRequest

func (p *Prepared) GetBtcDuperRecursiveRequest(start, end uint64) (*rpc.BtcDuperRecursiveRequest, bool, error)

func (*Prepared) GetBtcMiddleRequest

func (p *Prepared) GetBtcMiddleRequest(start, end uint64) (*rpc.BtcMiddleRequest, bool, error)

func (*Prepared) GetBtcTimestampRequest

func (p *Prepared) GetBtcTimestampRequest(fIndex uint64, sIndex uint64) (*rpc.BtcTimestampRequest, bool, error)

func (*Prepared) GetBtcUpperRequest

func (p *Prepared) GetBtcUpperRequest(start, end uint64) (*rpc.BtcUpperRequest, bool, error)

func (*Prepared) GetDutyRequest

func (p *Prepared) GetDutyRequest(period uint64) (*rpc.SyncCommDutyRequest, bool, error)

func (*Prepared) GetRedeemRequest

func (p *Prepared) GetRedeemRequest(txHash string, txSlot, finalizedSlot uint64) (*rpc.RedeemRequest, bool, error)

func (*Prepared) GetSyncComInnerRequest

func (p *Prepared) GetSyncComInnerRequest(period, index uint64) (*rpc.SyncCommInnerRequest, bool, error)

func (*Prepared) GetSyncComUnitRequest

func (p *Prepared) GetSyncComUnitRequest(period uint64) (*rpc.SyncCommUnitsRequest, bool, error)

func (*Prepared) GetSyncCommitRootId

func (p *Prepared) GetSyncCommitRootId(period uint64) ([]byte, bool, error)

func (*Prepared) GetSyncCommitUpdate

func (p *Prepared) GetSyncCommitUpdate(period uint64) (*rpc.WrapSyncCommitteeUpdate, bool, error)

func (*Prepared) GetSyncCommittee

func (p *Prepared) GetSyncCommittee(period uint64) (*WrapSyncCommittee, bool, error)

func (*Prepared) GetSyncOuterRequest

func (p *Prepared) GetSyncOuterRequest(period uint64) (*rpc.SyncCommOuterRequest, bool, error)

func (*Prepared) GetTxInEth2Request

func (p *Prepared) GetTxInEth2Request(txHash string, txSlot uint64) (*rpc.TxInEth2ProveRequest, bool, error)

type ProofRespQueue

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

func NewProofRespQueue

func NewProofRespQueue() *ProofRespQueue

func (*ProofRespQueue) Delete

func (q *ProofRespQueue) Delete(key string)

func (*ProofRespQueue) Get

func (q *ProofRespQueue) Get(key string) (*common.SubmitProof, error)

func (*ProofRespQueue) Iterator

func (q *ProofRespQueue) Iterator(fn func(value *common.SubmitProof) error)

func (*ProofRespQueue) Push

func (q *ProofRespQueue) Push(value *common.SubmitProof)

type QueueManager

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

func NewQueueManager

func NewQueueManager() *QueueManager

func (*QueueManager) AddPending

func (q *QueueManager) AddPending(key string, value *common.ProofRequest)

func (*QueueManager) CheckId

func (q *QueueManager) CheckId(proofId string) bool

func (*QueueManager) DeleteId

func (q *QueueManager) DeleteId(proofId string)

func (*QueueManager) DeletePending

func (q *QueueManager) DeletePending(key string)

func (*QueueManager) FilterPending

func (q *QueueManager) FilterPending(fn func(value *common.ProofRequest) bool) []*common.ProofRequest

func (*QueueManager) FilterRequest

func (q *QueueManager) FilterRequest(fn func(value *common.ProofRequest) bool) []*common.ProofRequest

func (*QueueManager) GetPending

func (q *QueueManager) GetPending(key string) (*common.ProofRequest, bool)

func (*QueueManager) ListRequest

func (q *QueueManager) ListRequest() []*common.ProofRequest

func (*QueueManager) PopFnRequest

func (q *QueueManager) PopFnRequest(fn func(req *common.ProofRequest) bool) (*common.ProofRequest, bool)

func (*QueueManager) PopRequest

func (q *QueueManager) PopRequest() (*common.ProofRequest, bool)

func (*QueueManager) PushRequest

func (q *QueueManager) PushRequest(req *common.ProofRequest)

func (*QueueManager) RemoveRequest

func (q *QueueManager) RemoveRequest(fn func(value *common.ProofRequest) bool) []*common.ProofRequest

func (*QueueManager) RequestLen

func (q *QueueManager) RequestLen() int

func (*QueueManager) StoreId

func (q *QueueManager) StoreId(proofId string)

type ReScnSignal

type ReScnSignal struct {
	Height uint64
}

type RunConfig

type RunConfig struct {
	Datadir            string        `json:"datadir"`
	Rpcbind            string        `json:"rpcbind"`
	Rpcport            string        `json:"rpcport"`
	WsPort             string        `json:"wsport"`
	Network            string        `json:"network"`
	BtcUser            string        `json:"btcUser"`
	BtcPwd             string        `json:"btcPwd"`
	BtcUrl             []string      `json:"btcUrl"`
	EthUrl             string        `json:"ethUrl"`
	BeaconUrl          []string      `json:"beaconUrl"`
	OasisUrl           string        `json:"oasisUrl"`
	SgxUrl             []string      `json:"sgxUrl"`
	DiscordHookUrl     string        `json:"discordHookUrl"`
	ScNewRecursive     bool          `json:"scNewRecursive"`
	IcpWalletAddress   string        `json:"icpWalletAddress"`
	IcpPrivateKey      string        `json:"icpPrivateKey"`
	Mode               Mode          `json:"mode"`
	MinerAddr          string        `json:"minerAddr"`
	BtcReScan          bool          `json:"btcReScan"`
	EthReScan          bool          `json:"ethReScan"`
	TxMode             common.TxMode `json:"txMode"`
	BeaconReScan       bool          `json:"beaconReScan"`
	EthPrivateKey      string        `json:"ethPrivateKey"`
	EnableLocalWorker  bool          `json:"enableLocalWorker"`
	BtcInitHeight      uint64        `json:"btcInitHeight"`
	EthInitHeight      uint64        `json:"ethInitHeight"`
	BeaconInitSlot     uint64        `json:"beaconInitSlot"`
	GenesisBeaconSlot  uint64        `json:"genesisBeaconSlot"`
	BtcGenesisHeight   uint64        `json:"btcGenesisHeight"`
	BtcCpBlockHeight   int64         `json:"btcCpBlockHeight"`
	DisableBtcAgent    bool          `json:"disableBtcAgent"`
	DisableEthAgent    bool          `json:"disableEthAgent"`
	DisableBeaconAgent bool          `json:"disableBeaconAgent"`
	BtcMainnetPath     string        `json:"btcMainnetPath"`

	DisableLipP2p bool     `json:"disableLipP2p"`
	BtcSetupDir   string   `json:"btcSetupDir"`
	EthSetupDir   string   `json:"ethSetupDir"`
	DisableFetch  bool     `json:"disableFetch"`
	P2pPort       int      `json:"p2pPort"`
	P2pBootstraps []string `json:"p2pBootstraps"`
}

func (*RunConfig) Check

func (rc *RunConfig) Check() error

type Scheduler

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

func NewScheduler

func NewScheduler(filestore *FileStorage, store store.IStore, preparedData *Prepared,
	icpClient *dfinity.Client, btcClient *bitcoin.Client, ethClient *ethereum.Client, beaconClient *beacon.Client) (*Scheduler, error)

func (*Scheduler) CheckBeaconState

func (s *Scheduler) CheckBeaconState() error

func (*Scheduler) CheckBtcState

func (s *Scheduler) CheckBtcState() error

func (*Scheduler) CheckEthState

func (s *Scheduler) CheckEthState() error

func (*Scheduler) CheckPreBtcState

func (s *Scheduler) CheckPreBtcState() error

func (*Scheduler) GetPendingRequest

func (s *Scheduler) GetPendingRequest(proofId string) (*common.ProofRequest, bool)

func (*Scheduler) Locks

func (s *Scheduler) Locks() func()

func (*Scheduler) PendingProofRequest

func (s *Scheduler) PendingProofRequest() []*common.ProofRequest

func (*Scheduler) PendingRequest

func (s *Scheduler) PendingRequest() []*common.ProofRequest

func (*Scheduler) UpdateProofStatus

func (s *Scheduler) UpdateProofStatus(req *common.ProofRequest, status common.ProofStatus) error

type SigRes

type SigRes struct {
	Index int
	Sigs  [][]byte
}

type SignFn

type SignFn struct {
	Index int
	Sign  func(currentScRoot, ethTxHash, btcTxId, proof string, sigHashes []string, minerReward *big.Int) ([][]byte, error)
}

type StoreKey

type StoreKey struct {
	PType          common.ProofType
	Hash           string
	FIndex, SIndex uint64
	Prefix         uint64

	BlockTime uint64
	TxIndex   uint32
	// contains filtered or unexported fields
}

func NewDoubleStoreKey

func NewDoubleStoreKey(proofType common.ProofType, fIndex, sIndex uint64) StoreKey

func NewHashStoreKey

func NewHashStoreKey(proofType common.ProofType, hash string) StoreKey

func NewHeightStoreKey

func NewHeightStoreKey(proofType common.ProofType, height uint64) StoreKey

func NewPrefixStoreKey

func NewPrefixStoreKey(proofType common.ProofType, prefix, fIndex, sIndex uint64) StoreKey

func NewStoreKey

func NewStoreKey(proofType common.ProofType, hash string, prefix, fIndex, sIndex uint64) StoreKey

func (*StoreKey) FileKey

func (sk *StoreKey) FileKey() store.FileKey

func (*StoreKey) ProofId

func (sk *StoreKey) ProofId() string

type StoreProof

type StoreProof struct {
	Id        string `json:"id"`
	ProofType string `json:"type"`
	Proof     string `json:"proof"`
	Witness   string `json:"witness"`
}

type SubmitQueue

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

func NewSubmitQueue

func NewSubmitQueue() *SubmitQueue

func (*SubmitQueue) Delete

func (q *SubmitQueue) Delete(key string)

func (*SubmitQueue) Get

func (q *SubmitQueue) Get(key string) (*common.ProofResponse, error)

func (*SubmitQueue) Iterator

func (q *SubmitQueue) Iterator(fn func(value *common.ProofResponse) error)

func (*SubmitQueue) Push

func (q *SubmitQueue) Push(value *common.ProofResponse)

type TxManager

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

func NewTxManager

func NewTxManager(store store.IStore, fileStore *FileStorage, prepared *Prepared, keyStore *KeyStore, ethClient *ethrpc.Client, btcClient *bitcoin.Client,
	oasisClient *oasis.Client, dfinityClient *dfinity.Client, sgxClient sgx.ISgx, proverClient btcproverClient.IClient, minerAddr, network string) (*TxManager, error)

func (*TxManager) AddTask

func (t *TxManager) AddTask(resp *common.ProofResponse)

func (*TxManager) Check

func (t *TxManager) Check() error

func (*TxManager) CheckEthBalance

func (t *TxManager) CheckEthBalance(addr string, gasPrice *big.Int, gasLimit uint64) (bool, error)

func (*TxManager) Close

func (t *TxManager) Close() error

func (*TxManager) DepositBtc

func (t *TxManager) DepositBtc(tx DbUnSubmitTx) (string, error)

func (*TxManager) RedeemZkbtc

func (t *TxManager) RedeemZkbtc(hash, proof string) (string, error)

func (*TxManager) SignerBtc

func (t *TxManager) SignerBtc(currentScRoot, ethTxHash, btcTxId, proof string, sigHashes []string, minerReward *big.Int) ([][][]byte, error)

func (*TxManager) UpdateUtxoChange

func (t *TxManager) UpdateUtxoChange(tx DbUnSubmitTx) (string, error)

type UniqueList

type UniqueList struct {
	Ids []string
	Map map[string]bool
}

func NewUniqueList

func NewUniqueList() *UniqueList

func (*UniqueList) Add

func (ul *UniqueList) Add(value string)

func (*UniqueList) List

func (ul *UniqueList) List() []string

type Worker

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

func NewWorker

func NewWorker(client rpc.IProof, parallelNums int) *Worker

func (*Worker) AddReqNum

func (w *Worker) AddReqNum()

func (*Worker) BackendRedeemProof

func (w *Worker) BackendRedeemProof(req *rpc.RedeemRequest) (*rpc.RedeemResponse, error)

func (*Worker) BlockHeaderFinalityProve

func (w *Worker) BlockHeaderFinalityProve(req *rpc.BlockHeaderFinalityRequest) (*rpc.BlockHeaderFinalityResponse, error)

func (*Worker) BlockHeaderProve

func (w *Worker) BlockHeaderProve(req *rpc.BlockHeaderRequest) (*rpc.BlockHeaderResponse, error)

func (*Worker) BtcBaseProve

func (w *Worker) BtcBaseProve(req *rpc.BtcBaseRequest) (*rpc.ProofResponse, error)

func (*Worker) BtcBulkProve

func (w *Worker) BtcBulkProve(req *rpc.BtcBulkRequest) (*rpc.BtcBulkResponse, error)

func (*Worker) BtcChangeProve

func (w *Worker) BtcChangeProve(req *rpc.BtcChangeRequest) (*rpc.ProofResponse, error)

func (*Worker) BtcDepositProve

func (w *Worker) BtcDepositProve(req *rpc.BtcDepositRequest) (*rpc.ProofResponse, error)

func (*Worker) BtcDepthRecursiveProve

func (w *Worker) BtcDepthRecursiveProve(req *rpc.BtcDepthRecursiveRequest) (*rpc.ProofResponse, error)

func (*Worker) BtcDuperRecursiveProve

func (w *Worker) BtcDuperRecursiveProve(req *rpc.BtcDuperRecursiveRequest) (*rpc.ProofResponse, error)

func (*Worker) BtcMiddleProve

func (w *Worker) BtcMiddleProve(req *rpc.BtcMiddleRequest) (*rpc.ProofResponse, error)

func (*Worker) BtcTimestamp

func (w *Worker) BtcTimestamp(req *rpc.BtcTimestampRequest) (*rpc.ProofResponse, error)

func (*Worker) BtcUpperProve

func (w *Worker) BtcUpperProve(req *rpc.BtcUpperRequest) (*rpc.ProofResponse, error)

func (*Worker) Close

func (w *Worker) Close() error

func (*Worker) CurrentNums

func (w *Worker) CurrentNums() int

func (*Worker) DelReqNum

func (w *Worker) DelReqNum()

func (*Worker) Id

func (w *Worker) Id() string

func (*Worker) MaxNums

func (w *Worker) MaxNums() int

func (*Worker) ProofInfo

func (w *Worker) ProofInfo(proofId string) (rpc.ProofInfo, error)

func (*Worker) RedeemProof

func (w *Worker) RedeemProof(req *rpc.RedeemRequest) (*rpc.RedeemResponse, error)

func (*Worker) SupportProofType

func (w *Worker) SupportProofType() []common.ProofType

func (*Worker) SyncCommDutyProve

func (w *Worker) SyncCommDutyProve(req rpc.SyncCommDutyRequest) (*rpc.SyncCommDutyResponse, error)

func (*Worker) SyncCommInner

func (w *Worker) SyncCommInner(req *rpc.SyncCommInnerRequest) (*rpc.ProofResponse, error)

func (*Worker) SyncCommOuter

func (w *Worker) SyncCommOuter(req *rpc.SyncCommOuterRequest) (*rpc.ProofResponse, error)

func (*Worker) SyncCommitUnitProve

func (w *Worker) SyncCommitUnitProve(req rpc.SyncCommUnitsRequest) (*rpc.SyncCommUnitsResponse, error)

func (*Worker) TxInEth2Prove

func (w *Worker) TxInEth2Prove(req *rpc.TxInEth2ProveRequest) (*rpc.TxInEth2ProveResponse, error)

type WorkerConfig

type WorkerConfig struct {
	MaxNums int    `json:"maxNums"`
	Url     string `json:"url"`
}

type WrapStorageProof

type WrapStorageProof struct {
	StoreProof
	ChainIndex
}

type WrapSyncCommittee

type WrapSyncCommittee struct {
	*proverType.SyncCommittee
	Version string
}

type WrapperAgent

type WrapperAgent struct {
	IAgent
	// contains filtered or unexported fields
}

func NewWrapperAgent

func NewWrapperAgent(agent IAgent, scanTime time.Duration, reScan chan *ReScnSignal, proofResp chan *common.ProofResponse) *WrapperAgent

type WrapperManger

type WrapperManger struct {
	IManager
	// contains filtered or unexported fields
}

func NewWrapperManger

func NewWrapperManger(manager IManager, request chan *ChainFork) *WrapperManger

type ZkParams

type ZkParams struct {
	*zkbridge.IBtcTxVerifierPublicWitnessParams
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL