Documentation ¶
Index ¶
Constants ¶
const AvsName = "chainbase_coordinator"
Variables ¶
var (
TaskResponseDigestNotFoundError500 = errors.New("500. Failed to get task response digest")
)
Functions ¶
Types ¶
type Coordinator ¶
type Coordinator struct { coordinatorpb.UnimplementedCoordinatorServiceServer // contains filtered or unexported fields }
Coordinator sends tasks onchain, then listens for operator signed TaskResponses. It aggregates responses signatures, and if any of the TaskResponses reaches the QuorumThresholdPercentage for each quorum it sends the aggregated TaskResponse and signature onchain.
The signature is checked in the BLSSignatureChecker.sol contract, which expects a
struct NonSignerStakesAndSignature { uint32[] nonSignerQuorumBitmapIndices; BN254.G1Point[] nonSignerPubkeys; BN254.G1Point[] quorumApks; BN254.G2Point apkG2; BN254.G1Point sigma; uint32[] quorumApkIndices; uint32[] totalStakeIndices; uint32[][] nonSignerStakeIndices; // nonSignerStakeIndices[quorumNumberIndex][nonSignerIndex] }
A task can only be responded onchain by having enough operators sign on it such that their stake in each quorum reaches the QuorumThresholdPercentage. In order to verify this onchain, the Registry contracts store the history of stakes and aggregate pubkeys (apks) for each operators and each quorum. These are updated everytime an operator registers or deregisters with the BLSRegistryCoordinatorWithIndices.sol contract, or calls UpdateStakes() on the StakeRegistry.sol contract, after having received new delegated shares or having delegated shares removed by stakers queuing withdrawals. Each of these pushes to their respective datatype array a new entry.
This is true for quorumBitmaps (represent the quorums each operator is opted into), quorumApks (apks per quorum), totalStakes (total stake per quorum), and nonSignerStakes (stake per quorum per operator). The 4 "indices" in NonSignerStakesAndSignature basically represent the index at which to fetch their respective data, given a blockNumber at which the task was created. Note that different data types might have different indices, since for eg QuorumBitmaps are updated for operators registering/deregistering, but not for UpdateStakes. Thankfully, we have deployed a helper contract BLSOperatorStateRetriever.sol whose function getCheckSignaturesIndices() can be used to fetch the indices given a block number.
The 4 other fields nonSignerPubkeys, quorumApks, apkG2, and sigma, however, must be computed individually. apkG2 and sigma are just the aggregated signature and pubkeys of the operators who signed the task response (aggregated over all quorums, so individual signatures might be duplicated). quorumApks are the G1 aggregated pubkeys of the operators who signed the task response, but one per quorum, as opposed to apkG2 which is summed over all quorums. nonSignerPubkeys are the G1 pubkeys of the operators who did not sign the task response, but were opted into the quorum at the blocknumber at which the task was created. Upon sending a task onchain (or receiving a NewTaskCreated Event if the tasks were sent by an external task generator), the coordinator can get the list of all operators opted into each quorum at that block number by calling the getOperatorState() function of the BLSOperatorStateRetriever.sol contract.
func NewCoordinator ¶
func NewCoordinator(c *config.Config) (*Coordinator, error)
NewCoordinator creates a new Coordinator with the provided config.
func (*Coordinator) InsertOperatorTasks ¶ added in v0.2.6
func (*Coordinator) ProcessSignedTaskResponse ¶
func (c *Coordinator) ProcessSignedTaskResponse(ctx context.Context, signedTaskResponse *coordinatorpb.SignedTaskResponseRequest) (*coordinatorpb.SignedTaskResponseReply, error)
ProcessSignedTaskResponse rpc endpoint which is called by manuscript node
type FlinkClient ¶
type FlinkClient struct { FlinkGatewayHttpUrl string OssAccessKeyId string OssAccessKeySecret string Client *http.Client }
func NewFlinkClient ¶
func NewFlinkClient(flinkGatewayHttpUrl, ossAccessKeyId, ossAccessKeySecret string) *FlinkClient
NewFlinkClient creates a new FlinkClient
func (*FlinkClient) GetChainLatestBlockHeight ¶
func (f *FlinkClient) GetChainLatestBlockHeight(chain string) (int64, error)
GetChainLatestBlockHeight gets the latest block height of a chain
type IpApiResponse ¶ added in v0.2.6
type ManuscriptRpcClient ¶
type ManuscriptRpcClient struct {
// contains filtered or unexported fields
}
func NewManuscriptRpcClient ¶
func (*ManuscriptRpcClient) CreateNewTask ¶
func (c *ManuscriptRpcClient) CreateNewTask(task *nodepb.NewTaskRequest)
CreateNewTask sends a new task to the Manuscript node.
func (*ManuscriptRpcClient) GetOperatorInfo ¶ added in v0.2.6
func (c *ManuscriptRpcClient) GetOperatorInfo() (*nodepb.GetOperatorInfoResponse, error)
type ManuscriptRpcClienter ¶
type ManuscriptRpcClienter interface {
CreateNewTask(task *nodepb.NewTaskRequest)
}
type ResponseTxInput ¶ added in v0.2.6
type ResponseTxInput struct { Task bindings.IChainbaseServiceManagerTask TaskResponse bindings.IChainbaseServiceManagerTaskResponse NonSignerStakesAndSignature bindings.IBLSSignatureCheckerNonSignerStakesAndSignature }