Documentation ¶
Overview ¶
Package sc implements an auxiliary blockchain called Service Chain.
Service Chains in Kaia are auxiliary blockchains independent from the Kaia main chain. They mostly act like normal Kaia blockchains but has additional features to connect them to another Kaia network. They can be used as separate public/private blockchains or child chains of a Kaia chain (or another Service Chain). The followings describe main features of Service chain.
- Anchoring block data of Service Chain
- Value Transfer (KAIA, KCT)
- Various bridge contract configurations
- Support high availability
Service Chain provides the inter-connectivity to another Kaia chain through two bridges, MainBridge and SubBridge. Each bridge has a bridge contract on different blockchain networks and pairs up with another bridge to interact with. They are directly connected on the network layer and communicate with each other through p2p messages enabling inter-chain operations.
MainBridge is configured on the node of a parent chain and SubBridge is configured on the node of a child chain. Both of a Kaia chain and a Service Chain can be a parent chain, but only a Service Chain can be a child chain. The block data of a child chain can be anchored to the bridge contract of MainBridge with the chain data anchoring transaction.
Unlike the block data anchoring, user data transfer is bi-directional. For example, users can transfer KAIA of Kaia main chain to an address of a Service Chain or vice versa. This kind of inter-chain operation requires read/write ability on both chains but does not use MainBridge functions in the process. Instead of the MainBridge, the SubBridge in the child chain directly calls read/write operations to the parent chain node through RPC (In the basic configuration, the parent chain node is the same with the MainBridge enabled node). Of course, the accounts of both chains should be registered on the SubBridge to generate transactions. Following is the process of the KAIA transfer from Kaia main chain to a Service Chain. 1. A user executes the inter-chain operation by sending a transaction with KAIA to the bridge contract of Kaia main chain. 2. The bridge contract keeps KAIA on its account and creates an event for the inter-chain request. 3. The SubBridge subscribes the event log on the main chain node through RPC. 4. The SubBridge generates a transaction on the child chain node to the bridge contract of the SubBridge. 5. Finally, The bridge contract mints (or uses its KAIA) and sends KAIA to the target address.
Source Files ¶
Functions and variables related to Service Chain are defined in the files listed below.
- api_bridge.go : provides APIs for MainBridge or SubBridge.
- bridge_accounts.go : generates inter-chain transactions between a parent chain and a child chain.
- bridge_addr_journal.go : provides a journal mechanism for bridge addresses to provide the persistence service.
- bridge_manager.go : handles the bridge information and manages the bridge operations.
- bridgepeer.go : implements data structures of p2p peers used for Service Chain bridges.
- config.go : provides configurations of Service Chain nodes.
- gen_config.go : provides marshalling and unmarshalling functions of the Service Chain configuration.
- local_backend.go : provides read/write operations for the child chain block data.
- main_bridge_handler.go : implements a p2p message handler of MainBridge.
- main_event_handler.go : implements a event handler of MainBridge.
- mainbridge.go : implements MainBridge of the parent chain node.
- metrics.go : contains metrics used for sc package.
- protocol.go : defines protocols of Service Chain.
- remote_backend.go : provides read/write RPC calls for the parent chain block data.
- sub_bridge_handler.go : implements a p2p message handler of SubBridge.
- sub_event_handler.go : implements a event handler of SubBridge.
- subbridge.go : implements SubBridge of the child chain node.
- vt_recovery.go : provides recovery from the service failure for inter-chain value transfer.
Copyright 2024 The Kaia Authors This file is part of the Kaia library.
The Kaia library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Kaia library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Kaia library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2024 The Kaia Authors This file is part of the Kaia library.
The Kaia library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Kaia library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Kaia library. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func CreateDB(ctx *node.ServiceContext, config *SCConfig, name string) database.DBManager
- func GetURI(ev IRequestValueTransferEvent) string
- func InitializeBridgeAccountKeystore(keystorePath string) (*keystore.KeyStore, common.Address, bool, error)
- func NewRpcClientP2P(sb *SubBridge) *rpc.Client
- func NewValueTransferRecovery(config *SCConfig, cBridgeInfo, pBridgeInfo *BridgeInfo) *valueTransferRecovery
- func UnpackEncodedData(ver uint8, packed []byte) map[string]interface{}
- type Backend
- type BridgeAccounts
- func (ba *BridgeAccounts) GetBridgeOperators() map[string]interface{}
- func (ba *BridgeAccounts) GetChildBridgeOperatorGasLimit() uint64
- func (ba *BridgeAccounts) GetChildOperatorFeePayer() common.Address
- func (ba *BridgeAccounts) GetParentBridgeOperatorGasLimit() uint64
- func (ba *BridgeAccounts) GetParentGasPrice() uint64
- func (ba *BridgeAccounts) GetParentKIP71Config() params.KIP71Config
- func (ba *BridgeAccounts) GetParentOperatorFeePayer() common.Address
- func (ba *BridgeAccounts) SetChildBridgeOperatorGasLimit(fee uint64)
- func (ba *BridgeAccounts) SetChildOperatorFeePayer(feePayer common.Address) error
- func (ba *BridgeAccounts) SetParentBridgeOperatorGasLimit(fee uint64)
- func (ba *BridgeAccounts) SetParentKIP71Config(kip71Config params.KIP71Config)
- func (ba *BridgeAccounts) SetParentOperatorFeePayer(feePayer common.Address) error
- type BridgeInfo
- func (bi *BridgeInfo) AddRequestValueTransferEvents(evs []IRequestValueTransferEvent)
- func (bi *BridgeInfo) DeregisterToken(token, counterpartToken common.Address) error
- func (bi *BridgeInfo) GetCounterPartToken(token common.Address) common.Address
- func (bi *BridgeInfo) GetCurrentBlockNumber() (uint64, error)
- func (bi *BridgeInfo) GetPendingRequestEvents() []IRequestValueTransferEvent
- func (bi *BridgeInfo) GetReadyRequestValueTransferEvents() []IRequestValueTransferEvent
- func (bi *BridgeInfo) MarkHandledNonce(nonce uint64)
- func (bi *BridgeInfo) RegisterToken(token, counterpartToken common.Address) error
- func (bi *BridgeInfo) SetHandleNonce(nonce uint64)
- func (bi *BridgeInfo) SetRequestNonce(nonce uint64)
- func (bi *BridgeInfo) SetRequestNonceFromCounterpart(nonce uint64)
- func (bi *BridgeInfo) UpdateInfo() error
- func (bi *BridgeInfo) UpdateLowerHandleNonce(nonce uint64)
- type BridgeJournal
- type BridgeManager
- func (bm *BridgeManager) AddRecovery(localAddress, remoteAddress common.Address) error
- func (bm *BridgeManager) DeleteBridgeInfo(addr common.Address) error
- func (bm *BridgeManager) DeleteRecovery(localAddress, remoteAddress common.Address) error
- func (bm *BridgeManager) DeployBridge(auth *bind.TransactOpts, backend bind.ContractBackend, local bool) (*bridgecontract.Bridge, common.Address, error)
- func (bm *BridgeManager) GetAllBridge() []*BridgeJournal
- func (bm *BridgeManager) GetBridge(bridgeAlias string) *BridgeJournal
- func (bm *BridgeManager) GetBridgeInfo(addr common.Address) (*BridgeInfo, bool)
- func (bm *BridgeManager) GetCounterPartBridge(bridgeAddr common.Address) *bridgecontract.Bridge
- func (bm *BridgeManager) GetCounterPartBridgeAddr(bridgeAddr common.Address) common.Address
- func (bm *BridgeManager) GetERC20Fee(bridgeAddr, tokenAddr common.Address) (*big.Int, error)
- func (bm *BridgeManager) GetFeeReceiver(bridgeAddr common.Address) (common.Address, error)
- func (bm *BridgeManager) GetKLAYFee(bridgeAddr common.Address) (*big.Int, error)
- func (bm *BridgeManager) GetOperators(bridgeAddr common.Address) ([]common.Address, error)
- func (bm *BridgeManager) GetValueTransferOperatorThreshold(bridgeAddr common.Address) (uint8, error)
- func (bm *BridgeManager) IsInChildAddrs(bridgeAddr common.Address) bool
- func (bm *BridgeManager) IsInParentAddrs(bridgeAddr common.Address) bool
- func (bm *BridgeManager) IsValidBridgePair(bridge1, bridge2 common.Address) bool
- func (bm *BridgeManager) LogBridgeStatus()
- func (bm *BridgeManager) RegisterOperator(bridgeAddr, operatorAddr common.Address) (common.Hash, error)
- func (bm *BridgeManager) ResetAllSubscribedEvents() error
- func (bm *BridgeManager) RestoreBridges() error
- func (bm *BridgeManager) SetBridgeInfo(addr common.Address, bridge *bridgecontract.Bridge, cpAddr common.Address, ...) error
- func (bm *BridgeManager) SetERC20Fee(bridgeAddr, tokenAddr common.Address, fee *big.Int) (common.Hash, error)
- func (bm *BridgeManager) SetFeeReceiver(bridgeAddr, receiver common.Address) (common.Hash, error)
- func (bm *BridgeManager) SetJournal(bridgeAlias string, localAddress, remoteAddress common.Address) error
- func (bm *BridgeManager) SetKLAYFee(bridgeAddr common.Address, fee *big.Int) (common.Hash, error)
- func (bm *BridgeManager) SetValueTransferOperatorThreshold(bridgeAddr common.Address, threshold uint8) (common.Hash, error)
- func (bm *BridgeManager) Stop()
- func (bm *BridgeManager) SubscribeEvent(addr common.Address) error
- func (bm *BridgeManager) SubscribeHandleVTev(ch chan<- *HandleValueTransferEvent) event.Subscription
- func (bm *BridgeManager) SubscribeReqVTencodedEv(ch chan<- RequestValueTransferEncodedEvent) event.Subscription
- func (bm *BridgeManager) SubscribeReqVTev(ch chan<- RequestValueTransferEvent) event.Subscription
- func (bm *BridgeManager) UnsubscribeEvent(addr common.Address)
- type BridgePeer
- type BridgePeerInfo
- type BridgeTxPool
- type ChildChainEventHandler
- func (cce *ChildChainEventHandler) ConvertChildChainBlockHashToParentChainTxHash(scBlockHash common.Hash) common.Hash
- func (cce *ChildChainEventHandler) HandleChainHeadEvent(block *types.Block) error
- func (cce *ChildChainEventHandler) HandleLogsEvent(logs []*types.Log) error
- func (cce *ChildChainEventHandler) HandleTxEvent(tx *types.Transaction) error
- func (cce *ChildChainEventHandler) HandleTxsEvent(txs []*types.Transaction) error
- func (cce *ChildChainEventHandler) ProcessHandleEvent(ev *HandleValueTransferEvent) error
- func (cce *ChildChainEventHandler) ProcessRequestEvent(ev IRequestValueTransferEvent) error
- type HandleValueTransferEvent
- type IRequestValueTransferEvent
- type InvalidParentChainTx
- type MainBridge
- func (mb *MainBridge) APIs() []rpc.API
- func (mb *MainBridge) AccountManager() *accounts.Manager
- func (mb *MainBridge) BridgePeerSet() *bridgePeerSet
- func (mb *MainBridge) ChainDB() database.DBManager
- func (mb *MainBridge) Components() []interface{}
- func (mb *MainBridge) EventMux() *event.TypeMux
- func (mb *MainBridge) IsListening() bool
- func (mb *MainBridge) NetVersion() uint64
- func (mb *MainBridge) NodeInfo() *MainBridgeInfo
- func (mb *MainBridge) ProtocolVersion() int
- func (mb *MainBridge) Protocols() []p2p.Protocol
- func (mb *MainBridge) SCProtocol() SCProtocol
- func (mb *MainBridge) SendRPCResponseData(data []byte) error
- func (mb *MainBridge) SetComponents(components []interface{})
- func (mb *MainBridge) Start(srvr p2p.Server) error
- func (mb *MainBridge) Stop() error
- type MainBridgeAPI
- type MainBridgeHandler
- type MainBridgeInfo
- type MainChainEventHandler
- func (mce *MainChainEventHandler) ConvertChildChainBlockHashToParentChainTxHash(scBlockHash common.Hash) common.Hash
- func (mce *MainChainEventHandler) GetChildChainIndexingEnabled() bool
- func (mce *MainChainEventHandler) GetLastIndexedBlockNumber() uint64
- func (mce *MainChainEventHandler) HandleChainHeadEvent(block *types.Block) error
- func (mce *MainChainEventHandler) HandleLogsEvent(logs []*types.Log) error
- func (mce *MainChainEventHandler) HandleTxEvent(tx *types.Transaction) error
- func (mce *MainChainEventHandler) HandleTxsEvent(txs []*types.Transaction) error
- func (mce *MainChainEventHandler) WriteLastIndexedBlockNumber(blockNum uint64)
- type PeerSetManager
- type RemoteBackend
- func (rb *RemoteBackend) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
- func (rb *RemoteBackend) CallContract(ctx context.Context, call kaia.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (rb *RemoteBackend) ChainID(ctx context.Context) (*big.Int, error)
- func (rb *RemoteBackend) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
- func (rb *RemoteBackend) CurrentBlockNumber(ctx context.Context) (uint64, error)
- func (rb *RemoteBackend) EstimateGas(ctx context.Context, msg kaia.CallMsg) (uint64, error)
- func (rb *RemoteBackend) FilterLogs(ctx context.Context, query kaia.FilterQuery) (result []types.Log, err error)
- func (rb *RemoteBackend) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error)
- func (rb *RemoteBackend) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (rb *RemoteBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (rb *RemoteBackend) SubscribeFilterLogs(ctx context.Context, query kaia.FilterQuery, ch chan<- types.Log) (kaia.Subscription, error)
- func (rb *RemoteBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (rb *RemoteBackend) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- func (rb *RemoteBackend) TransactionReceiptRpcOutput(ctx context.Context, txHash common.Hash) (r map[string]interface{}, err error)
- type RemoteBackendInterface
- type RequestValueTransferEncodedEvent
- func (rEv RequestValueTransferEncodedEvent) GetExtraData() []byte
- func (rEv RequestValueTransferEncodedEvent) GetFee() *big.Int
- func (rEv RequestValueTransferEncodedEvent) GetFrom() common.Address
- func (rEv RequestValueTransferEncodedEvent) GetRaw() types.Log
- func (rEv RequestValueTransferEncodedEvent) GetRequestNonce() uint64
- func (rEv RequestValueTransferEncodedEvent) GetTo() common.Address
- func (rEv RequestValueTransferEncodedEvent) GetTokenAddress() common.Address
- func (rEv RequestValueTransferEncodedEvent) GetTokenType() uint8
- func (rEv RequestValueTransferEncodedEvent) GetValueOrTokenId() *big.Int
- func (rEv RequestValueTransferEncodedEvent) Nonce() uint64
- type RequestValueTransferEvent
- func (rEv RequestValueTransferEvent) GetExtraData() []byte
- func (rEv RequestValueTransferEvent) GetFee() *big.Int
- func (rEv RequestValueTransferEvent) GetFrom() common.Address
- func (rEv RequestValueTransferEvent) GetRaw() types.Log
- func (rEv RequestValueTransferEvent) GetRequestNonce() uint64
- func (rEv RequestValueTransferEvent) GetTo() common.Address
- func (rEv RequestValueTransferEvent) GetTokenAddress() common.Address
- func (rEv RequestValueTransferEvent) GetTokenType() uint8
- func (rEv RequestValueTransferEvent) GetValueOrTokenId() *big.Int
- func (rEv RequestValueTransferEvent) Nonce() uint64
- type SCConfig
- type SCProtocol
- type SubBridge
- func (sb *SubBridge) APIs() []rpc.API
- func (sb *SubBridge) AccountManager() *accounts.Manager
- func (sb *SubBridge) BridgePeerSet() *bridgePeerSet
- func (sb *SubBridge) ChainDB() database.DBManager
- func (sb *SubBridge) Components() []interface{}
- func (sb *SubBridge) EventMux() *event.TypeMux
- func (sb *SubBridge) GetAnchoringTx() bool
- func (sb *SubBridge) GetBridgeTxPool() BridgeTxPool
- func (sb *SubBridge) IsListening() bool
- func (sb *SubBridge) NetVersion() uint64
- func (sb *SubBridge) NodeInfo() *SubBridgeInfo
- func (sb *SubBridge) ProtocolVersion() int
- func (sb *SubBridge) Protocols() []p2p.Protocol
- func (sb *SubBridge) SCProtocol() SCProtocol
- func (sb *SubBridge) SendRPCData(data []byte) error
- func (sb *SubBridge) SetAnchoringTx(flag bool) bool
- func (sb *SubBridge) SetComponents(components []interface{})
- func (sb *SubBridge) SetRPCConn(conn net.Conn)
- func (sb *SubBridge) Start(srvr p2p.Server) error
- func (sb *SubBridge) Stop() error
- type SubBridgeAPI
- func (sb *SubBridgeAPI) AddPeer(url string) (bool, error)
- func (sb *SubBridgeAPI) Anchoring(flag bool) bool
- func (sb *SubBridgeAPI) ChangeBridgeAlias(oldAlias, newAlias string) error
- func (sb *SubBridgeAPI) ConvertChildChainBlockHashToParentChainTxHash(cBlockHash common.Hash) common.Hash
- func (sb *SubBridgeAPI) ConvertRequestTxHashToHandleTxHash(hash common.Hash) common.Hash
- func (sb *SubBridgeAPI) DeployBridge() ([]common.Address, error)
- func (sb *SubBridgeAPI) DeregisterBridge(cBridgeAddrOrAlias, pBridgeAddrOrEmpty *string) error
- func (sb *SubBridgeAPI) DeregisterToken(cBridgeAddrOrAlias, pBridgeOrChildToken, cTokenAddrOrPtokenAddr, ... *string) error
- func (sb *SubBridgeAPI) GetAnchoring() bool
- func (sb *SubBridgeAPI) GetAnchoringPeriod() uint64
- func (sb *SubBridgeAPI) GetAnchoringTxHashByBlockNumber(bn uint64) common.Hash
- func (sb *SubBridgeAPI) GetBridgeInformation(bridgeAddr common.Address) (map[string]interface{}, error)
- func (sb *SubBridgeAPI) GetBridgePairByAlias(bridgeAlias string) *BridgeJournal
- func (sb *SubBridgeAPI) GetChildBridgeContractBalance(addr common.Address) (*big.Int, error)
- func (sb *SubBridgeAPI) GetChildBridgeOperatorGasLimit() uint64
- func (sb *SubBridgeAPI) GetChildOperatorAddr() common.Address
- func (sb *SubBridgeAPI) GetChildOperatorBalance() (*big.Int, error)
- func (sb *SubBridgeAPI) GetChildOperatorFeePayer() common.Address
- func (sb *SubBridgeAPI) GetChildOperatorNonce() uint64
- func (sb *SubBridgeAPI) GetERC20Fee(bridgeAddr, tokenAddr common.Address) (*big.Int, error)
- func (sb *SubBridgeAPI) GetFeeReceiver(bridgeAddr common.Address) (common.Address, error)
- func (sb *SubBridgeAPI) GetKLAYFee(bridgeAddr common.Address) (*big.Int, error)
- func (sb *SubBridgeAPI) GetLatestAnchoredBlockNumber() uint64
- func (sb *SubBridgeAPI) GetOperators() map[string]interface{}
- func (sb *SubBridgeAPI) GetParentBridgeContractBalance(addr common.Address) (*big.Int, error)
- func (sb *SubBridgeAPI) GetParentBridgeOperatorGasLimit() uint64
- func (sb *SubBridgeAPI) GetParentGasPrice() uint64
- func (sb *SubBridgeAPI) GetParentKIP71Config() params.KIP71Config
- func (sb *SubBridgeAPI) GetParentOperatorAddr() common.Address
- func (sb *SubBridgeAPI) GetParentOperatorBalance() (*big.Int, error)
- func (sb *SubBridgeAPI) GetParentOperatorFeePayer() common.Address
- func (sb *SubBridgeAPI) GetParentOperatorNonce() uint64
- func (sb *SubBridgeAPI) GetParentTransactionReceipt(txHash common.Hash) (map[string]interface{}, error)
- func (sb *SubBridgeAPI) GetReceiptFromParentChain(blockHash common.Hash) *types.Receipt
- func (sb *SubBridgeAPI) GetRegisteredOperators(bridgeAddr common.Address) ([]common.Address, error)
- func (sb *SubBridgeAPI) GetSentChainTxsLimit() uint64
- func (sb *SubBridgeAPI) GetValueTransferOperatorThreshold(bridgeAddr common.Address) (uint8, error)
- func (sb *SubBridgeAPI) KASAnchor(blkNum uint64) error
- func (sb *SubBridgeAPI) ListBridge() []*BridgeJournal
- func (sb *SubBridgeAPI) LockChildOperator() error
- func (sb *SubBridgeAPI) LockParentOperator() error
- func (sb *SubBridgeAPI) NodeInfo() (*p2p.NodeInfo, error)
- func (sb *SubBridgeAPI) Peers() ([]*p2p.PeerInfo, error)
- func (sb *SubBridgeAPI) RegisterBridge(cBridgeAddr, pBridgeAddr common.Address, bridgeAliasP *string) error
- func (sb *SubBridgeAPI) RegisterOperator(bridgeAddr, operatorAddr common.Address) (common.Hash, error)
- func (sb *SubBridgeAPI) RegisterToken(cBridgeAddrOrAlias, pBridgeOrChildToken, cTokenAddrOrPtokenAddr, ... *string) error
- func (sb *SubBridgeAPI) RemovePeer(url string) (bool, error)
- func (sb *SubBridgeAPI) RequestParentSync()
- func (sb *SubBridgeAPI) SetChildBridgeOperatorGasLimit(fee uint64)
- func (sb *SubBridgeAPI) SetChildOperatorFeePayer(feePayer common.Address) error
- func (sb *SubBridgeAPI) SetERC20Fee(bridgeAddr, tokenAddr common.Address, fee *big.Int) (common.Hash, error)
- func (sb *SubBridgeAPI) SetFeeReceiver(bridgeAddr, receiver common.Address) (common.Hash, error)
- func (sb *SubBridgeAPI) SetKLAYFee(bridgeAddr common.Address, fee *big.Int) (common.Hash, error)
- func (sb *SubBridgeAPI) SetParentBridgeOperatorGasLimit(fee uint64)
- func (sb *SubBridgeAPI) SetParentOperatorFeePayer(feePayer common.Address) error
- func (sb *SubBridgeAPI) SetValueTransferOperatorThreshold(bridgeAddr common.Address, threshold uint8) (common.Hash, error)
- func (sb *SubBridgeAPI) SubscribeBridge(cBridgeAddrOrAlias, pBridgeAddrOrEmpty *string) error
- func (sb *SubBridgeAPI) TxPending() map[common.Address]types.Transactions
- func (sb *SubBridgeAPI) TxPendingCount() int
- func (sb *SubBridgeAPI) UnlockChildOperator(passphrase string, duration *uint64) error
- func (sb *SubBridgeAPI) UnlockParentOperator(passphrase string, duration *uint64) error
- func (sb *SubBridgeAPI) UnsubscribeBridge(cBridgeAddrOrAlias, pBridgeAddrOrEmpty *string) error
- type SubBridgeHandler
- func (sbh *SubBridgeHandler) GetAnchoringPeriod() uint64
- func (sbh *SubBridgeHandler) GetChildOperatorAddr() *common.Address
- func (sbh *SubBridgeHandler) GetLatestAnchoredBlockNumber() uint64
- func (sbh *SubBridgeHandler) GetParentOperatorAddr() *common.Address
- func (sbh *SubBridgeHandler) GetReceiptFromParentChain(blockHash common.Hash) *types.Receipt
- func (sbh *SubBridgeHandler) GetSentChainTxsLimit() uint64
- func (sbh *SubBridgeHandler) HandleMainMsg(p BridgePeer, msg p2p.Msg) error
- func (sbh *SubBridgeHandler) LocalChainHeadEvent(block *types.Block)
- func (sbh *SubBridgeHandler) LockParentOperator()
- func (sbh *SubBridgeHandler) RegisterNewPeer(p BridgePeer) error
- func (scpm *SubBridgeHandler) SyncNonceAndGasPrice()
- func (sbh *SubBridgeHandler) UnLockParentOperator()
- func (sbh *SubBridgeHandler) UpdateLatestTxCountAddedBlockNumber(newLatestAnchoredBN uint64)
- func (sbh *SubBridgeHandler) WriteAnchoredBlockNumber(blockNum uint64)
- func (sbh *SubBridgeHandler) WriteReceiptFromParentChain(blockHash common.Hash, receipt *types.Receipt)
- type SubBridgeInfo
Constants ¶
const ( ParentOperatorStr = "parentOperator" ChildOperatorStr = "childOperator" ParentBridgeAccountName = "parent_bridge_account" ChildBridgeAccountName = "child_bridge_account" )
const ( TokenEventChanSize = 10000 BridgeAddrJournal = "bridge_addrs.rlp" )
const ( KAIA uint8 = iota ERC20 ERC721 )
const ( // Protocol messages belonging to servicechain/1 StatusMsg = 0x00 // Below message can be deprecated. ServiceChainTxsMsg = 0x01 ServiceChainReceiptResponseMsg = 0x02 ServiceChainReceiptRequestMsg = 0x03 ServiceChainParentChainInfoResponseMsg = 0x04 ServiceChainParentChainInfoRequestMsg = 0x05 ServiceChainCall = 0x06 ServiceChainResponse = 0x07 ServiceChainNotify = 0x08 ServiceChainInvalidTxResponseMsg = 0x09 )
const ( ErrMsgTooLarge = iota ErrDecode ErrInvalidMsgCode ErrProtocolVersionMismatch ErrNetworkIdMismatch ErrNoStatusMsg ErrUnexpectedTxType )
const ProtocolMaxMsgSize = 12 * 1024 * 1024 // Maximum cap on the size of a protocol message
const (
SyncRequestInterval = 10
)
Variables ¶
var ( ErrInvalidBridgePair = errors.New("Invalid bridge pair") ErrBridgeContractVersionMismatch = errors.New("Bridge contract version mismatch") )
var ( ErrNoActiveAddressJournal = errors.New("no active address journal") ErrDuplicatedJournal = errors.New("duplicated journal is inserted") ErrDuplicatedAlias = errors.New("duplicated alias") ErrEmptyBridgeAddress = errors.New("empty bridge address is not allowed") ErrEmptyJournalCache = errors.New("empty bridge journal") ErrEmptyBridgeAlias = errors.New("empty bridge Alias") ErrNotAllowedAliasFormat = errors.New("Not allowed bridge alias format") )
var ( ErrInvalidTokenPair = errors.New("invalid token pair") ErrNoBridgeInfo = errors.New("bridge information does not exist") ErrDuplicatedBridgeInfo = errors.New("bridge information is duplicated") ErrDuplicatedToken = errors.New("token is duplicated") ErrNoRecovery = errors.New("recovery does not exist") ErrAlreadySubscribed = errors.New("already subscribed") ErrBridgeRestore = errors.New("restoring bridges is failed") ErrBridgeAliasFormatDecode = errors.New("failed to decode alias-format bridge") )
var ( SCProtocolName = "servicechain" SCProtocolVersion = []uint{2} SCProtocolLength = []uint64{10} )
var ( ErrInvalidBlock = errors.New("block is invalid") ErrUnknownBridgeContractAddr = errors.New("The given address was not found in the bridge contract list") )
var ( ErrVtrDisabled = errors.New("VTR is disabled") ErrVtrAlreadyStarted = errors.New("VTR is already started") )
var ErrGetServiceChainPHInCCEH = errors.New("ServiceChainPH isn't set in ChildChainEventHandler")
var ErrGetServiceChainPHInMCEH = errors.New("ServiceChainPH isn't set in MainChainEventHandler")
var ErrRPCDecode = errors.New("failed to decode mainbridge rpc call message")
var ErrUnknownEvent = errors.New("Unknown event type")
var NoParentPeerErr = errors.New("no parent peer")
var RequestValueTransferEncodeABIs = map[uint]string{
2: `[{
"anonymous":false,
"inputs": [{
"name": "uri",
"type": "string"
}],
"name": "packedURI",
"type": "event"
}]`,
}
Functions ¶
func GetURI ¶
func GetURI(ev IRequestValueTransferEvent) string
func InitializeBridgeAccountKeystore ¶
func InitializeBridgeAccountKeystore(keystorePath string) (*keystore.KeyStore, common.Address, bool, error)
InitializeBridgeAccountKeystore initializes a keystore, imports existing keys, and tries to unlock the bridge account. This returns the 1st account of the wallet, its address, the lock status and the error.
func NewRpcClientP2P ¶
func NewValueTransferRecovery ¶
func NewValueTransferRecovery(config *SCConfig, cBridgeInfo, pBridgeInfo *BridgeInfo) *valueTransferRecovery
NewValueTransferRecovery creates a new value transfer recovery structure.
func UnpackEncodedData ¶
Types ¶
type Backend ¶
type Backend interface { bind.ContractBackend CurrentBlockNumber(context.Context) (uint64, error) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error) }
Backend wraps all methods for local and remote backend
type BridgeAccounts ¶
type BridgeAccounts struct {
// contains filtered or unexported fields
}
BridgeAccounts manages bridge account for parent/child chain.
func NewBridgeAccounts ¶
func NewBridgeAccounts(am *accounts.Manager, dataDir string, db feePayerDB, parentOperatorGaslimit, childOperatorGaslimit uint64) (*BridgeAccounts, error)
NewBridgeAccounts returns bridgeAccounts created by main/service bridge account keys.
func (*BridgeAccounts) GetBridgeOperators ¶
func (ba *BridgeAccounts) GetBridgeOperators() map[string]interface{}
GetBridgeOperators returns the information of bridgeOperator.
func (*BridgeAccounts) GetChildBridgeOperatorGasLimit ¶
func (ba *BridgeAccounts) GetChildBridgeOperatorGasLimit() uint64
GetChildBridgeOperatorGasLimit gets value of GasLimit of child operator.
func (*BridgeAccounts) GetChildOperatorFeePayer ¶
func (ba *BridgeAccounts) GetChildOperatorFeePayer() common.Address
GetChildOperatorFeePayer can return the fee payer of child operator.
func (*BridgeAccounts) GetParentBridgeOperatorGasLimit ¶
func (ba *BridgeAccounts) GetParentBridgeOperatorGasLimit() uint64
GetParentBridgeOperatorGasLimit gets value of GasLimit of parent operator.
func (*BridgeAccounts) GetParentGasPrice ¶
func (ba *BridgeAccounts) GetParentGasPrice() uint64
GetParentGasPrice returns the parent chain's gas price.
func (*BridgeAccounts) GetParentKIP71Config ¶
func (ba *BridgeAccounts) GetParentKIP71Config() params.KIP71Config
func (*BridgeAccounts) GetParentOperatorFeePayer ¶
func (ba *BridgeAccounts) GetParentOperatorFeePayer() common.Address
GetParentOperatorFeePayer can return the fee payer of parent operator.
func (*BridgeAccounts) SetChildBridgeOperatorGasLimit ¶
func (ba *BridgeAccounts) SetChildBridgeOperatorGasLimit(fee uint64)
SetChildBridgeOperatorGasLimit changes GasLimit of child operator.
func (*BridgeAccounts) SetChildOperatorFeePayer ¶
func (ba *BridgeAccounts) SetChildOperatorFeePayer(feePayer common.Address) error
SetChildOperatorFeePayer can set the fee payer of child operator.
func (*BridgeAccounts) SetParentBridgeOperatorGasLimit ¶
func (ba *BridgeAccounts) SetParentBridgeOperatorGasLimit(fee uint64)
SetParentBridgeOperatorGasLimit changes GasLimit of parent operator.
func (*BridgeAccounts) SetParentKIP71Config ¶
func (ba *BridgeAccounts) SetParentKIP71Config(kip71Config params.KIP71Config)
func (*BridgeAccounts) SetParentOperatorFeePayer ¶
func (ba *BridgeAccounts) SetParentOperatorFeePayer(feePayer common.Address) error
SetParentOperatorFeePayer can set the fee payer of parent operator.
type BridgeInfo ¶
type BridgeInfo struct {
// contains filtered or unexported fields
}
func NewBridgeInfo ¶
func NewBridgeInfo(sb *SubBridge, addr common.Address, bridge *bridgecontract.Bridge, cpAddr common.Address, cpBridge *bridgecontract.Bridge, account *accountInfo, local, subscribed bool, cpBackend Backend) (*BridgeInfo, error)
func (*BridgeInfo) AddRequestValueTransferEvents ¶
func (bi *BridgeInfo) AddRequestValueTransferEvents(evs []IRequestValueTransferEvent)
AddRequestValueTransferEvents adds events into the pendingRequestEvent.
func (*BridgeInfo) DeregisterToken ¶
func (bi *BridgeInfo) DeregisterToken(token, counterpartToken common.Address) error
func (*BridgeInfo) GetCounterPartToken ¶
func (bi *BridgeInfo) GetCounterPartToken(token common.Address) common.Address
func (*BridgeInfo) GetCurrentBlockNumber ¶
func (bi *BridgeInfo) GetCurrentBlockNumber() (uint64, error)
GetCurrentBlockNumber returns a current block number for each local and remote backend.
func (*BridgeInfo) GetPendingRequestEvents ¶
func (bi *BridgeInfo) GetPendingRequestEvents() []IRequestValueTransferEvent
func (*BridgeInfo) GetReadyRequestValueTransferEvents ¶
func (bi *BridgeInfo) GetReadyRequestValueTransferEvents() []IRequestValueTransferEvent
GetReadyRequestValueTransferEvents returns the processable events with the increasing nonce.
func (*BridgeInfo) MarkHandledNonce ¶
func (bi *BridgeInfo) MarkHandledNonce(nonce uint64)
MarkHandledNonce marks the handled nonce and sets the handle nonce value.
func (*BridgeInfo) RegisterToken ¶
func (bi *BridgeInfo) RegisterToken(token, counterpartToken common.Address) error
func (*BridgeInfo) SetHandleNonce ¶
func (bi *BridgeInfo) SetHandleNonce(nonce uint64)
SetHandleNonce sets the handled nonce with a new nonce.
func (*BridgeInfo) SetRequestNonce ¶
func (bi *BridgeInfo) SetRequestNonce(nonce uint64)
SetRequestNonce sets the request nonce of the bridge.
func (*BridgeInfo) SetRequestNonceFromCounterpart ¶
func (bi *BridgeInfo) SetRequestNonceFromCounterpart(nonce uint64)
SetRequestNonceFromCounterpart sets the request nonce from counterpart bridge.
func (*BridgeInfo) UpdateInfo ¶
func (bi *BridgeInfo) UpdateInfo() error
func (*BridgeInfo) UpdateLowerHandleNonce ¶
func (bi *BridgeInfo) UpdateLowerHandleNonce(nonce uint64)
UpdateLowerHandleNonce updates the lower handle nonce.
type BridgeJournal ¶
type BridgeJournal struct { BridgeAlias string `json:"bridgeAlias"` ChildAddress common.Address `json:"childAddress"` ParentAddress common.Address `json:"parentAddress"` Subscribed bool `json:"subscribed"` // contains filtered or unexported fields }
type BridgeManager ¶
type BridgeManager struct {
// contains filtered or unexported fields
}
BridgeManager manages Bridge SmartContracts for value transfer between child chain and parent chain
func NewBridgeManager ¶
func NewBridgeManager(main *SubBridge) (*BridgeManager, error)
func (*BridgeManager) AddRecovery ¶
func (bm *BridgeManager) AddRecovery(localAddress, remoteAddress common.Address) error
AddRecovery starts value transfer recovery for a given addresses pair.
func (*BridgeManager) DeleteBridgeInfo ¶
func (bm *BridgeManager) DeleteBridgeInfo(addr common.Address) error
DeleteBridgeInfo deletes the bridge info of the specified address.
func (*BridgeManager) DeleteRecovery ¶
func (bm *BridgeManager) DeleteRecovery(localAddress, remoteAddress common.Address) error
DeleteRecovery deletes the journal and stop the value transfer recovery for a given address pair.
func (*BridgeManager) DeployBridge ¶
func (bm *BridgeManager) DeployBridge(auth *bind.TransactOpts, backend bind.ContractBackend, local bool) (*bridgecontract.Bridge, common.Address, error)
Deploy Bridge SmartContract on same node or remote node
func (*BridgeManager) GetAllBridge ¶
func (bm *BridgeManager) GetAllBridge() []*BridgeJournal
GetAllBridge returns a slice of journal cache.
func (*BridgeManager) GetBridge ¶
func (bm *BridgeManager) GetBridge(bridgeAlias string) *BridgeJournal
GetBridge returns bridge journal structure that contains local(child) and remote(parent) addresses.
func (*BridgeManager) GetBridgeInfo ¶
func (bm *BridgeManager) GetBridgeInfo(addr common.Address) (*BridgeInfo, bool)
GetBridgeInfo returns bridge contract of the specified address.
func (*BridgeManager) GetCounterPartBridge ¶
func (bm *BridgeManager) GetCounterPartBridge(bridgeAddr common.Address) *bridgecontract.Bridge
func (*BridgeManager) GetCounterPartBridgeAddr ¶
func (bm *BridgeManager) GetCounterPartBridgeAddr(bridgeAddr common.Address) common.Address
func (*BridgeManager) GetERC20Fee ¶
GetERC20Fee returns the ERC20 transfer fee on the bridge contract.
func (*BridgeManager) GetFeeReceiver ¶
GetFeeReceiver returns the receiver which can get fee of value transfer request.
func (*BridgeManager) GetKLAYFee ¶
GetKLAYFee returns the KAIA transfer fee on the bridge contract.
func (*BridgeManager) GetOperators ¶
func (*BridgeManager) GetValueTransferOperatorThreshold ¶
func (bm *BridgeManager) GetValueTransferOperatorThreshold(bridgeAddr common.Address) (uint8, error)
func (*BridgeManager) IsInChildAddrs ¶
func (bm *BridgeManager) IsInChildAddrs(bridgeAddr common.Address) bool
IsInChildAddrs returns true if the bridgeAddr is in the list of child bridge addresses and returns false if not.
func (*BridgeManager) IsInParentAddrs ¶
func (bm *BridgeManager) IsInParentAddrs(bridgeAddr common.Address) bool
IsInParentAddrs returns true if the bridgeAddr is in the list of parent bridge addresses and returns false if not.
func (*BridgeManager) IsValidBridgePair ¶
func (bm *BridgeManager) IsValidBridgePair(bridge1, bridge2 common.Address) bool
func (*BridgeManager) LogBridgeStatus ¶
func (bm *BridgeManager) LogBridgeStatus()
LogBridgeStatus logs the bridge contract requested/handled nonce status as an information.
func (*BridgeManager) RegisterOperator ¶
func (*BridgeManager) ResetAllSubscribedEvents ¶
func (bm *BridgeManager) ResetAllSubscribedEvents() error
resetAllSubscribedEvents resets watch logs and recreates a goroutine loop to handle event messages.
func (*BridgeManager) RestoreBridges ¶
func (bm *BridgeManager) RestoreBridges() error
RestoreBridges setups bridge subscription by using the journal cache.
func (*BridgeManager) SetBridgeInfo ¶
func (bm *BridgeManager) SetBridgeInfo(addr common.Address, bridge *bridgecontract.Bridge, cpAddr common.Address, cpBridge *bridgecontract.Bridge, account *accountInfo, local bool, subscribed bool) error
SetBridgeInfo stores the address and bridge pair with local/remote and subscription status.
func (*BridgeManager) SetERC20Fee ¶
func (bm *BridgeManager) SetERC20Fee(bridgeAddr, tokenAddr common.Address, fee *big.Int) (common.Hash, error)
SetERC20Fee set the ERC20 transfer fee on the bridge contract.
func (*BridgeManager) SetFeeReceiver ¶
SetFeeReceiver set the fee receiver which can get the fee of value transfer request.
func (*BridgeManager) SetJournal ¶
func (bm *BridgeManager) SetJournal(bridgeAlias string, localAddress, remoteAddress common.Address) error
SetJournal inserts or updates journal for a given addresses pair.
func (*BridgeManager) SetKLAYFee ¶
SetKLAYFee set the KAIA transfer fee on the bridge contract.
func (*BridgeManager) SetValueTransferOperatorThreshold ¶
func (*BridgeManager) Stop ¶
func (bm *BridgeManager) Stop()
Stop closes a subscribed event scope of the bridge manager.
func (*BridgeManager) SubscribeEvent ¶
func (bm *BridgeManager) SubscribeEvent(addr common.Address) error
SubscribeEvent registers a subscription of BridgeERC20Received and BridgeTokenWithdrawn
func (*BridgeManager) SubscribeHandleVTev ¶
func (bm *BridgeManager) SubscribeHandleVTev(ch chan<- *HandleValueTransferEvent) event.Subscription
SubscribeHandleVTev registers a subscription of HandleValueTransferEvent.
func (*BridgeManager) SubscribeReqVTencodedEv ¶
func (bm *BridgeManager) SubscribeReqVTencodedEv(ch chan<- RequestValueTransferEncodedEvent) event.Subscription
SubscribeReqVTencodedEv registers a subscription of RequestValueTransferEncoded.
func (*BridgeManager) SubscribeReqVTev ¶
func (bm *BridgeManager) SubscribeReqVTev(ch chan<- RequestValueTransferEvent) event.Subscription
SubscribeReqVTev registers a subscription of RequestValueTransferEvent.
func (*BridgeManager) UnsubscribeEvent ¶
func (bm *BridgeManager) UnsubscribeEvent(addr common.Address)
UnsubscribeEvent cancels the contract's watch logs and initializes the status.
type BridgePeer ¶
type BridgePeer interface { // Close signals the broadcast goroutine to terminate. Close() // Info gathers and returns a collection of metadata known about a peer. Info() *BridgePeerInfo Head() (hash common.Hash, td *big.Int) // AddToKnownTxs adds a transaction hash to knownTxsCache for the peer, ensuring that it // will never be propagated to this particular peer. AddToKnownTxs(hash common.Hash) // Send writes an RLP-encoded message with the given code. // data should have been encoded as an RLP list. Send(msgcode uint64, data interface{}) error // Handshake executes the Kaia protocol handshake, negotiating version number, // network IDs, difficulties, head, genesis blocks, and onChildChain(if the node is on child chain for the peer) // and returning if the peer on the same chain or not and error. Handshake(network uint64, chainID, td *big.Int, head common.Hash) error // ConnType returns the conntype of the peer. ConnType() common.ConnType // GetID returns the id of the peer. GetID() string // GetP2PPeerID returns the id of the p2p.Peer. GetP2PPeerID() discover.NodeID // GetChainID returns the chain id of the peer. GetChainID() *big.Int // GetAddr returns the address of the peer. GetAddr() common.Address // SetAddr sets the address of the peer. SetAddr(addr common.Address) // GetVersion returns the version of the peer. GetVersion() int // KnowsTx returns if the peer is known to have the transaction, based on knownTxsCache. KnowsTx(hash common.Hash) bool // GetP2PPeer returns the p2p. GetP2PPeer() *p2p.Peer // GetRW returns the MsgReadWriter of the peer. GetRW() p2p.MsgReadWriter // Handle is the callback invoked to manage the life cycle of a Kaia Peer. When // this function terminates, the Peer is disconnected. Handle(bn *MainBridge) error SendRequestRPC(data []byte) error SendResponseRPC(data []byte) error // SendServiceChainTxs sends child chain tx data to from child chain to parent chain. SendServiceChainTxs(txs types.Transactions) error // SendServiceChainInfoRequest sends a parentChainInfo request from child chain to parent chain. SendServiceChainInfoRequest(addr *common.Address) error // SendServiceChainInfoResponse sends a parentChainInfo from parent chain to child chain. // parentChainInfo includes nonce of an account and gasPrice in the parent chain. SendServiceChainInfoResponse(pcInfo *parentChainInfo) error // SendServiceChainReceiptRequest sends a receipt request from child chain to parent chain. SendServiceChainReceiptRequest(txHashes []common.Hash) error // SendServiceChainReceiptResponse sends a receipt as a response to request from child chain. SendServiceChainReceiptResponse(receipts []*types.ReceiptForStorage) error // SendServiceChainInvalidTxResponse sends a response that contains list of invalid tx and error from parent chain. SendServiceChainInvalidTxResponse(invalidTxs []InvalidParentChainTx) error }
type BridgePeerInfo ¶
type BridgePeerInfo struct { Version int `json:"version"` // Kaia Bridge protocol version negotiated Head string `json:"head"` // SHA3 hash of the peer's best owned block }
BridgePeerInfo represents a short summary of the Kaia Bridge sub-protocol metadata known about a connected peer.
type BridgeTxPool ¶
type BridgeTxPool interface { GetMaxTxNonce(from *common.Address) uint64 AddLocal(tx *types.Transaction) error Stats() int Pending() map[common.Address]types.Transactions Get(hash common.Hash) *types.Transaction RemoveTx(tx *types.Transaction) error PendingTxHashesByAddress(from *common.Address, limit int) []common.Hash PendingTxsByAddress(from *common.Address, limit int) types.Transactions Stop() }
type ChildChainEventHandler ¶
type ChildChainEventHandler struct {
// contains filtered or unexported fields
}
func NewChildChainEventHandler ¶
func NewChildChainEventHandler(bridge *SubBridge, handler *SubBridgeHandler) (*ChildChainEventHandler, error)
func (*ChildChainEventHandler) ConvertChildChainBlockHashToParentChainTxHash ¶
func (cce *ChildChainEventHandler) ConvertChildChainBlockHashToParentChainTxHash(scBlockHash common.Hash) common.Hash
ConvertChildChainBlockHashToParentChainTxHash returns a transaction hash of a transaction which contains AnchoringData, with the key made with given child chain block hash. Index is built when child chain indexing is enabled.
func (*ChildChainEventHandler) HandleChainHeadEvent ¶
func (cce *ChildChainEventHandler) HandleChainHeadEvent(block *types.Block) error
func (*ChildChainEventHandler) HandleLogsEvent ¶
func (cce *ChildChainEventHandler) HandleLogsEvent(logs []*types.Log) error
func (*ChildChainEventHandler) HandleTxEvent ¶
func (cce *ChildChainEventHandler) HandleTxEvent(tx *types.Transaction) error
func (*ChildChainEventHandler) HandleTxsEvent ¶
func (cce *ChildChainEventHandler) HandleTxsEvent(txs []*types.Transaction) error
func (*ChildChainEventHandler) ProcessHandleEvent ¶
func (cce *ChildChainEventHandler) ProcessHandleEvent(ev *HandleValueTransferEvent) error
func (*ChildChainEventHandler) ProcessRequestEvent ¶
func (cce *ChildChainEventHandler) ProcessRequestEvent(ev IRequestValueTransferEvent) error
type HandleValueTransferEvent ¶
type HandleValueTransferEvent struct {
*bridgecontract.BridgeHandleValueTransfer
}
HandleValueTransferEvent from Bridge contract
type InvalidParentChainTx ¶
type MainBridge ¶
type MainBridge struct { APIBackend *MainBridgeAPI // contains filtered or unexported fields }
MainBridge implements the main bridge of service chain.
func NewMainBridge ¶
func NewMainBridge(ctx *node.ServiceContext, config *SCConfig) (*MainBridge, error)
NewMainBridge creates a new MainBridge object (including the initialisation of the common MainBridge object)
func (*MainBridge) APIs ¶
func (mb *MainBridge) APIs() []rpc.API
APIs returns the collection of RPC services the Kaia sc package offers. NOTE, some of these services probably need to be moved to somewhere else.
func (*MainBridge) AccountManager ¶
func (mb *MainBridge) AccountManager() *accounts.Manager
func (*MainBridge) BridgePeerSet ¶
func (mb *MainBridge) BridgePeerSet() *bridgePeerSet
BridgePeerSet implements PeerSetManager
func (*MainBridge) ChainDB ¶
func (mb *MainBridge) ChainDB() database.DBManager
func (*MainBridge) Components ¶
func (mb *MainBridge) Components() []interface{}
func (*MainBridge) EventMux ¶
func (mb *MainBridge) EventMux() *event.TypeMux
func (*MainBridge) IsListening ¶
func (mb *MainBridge) IsListening() bool
func (*MainBridge) NetVersion ¶
func (mb *MainBridge) NetVersion() uint64
func (*MainBridge) NodeInfo ¶
func (mb *MainBridge) NodeInfo() *MainBridgeInfo
NodeInfo retrieves some protocol metadata about the running host node.
func (*MainBridge) ProtocolVersion ¶
func (mb *MainBridge) ProtocolVersion() int
func (*MainBridge) Protocols ¶
func (mb *MainBridge) Protocols() []p2p.Protocol
Protocols implements node.Service, returning all the currently configured network protocols to start.
func (*MainBridge) SCProtocol ¶
func (mb *MainBridge) SCProtocol() SCProtocol
func (*MainBridge) SendRPCResponseData ¶
func (mb *MainBridge) SendRPCResponseData(data []byte) error
func (*MainBridge) SetComponents ¶
func (mb *MainBridge) SetComponents(components []interface{})
func (*MainBridge) Start ¶
func (mb *MainBridge) Start(srvr p2p.Server) error
Start implements node.Service, starting all internal goroutines needed by the Kaia protocol implementation.
func (*MainBridge) Stop ¶
func (mb *MainBridge) Stop() error
Stop implements node.Service, terminating all internal goroutines used by the Kaia protocol.
type MainBridgeAPI ¶
type MainBridgeAPI struct {
// contains filtered or unexported fields
}
MainBridgeAPI Implementation for main-bridge node
func (*MainBridgeAPI) ConvertChildChainBlockHashToParentChainTxHash ¶
func (mb *MainBridgeAPI) ConvertChildChainBlockHashToParentChainTxHash(scBlockHash common.Hash) common.Hash
func (*MainBridgeAPI) GetChildChainIndexingEnabled ¶
func (mb *MainBridgeAPI) GetChildChainIndexingEnabled() bool
type MainBridgeHandler ¶
type MainBridgeHandler struct {
// contains filtered or unexported fields
}
func NewMainBridgeHandler ¶
func NewMainBridgeHandler(scc *SCConfig, main *MainBridge) (*MainBridgeHandler, error)
func (*MainBridgeHandler) HandleSubMsg ¶
func (mbh *MainBridgeHandler) HandleSubMsg(p BridgePeer, msg p2p.Msg) error
type MainBridgeInfo ¶
type MainBridgeInfo struct { Network uint64 `json:"network"` // Kaia network ID BlockScore *big.Int `json:"blockscore"` // Total blockscore of the host's blockchain Genesis common.Hash `json:"genesis"` // SHA3 hash of the host's genesis block Config *params.ChainConfig `json:"config"` // Chain configuration for the fork rules Head common.Hash `json:"head"` // SHA3 hash of the host's best owned block }
MainBridgeInfo represents a short summary of the Kaia sub-protocol metadata known about the host peer.
type MainChainEventHandler ¶
type MainChainEventHandler struct {
// contains filtered or unexported fields
}
func NewMainChainEventHandler ¶
func NewMainChainEventHandler(bridge *MainBridge, handler *MainBridgeHandler) (*MainChainEventHandler, error)
func (*MainChainEventHandler) ConvertChildChainBlockHashToParentChainTxHash ¶
func (mce *MainChainEventHandler) ConvertChildChainBlockHashToParentChainTxHash(scBlockHash common.Hash) common.Hash
ConvertChildChainBlockHashToParentChainTxHash returns a transaction hash of a transaction which contains AnchoringData, with the key made with given child chain block hash. Index is built when service chain indexing is enabled.
func (*MainChainEventHandler) GetChildChainIndexingEnabled ¶
func (mce *MainChainEventHandler) GetChildChainIndexingEnabled() bool
GetChildChainIndexingEnabled returns the current child chain indexing configuration.
func (*MainChainEventHandler) GetLastIndexedBlockNumber ¶
func (mce *MainChainEventHandler) GetLastIndexedBlockNumber() uint64
GetLastIndexedBlockNumber returns the last child block number indexed to chain DB.
func (*MainChainEventHandler) HandleChainHeadEvent ¶
func (mce *MainChainEventHandler) HandleChainHeadEvent(block *types.Block) error
func (*MainChainEventHandler) HandleLogsEvent ¶
func (mce *MainChainEventHandler) HandleLogsEvent(logs []*types.Log) error
func (*MainChainEventHandler) HandleTxEvent ¶
func (mce *MainChainEventHandler) HandleTxEvent(tx *types.Transaction) error
func (*MainChainEventHandler) HandleTxsEvent ¶
func (mce *MainChainEventHandler) HandleTxsEvent(txs []*types.Transaction) error
func (*MainChainEventHandler) WriteLastIndexedBlockNumber ¶
func (mce *MainChainEventHandler) WriteLastIndexedBlockNumber(blockNum uint64)
WriteLastIndexedBlockNumber writes the last child block number indexed to chain DB.
type PeerSetManager ¶
type PeerSetManager interface {
BridgePeerSet() *bridgePeerSet
}
type RemoteBackend ¶
type RemoteBackend struct {
// contains filtered or unexported fields
}
TODO-Kaia currently RemoteBackend is only for ServiceChain, especially Bridge SmartContract
func NewRemoteBackend ¶
func NewRemoteBackend(sb *SubBridge) (*RemoteBackend, error)
func (*RemoteBackend) CallContract ¶
func (*RemoteBackend) CurrentBlockNumber ¶
func (rb *RemoteBackend) CurrentBlockNumber(ctx context.Context) (uint64, error)
CurrentBlockNumber returns a current block number.
func (*RemoteBackend) EstimateGas ¶
func (*RemoteBackend) FilterLogs ¶
func (rb *RemoteBackend) FilterLogs(ctx context.Context, query kaia.FilterQuery) (result []types.Log, err error)
func (*RemoteBackend) PendingCodeAt ¶
func (*RemoteBackend) PendingNonceAt ¶
func (*RemoteBackend) SendTransaction ¶
func (rb *RemoteBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error
func (*RemoteBackend) SubscribeFilterLogs ¶
func (rb *RemoteBackend) SubscribeFilterLogs(ctx context.Context, query kaia.FilterQuery, ch chan<- types.Log) (kaia.Subscription, error)
func (*RemoteBackend) SuggestGasPrice ¶
func (*RemoteBackend) TransactionReceipt ¶
func (*RemoteBackend) TransactionReceiptRpcOutput ¶
type RemoteBackendInterface ¶
type RemoteBackendInterface interface { bind.ContractBackend TransactionReceiptRpcOutput(ctx context.Context, txHash common.Hash) (map[string]interface{}, error) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error) }
RemoteBackendInterface wraps methods for remote backend
type RequestValueTransferEncodedEvent ¶
type RequestValueTransferEncodedEvent struct {
*bridgecontract.BridgeRequestValueTransferEncoded
}
////////////////// type RequestValueTransferEncodedEvent struct ////////////////////
func (RequestValueTransferEncodedEvent) GetExtraData ¶
func (rEv RequestValueTransferEncodedEvent) GetExtraData() []byte
func (RequestValueTransferEncodedEvent) GetFee ¶
func (rEv RequestValueTransferEncodedEvent) GetFee() *big.Int
func (RequestValueTransferEncodedEvent) GetFrom ¶
func (rEv RequestValueTransferEncodedEvent) GetFrom() common.Address
func (RequestValueTransferEncodedEvent) GetRaw ¶
func (rEv RequestValueTransferEncodedEvent) GetRaw() types.Log
func (RequestValueTransferEncodedEvent) GetRequestNonce ¶
func (rEv RequestValueTransferEncodedEvent) GetRequestNonce() uint64
func (RequestValueTransferEncodedEvent) GetTo ¶
func (rEv RequestValueTransferEncodedEvent) GetTo() common.Address
func (RequestValueTransferEncodedEvent) GetTokenAddress ¶
func (rEv RequestValueTransferEncodedEvent) GetTokenAddress() common.Address
func (RequestValueTransferEncodedEvent) GetTokenType ¶
func (rEv RequestValueTransferEncodedEvent) GetTokenType() uint8
func (RequestValueTransferEncodedEvent) GetValueOrTokenId ¶
func (rEv RequestValueTransferEncodedEvent) GetValueOrTokenId() *big.Int
func (RequestValueTransferEncodedEvent) Nonce ¶
func (rEv RequestValueTransferEncodedEvent) Nonce() uint64
type RequestValueTransferEvent ¶
type RequestValueTransferEvent struct {
*bridgecontract.BridgeRequestValueTransfer
}
////////////////// type RequestValueTransferEvent struct //////////////////// RequestValueTransferEvent from Bridge contract
func (RequestValueTransferEvent) GetExtraData ¶
func (rEv RequestValueTransferEvent) GetExtraData() []byte
func (RequestValueTransferEvent) GetFee ¶
func (rEv RequestValueTransferEvent) GetFee() *big.Int
func (RequestValueTransferEvent) GetFrom ¶
func (rEv RequestValueTransferEvent) GetFrom() common.Address
func (RequestValueTransferEvent) GetRaw ¶
func (rEv RequestValueTransferEvent) GetRaw() types.Log
func (RequestValueTransferEvent) GetRequestNonce ¶
func (rEv RequestValueTransferEvent) GetRequestNonce() uint64
func (RequestValueTransferEvent) GetTo ¶
func (rEv RequestValueTransferEvent) GetTo() common.Address
func (RequestValueTransferEvent) GetTokenAddress ¶
func (rEv RequestValueTransferEvent) GetTokenAddress() common.Address
func (RequestValueTransferEvent) GetTokenType ¶
func (rEv RequestValueTransferEvent) GetTokenType() uint8
func (RequestValueTransferEvent) GetValueOrTokenId ¶
func (rEv RequestValueTransferEvent) GetValueOrTokenId() *big.Int
func (RequestValueTransferEvent) Nonce ¶
func (rEv RequestValueTransferEvent) Nonce() uint64
type SCConfig ¶
type SCConfig struct { // Name sets the instance name of the node. It must not contain the / character and is // used in the devp2p node identifier. The instance name is "kscn". If no // value is specified, the basename of the current executable is used. Name string `toml:"-"` // BridgeService EnabledMainBridge bool EnabledSubBridge bool DataDir string // Protocol options NetworkId uint64 // Network ID to use for selecting peers to connect to // Database options SkipBcVersionCheck bool `toml:"-"` DatabaseHandles int `toml:"-"` LevelDBCacheSize int PebbleDBCacheSize int TrieCacheSize int TrieTimeout time.Duration TrieBlockInterval uint ChildChainIndexing bool // Network MainBridgePort string SubBridgePort string MaxPeer int // ServiceChain ServiceChainConsensus string AnchoringPeriod uint64 SentChainTxsLimit uint64 ParentChainID uint64 VTRecovery bool VTRecoveryInterval uint64 Anchoring bool ServiceChainParentOperatorGasLimit uint64 ServiceChainChildOperatorGasLimit uint64 // KAS KASAnchor bool KASAnchorUrl string KASAnchorPeriod uint64 KASAnchorOperator string KASAccessKey string KASSecretKey string KASXChainId string KASAnchorRequestTimeout time.Duration }
func DefaultServiceChainConfig ¶
func DefaultServiceChainConfig() *SCConfig
func (*SCConfig) MainBridges ¶
StaticNodes returns a list of node enode URLs configured as static nodes.
func (*SCConfig) ResolvePath ¶
ResolvePath resolves path in the instance directory.
type SCProtocol ¶
type SCProtocol struct { // Official short name of the protocol used during capability negotiation. Name string // Supported versions of the Kaia protocol (first is primary). Versions []uint // Number of implemented message corresponding to different protocol versions. Lengths []uint64 }
Protocol defines the protocol of the consensus
type SubBridge ¶
type SubBridge struct { APIBackend *SubBridgeAPI // contains filtered or unexported fields }
SubBridge implements the Kaia consensus node service.
func NewSubBridge ¶
func NewSubBridge(ctx *node.ServiceContext, config *SCConfig) (*SubBridge, error)
New creates a new CN object (including the initialisation of the common CN object)
func (*SubBridge) APIs ¶
APIs returns the collection of RPC services the ethereum package offers. NOTE, some of these services probably need to be moved to somewhere else.
func (*SubBridge) AccountManager ¶
func (*SubBridge) BridgePeerSet ¶
func (sb *SubBridge) BridgePeerSet() *bridgePeerSet
implement PeerSetManager
func (*SubBridge) Components ¶
func (sb *SubBridge) Components() []interface{}
func (*SubBridge) GetAnchoringTx ¶
func (*SubBridge) GetBridgeTxPool ¶
func (sb *SubBridge) GetBridgeTxPool() BridgeTxPool
func (*SubBridge) IsListening ¶
func (*SubBridge) NetVersion ¶
func (*SubBridge) NodeInfo ¶
func (sb *SubBridge) NodeInfo() *SubBridgeInfo
NodeInfo retrieves some protocol metadata about the running host node.
func (*SubBridge) ProtocolVersion ¶
func (*SubBridge) Protocols ¶
Protocols implements node.Service, returning all the currently configured network protocols to start.
func (*SubBridge) SCProtocol ¶
func (sb *SubBridge) SCProtocol() SCProtocol
func (*SubBridge) SendRPCData ¶
func (*SubBridge) SetAnchoringTx ¶
func (*SubBridge) SetComponents ¶
func (sb *SubBridge) SetComponents(components []interface{})
func (*SubBridge) SetRPCConn ¶
type SubBridgeAPI ¶
type SubBridgeAPI struct {
// contains filtered or unexported fields
}
SubBridgeAPI Implementation for sub-bridge node
func (*SubBridgeAPI) AddPeer ¶
func (sb *SubBridgeAPI) AddPeer(url string) (bool, error)
AddPeer requests connecting to a remote node, and also maintaining the new connection at all times, even reconnecting if it is lost.
func (*SubBridgeAPI) Anchoring ¶
func (sb *SubBridgeAPI) Anchoring(flag bool) bool
func (*SubBridgeAPI) ChangeBridgeAlias ¶
func (sb *SubBridgeAPI) ChangeBridgeAlias(oldAlias, newAlias string) error
func (*SubBridgeAPI) ConvertChildChainBlockHashToParentChainTxHash ¶
func (sb *SubBridgeAPI) ConvertChildChainBlockHashToParentChainTxHash(cBlockHash common.Hash) common.Hash
func (*SubBridgeAPI) ConvertRequestTxHashToHandleTxHash ¶
func (sb *SubBridgeAPI) ConvertRequestTxHashToHandleTxHash(hash common.Hash) common.Hash
func (*SubBridgeAPI) DeployBridge ¶
func (sb *SubBridgeAPI) DeployBridge() ([]common.Address, error)
func (*SubBridgeAPI) DeregisterBridge ¶
func (sb *SubBridgeAPI) DeregisterBridge(cBridgeAddrOrAlias, pBridgeAddrOrEmpty *string) error
func (*SubBridgeAPI) DeregisterToken ¶
func (sb *SubBridgeAPI) DeregisterToken(cBridgeAddrOrAlias, pBridgeOrChildToken, cTokenAddrOrPtokenAddr, pTokenAddrOrEmpty *string) error
func (*SubBridgeAPI) GetAnchoring ¶
func (sb *SubBridgeAPI) GetAnchoring() bool
func (*SubBridgeAPI) GetAnchoringPeriod ¶
func (sb *SubBridgeAPI) GetAnchoringPeriod() uint64
func (*SubBridgeAPI) GetAnchoringTxHashByBlockNumber ¶
func (sb *SubBridgeAPI) GetAnchoringTxHashByBlockNumber(bn uint64) common.Hash
func (*SubBridgeAPI) GetBridgeInformation ¶
func (sb *SubBridgeAPI) GetBridgeInformation(bridgeAddr common.Address) (map[string]interface{}, error)
func (*SubBridgeAPI) GetBridgePairByAlias ¶
func (sb *SubBridgeAPI) GetBridgePairByAlias(bridgeAlias string) *BridgeJournal
func (*SubBridgeAPI) GetChildBridgeContractBalance ¶
GetChildBridgeContractBalance returns the balance of the bridge contract in the child chain.
func (*SubBridgeAPI) GetChildBridgeOperatorGasLimit ¶
func (sb *SubBridgeAPI) GetChildBridgeOperatorGasLimit() uint64
GetChildBridgeOperatorGasLimit gets value of bridge child operator's gaslimit.
func (*SubBridgeAPI) GetChildOperatorAddr ¶
func (sb *SubBridgeAPI) GetChildOperatorAddr() common.Address
func (*SubBridgeAPI) GetChildOperatorBalance ¶
func (sb *SubBridgeAPI) GetChildOperatorBalance() (*big.Int, error)
func (*SubBridgeAPI) GetChildOperatorFeePayer ¶
func (sb *SubBridgeAPI) GetChildOperatorFeePayer() common.Address
GetChildOperatorFeePayer can return the child bridge operator's fee payer.
func (*SubBridgeAPI) GetChildOperatorNonce ¶
func (sb *SubBridgeAPI) GetChildOperatorNonce() uint64
func (*SubBridgeAPI) GetERC20Fee ¶
func (*SubBridgeAPI) GetFeeReceiver ¶
func (*SubBridgeAPI) GetKLAYFee ¶
func (*SubBridgeAPI) GetLatestAnchoredBlockNumber ¶
func (sb *SubBridgeAPI) GetLatestAnchoredBlockNumber() uint64
func (*SubBridgeAPI) GetOperators ¶
func (sb *SubBridgeAPI) GetOperators() map[string]interface{}
GetOperators returns the information of bridge operators.
func (*SubBridgeAPI) GetParentBridgeContractBalance ¶
GetParentBridgeContractBalance returns the balance of the bridge contract in the parent chain.
func (*SubBridgeAPI) GetParentBridgeOperatorGasLimit ¶
func (sb *SubBridgeAPI) GetParentBridgeOperatorGasLimit() uint64
GetParentBridgeOperatorGasLimit gets value of bridge parent operator's gaslimit.
func (*SubBridgeAPI) GetParentGasPrice ¶
func (sb *SubBridgeAPI) GetParentGasPrice() uint64
getParentGasPrice returns the recently synced parent chain's gas price
func (*SubBridgeAPI) GetParentKIP71Config ¶
func (sb *SubBridgeAPI) GetParentKIP71Config() params.KIP71Config
GetParentKIP71Config returns the recently synced parent chain's Magma config values
func (*SubBridgeAPI) GetParentOperatorAddr ¶
func (sb *SubBridgeAPI) GetParentOperatorAddr() common.Address
func (*SubBridgeAPI) GetParentOperatorBalance ¶
func (sb *SubBridgeAPI) GetParentOperatorBalance() (*big.Int, error)
func (*SubBridgeAPI) GetParentOperatorFeePayer ¶
func (sb *SubBridgeAPI) GetParentOperatorFeePayer() common.Address
GetParentOperatorFeePayer can return the parent bridge operator's fee payer.
func (*SubBridgeAPI) GetParentOperatorNonce ¶
func (sb *SubBridgeAPI) GetParentOperatorNonce() uint64
func (*SubBridgeAPI) GetParentTransactionReceipt ¶
func (sb *SubBridgeAPI) GetParentTransactionReceipt(txHash common.Hash) (map[string]interface{}, error)
func (*SubBridgeAPI) GetReceiptFromParentChain ¶
func (sb *SubBridgeAPI) GetReceiptFromParentChain(blockHash common.Hash) *types.Receipt
func (*SubBridgeAPI) GetRegisteredOperators ¶
func (*SubBridgeAPI) GetSentChainTxsLimit ¶
func (sb *SubBridgeAPI) GetSentChainTxsLimit() uint64
func (*SubBridgeAPI) GetValueTransferOperatorThreshold ¶
func (sb *SubBridgeAPI) GetValueTransferOperatorThreshold(bridgeAddr common.Address) (uint8, error)
func (*SubBridgeAPI) KASAnchor ¶
func (sb *SubBridgeAPI) KASAnchor(blkNum uint64) error
func (*SubBridgeAPI) ListBridge ¶
func (sb *SubBridgeAPI) ListBridge() []*BridgeJournal
func (*SubBridgeAPI) LockChildOperator ¶
func (sb *SubBridgeAPI) LockChildOperator() error
LockChildOperator can lock the child bridge operator.
func (*SubBridgeAPI) LockParentOperator ¶
func (sb *SubBridgeAPI) LockParentOperator() error
LockParentOperator can lock the parent bridge operator.
func (*SubBridgeAPI) NodeInfo ¶
func (sb *SubBridgeAPI) NodeInfo() (*p2p.NodeInfo, error)
NodeInfo retrieves all the information we know about the host node at the protocol granularity.
func (*SubBridgeAPI) Peers ¶
func (sb *SubBridgeAPI) Peers() ([]*p2p.PeerInfo, error)
Peers retrieves all the information we know about each individual peer at the protocol granularity.
func (*SubBridgeAPI) RegisterBridge ¶
func (sb *SubBridgeAPI) RegisterBridge(cBridgeAddr, pBridgeAddr common.Address, bridgeAliasP *string) error
func (*SubBridgeAPI) RegisterOperator ¶
func (*SubBridgeAPI) RegisterToken ¶
func (sb *SubBridgeAPI) RegisterToken(cBridgeAddrOrAlias, pBridgeOrChildToken, cTokenAddrOrPtokenAddr, pTokenAddrOrEmpty *string) error
func (*SubBridgeAPI) RemovePeer ¶
func (sb *SubBridgeAPI) RemovePeer(url string) (bool, error)
RemovePeer disconnects from a remote node if the connection exists
func (*SubBridgeAPI) RequestParentSync ¶
func (sb *SubBridgeAPI) RequestParentSync()
RequestParentSync request to synchronize the parent chain values
func (*SubBridgeAPI) SetChildBridgeOperatorGasLimit ¶
func (sb *SubBridgeAPI) SetChildBridgeOperatorGasLimit(fee uint64)
SetChildBridgeOperatorGasLimit changes value of bridge child operator's gaslimit.
func (*SubBridgeAPI) SetChildOperatorFeePayer ¶
func (sb *SubBridgeAPI) SetChildOperatorFeePayer(feePayer common.Address) error
SetChildOperatorFeePayer can set the child bridge operator's fee payer.
func (*SubBridgeAPI) SetERC20Fee ¶
func (*SubBridgeAPI) SetFeeReceiver ¶
func (*SubBridgeAPI) SetKLAYFee ¶
func (*SubBridgeAPI) SetParentBridgeOperatorGasLimit ¶
func (sb *SubBridgeAPI) SetParentBridgeOperatorGasLimit(fee uint64)
SetParentBridgeOperatorGasLimit changes value of bridge parent operator's gaslimit.
func (*SubBridgeAPI) SetParentOperatorFeePayer ¶
func (sb *SubBridgeAPI) SetParentOperatorFeePayer(feePayer common.Address) error
SetParentOperatorFeePayer can set the parent bridge operator's fee payer.
func (*SubBridgeAPI) SetValueTransferOperatorThreshold ¶
func (*SubBridgeAPI) SubscribeBridge ¶
func (sb *SubBridgeAPI) SubscribeBridge(cBridgeAddrOrAlias, pBridgeAddrOrEmpty *string) error
func (*SubBridgeAPI) TxPending ¶
func (sb *SubBridgeAPI) TxPending() map[common.Address]types.Transactions
func (*SubBridgeAPI) TxPendingCount ¶
func (sb *SubBridgeAPI) TxPendingCount() int
func (*SubBridgeAPI) UnlockChildOperator ¶
func (sb *SubBridgeAPI) UnlockChildOperator(passphrase string, duration *uint64) error
UnlockChildOperator can unlock the child bridge operator.
func (*SubBridgeAPI) UnlockParentOperator ¶
func (sb *SubBridgeAPI) UnlockParentOperator(passphrase string, duration *uint64) error
UnlockParentOperator can unlock the parent bridge operator.
func (*SubBridgeAPI) UnsubscribeBridge ¶
func (sb *SubBridgeAPI) UnsubscribeBridge(cBridgeAddrOrAlias, pBridgeAddrOrEmpty *string) error
type SubBridgeHandler ¶
type SubBridgeHandler struct {
// contains filtered or unexported fields
}
func NewSubBridgeHandler ¶
func NewSubBridgeHandler(main *SubBridge) (*SubBridgeHandler, error)
func (*SubBridgeHandler) GetAnchoringPeriod ¶
func (sbh *SubBridgeHandler) GetAnchoringPeriod() uint64
GetAnchoringPeriod returns the period to make and send a chain transaction to parent chain.
func (*SubBridgeHandler) GetChildOperatorAddr ¶
func (sbh *SubBridgeHandler) GetChildOperatorAddr() *common.Address
GetChildOperatorAddr returns a pointer of a hex address of an account used for child chain. If given as a parameter, it will use it. If not given, it will use the address of the public key derived from chainKey.
func (*SubBridgeHandler) GetLatestAnchoredBlockNumber ¶
func (sbh *SubBridgeHandler) GetLatestAnchoredBlockNumber() uint64
GetLatestAnchoredBlockNumber returns the latest block number whose data has been anchored to the parent chain.
func (*SubBridgeHandler) GetParentOperatorAddr ¶
func (sbh *SubBridgeHandler) GetParentOperatorAddr() *common.Address
GetParentOperatorAddr returns a pointer of a hex address of an account used for parent chain. If given as a parameter, it will use it. If not given, it will use the address of the public key derived from chainKey.
func (*SubBridgeHandler) GetReceiptFromParentChain ¶
func (sbh *SubBridgeHandler) GetReceiptFromParentChain(blockHash common.Hash) *types.Receipt
GetReceiptFromParentChain returns a receipt received from parent chain to child chain with corresponding block hash. It assumes that a child chain has only one parent chain.
func (*SubBridgeHandler) GetSentChainTxsLimit ¶
func (sbh *SubBridgeHandler) GetSentChainTxsLimit() uint64
GetSentChainTxsLimit returns the maximum number of stored chain transactions for resending.
func (*SubBridgeHandler) HandleMainMsg ¶
func (sbh *SubBridgeHandler) HandleMainMsg(p BridgePeer, msg p2p.Msg) error
func (*SubBridgeHandler) LocalChainHeadEvent ¶
func (sbh *SubBridgeHandler) LocalChainHeadEvent(block *types.Block)
LocalChainHeadEvent deals with servicechain feature to generate/broadcast service chain transactions and request receipts.
func (*SubBridgeHandler) LockParentOperator ¶
func (sbh *SubBridgeHandler) LockParentOperator()
func (*SubBridgeHandler) RegisterNewPeer ¶
func (sbh *SubBridgeHandler) RegisterNewPeer(p BridgePeer) error
func (*SubBridgeHandler) SyncNonceAndGasPrice ¶
func (scpm *SubBridgeHandler) SyncNonceAndGasPrice()
SyncNonceAndGasPrice requests the nonce of address used for service chain tx to parent chain peers.
func (*SubBridgeHandler) UnLockParentOperator ¶
func (sbh *SubBridgeHandler) UnLockParentOperator()
func (*SubBridgeHandler) UpdateLatestTxCountAddedBlockNumber ¶
func (sbh *SubBridgeHandler) UpdateLatestTxCountAddedBlockNumber(newLatestAnchoredBN uint64)
UpdateLatestTxCountAddedBlockNumber sets the latestTxCountAddedBlockNumber to the block number of the last anchoring tx which was added into bridge txPool.
func (*SubBridgeHandler) WriteAnchoredBlockNumber ¶
func (sbh *SubBridgeHandler) WriteAnchoredBlockNumber(blockNum uint64)
WriteAnchoredBlockNumber writes the block number whose data has been anchored to the parent chain.
func (*SubBridgeHandler) WriteReceiptFromParentChain ¶
func (sbh *SubBridgeHandler) WriteReceiptFromParentChain(blockHash common.Hash, receipt *types.Receipt)
WriteReceiptFromParentChain writes a receipt received from parent chain to child chain with corresponding block hash. It assumes that a child chain has only one parent chain.
type SubBridgeInfo ¶
type SubBridgeInfo struct { Network uint64 `json:"network"` // Kaia network ID Genesis common.Hash `json:"genesis"` // SHA3 hash of the host's genesis block Config *params.ChainConfig `json:"config"` // Chain configuration for the fork rules Head common.Hash `json:"head"` // SHA3 hash of the host's best owned block ChainID *big.Int `json:"chainid"` // ChainID }
NodeInfo represents a short summary of the ServiceChain sub-protocol metadata known about the host peer.
Source Files ¶
- api_bridge.go
- bridge_accounts.go
- bridge_addr_journal.go
- bridge_manager.go
- bridgepeer.go
- config.go
- doc.go
- event_interface.go
- event_parse.go
- local_backend.go
- main_bridge_handler.go
- main_event_handler.go
- mainbridge.go
- metrics.go
- protocol.go
- remote_backend.go
- sub_bridge_handler.go
- sub_event_handler.go
- subbridge.go
- vt_recovery.go