Documentation ¶
Index ¶
- Constants
- Variables
- func Addr2IP(addr net.Addr) string
- func MakeName(name, version string) string
- func MakePoWTarget(difficulty, targetBits uint) []byte
- func PrettyStorage(storage uint64) string
- func Sizeof(i interface{}) (size uint64)
- type BLSPrivKey
- type BLSPubKey
- type BlsMaster
- func (bm *BlsMaster) Destroy() bool
- func (bm *BlsMaster) GetAddress() common.Address
- func (bm *BlsMaster) GetPublicKey() bls.PublicKey
- func (bm *BlsMaster) Print()
- func (bm *BlsMaster) SignHash(hash [32]byte) []byte
- func (bm *BlsMaster) SignMessage(msg []byte) bls.Signature
- func (bm *BlsMaster) ValidateKeyPair() bool
- func (bm *BlsMaster) VerifySignature(signature, msgHash, blsPK []byte) (bool, error)
- type Bytes32
- func (b Bytes32) AbbrevString() string
- func (b Bytes32) Bytes() []byte
- func (b Bytes32) Equal(a Bytes32) bool
- func (b Bytes32) IsZero() bool
- func (b *Bytes32) MarshalJSON() ([]byte, error)
- func (b Bytes32) String() string
- func (b Bytes32) ToBlockShortID() string
- func (b *Bytes32) UnmarshalJSON(data []byte) error
- type ForkConfig
- type ID
- type MemStore
- type NetAddress
- func (na *NetAddress) Dial() (net.Conn, error)
- func (na *NetAddress) DialString() string
- func (na *NetAddress) DialTimeout(timeout time.Duration) (net.Conn, error)
- func (na *NetAddress) Equals(other interface{}) bool
- func (na *NetAddress) Local() bool
- func (na *NetAddress) RFC1918() bool
- func (na *NetAddress) RFC3849() bool
- func (na *NetAddress) RFC3927() bool
- func (na *NetAddress) RFC3964() bool
- func (na *NetAddress) RFC4193() bool
- func (na *NetAddress) RFC4380() bool
- func (na *NetAddress) RFC4843() bool
- func (na *NetAddress) RFC4862() bool
- func (na *NetAddress) RFC6052() bool
- func (na *NetAddress) RFC6145() bool
- func (na *NetAddress) ReachabilityTo(o *NetAddress) int
- func (na *NetAddress) Routable() bool
- func (na *NetAddress) Same(other interface{}) bool
- func (na *NetAddress) String() string
- func (na *NetAddress) Valid() bool
- type NodeKey
- type PrettyDuration
- type TimeoutCert
- type Transactions
- type ValidatorDef
Constants ¶
const ( // --------------------- Epoch -------------------------- MTR = byte(0) MTRG = byte(1) // ------------------ Basics ---------------------------- BlockInterval uint64 = 10 // time interval between two consecutive blocks. BaseTxGas uint64 = ParamsTxGas // 21000 TxGas uint64 = 5000 // InitialGasLimit was 10 *1000 *100, only accommodates 476 Txs, block size 61k, so change to 200M SloadGas uint64 = 200 // EIP158 gas table SstoreSetGas uint64 = ParamsSstoreSetGas SstoreResetGas uint64 = ParamsSstoreResetGas NBlockDelayToEnableValidatorSet = 4 )
Constants of block chain.
const ( MaximumExtraDataSize uint64 = 32 // Maximum size extra data may be after Genesis. ExpByteGas uint64 = 10 // Times ceil(log256(exponent)) for the EXP instruction. ParamsSloadGas uint64 = 50 // Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. CallValueTransferGas uint64 = 9000 // Paid for CALL when the value transfer is non-zero. CallNewAccountGas uint64 = 25000 // Paid for CALL when the destination address didn't exist prior. ParamsTxGas uint64 = 21000 // Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions. ParamsTxGasContractCreation uint64 = 53000 // Per transaction that creates a contract. NOTE: Not payable on data of calls between transactions. TxDataZeroGas uint64 = 4 // Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. QuadCoeffDiv uint64 = 512 // Divisor for the quadratic particle of the memory cost equation. LogDataGas uint64 = 8 // Per byte in a LOG* operation's data. CallStipend uint64 = 2300 // Free gas given at beginning of call. Sha3Gas uint64 = 30 // Once per SHA3 operation. Sha3WordGas uint64 = 4 // Once per word of the SHA3 operation's data. ParamsSstoreSetGas uint64 = 20000 // Once per SLOAD operation. ParamsSstoreResetGas uint64 = 5000 // Once per SSTORE operation if the zeroness changes from zero. SstoreClearGas uint64 = 5000 // Once per SSTORE operation if the zeroness doesn't change. SstoreRefundGas uint64 = 15000 // Once per SSTORE operation if the zeroness changes to zero. InitCodeWordGas uint64 = 2 // Once per word of the init code when creating a contract. NetSstoreNoopGas uint64 = 200 // Once per SSTORE operation if the value doesn't change. NetSstoreInitGas uint64 = 20000 // Once per SSTORE operation from clean zero. NetSstoreCleanGas uint64 = 5000 // Once per SSTORE operation from clean non-zero. NetSstoreDirtyGas uint64 = 200 // Once per SSTORE operation from dirty. NetSstoreClearRefund uint64 = 15000 // Once per SSTORE operation for clearing an originally existing storage slot NetSstoreResetRefund uint64 = 4800 // Once per SSTORE operation for resetting to the original non-zero value NetSstoreResetClearRefund uint64 = 19800 // Once per SSTORE operation for resetting to the original zero value WarmStorageReadCostEIP2929 = uint64(100) // WARM_STORAGE_READ_COST JumpdestGas uint64 = 1 // Once per JUMPDEST operation. EpochDuration uint64 = 30000 // Duration between proof-of-work epochs. CallGas uint64 = 40 // Once per CALL operation & message call transaction. CreateDataGas uint64 = 200 // CallCreateDepth uint64 = 1024 // Maximum depth of call/create stack. ExpGas uint64 = 10 // Once per EXP instruction LogGas uint64 = 375 // Per LOG* operation. CopyGas uint64 = 3 // StackLimit uint64 = 1024 // Maximum size of VM stack allowed. TierStepGas uint64 = 0 // Once per operation, for a selection of them. LogTopicGas uint64 = 375 // Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. CreateGas uint64 = 32000 // Once per CREATE operation & contract-creation transaction. Create2Gas uint64 = 32000 // Once per CREATE2 operation SuicideRefundGas uint64 = 24000 // Refunded following a suicide operation. MemoryGas uint64 = 3 // Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. TxDataNonZeroGas uint64 = 68 // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. TxDataNonZeroGasEIP2028 uint64 = 16 // Per byte of non zero data attached to a transaction after EIP 2028 (part in Istanbul) MaxCodeSize = 24576 // Maximum bytecode to permit for a contract MaxInitCodeSize = 2 * MaxCodeSize // Maximum initcode to permit in a creation transaction and create instructions Keccak256Gas uint64 = 30 // Once per KECCAK256 operation. Keccak256WordGas uint64 = 6 // Once per word of the KECCAK256 operation's data. EcrecoverGas uint64 = 3000 // Elliptic curve sender recovery gas price Sha256BaseGas uint64 = 60 // Base price for a SHA256 operation Sha256PerWordGas uint64 = 12 // Per-word price for a SHA256 operation Ripemd160BaseGas uint64 = 600 // Base price for a RIPEMD160 operation Ripemd160PerWordGas uint64 = 120 // Per-word price for a RIPEMD160 operation IdentityBaseGas uint64 = 15 // Base price for a data copy operation IdentityPerWordGas uint64 = 3 // Per-work price for a data copy operation ModExpQuadCoeffDiv uint64 = 20 // Divisor for the quadratic particle of the big int modular exponentiation Bn256AddGas uint64 = 500 // Gas needed for an elliptic curve addition Bn256ScalarMulGas uint64 = 40000 // Gas needed for an elliptic curve scalar multiplication Bn256PairingBaseGas uint64 = 100000 // Base price for an elliptic curve pairing check Bn256PairingPerPointGas uint64 = 80000 // Per-point price for an elliptic curve pairing check )
const IDByteLength = crypto.AddressSize
IDByteLength is the length of a crypto.Address. Currently only 20. TODO: support other length addresses ?
const MaxUint32 = 1<<32 - 1
Variables ¶
var ( // Keys KeyExecutorAddress = BytesToBytes32([]byte("executor")) ZeroAddress = common.HexToAddress("0x0000000000000000000000000000000000000000") )
Keys of governance params.
var ( DifficultyBoundDivisor = big.NewInt(2048) // The bound divisor of the difficulty, used in the update calculations. GenesisDifficulty = big.NewInt(131072) // Difficulty of the Genesis block. MinimumDifficulty = big.NewInt(131072) // The minimum that the difficulty may ever be. DurationLimit = big.NewInt(13) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. )
var NoFork = ForkConfig{ FixTransferLog: MaxUint32, }
NoFork a special config without any forks.
var Size []uint64
Functions ¶
func MakeName ¶
MakeName creates a node name that follows the ethereum convention for such names. It adds the operation system name and Go runtime version the name.
func MakePoWTarget ¶ added in v0.0.2
MakePoWTarget returns the big-endian encoding of 2^(targetBits - difficulty) - 1. It can be used as a Proof of Work target. NOTE: targetBits must be a multiple of 8 and difficulty must be less than targetBits.
func PrettyStorage ¶
Types ¶
type BLSPrivKey ¶
type BLSPrivKey []byte
func NewBlsPrivKey ¶
func NewBlsPrivKey() BLSPrivKey
func (BLSPrivKey) Bytes ¶
func (k BLSPrivKey) Bytes() []byte
func (BLSPrivKey) PubKey ¶
func (k BLSPrivKey) PubKey() cmtcrypto.PubKey
func (BLSPrivKey) Type ¶
func (k BLSPrivKey) Type() string
type BLSPubKey ¶
type BLSPubKey []byte
crypto.PubKey
type PubKey interface { Address() Address Bytes() []byte VerifySignature(msg []byte, sig []byte) bool Equals(other PubKey) bool Type() string }
type BlsMaster ¶
type BlsMaster struct { PrivKey bls.SecretKey //my private key PubKey bls.PublicKey //my public key CmtPrivKey cmtcrypto.PrivKey CmtPubKey cmtcrypto.PubKey }
func NewBlsMasterWithCometKeys ¶ added in v0.0.2
func NewBlsMasterWithRandKey ¶
func NewBlsMasterWithRandKey() *BlsMaster
func (*BlsMaster) Destroy ¶
BLS is implemented by C, memeory need to be freed. Signatures also need to be freed but Not here!!!
func (*BlsMaster) GetAddress ¶
func (*BlsMaster) GetPublicKey ¶
func (*BlsMaster) SignMessage ¶
sign the part of msg
func (*BlsMaster) ValidateKeyPair ¶
type Bytes32 ¶
type Bytes32 [32]byte
Bytes32 array of 32 bytes.
func BytesToBytes32 ¶
BytesToBytes32 converts bytes slice into Bytes32. If b is larger than Bytes32 legnth, b will be cropped (from the left). If b is smaller than Bytes32 length, b will be extended (from the left).
func MustParseBytes32 ¶
MustParseBytes32 convert string presented into Bytes32 type, panic on error.
func ParseBytes32 ¶
ParseBytes32 convert string presented into Bytes32 type
func (Bytes32) AbbrevString ¶
AbbrevString returns abbrev string presentation.
func (*Bytes32) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Bytes32) ToBlockShortID ¶
Number extract block number from block id.
func (*Bytes32) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type ForkConfig ¶
type ForkConfig struct {
FixTransferLog uint32
}
ForkConfig config for a fork.
func GetForkConfig ¶
func GetForkConfig(genesisID Bytes32) ForkConfig
GetForkConfig get fork config for given genesis ID.
func (ForkConfig) String ¶
func (fc ForkConfig) String() string
type ID ¶ added in v0.0.2
type ID string
ID is a hex-encoded crypto.Address.
func PubKeyToID ¶ added in v0.0.2
PubKeyToID returns the ID corresponding to the given PubKey. It's the hex-encoding of the pubKey.Address().
type MemStore ¶
type MemStore struct {
// contains filtered or unexported fields
}
func NewMemStore ¶
func NewMemStore() *MemStore
type NetAddress ¶
type NetAddress struct { IP net.IP `json:"ip"` Port uint32 `json:"port"` // contains filtered or unexported fields }
NetAddress defines information about a peer on the network including its ID, IP address, and port.
func NewNetAddress ¶
func NewNetAddress(addr net.Addr) *NetAddress
NewNetAddress returns a new NetAddress using the provided TCP address. When testing, other net.Addr (except TCP) will result in using 0.0.0.0:0. When normal run, other net.Addr (except TCP) will panic. TODO: socks proxies?
func NewNetAddressFromNetIP ¶
func NewNetAddressFromNetIP(ip netip.Addr, port uint32) *NetAddress
NewNetAddressIPPort returns a new NetAddress using the provided IP and port number.
func (*NetAddress) Dial ¶
func (na *NetAddress) Dial() (net.Conn, error)
Dial calls net.Dial on the address.
func (*NetAddress) DialString ¶
func (na *NetAddress) DialString() string
func (*NetAddress) DialTimeout ¶
DialTimeout calls net.DialTimeout on the address.
func (*NetAddress) Equals ¶
func (na *NetAddress) Equals(other interface{}) bool
Equals reports whether na and other are the same addresses, including their ID, IP, and Port.
func (*NetAddress) Local ¶
func (na *NetAddress) Local() bool
Local returns true if it is a local address.
func (*NetAddress) RFC1918 ¶
func (na *NetAddress) RFC1918() bool
func (*NetAddress) RFC3849 ¶
func (na *NetAddress) RFC3849() bool
func (*NetAddress) RFC3927 ¶
func (na *NetAddress) RFC3927() bool
func (*NetAddress) RFC3964 ¶
func (na *NetAddress) RFC3964() bool
func (*NetAddress) RFC4193 ¶
func (na *NetAddress) RFC4193() bool
func (*NetAddress) RFC4380 ¶
func (na *NetAddress) RFC4380() bool
func (*NetAddress) RFC4843 ¶
func (na *NetAddress) RFC4843() bool
func (*NetAddress) RFC4862 ¶
func (na *NetAddress) RFC4862() bool
func (*NetAddress) RFC6052 ¶
func (na *NetAddress) RFC6052() bool
func (*NetAddress) RFC6145 ¶
func (na *NetAddress) RFC6145() bool
func (*NetAddress) ReachabilityTo ¶
func (na *NetAddress) ReachabilityTo(o *NetAddress) int
ReachabilityTo checks whenever o can be reached from na.
func (*NetAddress) Routable ¶
func (na *NetAddress) Routable() bool
Routable returns true if the address is routable.
func (*NetAddress) Same ¶
func (na *NetAddress) Same(other interface{}) bool
Same returns true is na has the same non-empty ID or DialString as other.
func (*NetAddress) String ¶
func (na *NetAddress) String() string
String representation: <IP>:<PORT>
func (*NetAddress) Valid ¶
func (na *NetAddress) Valid() bool
For IPv4 these are either a 0 or all bits set address. For IPv6 a zero address or one that matches the RFC3849 documentation address format.
type NodeKey ¶
NodeKey is the persistent peer key. It contains the nodes private key for authentication.
func LoadNodeKey ¶
LoadNodeKey loads NodeKey located in filePath.
func LoadOrGenNodeKey ¶
LoadOrGenNodeKey attempts to load the NodeKey from the given filePath. If the file does not exist, it generates and saves a new NodeKey.
func (*NodeKey) ID ¶ added in v0.0.2
ID returns the peer's canonical ID - the hash of its public key.
type PrettyDuration ¶
PrettyDuration is a pretty printed version of a time.Duration value that cuts the unnecessary precision off from the formatted textual representation.
func (PrettyDuration) String ¶
func (d PrettyDuration) String() string
String implements the Stringer interface, allowing pretty printing of duration values rounded to three decimals.
type TimeoutCert ¶
type TimeoutCert struct { Epoch uint64 Round uint32 BitArray *cmn.BitArray MsgHash [32]byte AggSig []byte }
definition for TimeoutCert
func (*TimeoutCert) DecodeRLP ¶
func (tc *TimeoutCert) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder.
func (*TimeoutCert) EncodeRLP ¶
func (tc *TimeoutCert) EncodeRLP(w io.Writer) error
EncodeRLP implements rlp.Encoder.
func (*TimeoutCert) SigningHash ¶
func (tc *TimeoutCert) SigningHash() (hash Bytes32)
func (*TimeoutCert) String ¶
func (tc *TimeoutCert) String() string
type Transactions ¶
Transactions a slice of transactions.
func (Transactions) Convert ¶
func (txs Transactions) Convert() [][]byte
func (Transactions) RootHash ¶
func (txs Transactions) RootHash() cmtbytes.HexBytes
RootHash computes merkle root hash of transactions.