Skip to content

Latest commit

 

History

History
 
 

etcddb

etcd Payment Channel Storage

To enable etcd server as a payment channel storage in snet-daemon configure the following properties in the JSON config file:

  • payment_channel_storage_type
  • payment_channel_storage_client
  • payment_channel_storage_server

etcd storage type

There are two payment channel storage types which are currently supported by snet daemon: memory and etcd. memory storage type is used in configuration where only one service replica is used by snet-daemon or for testing purposes.

To run snet-daemon with several replicas set the payment_channel_storage_type to etcd in the json config file:

{
  "payment_channel_storage_type": "etcd"
}

etcd client configuration

payment_channel_storage_client JSON map can be used to configure payment channel storage etcd client.

Field name Description Default Value
connection_timeout timeout for failing to establish a connection 5 seconds
request_timeout per request timeout 3 seconds
endpoints list of etcd cluster endpoints (host:port) ["http://127.0.0.1:2379"]

Endpoints consist of a list of URLs which points to etcd cluster servers.

The following config describes a client which connects to 3 etcd server nodes:

{
	"payment_channel_storage_client": {
		"connection_timeout": "5s",
		"request_timeout": "3s",
		"endpoints": ["http://127.0.0.1:2379", "http://127.0.0.2:2379", "http://127.0.0.3:2379"]
	},
}

etcd server configuration

To use embedded etcd server in snet-daemon the configuration file needs to contain the payment_channel_storage_server JSON map with fields:

Field name Description Default Value
id unique name of the etcd server node storage-1
schema URL schema used to create client and peer and urls http
host host where the etcd server is executed 127.0.0.1
client_port port to listen clients requests 2379
peer_port port to listen etcd peers 2380
token unique initial cluster token unique-token
cluster initial cluster configuration for bootstrapping storage-1=http://127.0.0.1:2380
startup_timeout time to wait that etcd server is successfully started 1 minute
data_dir directory where etcd server stores its data storage-data-dir-1.etcd
log_level etcd server logging level (error, warning, info, debug) info
enabled enable running embedded etcd server true

The cluster field is a comma-separated list of one or more etcd peer URLs in form of id=host:peer_port.

schema, host, and client_port/peer_port are used together to compose etcd listen-client-urls/listen-peer-urls (see the link below).

Using unique token, etcd can generate unique cluster IDs and member IDs for the clusters even if they otherwise have the exact same configuration. This can protect etcd from cross-cluster-interaction, which might corrupt the clusters.

To disable etcd server log messages set log_level field to error.

For more details see etcd Clustering Guide link.

It is possible to configure snet-daemon to run with or without embedded etcd server using the enabled property.

Config for snet-daemon that runs embedded etcd server:

  • enabled field is set to true
{
    "payment_channel_storage_server": {
        "id": "storage-1",
        "host" : "127.0.0.1",
        "client_port": 2379,
        "peer_port": 2380,
        "token": "unique-token",
        "cluster": "storage-1=http://127.0.0.1:2380",
        "enabled": true
    }
}
  • enabled field is omitted
{
    "payment_channel_storage_server": {
        "id": "storage-1",
        "host" : "127.0.0.1",
        "client_port": 2379,
        "peer_port": 2380,
        "token": "unique-token",
        "cluster": "storage-1=http://127.0.0.1:2380",
    }
}

Config for snet-daemon that does not run embedded etcd node:

  • enabled field is set to false
{
    "payment_channel_storage_server": {
        "id": "storage-2",
        "host" : "127.0.0.2",
        "client_port": 2379,
        "peer_port": 2380,
        "token": "unique-token",
        "cluster": "storage-1=http://127.0.0.1:2380,storage-2=http://127.0.0.2:2380,storage-3=http://127.0.0.3:2380",
        "enabled": false
    }
}