Documentation
¶
Index ¶
- Constants
- Variables
- func OptionsToFile(options Options, path string) error
- type ChainOptions
- type Contract
- type Fees
- type Options
- type Selector
- func (selector Selector) Asset() multichain.Asset
- func (selector Selector) Contract() string
- func (selector Selector) Destination() multichain.Chain
- func (selector Selector) Fn() string
- func (Selector) Generate(r *rand.Rand, size int) reflect.Value
- func (selector Selector) IsBurn() bool
- func (selector Selector) IsClaimFees() bool
- func (selector Selector) IsCrossChain() bool
- func (selector Selector) IsIntrinsic() bool
- func (selector Selector) IsLock() bool
- func (selector Selector) IsMint() bool
- func (selector Selector) IsRelease() bool
- func (selector Selector) IsReturnStateAndOutputs() bool
- func (selector Selector) Marshal(buf []byte, rem int) ([]byte, int, error)
- func (selector Selector) MarshalJSON() ([]byte, error)
- func (selector Selector) SizeHint() int
- func (selector Selector) Source() multichain.Chain
- func (selector Selector) String() string
- func (selector *Selector) Unmarshal(buf []byte, rem int) ([]byte, int, error)
- func (selector *Selector) UnmarshalJSON(data []byte) error
- type Simulate
- type SimulateOutOfMemory
- type State
- type SystemState
- type SystemStateEpoch
- type SystemStateNode
- type SystemStateShards
- type SystemStateShardsShard
- type Whitelist
Constants ¶
const ( // SyncWithChainFn is an intrinsic function that is generated by block // proposers when updating the state for a contract. SyncWithChainFn = "syncWithChain" // ChangeFeesFn is an intrinsic function that is generated by block // proposers when updating the mint or burn fees for a host chain. ChangeFeesFn = "changeFees" // EpochFn is an intrinsic function that is generated by block proposers // upon detecting a new epoch. EpochFn = "epoch" // ReturnStateAndOutputsFn is an extrinsic function that is generated by a // shard once it has finished processing transactions in a block. ReturnStateAndOutputsFn = "returnStateAndOutputs" // ClaimFeesFn is an extrinsic function that is used by Darknode operators // to request unclaimed fees earned by their Darknode. ClaimFeesFn = "claimFees" )
Variables ¶
var ( DefaultHome = "/home/darknode/.darknode" DefaultHost = "0.0.0.0" DefaultPort = uint16(18514) DefaultSimulate = Simulate{ SimulateOutOfMemory: SimulateOutOfMemory{ Enable: false, }, } DefaultProfile = false )
Default options.
var ( // RegExToDestinationFromSource captures chains from selectors that // explicitly define their destination and source chains. This regex must be // matched before attempting to match RegExToDestination or // RegExToFromSource. RegExToDestinationFromSource = regexp.MustCompile(`/to(.*)From(.*)`) // RegExToDestination captures the destination chain from selectors that // explicitly define their destination chain. This regex does not work, but // will not error, if the selector also explicitly defines a source chain. // To prevent this, always try and match RegExToDestinationFromSource first. RegExToDestination = regexp.MustCompile(`/to(.*)`) // RegExFromSource captures the source chain from selectors that explicitly // define their source chain. This regex does not work, but will not error, // if the selector also explicitly defines a destination chain. To prevent // this, always try and match RegExToDestinationFromSource first. RegExFromSource = regexp.MustCompile(`/from(.*)`) )
var ( // IntrinsicSelectors is a list of selector functions for intrinsic // transactions. IntrinsicSelectors []string = []string{ ChangeFeesFn, SyncWithChainFn, EpochFn, } )
Functions ¶
func OptionsToFile ¶
OptionsToFile writes the Options to the target file in json format.
Types ¶
type ChainOptions ¶
type ChainOptions struct {
RPC pack.String `json:"rpc"`
Confirmations pack.U64 `json:"confirmations"`
MaxConfirmations pack.U64 `json:"maxConfirmations"`
GasLimit pack.U256 `json:"gasLimit"`
Registry pack.String `json:"registry"`
Fees map[multichain.Chain]Fees `json:"fees"`
Extras map[pack.String]pack.String `json:"extras"`
// TokenAssets are the supported tokens that originate on this chain, e.g.
// USDC, REN for Ethereum.
TokenAssets []multichain.Asset `json:"tokenAssets"`
}
ChainOptions used to parameterise chain-specific behaviour for chains that are supported by the transaction engine bindings. It is expected that these options will be marshalled to/from JSON as part of configuring the overall system.
type Options ¶
type Options struct {
// Home directory for the database and configuration files.
Home string `json:"home"`
// PrivKey that defines the identity of the node.
PrivKey *id.PrivKey `json:"privKey"`
// Peers that the node will use to bootstrap into the network (in addition
// to peers that have been saved to the database).
Peers []wire.Address `json:"peers"`
// Host that will be used to listen for incoming connections.
Host string `json:"host"`
// Port that will be used to listen for incoming connections.
Port uint16 `json:"port"`
// Simulate enables/disables different simulation options. These options
// should only be used during development and testing.
Simulate Simulate `json:"simulate"`
// Profile enables/disables the exposure of profiling information at
// http://localhost:8080.
Profile bool `json:"profile"`
// Network environment. Must be one of "localnet", "testnet", or "mainnet".
Network multichain.Network `json:"net"`
// Chains along with their options.
Chains map[multichain.Chain]ChainOptions `json:"chains"`
// Selectors is a whitelist containing the supported selectors.
Selectors []Selector `json:"selectors"`
// Whitelist contains the pubkeys used in various withdraws
Whitelist Whitelist `json:"whitelist"`
}
Options parameterise the behaviour of a node. During testing, options are usually defined in-memory, however these options can also be marshalled/unmarshalled to/from the disk. This allows the node to keep the exact same configuration between boots, and allows the operator to modify its behaviour at runtime (by modifying the configuration file, and then rebooting the node).
func NewOptions ¶
func NewOptions(network multichain.Network) Options
NewOptions creates a new Options using the default values.
func NewOptionsFromFile ¶
NewOptionsFromFile parses a file to Options.
func OptionTemplate ¶
OptionTemplate fetches and returns the Options template from remote server.
type Selector ¶
type Selector string
A Selector identifies a specific function from a specific contract. The contract comes first, and the function comes second, separated by "/". For example, sending BTC to Ethereum is done by sending a cross-chain transactions to the "BTC/toEthereum" selector.
func (Selector) Asset ¶
func (selector Selector) Asset() multichain.Asset
Asset moving from the source chain to the destination chain.
func (Selector) Destination ¶
func (selector Selector) Destination() multichain.Chain
Destination returns the chain to which assets are moving. For example, "BTC/toEthereum" selector has "Ethereum" as its destination chain, and "BTC/fromEthereum" selector has "Bitcoin" as its destination chain.
func (Selector) Generate ¶
Generate allows us to quickly generate random transaction selectors. This is mostly used for writing tests.
func (Selector) IsBurn ¶
IsBurn returns true if the asset is being burned from a host chain. This is true for burn-and-release and burn-and-mint transactions.
func (Selector) IsClaimFees ¶
IsClaimFees returns true if the selector is for a claim fees tx.
func (Selector) IsCrossChain ¶
IsCrossChain returns true if the selector is for a cross-chain tx.
func (Selector) IsIntrinsic ¶
IsIntrinsic returns true if the selector is for an intrinsic tx.
func (Selector) IsLock ¶
IsLock returns true if the asset is being locked into RenVM on its origin chain. This is true for lock-and-mint transactions.
func (Selector) IsMint ¶
IsMint returns true if the asset is being minted to a host chain. This is true for lock-and-mint and burn-and-mint transactions.
func (Selector) IsRelease ¶
IsRelease returns true if the asset is being released from RenVM back to its origin chain. This is true for burn-and-release transactions.
func (Selector) IsReturnStateAndOutputs ¶
IsReturnStateAndOutputs returns true if the selector is for a return-state-and-outputs tx.
func (Selector) MarshalJSON ¶
MarshalJSON implements the JSON marshaler interface.
func (Selector) SizeHint ¶
SizeHint returns the number of bytes required to represent the selector in binary.
func (Selector) Source ¶
func (selector Selector) Source() multichain.Chain
Source returns the chain from which assets are moving. For example, "BTC/toEthereum" selector has "Bitcoin" as its source chain, and "BTC/fromEthereum" selector has "Ethereum" as its source chain.
func (*Selector) UnmarshalJSON ¶
UnmarshalJSON implements the JSON unmarshaler interface.
type Simulate ¶
type Simulate struct {
SimulateOutOfMemory `json:"oom"`
}
Simulate defines options for enabling/configuring the simulation of test scenarios that are difficult to force externally.
type SimulateOutOfMemory ¶
type SimulateOutOfMemory struct {
Enable bool `json:"enable"`
Min int `json:"min"`
Max int `json:"max"`
}
SimulateOutOfMemory defines options for enabling/configuring the simulation of out-of-memory errors.
type SystemState ¶
type SystemState struct {
Epoch SystemStateEpoch `json:"epoch"`
Nodes []SystemStateNode `json:"nodes"`
Shards SystemStateShards `json:"shards"`
}
SystemState defines the state of the "System" contract. It records information about RenVM itself, including shards, epochs, and so on.
type SystemStateEpoch ¶
type SystemStateEpoch struct {
Hash pack.Bytes32 `json:"hash"`
Number pack.U64 `json:"number"`
NumNodes pack.U64 `json:"numNodes"`
Timestamp pack.U64 `json:"timestamp"`
}
SystemStateEpoch defines the record of the current epoch. It includes the epoch hash and number.
type SystemStateNode ¶
SystemStateNode defines the record of a single node. Currently, it includes the public key of the node.
type SystemStateShards ¶
type SystemStateShards struct {
// Primary shards are used by all new cross-chain transactions.
Primary []SystemStateShardsShard `json:"primary"`
// Secondary shards finish processing the remaining cross-chain transactions
// that are left over from when these shards were primary shards. This
// overlap protects against cross-chain transactions getting lost between
// epochs.
Secondary []SystemStateShardsShard `json:"secondary"`
// Tertiary shards do nothing. They exist to allow time for malicious nodes
// in the shards to be punished for malicious behaviour that may have
// occurred when these shards where primary/secondary shards.
Tertiary []SystemStateShardsShard `json:"tertiary"`
}
SystemStateShards defines the record of shards kept by the "System" contract. At the beginning of every epoch, new primary shards are selected, primary shards become secondary shards, secondary shards become tertiary shards, and tertiary shards are dropped.
type SystemStateShardsShard ¶
type SystemStateShardsShard struct {
Shard pack.Bytes32 `json:"shard"`
PubKey pack.Bytes `json:"pubKey"`
}
SystemStateShardsShard defines the record of one shard. It includes the identify of the shard, and the ECDSA public key of the shard (encoded using the 33-byte compressed format).