oracle

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2021 License: Apache-2.0 Imports: 36 Imported by: 0

README

Oracle Operator

Oracle Operator listens to the creat_task event from CertiK Chain, queries the primitives and pushes the result back to CertiK Chain.

How to Config and Run

  1. Register the operator on CertiK Chain (through CLI or RESTful API) and lock a certain amount of CTK.
$ certikcli tx oracle create-operator <account address> <collateral> --name <operator name> --from <account> --fees 5000uctk -y -b block
  1. Create the oracle operator configuration file in certikcli home (default .certikcli/config/oracle-operator.toml). See template at oracle-operator.toml:
  • type: Aggregation type, e.g. linear. Check Strategy.
  • primitive_contract_address: security primitive contract address.
  • weight: the weight of the result from the corresponding primitive to the final result.
  1. Run the oracle operator by the following command.
$ certikcli oracle-operator --from <account>

A sample shell script of running Oracle Operator:

certikcli tx oracle create-operator $(certikcli keys show alice --keyring-backend test -a) 100000uctk --from alice --fees 5000uctk -y -b block
certikcli oracle-operator --log_level "debug" --keyring-backend test --from alice

Support of Multiple Client Chain

Contract addresses in security oracle tasks are prefixed with the chain identifier, e.g. eth:0xabc(Ethereum), bsc:0xdef(Binance Smart Chain). To enable oracle operator handle tasks for multiple chains, the configuration file can be specified as:

[strategy.eth]
type = "linear"
[[stragety.eth.primitive]]
primitive_contract_address = "certik111..."
weight = 0.1
[[stragety.eth.primitive]]
primitive_contract_address = "certik222..."
weight = 0.1

[strategy.bsc]
type = "linear"
[[stragety.bsc.primitive]]
primitive_contract_address = "certik333..."
weight = 0.1
[[stragety.bsc.primitive]]
primitive_contract_address = "certik444..."
weight = 0.1
How to Deploy SecurityPrimitive Contract on CertiK Chain

Security Primitive Contract wraps a security endpoint to chain.

  1. Set function getEndpointUrl based on template at SecurityPrimtive.sol.
  2. Deploy your SecurityPrimitive Contract on CertiK Chain
certikcli tx cvm deploy SecurityPrimitive.sol --args <security-primitive-endpoint> --from <account> --gas-prices 0.025uctk --gas-adjustment 2.0 --gas auto -y -b block
  1. Record your SecurityPrimitive Contract's address new-contract-address from screen output.
  2. Check your PrimitivePrimitive Contract by querying getInsight function.
certikcli tx cvm call <primitive-contract-address> "getInsight" "0x00000000000000000000" "0x0100" --from <account> --gas-prices 0.025uctk --gas-adjustment 2.0 --gas auto -y -b block
  1. Set your contract address in the oracle-operator configuration file (~/.certikcli/config/oracle-operator.toml).

Modules

Chain x/oracle

The x/oracle module in chain handles operator registry and task management (create, response, delete, etc...)

Oracle Operator

The oracle operator listens to the create_task event published by certik chain, queries the primitive endpoint for the task result and delivers the result back to certik chain.

Documentation

Overview

Package oracle defines oracle-operator

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompleteAndBroadcastTx

func CompleteAndBroadcastTx(cliCtx context.CLIContext, txBldr authtypes.TxBuilder, msgs []sdk.Msg) (sdk.TxResponse, error)

CompleteAndBroadcastTx is adopted from auth.CompleteAndBroadcastTxCLI. The original function prints out response.

func Listen

func Listen(ctx types.Context, ctkMsgChan chan<- interface{}, fatalError chan<- error)

Listen listens for events from CertiK chain.

func Push

func Push(ctx types.Context, ctkMsgChan <-chan interface{}, errorChan chan<- error)

Push pushes MsgInquiryEvent to certik chain.

func PushMsgTaskResponse

func PushMsgTaskResponse(ctx types.Context, msg oracle.MsgTaskResponse)

PushMsgTaskResponse pushes MsgTaskResponse message to CertiK Chain.

func ServeCommand

func ServeCommand(cdc *codec.Codec) *cobra.Command

ServeCommand will start the oracle operator as a blocking process.

Types

type Aggregation

type Aggregation interface {
	Aggregate(scores <-chan types.PrimitiveScore) (uint8, error)
}

Aggregation for scores.

func NewAggregation

func NewAggregation(strategy types.Strategy) (Aggregation, error)

NewAggregation returns the strategy implementation based on configured type.

type LinearCombination

type LinearCombination struct {
	Aggregation
}

LinearCombination of scores.

func (LinearCombination) Aggregate

func (LinearCombination) Aggregate(scores <-chan types.PrimitiveScore) (uint8, error)

Aggregate performs linear combination of the primitive scores.

Directories

Path Synopsis
Package types includes global types for syncer.
Package types includes global types for syncer.

Jump to

Keyboard shortcuts

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