driver

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2019 License: MIT Imports: 14 Imported by: 0

README

Full flow

flow deploy
  • deploy TestingERC20 to ethereum (future with orbstoken from its repo)
    • set 10 initial account with 5 different inital values
  • deploy Validators to ethereum
    • set initial 5 validators (assume 3 will be elected)
  • deploy Voting to ethereum
flow record
  • run 15 delegation transfer txs on ethereum
  • run 15 random transfer txs on ethereum
  • future : run 5 direct delegate txs on ethereum
  • run 5 activist votes on ethereum
  • future : run the txs in random order
flow mirror
  • generate orbs mirroring txs
    • option 1 : run web3 script
    • option 2 : sum up the txs from recording flow
  • send mirroring with gammacli to orbs
  • future : simple byzantine txs sent with real data
  • advance ganache x txs forward
flow process
  • call orbs process tx till its returns true
  • run query on _Config contract to validate expectations

Future flows

  • run more than one period

 

 

Naming:

Players:

  • Stakeholder
  • Activist
  • Validator

Verbs:

  • Stakeholder delegates to activist
  • Activist votes for validator
  • Recording - taking action on Ethereum
  • Mirroring - mirroring Ethereum recorded action to orbs
  • Processing - processing mirrored information & storing result

Nouns:

  • Candidates validator (candidates)
  • Elected validator (elected)

Names of contracts:

  • Voting - the voting contract on Ethereum
  • Validators - the list of candidates validators on Ethereum
  • _Elections - the contract on orbs that mirrors and processes the votes from Ethereum. (Repository contract)
  • _Config - the contract on orbs that stores the elected validators. (Repository contract)

Documentation

Index

Constants

View Source
const DELEGATE_TRANSFER = float32(0.07)

Variables

View Source
var DELEGATION_BY_TRANSFER_VALUE = big.NewInt(70000000000000000)
View Source
var ETHEREUM_STAKE_FACTOR = big.NewFloat(1000000000000000000)

Functions

func IpToHexaBytes

func IpToHexaBytes(ip string) string

func NodeAdater

func NodeAdater(config *Config) *nodeAdapter

func RunDeployFlow

func RunDeployFlow(t *testing.T, config *Config, orbs OrbsAdapter, ethereum EthereumAdapter)

func RunMirrorFlow

func RunMirrorFlow(t *testing.T, config *Config, orbs OrbsAdapter, ethereum EthereumAdapter)

func RunProcessFlow

func RunProcessFlow(t *testing.T, config *Config, orbs OrbsAdapter, ethereum EthereumAdapter)

func RunReclaimGuardianDepositsFlow

func RunReclaimGuardianDepositsFlow(t *testing.T, config *Config, ethereum EthereumAdapter)

func RunRecordFlow

func RunRecordFlow(t *testing.T, config *Config, orbs OrbsAdapter, ethereum EthereumAdapter)

Types

type Config

type Config struct {
	DebugLogs                    bool
	EthereumErc20Address         string
	EthereumValidatorsAddress    string
	EthereumValidatorsRegAddress string
	EthereumVotingAddress        string
	EthereumGuardiansAddress     string
	UserAccountOnOrbs            string
	NumberOfAccounts             int
	AccountStakeValues           []float32
	GuardiansAccounts            []int
	ValidatorsAccounts           []int
	ValidatorsOrbsAddresses      []string
	ValidatorsOrbsIps            []string
	SetupOverEthereumBlock       int
	Transfers                    []*TransferEvent
	Delegates                    []*DelegateEvent
	Votes                        []*VoteEvent
	OrbsVotingContractName       string
	FirstElectionBlockNumber     int // zero to automatically determine after mirroring completes. positive value to enforce static value
}

func (*Config) Validate

func (config *Config) Validate(isDeploy bool) error

type DelegateEvent

type DelegateEvent struct {
	FromIndex int
	ToIndex   int
}

type EthereumAdapter

type EthereumAdapter interface {
	GetStartOfHistoryBlock() int
	GetCurrentBlock() int

	DeployERC20Contract() (ethereumErc20Address string)
	GetStakes(ethereumErc20Address string, numberOfStakes int) (stakes map[int]float32)
	SetStakes(ethereumErc20Address string, stakes []float32)
	Transfer(ethereumErc20Address string, from int, to int, amount float32)
	TopUpEther(accountIndexes []int)
	PrintBalances()

	DeployValidatorsContract() (ethereumValidatorsAddress string, ethereumValidatorsRegAddress string)
	GetValidators(ethereumValidatorsAddress string, ethereumValidatorsRegAddress string) []validatorData
	SetValidators(ethereumValidatorsAddress string, ethereumValidatorsRegAddress string, validators []int, orbsAddresses []string, orbsIps []string)

	DeployVotingContract() (ethereumVotingAddress string)
	Delegate(ethereumVotingAddress string, from int, to int)
	Vote(ethereumVotingAddress string, activistInded int, to []int)

	DeployGuardiansContract() (ethereumGuardiansAddress string)
	SetGuardians(ethereumGuardiansAddress string, guardians []int)
	ResignGuardians(ethereumGuardiansAddress string, guardians []int)

	WaitForBlock(blockNumber int)
	GetConnectionUrl() string
}

type GammaCliAdapter

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

func NewGammaCliAdapter

func NewGammaCliAdapter(
	debug bool,
	env string,
	voteMirrorPeriod uint64,
	voteValidPeriod uint64,
	electionPeriod uint64,
	maxElectedValidators int,
	minElectedValidators int,
	finalityBlocksComponent int,
	finalityTimeComponent time.Duration,
) *GammaCliAdapter

func (*GammaCliAdapter) BindERC20ContractToEthereum

func (gamma *GammaCliAdapter) BindERC20ContractToEthereum(orbsVotingContractName string, ethereumErc20Address string)

func (*GammaCliAdapter) BindGuardiansContractToEthereum

func (gamma *GammaCliAdapter) BindGuardiansContractToEthereum(orbsVotingContractName string, ethereumGuardiansAddress string)

func (*GammaCliAdapter) BindValidatorsContractToEthereum

func (gamma *GammaCliAdapter) BindValidatorsContractToEthereum(orbsVotingContractName string, ethereumValidatorsAddress string)

func (*GammaCliAdapter) BindValidatorsRegistryContractToEthereum

func (gamma *GammaCliAdapter) BindValidatorsRegistryContractToEthereum(orbsVotingContractName string, ethereumValidatorsRegistryAddress string)

func (*GammaCliAdapter) BindVotingContractToEthereum

func (gamma *GammaCliAdapter) BindVotingContractToEthereum(orbsVotingContractName string, ethereumVotingAddress string)

func (*GammaCliAdapter) DeployContract

func (gamma *GammaCliAdapter) DeployContract(orbsVotingContractName string) string

func (*GammaCliAdapter) ForwardElectionResultsToSystem

func (gamma *GammaCliAdapter) ForwardElectionResultsToSystem(electedValidatorAddresses []string)

func (*GammaCliAdapter) GetCurrentSystemBlockSigners

func (gamma *GammaCliAdapter) GetCurrentSystemBlockSigners() []string

func (*GammaCliAdapter) GetElectedNodes

func (gamma *GammaCliAdapter) GetElectedNodes(orbsVotingContractName string) []string

func (*GammaCliAdapter) GetFinalityBlocksComponent

func (gamma *GammaCliAdapter) GetFinalityBlocksComponent() int

func (*GammaCliAdapter) GetFinalityTimeComponent

func (gamma *GammaCliAdapter) GetFinalityTimeComponent() time.Duration

func (*GammaCliAdapter) GetMirrorVotingPeriod

func (gamma *GammaCliAdapter) GetMirrorVotingPeriod() int

func (*GammaCliAdapter) GetOrbsEnvironment

func (gamma *GammaCliAdapter) GetOrbsEnvironment() string

func (*GammaCliAdapter) SetContractConstants

func (gamma *GammaCliAdapter) SetContractConstants(orbsVotingContractName string)

func (*GammaCliAdapter) SetElectionBlockNumber

func (gamma *GammaCliAdapter) SetElectionBlockNumber(orbsVotingContractName string, blockHeight int)

type NodeScriptAdapter

type NodeScriptAdapter interface {
	Mirror(orbsVotingContractName string, gammaEnv string)
	Process(orbsVotingContractName string, ethereumErc20Address string, ethereumVotingAddress string, startBlock int, endBlock int, ethereumUrl string, gammaEnv string)
}

type OrbsAdapter

type OrbsAdapter interface {
	DeployContract(orbsVotingContractName string) string
	SetContractConstants(orbsVotingContractName string)
	BindERC20ContractToEthereum(orbsVotingContractName string, ethereumErc20Address string)
	BindValidatorsContractToEthereum(orbsVotingContractName string, ethereumValidatorsAddress string)
	BindValidatorsRegistryContractToEthereum(orbsVotingContractName string, ethereumValidatorsRegistryAddress string)
	BindVotingContractToEthereum(orbsVotingContractName string, ethereumVotingAddress string)
	BindGuardiansContractToEthereum(orbsVotingContractName string, ethereumGuardiansAddress string)
	SetElectionBlockNumber(orbsVotingContractName string, blockHeight int)

	GetElectedNodes(orbsVotingContractName string) []string
	ForwardElectionResultsToSystem(electedValidatorAddresses []string)
	GetCurrentSystemBlockSigners() []string

	GetMirrorVotingPeriod() int
	GetOrbsEnvironment() string
	GetFinalityBlocksComponent() int
	GetFinalityTimeComponent() time.Duration
}

type TransferEvent

type TransferEvent struct {
	FromIndex int
	ToIndex   int
	Amount    float32
}

type TruffleAdapter

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

func NewTruffleAdapter

func NewTruffleAdapter(
	debug bool,
	projectPath string,
	network string,
	networkUrl string,
	startBlock int,
) *TruffleAdapter

func (*TruffleAdapter) Delegate

func (ta *TruffleAdapter) Delegate(ethereumVotingAddress string, from int, to int)

func (*TruffleAdapter) DeployERC20Contract

func (ta *TruffleAdapter) DeployERC20Contract() (ethereumErc20Address string)

func (*TruffleAdapter) DeployGuardiansContract

func (ta *TruffleAdapter) DeployGuardiansContract() (ethereumGuardiansAddress string)

func (*TruffleAdapter) DeployValidatorsContract

func (ta *TruffleAdapter) DeployValidatorsContract() (ethereumValidatorsAddress string, ethereumValidatorsRegAddress string)

func (*TruffleAdapter) DeployVotingContract

func (ta *TruffleAdapter) DeployVotingContract() (ethereumVotingAddress string)

func (*TruffleAdapter) GetConnectionUrl

func (ta *TruffleAdapter) GetConnectionUrl() string

func (*TruffleAdapter) GetCurrentBlock

func (ta *TruffleAdapter) GetCurrentBlock() int

func (*TruffleAdapter) GetStakes

func (ta *TruffleAdapter) GetStakes(ethereumErc20Address string, numberOfStakes int) map[int]float32

func (*TruffleAdapter) GetStartOfHistoryBlock

func (ta *TruffleAdapter) GetStartOfHistoryBlock() int

func (*TruffleAdapter) GetValidators

func (ta *TruffleAdapter) GetValidators(ethereumValidatorsAddress string, ethereumValidatorsRegAddress string) []validatorData

func (*TruffleAdapter) PrintBalances

func (ta *TruffleAdapter) PrintBalances()

func (*TruffleAdapter) ResignGuardians

func (ta *TruffleAdapter) ResignGuardians(ethereumGuardiansAddress string, guardians []int)

func (*TruffleAdapter) SetGuardians

func (ta *TruffleAdapter) SetGuardians(ethereumGuardiansAddress string, guardians []int)

func (*TruffleAdapter) SetStakes

func (ta *TruffleAdapter) SetStakes(ethereumErc20Address string, stakes []float32)

func (*TruffleAdapter) SetValidators

func (ta *TruffleAdapter) SetValidators(ethereumValidatorsAddress string, ethereumValidatorsRegAddress string, validators []int, orbsAddresses []string, orbsIps []string)

func (*TruffleAdapter) TopUpEther

func (ta *TruffleAdapter) TopUpEther(accountIndexes []int)

func (*TruffleAdapter) Transfer

func (ta *TruffleAdapter) Transfer(ethereumErc20Address string, from int, to int, amount float32)

func (*TruffleAdapter) Vote

func (ta *TruffleAdapter) Vote(ethereumVotingAddress string, activistIndex int, candidates []int)

func (*TruffleAdapter) WaitForBlock

func (ta *TruffleAdapter) WaitForBlock(blockNumber int)

func (*TruffleAdapter) WaitForFinality

func (ta *TruffleAdapter) WaitForFinality()

type VoteEvent

type VoteEvent struct {
	GuardianIndex int
	Candidates    []int
}

Jump to

Keyboard shortcuts

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