Documentation ¶
Index ¶
- Constants
- func CheckConfigErr(err error)
- func FromGOB64(str string) []byte
- func GetCWD() string
- func GetDefaultGenesisBlock() *pb.PbftBlock
- func GetHash(plaintext string) string
- func LoadLogisticsCfg() (*ini.File, error)
- func NewPbftBlock(header *pb.PbftBlockHeader, txns []*pb.Transaction) *pb.PbftBlock
- func NewPbftBlockHeader(n, gasLimit, gasUsed int64, parentHash, txnsHash []byte) *pb.PbftBlockHeader
- func RegisterPbftGrpcListener(grpcPort int, sv *Server)
- func ToGOB64(m []byte) string
- func VerifySender(tx *pb.Transaction, n int) ([]byte, bool)
- func WriteNewKeys(kcount int, kdir string)
- type ActiveItem
- type ApplyMsg
- type BftCommittee
- type Config
- type DailyBFTNode
- type DigType
- type General
- type Log
- type Logistics
- type MsgSignature
- type MsgType
- type Network
- type Node
- func (nd *Node) ProxyProcessCheckpoint(arg ProxyProcessCheckpointArg, reply *ProxyProcessCheckpointReply) error
- func (nd *Node) ProxyProcessCommit(arg ProxyProcessCommitArg, reply *ProxyProcessCommitReply) error
- func (nd *Node) ProxyProcessNewView(arg ProxyProcessNewViewArg, reply *ProxyProcessNewViewReply) error
- func (nd *Node) ProxyProcessPrePrepare(arg ProxyProcessPrePrepareArg, reply *ProxyProcessPrePrepareReply) error
- func (nd *Node) ProxyProcessPrepare(arg ProxyProcessPrepareArg, reply *ProxyProcessPrepareReply) error
- func (nd *Node) ProxyProcessViewChange(arg ProxyProcessViewChangeArg, reply *ProxyProcessViewChangeReply) error
- func (nd *Node) VerifyBlockTxs(blk *pb.PbftBlock) bool
- type ProxyProcessCheckpointArg
- type ProxyProcessCheckpointReply
- type ProxyProcessCommitArg
- type ProxyProcessCommitReply
- type ProxyProcessNewViewArg
- type ProxyProcessNewViewReply
- type ProxyProcessPrePrepareArg
- type ProxyProcessPrePrepareReply
- type ProxyProcessPrepareArg
- type ProxyProcessPrepareReply
- type ProxyProcessViewChangeArg
- type ProxyProcessViewChangeReply
- type Request
- type RequestInner
- type Server
- type Slowchain
- type Testbed
- type Tunables
- type TxPool
Constants ¶
const ( // TunablesConfigEnv is an env var to fetch tunables .yaml conf TunablesConfigEnv = "TRUE_TUNABLES_CONF" // GeneralConfigEnv is an env var to fetch logistics .ini conf GeneralConfigEnv = "TRUE_GENERAL_CONF" // PeerNetworkEnv is an env var to fetch hosts file contaning peer address list PeerNetworkEnv = "TRUE_NETWORK_CONF" // SimulatedEnv apprises the project of products env vs an alternate reality SimulatedEnv = "TRUE_SIMULATION" )
const (
TypeRequest = iota
)
const ServerPort = 40162 const BufferSize = 4096 * 32
Variables ¶
This section is empty.
Functions ¶
func CheckConfigErr ¶
func CheckConfigErr(err error)
CheckConfigErr first prints config specific error messages (TODO: add context param for message), then redirects to project wide CheckErr()
func GetCWD ¶
func GetCWD() string
GetCWD provides the current work dir's absolute filepath, where CWD is the one where truechain-engine binary shots were was fired from.
func GetDefaultGenesisBlock ¶
GetDefaultGenesisBlock returns a default genesis block
func LoadLogisticsCfg ¶
func LoadLogisticsCfg() (*ini.File, error)
LoadLogisticsCfg loads the .cfg file
func NewPbftBlock ¶
func NewPbftBlock(header *pb.PbftBlockHeader, txns []*pb.Transaction) *pb.PbftBlock
NewPbftBlock creates and returns a new block
func NewPbftBlockHeader ¶
func NewPbftBlockHeader(n, gasLimit, gasUsed int64, parentHash, txnsHash []byte) *pb.PbftBlockHeader
NewPbftBlockHeader creates and returns a new block header
func RegisterPbftGrpcListener ¶
RegisterPbftGrpcListener listens to client for new transaction requests on grpcPort
func VerifySender ¶
func VerifySender(tx *pb.Transaction, n int) ([]byte, bool)
VerifySender verifies transaction sender by matching public key obtained from transaction signature with expected public key TODO This should match sender addresses later
func WriteNewKeys ¶
WriteNewKeys generates kcount # of ECDSA public-private key pairs and writes them into a folder kdir.
Types ¶
type ActiveItem ¶
type ActiveItem struct {
// contains filtered or unexported fields
}
ActiveItem keeps track of currently active request and msg digest
type ApplyMsg ¶
type ApplyMsg struct { Index int Content interface{} }
ApplyMsg keeps track of messages and their indices. It's used by both the server and client. Consider it as kind of like the common Z environment variable.
type BftCommittee ¶
type BftCommittee struct { Blocksize int `yaml:"block_size"` // Blocksize specifies the number of transactions per block BlockFrequency int `yaml:"block_frequency"` Lambda int `yaml:"lambda"` WaitTimeout int `yaml:"wait_timeout"` Tbft int `yaml:"tbft"` Th int `yaml:"th"` ActualDelta int `yaml:"actual_delta"` Delta int `yaml:"delta"` Alpha int `yaml:"alpha"` Csize int `yaml:"csize"` }
BftCommittee config initiates assumption values from whitepaper May or maynot change during runtime
type Config ¶
Config - configuration for pbft.Config Note: struct fields must be public in order for unmarshal to correctly populate the data.
func GetPbftConfig ¶
func GetPbftConfig() *Config
GetPbftConfig returns the basic PBFT configuration used for simulation
func (*Config) GenerateKeysToFile ¶
func (cfg *Config) GenerateKeysToFile()
GenerateKeysToFile generates ECDSA public-private keypairs to a folder
func (*Config) GetIPConfigs ¶
func (cfg *Config) GetIPConfigs()
GetIPConfigs loads all the IPs from the ~/hosts files
func (*Config) LoadTunablesConfig ¶
LoadTunablesConfig loads the .yaml file
func (*Config) MakeTransportations ¶
MakeTransportations is a placeholder. All network related functions should be defined here. TODO: implement send/receive messages with RPC
func (*Config) ValidateConfig ¶
ValidateConfig checks for aberrance and loads struct Config{} with tunables and logistics vars
type DailyBFTNode ¶
type DailyBFTNode interface { ProxyProcessPrePrepare(arg ProxyProcessPrePrepareArg, reply *ProxyProcessPrePrepareReply) error ProxyProcessPrepare(arg ProxyProcessPrepareArg, reply *ProxyProcessPrepareReply) error ProxyProcessCommit(arg ProxyProcessCommitArg, reply *ProxyProcessCommitReply) error ProxyProcessViewChange(arg ProxyProcessViewChangeArg, reply *ProxyProcessViewChangeReply) error ProxyProcessNewView(arg ProxyProcessNewViewArg, reply *ProxyProcessNewViewReply) error ProxyProcessCheckpoint(arg ProxyProcessCheckpointArg, reply *ProxyProcessCheckpointReply) error NewClientRequest(req Request, clientID int) // contains filtered or unexported methods }
DailyBFTNode - an interface supposed to expose fastchain / committee consensus to an orchestration mechanism See - https://github.com/truechain/truechain-consensus-core/issues/26
type General ¶
type General struct { MaxFail int `yaml:"max_fail"` BasePort int `yaml:"rpc_base_port"` OutputThreshold int `yaml:"output_threshold"` MaxLogSize int `yaml:"max_log_size"` GrpcBasePort int `yaml:"grpc_base_port"` RequestTimeout int `yaml:"request_timeout"` }
General defines generic tunables
type Logistics ¶
type Logistics struct { LedgerLoc string LD string ServerLog string ClientLog string KD string // key directory where pub/priva ECDSA keys are stored }
Logistics contains paths corresponding to following env vars: TRUE_CONF_DIR='/etc/truechain/' - contains hosts, tunables and logistics configurables TRUE_LOG_DIR='/var/log/truechain' - contains all things ledger and logs TRUE_LIB_DIR='/var/lib/truechain' - contains keys and all things db
type MsgSignature ¶
MsgSignature contains the EC coordinates
type MsgType ¶
type MsgType string
MsgType contains the message of the request as part of RequestInner
type Network ¶
type Network struct { N int // number of nodes to be launchedt IPList []string // stores list of IP addresses belonging to BFT nodes Ports []int // stores list of Ports belonging to BFT nodes GrpcPorts []int // stores list of ports serving grpc requests NumQuest int // NumQuest is the number of requests sent from client NumKeys int // NumKeys is the count of IP addresses (BFT nodes) participating HostsFile string // contains network addresses for server/client/peers }
Network - generic struct used by each node to interact with connection pool details
type Node ¶
type Node struct { ListenReady chan bool SetupReady chan bool EcdsaKey *ecdsa.PrivateKey ID int N int Primary int KeyDict map[int]keyItem // contains filtered or unexported fields }
Node contains base properties of a Node
func (*Node) ProxyProcessCheckpoint ¶
func (nd *Node) ProxyProcessCheckpoint(arg ProxyProcessCheckpointArg, reply *ProxyProcessCheckpointReply) error
ProxyProcessCheckpoint processes checkpoint for PBFT ledger
func (*Node) ProxyProcessCommit ¶
func (nd *Node) ProxyProcessCommit(arg ProxyProcessCommitArg, reply *ProxyProcessCommitReply) error
ProxyProcessCommit trigger Commit phase of PBFT
func (*Node) ProxyProcessNewView ¶
func (nd *Node) ProxyProcessNewView(arg ProxyProcessNewViewArg, reply *ProxyProcessNewViewReply) error
ProxyProcessNewView triggers and frames a new view from current request
func (*Node) ProxyProcessPrePrepare ¶
func (nd *Node) ProxyProcessPrePrepare(arg ProxyProcessPrePrepareArg, reply *ProxyProcessPrePrepareReply) error
ProxyProcessPrePrepare trigger Pre-Prepare request
func (*Node) ProxyProcessPrepare ¶
func (nd *Node) ProxyProcessPrepare(arg ProxyProcessPrepareArg, reply *ProxyProcessPrepareReply) error
ProxyProcessPrepare trigger Prepare phase of PBFT
func (*Node) ProxyProcessViewChange ¶
func (nd *Node) ProxyProcessViewChange(arg ProxyProcessViewChangeArg, reply *ProxyProcessViewChangeReply) error
ProxyProcessViewChange trigger view change process request
type ProxyProcessCheckpointArg ¶
ProxyProcessCheckpointArg holds checkPoint args for PBFT checkpoints
type ProxyProcessCheckpointReply ¶
type ProxyProcessCheckpointReply struct { }
ProxyProcessCheckpointReply ack for PBFT checkpoint
type ProxyProcessCommitArg ¶
type ProxyProcessCommitArg struct {
Req Request
}
ProxyProcessCommitArg holds Commit Phase declarative args
type ProxyProcessCommitReply ¶
type ProxyProcessCommitReply struct { }
ProxyProcessCommitReply reply ack for PBFT commit phase
type ProxyProcessNewViewArg ¶
ProxyProcessNewViewArg holds new view arg for client request
type ProxyProcessNewViewReply ¶
type ProxyProcessNewViewReply struct { }
ProxyProcessNewViewReply reply ack for new view request
type ProxyProcessPrePrepareArg ¶
ProxyProcessPrePrepareArg holds context for committee, maps Request to client
type ProxyProcessPrePrepareReply ¶
type ProxyProcessPrePrepareReply struct { }
ProxyProcessPrePrepareReply is a stub atm, an ack of reply
type ProxyProcessPrepareArg ¶
ProxyProcessPrepareArg holds client-request context for Prepare phase of PBFT
type ProxyProcessPrepareReply ¶
type ProxyProcessPrepareReply struct { }
ProxyProcessPrepareReply is a stub atm, an ack of reply to trigger Prepare
type ProxyProcessViewChangeArg ¶
ProxyProcessViewChangeArg holds view change context from previous request
type ProxyProcessViewChangeReply ¶
type ProxyProcessViewChangeReply struct { }
ProxyProcessViewChangeReply holds view change reply context
type Request ¶
type Request struct { Inner RequestInner Dig DigType Sig MsgSignature }
Request is the object juggled between the nodes
func (*Request) AddSig ¶
func (req *Request) AddSig(privKey *ecdsa.PrivateKey)
AddSig signs message with private key of node
type RequestInner ¶
type RequestInner struct { ID int Seq int View int Reqtype int //or int? Msg MsgType Block *pb.PbftBlock Timestamp int64 }
RequestInner represents the core structure of a request Reqtype maps to following iota'ed constants ( typePrePrepare, typePrepare, typeCommit, typeInit,
typeRequest, typeViewChange, typeNewView, typeCheckpoint )
type Server ¶
type Server struct { IP string Port int Nd *Node Cfg *Config // contains filtered or unexported fields }
Server defines the base properties of a pbft node server
func BuildServer ¶
BuildServer initiates the Server resource properties and listens to client's message requests as well as interacts with the channel
type Slowchain ¶
type Slowchain struct {
Csize int `yaml:"csize"` // Snailchain's chainsize
}
Slowchain defines attiributes specific to slowchain. Note: Csize is just a placeholder and has no use.
type Testbed ¶
type Testbed struct { Total int `yaml:"total"` ClientID int `yaml:"client_id"` InitServerID int `yaml:"server_id_init"` ThreadingEnabled bool `yaml:"threading_enabled"` MaxRetries int `yaml:"max_retries"` MaxRequests int `yaml:"max_requests"` BatchSize int `yaml:"batch_size"` }
Testbed configuration params are a stimulus for simulation
type Tunables ¶
type Tunables struct { // struct tags, to add metadata to a struct's fields // testbed config Testbed `yaml:"testbed"` Slowchain `yaml:"slowchain"` General `yaml:"general"` BftCommittee `yaml:"bft_committee"` }
Tunables is grouped under the struct Config, cocoon params for the server
func DefaultTunables ¶
func DefaultTunables() *Tunables
DefaultTunables contains default values for Tunables, in case, config file wasn't found
type TxPool ¶
type TxPool struct {
// contains filtered or unexported fields
}
TxPool defines the transaction pool
func (*TxPool) Add ¶
func (tp *TxPool) Add(tx *pb.Transaction, sender []byte)
Add adds a new transaction from sender account to the transaction pool
func (*TxPool) Get ¶
func (tp *TxPool) Get(txHash common.Hash) *pb.Transaction
Get returns a transaction if it is contained in the pool and nil otherwise.
func (*TxPool) GetTxCount ¶
GetTxCount returns the number of transactions currently in the transaction pool