jury

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: GPL-3.0, GPL-3.0 Imports: 42 Imported by: 0

Documentation

Overview

* @author PalletOne core developers <dev@pallet.one> * @date 2018

* @author PalletOne core developers <dev@pallet.one> * @date 2018

* @author PalletOne core developers <dev@pallet.one> * @date 2018

* @author PalletOne core developers <dev@pallet.one> * @date 2018

* @author PalletOne core developers <dev@pallet.one> * @date 2018

* @author PalletOne core developers <dev@pallet.one> * @date 2018

* @author PalletOne core developers <dev@pallet.one> * @date 2018

* @author PalletOne core developers <dev@pallet.one> * @date 2018

Index

Constants

View Source
const (
	ContractFeeTypeTimeOut = 1 //deploy during time, other is timeout
	ContractFeeTypeTxSize  = 2
)
View Source
const (
	MaxLengthTplName        = 64              //合约模板名字长度
	MaxLengthTplPath        = 512             //合约模板文件路径长度
	MaxLengthTplVersion     = 12              //合约模板版本号长度
	MaxNumberTplEleAddrHash = 5               //合约模板指定节点地址hash数量
	MaxLengthTplId          = 128             //合约模板Id长度
	MaxNumberArgs           = 32              //合约请求参数数量
	MaxLengthArgs           = 1024 * 1024 * 4 //合约请求输入参数长度(合约模板大小限制)
	MaxLengthExtData        = 16              //合约请求扩展数据长度
	MaxLengthAbi            = 1024 * 500      //合约Abi数据长度
	MaxLengthLanguage       = 32              //合约模板语言类型长度
	MaxLengthDescription    = 1024            //合约描述数据长度
	MaxNumberMergeUtxos     = 500             //合约合并utxo限制数量
)
View Source
const (
	ContractDefaultSignatureSize         = 256.0
	ContractDefaultElectionSize          = 768.0
	ContractDefaultRWSize                = 512.0
	ContractDefaultPayInputSignatureSize = 256.0
)

Variables

View Source
var (
	AccountInfoFlag = cli.BoolFlag{
		Name:  "accountInfo",
		Usage: "The About information account address,password,public and private key and on ",
	}
)
View Source
var DefaultConfig = Config{
	Accounts: []*AccountConf{
		&AccountConf{},
	},
}

Functions

func CheckContractTxResult added in v1.0.6

func CheckContractTxResult(tx *modules.Transaction, rwM rwset.TxManager, dag dboperation.IContractDag) bool

验证一个系统合约的执行结果是否正确

func ContractProcess

func ContractProcess(ctx *contracts.ContractProcessContext, req ContractReqInf) (interface{}, error)

func DeleOneMax

func DeleOneMax(signs [][]byte) [][]byte

func GetTxSig

func GetTxSig(tx *modules.Transaction, ks *keystore.KeyStore, signer common.Address) ([]byte, error)

func SetJuryConfig

func SetJuryConfig(ctx *cli.Context, cfg *Config)

func SortSigs

func SortSigs(pubkeys [][]byte, signs [][]byte, redeem []byte) [][]byte

func SortTxs added in v1.0.6

func SortTxs(txs map[common.Hash]*contractTx) []*contractTx

Types

type AccountConf

type AccountConf struct {
	Address,
	Password string
}

type AdapterEvent

type AdapterEvent struct {
	AType AdapterEventType `json:"atype"`
	Event interface{}      `json:"event"`
}

Adapter

func (*AdapterEvent) ToAdapterEventBytes

func (av *AdapterEvent) ToAdapterEventBytes() (*AdapterEventBytes, error)

type AdapterEventBytes

type AdapterEventBytes struct {
	AType AdapterEventType `json:"atype"`
	Event []byte           `json:"event"`
}

func (*AdapterEventBytes) Hash added in v1.0.5

func (es *AdapterEventBytes) Hash() common.Hash

func (*AdapterEventBytes) ToAdapterEvent

func (es *AdapterEventBytes) ToAdapterEvent() (*AdapterEvent, error)

type AdapterEventType

type AdapterEventType uint32

type AdapterInf

type AdapterInf struct {
	JuryMsgAll map[string]*MsgSigCollect
}

type AdapterRequestEvent

type AdapterRequestEvent struct {
	ReqId       common.Hash    `json:"reqId"`
	ContractId  common.Address `json:"contractId"`  //
	ConsultData []byte         `json:"consultdata"` //
	Answer      []byte         `json:"Answer"`
	Sig         []byte         `json:"sig"`
	Pubkey      []byte         `json:"Pubkey"`
}

type Config

type Config struct {
	//ContractSigNum int   //user contract jury sig number  //todo  no used
	//ElectionNum    int   //vrf election jury number       //todo  no used
	Accounts []*AccountConf // the set of the mediator info
}

func MakeConfig

func MakeConfig() Config

type ContractDeployReq

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

type ContractEvent

type ContractEvent struct {
	CType ContractEventType
	Ele   *modules.ElectionNode `rlp:"nil"`
	Tx    *modules.Transaction
}

contract

func (*ContractEvent) Hash

func (ce *ContractEvent) Hash() common.Hash

type ContractEventType

type ContractEventType uint8
const (
	CONTRACT_EVENT_EXEC   ContractEventType = 1 //合约执行,系统合约由Mediator完成,用户合约由Jury完成
	CONTRACT_EVENT_SIG    ContractEventType = 2 //多Jury执行合约并签名转发确认,由Jury接收并处理
	CONTRACT_EVENT_COMMIT ContractEventType = 4 //提交给Mediator进行验证确认并写到交易池
	CONTRACT_EVENT_ELE    ContractEventType = 8 //节点选举
)

type ContractInstallReq

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

type ContractInvokeReq

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

type ContractReqInf

type ContractReqInf interface {
	// contains filtered or unexported methods
}

type ContractResp

type ContractResp struct {
	Err  error
	Resp interface{}
}

type ContractStopReq

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

type ElectionEvent

type ElectionEvent struct {
	EType ElectionEventType `json:"etype"`
	Event interface{}       `json:"event"`
}

func (*ElectionEvent) ReqId added in v1.0.7

func (ev *ElectionEvent) ReqId() common.Hash

func (*ElectionEvent) ToElectionEventBytes

func (ev *ElectionEvent) ToElectionEventBytes() (*ElectionEventBytes, error)

type ElectionEventBytes

type ElectionEventBytes struct {
	EType ElectionEventType `json:"etype"`
	Event []byte            `json:"event"`
}

func (*ElectionEventBytes) Hash

func (es *ElectionEventBytes) Hash() common.Hash

func (*ElectionEventBytes) ToElectionEvent

func (es *ElectionEventBytes) ToElectionEvent() (*ElectionEvent, error)

type ElectionEventType

type ElectionEventType uint8
const (
	ELECTION_EVENT_VRF_REQUEST ElectionEventType = 1
	ELECTION_EVENT_VRF_RESULT  ElectionEventType = 2
	ELECTION_EVENT_SIG_REQUEST ElectionEventType = 3
	ELECTION_EVENT_SIG_RESULT  ElectionEventType = 4
)

type ElectionRequestEvent

type ElectionRequestEvent struct {
	ReqId     common.Hash
	JuryCount uint64
}

Election

type ElectionResultEvent

type ElectionResultEvent struct {
	ReqId     common.Hash
	JuryCount uint64
	Ele       modules.ElectionInf
}

type ElectionSigRequestEvent

type ElectionSigRequestEvent struct {
	ReqId     common.Hash
	JuryCount uint64
	Ele       []modules.ElectionInf
}

sig

type ElectionSigResultEvent

type ElectionSigResultEvent struct {
	ReqId     common.Hash
	JuryCount uint64
	Sig       modules.SignatureSet
}

type JuryAccount

type JuryAccount struct {
	Address  common.Address
	Password string
}

type JuryMsgAddr

type JuryMsgAddr struct {
	Address string
	Answer  []byte
}

type JuryMsgSig

type JuryMsgSig struct {
	Signature []byte
	Answer    []byte
}

type MsgSigCollect

type MsgSigCollect struct {
	OneMsgAllSig map[string]JuryMsgSig
}

type PalletOne

type PalletOne interface {
	GetKeyStore() *keystore.KeyStore
	TxPool() txspool.ITxPool

	MockContractLocalSend(event ContractEvent)
	ContractBroadcast(event ContractEvent, local bool)
	ElectionBroadcast(event ElectionEvent, local bool)
	AdapterBroadcast(event AdapterEvent)

	LocalHaveActiveMediator() bool
	GetLocalActiveMediators() []common.Address
	SignGenericTransaction(from common.Address, tx *modules.Transaction) (*modules.Transaction, error)
	EnableGasFee() bool
}

type Processor

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

func NewContractProcessor

func NewContractProcessor(ptn PalletOne, dag iDag, contract *contracts.Contract, cfg *Config) (*Processor, error)

func (*Processor) AdapterFunRequest

func (p *Processor) AdapterFunRequest(reqId common.Hash, contractId common.Address, msgType uint32,
	consultContent []byte, myAnswer []byte) ([]byte, error)

func (*Processor) AdapterFunResult

func (p *Processor) AdapterFunResult(reqId common.Hash, contractId common.Address, msgType uint32,
	consultContent []byte, timeOut time.Duration) ([]byte, error)

func (*Processor) AddLocalTx added in v1.0.7

func (p *Processor) AddLocalTx(tx *modules.Transaction) error

func (*Processor) BroadcastElectionSigRequestEvent

func (p *Processor) BroadcastElectionSigRequestEvent()

func (*Processor) BuildUnitTxs added in v1.0.7

func (p *Processor) BuildUnitTxs(rwM *rwset.RwSetTxMgr, mDag dboperation.IContractDag, sortedTxs []*modules.Transaction, addr common.Address) ([]*modules.Transaction, error)

func (*Processor) CheckContractTxValid

func (p *Processor) CheckContractTxValid(rwM rwset.TxManager, tx *modules.Transaction, execute bool) bool

func (*Processor) CheckTxValid added in v1.0.1

func (p *Processor) CheckTxValid(tx *modules.Transaction) bool

func (*Processor) ContractDeployReqFee added in v1.0.3

func (p *Processor) ContractDeployReqFee(from, to common.Address, daoAmount, daoFee uint64, templateId []byte,
	args [][]byte, extData []byte, timeout time.Duration) (fee float64, size float64, tm uint32, err error)

func (*Processor) ContractInstallReqFee added in v1.0.3

func (p *Processor) ContractInstallReqFee(from, to common.Address, daoAmount, daoFee uint64, tplName, path, version string,
	description, abi, language string, local bool, addrs []common.Address) (fee float64, size float64, tm uint32, err error)

func (*Processor) ContractInvokeReqFee added in v1.0.3

func (p *Processor) ContractInvokeReqFee(from, to common.Address, daoAmount, daoFee uint64, certID *big.Int,
	contractId common.Address, args [][]byte, timeout uint32) (fee float64, size float64, tm uint32, err error)

func (*Processor) ContractQuery added in v1.0.4

func (p *Processor) ContractQuery(id []byte, args [][]byte, timeout time.Duration) (rsp []byte, err error)

deploy -->invoke

func (*Processor) ContractStopReqFee added in v1.0.3

func (p *Processor) ContractStopReqFee(from, to common.Address, daoAmount, daoFee uint64,
	contractId common.Address, deleteImage bool) (fee float64, size float64, tm uint32, err error)

func (*Processor) ContractTxDeleteLoop

func (p *Processor) ContractTxDeleteLoop()

func (*Processor) CreateGenericTransaction added in v1.0.8

func (p *Processor) CreateGenericTransaction(from, to common.Address, daoAmount, daoFee uint64, certID *big.Int,
	msg *modules.Message, enableGasFee bool) (*modules.Transaction, uint64, error)

func (*Processor) CreateTokenTransaction added in v1.0.8

func (p *Processor) CreateTokenTransaction(from, to common.Address, token *modules.Asset, daoAmountToken, daoFee uint64,
	msg *modules.Message) (*modules.Transaction, uint64, error)

func (*Processor) ElectionVrfReq

func (p *Processor) ElectionVrfReq(id uint32) ([]byte, error)

func (*Processor) GenContractSigTransaction

func (p *Processor) GenContractSigTransaction(signer common.Address, password string, orgTx *modules.Transaction,
	ks *keystore.KeyStore, utxoFunc modules.QueryUtxoFunc) (*modules.Transaction, error)

func (*Processor) GenContractTransaction added in v1.0.5

func (p *Processor) GenContractTransaction(orgTx *modules.Transaction, msgs []*modules.Message) (*modules.Transaction, error)

func (*Processor) GetLocalJuryAddrs added in v1.0.1

func (p *Processor) GetLocalJuryAddrs() []common.Address

func (*Processor) ProcessAdapterEvent

func (p *Processor) ProcessAdapterEvent(event *AdapterEvent) (result *AdapterEvent, err error)

func (*Processor) ProcessContractEvent

func (p *Processor) ProcessContractEvent(event *ContractEvent) (bool, error)

func (*Processor) ProcessElectionEvent

func (p *Processor) ProcessElectionEvent(event *ElectionEvent) (err error)

func (*Processor) ProcessUserContractInvokeReqTx added in v1.0.7

func (p *Processor) ProcessUserContractInvokeReqTx(tx *modules.Transaction)

func (*Processor) RunAndSignTx added in v1.0.6

func (*Processor) SetContract

func (p *Processor) SetContract(contract *contracts.Contract)

func (*Processor) SetDocker added in v1.0.5

func (p *Processor) SetDocker(pDocker *utils.PalletOneDocker)

func (*Processor) SignAndExecuteAndSendRequest

func (p *Processor) SignAndExecuteAndSendRequest(from common.Address,
	tx *modules.Transaction) (*modules.Transaction, error)

func (*Processor) Start

func (p *Processor) Start(server *p2p.Server) error

func (*Processor) Stop

func (p *Processor) Stop() error

func (*Processor) SubscribeContractEvent

func (p *Processor) SubscribeContractEvent(ch chan<- ContractEvent) event.Subscription

func (*Processor) UpdateJuryAccount

func (p *Processor) UpdateJuryAccount(addr common.Address, pwd string) bool

type Txo4Greedy added in v1.0.8

type Txo4Greedy struct {
	modules.OutPoint
	Amount uint64
}

func (*Txo4Greedy) GetAmount added in v1.0.8

func (txo *Txo4Greedy) GetAmount() uint64

type UtxoQuery added in v1.0.6

type UtxoQuery func(addr common.Address, asset *modules.Asset) (map[modules.OutPoint]*modules.Utxo, error)

Directories

Path Synopsis
vrf
* @author PalletOne core developers <dev@pallet.one> * @date 2018
* @author PalletOne core developers <dev@pallet.one> * @date 2018
algorithm
* @author PalletOne core developers <dev@pallet.one> * @date 2018
* @author PalletOne core developers <dev@pallet.one> * @date 2018
ec
inf
* @author PalletOne core developers <dev@pallet.one> * @date 2018
* @author PalletOne core developers <dev@pallet.one> * @date 2018
vrfEc
* @author PalletOne core developers <dev@pallet.one> * @date 2018 * @author PalletOne core developers <dev@pallet.one> * @date 2018
* @author PalletOne core developers <dev@pallet.one> * @date 2018 * @author PalletOne core developers <dev@pallet.one> * @date 2018
vrfEs
* @author PalletOne core developers <dev@pallet.one> * @date 2018 * @author PalletOne core developers <dev@pallet.one> * @date 2018
* @author PalletOne core developers <dev@pallet.one> * @date 2018 * @author PalletOne core developers <dev@pallet.one> * @date 2018
vrfEss
* @author PalletOne core developers <dev@pallet.one> * @date 2018 * @author PalletOne core developers <dev@pallet.one> * @date 2018
* @author PalletOne core developers <dev@pallet.one> * @date 2018 * @author PalletOne core developers <dev@pallet.one> * @date 2018

Jump to

Keyboard shortcuts

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