prototype

package
v0.0.0-...-f39f649 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Acc

type Acc struct {
	Nonce uint64
	Value *big.Int
}

Acc contains an account's balance and transaction nonce.

type Enclave

type Enclave struct {
	*State // The enclave's essential state.
	// contains filtered or unexported fields
}

func NewEnclave

func NewEnclave(wallet accounts.Wallet) *Enclave

func NewEnclaveWithAccount

func NewEnclaveWithAccount(wallet accounts.Wallet, account accounts.Account) *Enclave

func (*Enclave) BalanceProofs

func (e *Enclave) BalanceProofs() ([]*tee.BalanceProof, error)

BalanceProofs returns all balance proofs at the end of each transaction phase.

Note that all blocks of the epoch's transaction phase (+k) need to be known to the Enclave. This call blocks until all necessary blocks are received and processed.

It should be called in a loop by the operator.

func (*Enclave) BlockNum

func (e *Enclave) BlockNum() uint64

func (*Enclave) DepositProofs

func (e *Enclave) DepositProofs() ([]*tee.DepositProof, error)

DepositProofs returns the deposit proofs of all deposits made in an epoch at the end of the deposit phase.

Note that all blocks of the epoch's deposit phase (+k) need to be known to the Enclave. This call blocks until all necessary blocks are received and processed.

It should be called in a loop by the operator.

func (*Enclave) Init

func (e *Enclave) Init() (_ common.Address, _ []byte, err error)

Init initializes the enclave, generating a new secp256k1 ECDSA key and storing it as the enclave's signing key.

It returns the public key derived Ethereum address and attestation of correct initialization of the enclave with the generated address. The attestation can be used to verify the enclave with the TEE vendor.

The Operator must deploy the contract with the Enclave's address after calling Init.

func (*Enclave) IsAtPhaseEnd

func (e *Enclave) IsAtPhaseEnd() bool

func (*Enclave) ProcessBlocks

func (e *Enclave) ProcessBlocks(blocks ...*tee.Block) error

ProcessBlocks instantaneously processes a list of blocks. If any of the blocks are erroneous, they are simply ignored, without affecting the rest of the blocks. Returns the accumulated error messages.

func (*Enclave) ProcessTXs

func (e *Enclave) ProcessTXs(txs ...*tee.Transaction) error

ProcessTXs should be called by the Operator whenever they receive new transactions from users. After a transaction epoch has finished and an additional k blocks made known to the Enclave, the epoch's balance proofs can be received by calling BalanceProofs.

func (*Enclave) Run

func (e *Enclave) Run(params tee.Parameters) error

Run starts the enclave's main loop.

Run must be called after Init.

Run can be stopped by calling Shutdown. However, Run will process blocks and transactions until the current phase has finished.

func (*Enclave) Shutdown

func (e *Enclave) Shutdown()

Shutdown lets the Enclave gracefully shutdown after the next phase is sealed. It will continue receiving transactions and blocks until the last block of the current phase is received via ProcessBlocks.

The Enclave Interface methods will return an tee.ErrEnclaveStopped error after the Enclave shut down.

type Epoch

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

Epoch manages deposits, transactions, and exits, as well as the progression of time in the system.

func (*Epoch) ApplyDeposits

func (e *Epoch) ApplyDeposits(deposits ...*erdstallDepEvent)

ApplyDeposits applies a series deposit events and makes the deposited values available instantly.

func (*Epoch) Balance

func (e *Epoch) Balance(who common.Address) *big.Int

Balance looks up an account balance in the epoch.

func (*Epoch) DepositNum

func (e *Epoch) DepositNum() tee.Epoch

DepositNum is the current deposit epoch number.

func (*Epoch) ExitNum

func (e *Epoch) ExitNum() tee.Epoch

ExitNum is the current exit epoch number.

func (*Epoch) IsExitLocked

func (e *Epoch) IsExitLocked(who common.Address) bool

IsExitLocked returns whether an account is exit locked.

func (*Epoch) Outcome

func (e *Epoch) Outcome() (o Outcome)

Outcome has to be called exactly once after each phase shift and contains all accounts that exited within this epoch, as well as all balances at the end of the epoch. It blocks until the epoch in which it was last called ends.

func (*Epoch) ProcessTx

func (e *Epoch) ProcessTx(contract common.Address, tx *tee.Transaction) error

ProcessTx processes a transaction. If it is invalid, does nothing and returns an error. A transaction is invalid if either party is currently locked for withdrawal or the transaction is otherwise invalid (e.g., insufficient funds, invalid signature, ...). Valid transactions increase the sender's nonce.

func (*Epoch) RegisterExits

func (e *Epoch) RegisterExits(exitReqs ...*erdstallExitEvent)

RegisterExits registers a exit requests for the end of the current phase. The requested accounts are locked for one epoch before they can be withdrawn.

func (*Epoch) TxNum

func (e *Epoch) TxNum() tee.Epoch

TxNum is the current transaction epoch number.

type Outcome

type Outcome struct {
	TxEpoch  tee.Epoch               // The finished TX epoch.
	Exits    map[common.Address]*Acc // Exited accounts.
	Accounts map[common.Address]*Acc // Final balances and nonces.
}

Outcome contains all of an epoch's final balances, as well as all accounts that exited the system at the end of the epoch.

type State

type State struct {
	Params *tee.Parameters // The fixed enclave parameters.

	Epoch         tee.Epoch   // The current epoch.
	LastBlock     uint64      // The last known block height.
	LastBlockHash common.Hash // The last known block's hash.

	Accounts map[common.Address]*Acc // The users' accounts.
}

State contains all essential enclave state.

Jump to

Keyboard shortcuts

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