Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full tests #75

Merged
merged 102 commits into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from 99 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
7145343
put-get integration
Aug 9, 2019
12d7c6f
bep-44 data models
Aug 12, 2019
07e80e9
align docs with options
Aug 12, 2019
fca8b37
align cli options with available options
Aug 12, 2019
c88fa95
document the rpc api
Aug 12, 2019
8d9ec0a
test every get
Aug 12, 2019
f2dadfd
put-get test refactor
Aug 12, 2019
fb37ec5
use dht rc for now
Aug 13, 2019
1e0b4c4
mutable test
Aug 13, 2019
2d08b8c
salt support
Aug 13, 2019
0cfb4d3
upgrade dht and hypersign
Aug 14, 2019
a9c76cb
update salt docs
Aug 14, 2019
4b60150
lint/uncomment
Aug 14, 2019
552f07f
bump hyperswarm dht
Aug 29, 2019
4735d6a
bump hypersign dev dep
Aug 29, 2019
6b06b70
support normal string salts
Aug 29, 2019
0d420cc
rm convenience script
Aug 29, 2019
b51b74c
scale test
Sep 2, 2019
2425399
save
Sep 4, 2019
7105bb3
working-ish
davidmarkclements Sep 9, 2019
ad7a7ba
progress
davidmarkclements Sep 9, 2019
400260a
wip on large dht
davidmarkclements Sep 10, 2019
eaf989c
iteration
davidmarkclements Sep 11, 2019
6bf44e6
rebootstrapping bug fix
davidmarkclements Sep 14, 2019
0ef44de
add raw bittorrent-dht scale tests
Sep 16, 2019
21e0153
dht spinup helper
davidmarkclements Sep 19, 2019
0ad531b
many announces same/varied topics
davidmarkclements Sep 20, 2019
577a60d
scenario building
Sep 25, 2019
8ec6952
uncomment
Sep 25, 2019
ed61017
add ephemerality
Oct 4, 2019
8829a13
grenache grape scale test initial happy path
Oct 4, 2019
4cdb61b
horde, basic, cross-linked (non functional), improvements/fixes
Oct 5, 2019
13d82d2
mininet code reorg
Oct 5, 2019
dcb85c2
sane numbers
Oct 5, 2019
4d64f23
lint
Oct 9, 2019
6017ab6
missing dep
Oct 9, 2019
14708d0
rm erroneous file
Oct 9, 2019
8ef8e2e
announce/lookup scale tests
Oct 9, 2019
ad211fa
announce: allow cb as second param
davidmarkclements Oct 9, 2019
e1e7d0f
rpc basic fix
davidmarkclements Oct 9, 2019
535e96f
1-announce-M-lookup.js fix
davidmarkclements Oct 9, 2019
2166039
upgrade standard
davidmarkclements Oct 9, 2019
52ad6d2
lint with updated standard rules
davidmarkclements Oct 9, 2019
775fda9
unnanounce bugfix
davidmarkclements Oct 9, 2019
4b6f92d
relint
Oct 9, 2019
085c421
put-get scale tests, first pass
Oct 10, 2019
0d7cc7d
fixes
davidmarkclements Oct 14, 2019
7c19501
safer err handling on immutableGet
Oct 14, 2019
a2c8175
lint
Oct 14, 2019
44782c2
describe bubbled errors as generic
Oct 14, 2019
4c29b24
support hash buffer mutable gets
Oct 17, 2019
c0f8239
lint
Oct 17, 2019
55ee9e4
test refactor
Oct 25, 2019
0827d3b
better error handling for http server
Oct 28, 2019
efca276
test setup improvements
Oct 28, 2019
fe3f662
unnanounce tests
Oct 28, 2019
b75eeb8
announce/unnanounce full cov
Oct 28, 2019
fb44b0f
test address method
Oct 28, 2019
22cccb1
get/put programmatic tests, port collision tests, rm async lib dep
Oct 28, 2019
5fce1cb
rm dead code paths
Oct 28, 2019
b08bf01
close event
Oct 28, 2019
641616f
more cov
Oct 28, 2019
a8b831b
lint
Oct 29, 2019
340dc69
improve dos tests, replace request with supertest
Oct 29, 2019
5ea1f7a
error handling improvements + rpc tests
Oct 29, 2019
ed89d11
error handling improve
Oct 29, 2019
c960d60
announce/lookup rpc tests
Oct 29, 2019
5074eef
ensure cleanup/exit on fail
Oct 29, 2019
4ad32f1
lint
Oct 29, 2019
4169276
do not include stack in message of generic errors
Oct 29, 2019
8b84c24
rpc unannounce tests
Oct 30, 2019
38659dc
generic errors refactor
Oct 30, 2019
1264698
more cov
Nov 1, 2019
580a530
95% cov
Nov 1, 2019
fcc200d
100% cov standard met and enforced
Nov 2, 2019
bf94da9
avoid using user input (url route) to determine function calls
Nov 2, 2019
4137480
wasteland compat
Nov 3, 2019
70d83d9
compat adjustments
Nov 3, 2019
0c36029
expose token
Nov 3, 2019
0a086cb
cache bust travis ci for gh repo branch dep
Nov 3, 2019
0b6b4ce
support for key only mutable get
Nov 3, 2019
a6b8d81
scale test runner
Nov 7, 2019
29efeb4
protect scale tests against freezing
Nov 7, 2019
400a4fb
hyperswarm scale tests freeze protection
Nov 7, 2019
92591f5
hs scale test fixes
Nov 7, 2019
f6e14bc
rm token, improve same seq test
Nov 15, 2019
8fda482
sync dht tmp commit
Nov 15, 2019
5f946e6
add options.sign functionality
Nov 22, 2019
7b8b035
ed25519-supercop compat test
Nov 22, 2019
54fda09
improve init startup error hadling
Nov 24, 2019
a6bbd2d
align announce api with legacy, e.g. second param is hits
Nov 24, 2019
f1f091e
typo
Nov 24, 2019
fabff64
clear init error on stop
Nov 24, 2019
74e5d38
improve test reliability
Nov 24, 2019
c725dd2
bump hs dht
Nov 29, 2019
ced566f
scale tests spinup fix
Dec 4, 2019
f57ef1b
easier scale test cmds
Dec 4, 2019
a9acdce
remove k for immutable get
Dec 17, 2019
49bc289
rm node_liveness option
Dec 18, 2019
693b8fb
lint
Dec 18, 2019
58b11a0
rm node liveness default config
Dec 18, 2019
aaeec9b
update get-port dev dep
Dec 19, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
coverage/
package-lock.json
.DS_Store
.nyc_output
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ sudo: false
language: node_js
node_js:
- 8
- 10
- 12
script:
- npm run ci
92 changes: 85 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@ bind-to-address]
Options:
-b, --bind Listening host [string]
--dp, --dht_port DHT listening port [number] [required]
--dc, --dht_concurrency DHT concurrency [number]
--dht_maxTables DHT max tables [number]
--de, --dht_ephemeral DHT node epemerality [number]
--dht_maxValues DHT max values [number]
--bn, --bootstrap Bootstrap nodes [string] [required]
--aph, --api_port HTTP api port [number] [required]
--dht_peer_maxAge, --dpa Max age for peers in DHT [number]
--cache_maxAge Maximum cache age [number]
--dnl, --dht_nodeLiveness Interval in ms to check for dead nodes [number]
--check_maxPayloadSize Limit for max payload size [number]
--help Show help [boolean]
--version Show version number [boolean]
Expand Down Expand Up @@ -76,10 +73,9 @@ g.start()

- `options` <Object> Options for the link
- `host` <String> IP to bind to. If null, Grape binds to all interfaces
- `dht_maxTables` <Number> Maximum number of DHT tables
- `dht_ephemeral` <Boolean> Whether to join the DHT (false) or just query it (true). Default is false
davidmarkclements marked this conversation as resolved.
Show resolved Hide resolved
- `dht_maxValues` <Number> Maximum number of DHT values
- `dht_port` <Number> Port for DHT
- `dht_concurrency` <Number> Concurrency for DHT
- `dht_bootstrap`: <Array> Bootstrap servers
- `dht_peer_maxAge` <Number> maxAge for DHT peers
- `api_port` <Number> Grenache API HTTP Port
Expand All @@ -103,13 +99,95 @@ Emitted when the DHT finds a new node.

#### Event: 'warning'

Emitted when a peer announces itself in order to be stored in the DHT.
Emitted when a warning occurs in the DHT.


#### Event: 'announce'

Emitted when a peer announces itself in order to be stored in the DHT.

#### Event: 'unannounce'

Emitted when a peer unannounces itself in order to be removed from the DHT.

## RPC API

### Immutable Get

#### `POST /get` `{data: hash}`
#### `POST /get` `{data: {hash, m: false}}`

`hash`: A hex string of the hash of the stored value. If `hash` is supplied inside an object, supply an `m` property set to false to disambiguate between mutable/immutable storage.

#### `POST /get` `{data: {hash}}` **Deprecated** **Legacy**

A `hash` in an object with no `m` property should be considered legacy and upgraded to one of the above forms. If this form is used, the request will first attempt a to get the value from the mutable store before attempting the immutable store, so this will be the slowest way to reference immutable data.

#### Response Body

The response body of an Immutable Get takes the following form:

```js
{ id: <hex string of responding node id>,
seq: null, // always null for immutable gets
sig: null, // always null for immutable gets
v: <stored value>,
k: <hash hex string>,
m: false // always false for immutable gets
}
```

### Immutable Put

#### `POST /put` `{data: {v}}`

The `v` property is the value to store.

#### Response Body

The response body will be a hex string containing a hash of the value. This can be passed to a `POST /get` request to fetch the stored value.

### Mutable Get

#### `POST /get` `{data: {key}}`
#### `POST /get` `{data: {hash, m: true}}`

`key`: A hex string of the public key for the signed data.

Mutable data is stored using a public key, so `hash` is a misnomer. However for backwards compatiblity `hash` can also be used to supply the public key for the mutable data. For best results use `hash` with `m: true` (or use `key` instead).

#### `POST /get` `{data: {hash}}` **Deprecated** **Legacy**

A `hash` in an object with no `m` property should be considered legacy and upgraded to one of the above forms.

#### Response Body

The response body of a Mutable Get takes the following form:

```js
{ id: <hex string of responding node id>,
seq: <monotonically increasing sequence number>,
sig: <signature hex string>,
v: <stored value>,
k: <public key hex string>,
salt: <salt string - if any>
m: true // always true for mutable gets
}
```

### Mutable Put

#### `POST /put` `{data: {k, v, sig, [seq, salt]}}`

`k`: The signed public key as a hex string. Required
`v`: The value to store. Required
`sig`: The signature as a hex string corresponding to the public key and value (and salt if supplied). Required
`seq`: The sequence number, used for versioning. Optional
`salt`: The salt as a string

#### Response Body

The response body will be a hex string representing of the public key.

## Implementations

Expand Down
34 changes: 8 additions & 26 deletions bin/grape.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ const program = require('yargs')
type: 'number',
demand: true
})
.option('dc', {
describe: 'DHT concurrency',
alias: 'dht_concurrency',
type: 'number'
})
.option('dht_maxTables', {
describe: 'DHT max tables',
.option('de', {
describe: 'DHT node epemerality',
alias: 'dht_ephemeral',
type: 'number'
})
.option('dht_maxValues', {
Expand All @@ -46,35 +42,24 @@ const program = require('yargs')
alias: 'dpa',
type: 'number'
})
.option('cache_maxAge', {
describe: 'Maximum cache age',
type: 'number'
})
.option('dnl', {
alias: 'dht_nodeLiveness',
describe: 'Interval in ms to check for dead nodes',
type: 'number'
})
.option('check_maxPayloadSize', {
describe: 'Limit for max payload size',
type: 'number'
})
.help('help')
.version()
.example('grape --dp 20001 --dc 32 --aph 30001 --bn \'127.0.0.1:20002,127.0.0.1:20003\'')
.example('grape --dp 20002 --dc 32 --b 127.0.0.1 --aph 40001 --bn \'127.0.0.1:20001,127.0.0.1:20003\'')
.example('grape --dp 20003 --dc 32 --aph 50001 --bn \'127.0.0.1:20001,127.0.0.1:20002\'')
.example('grape --dp 20001 --aph 30001 --bn \'127.0.0.1:20002,127.0.0.1:20003\'')
.example('grape --dp 20002 --b 127.0.0.1 --aph 40001 --bn \'127.0.0.1:20001,127.0.0.1:20003\'')
.example('grape --dp 20003 --aph 50001 --bn \'127.0.0.1:20001,127.0.0.1:20002\'')
.usage('Usage: $0 --dp <dht-port> --aph <http-api-port> --bn <nodes> [--b bind-to-address]')
.argv

const dhtEphemeral = program.de
const dhtPort = program.dp
const apiPort = program.aph
const bind = program.b
const maxDhtPeerAge = program.dpa
const maxCacheAge = program.cache_maxAge
const maxDhtTables = program.dht_maxTables
const maxDhtValues = program.dht_maxValues
const maxDhtConcurrency = program.dht_concurrency
const dhtNodeLiveness = program.dnl
const maxPayloadSize = program.check_maxPayloadSize

Expand All @@ -87,15 +72,12 @@ const dhtBoostrap = _.reduce((program.bn || '').split(','), (acc, e) => {

const g = new Grape({
host: bind,
dht_ephemeral: dhtEphemeral,
dht_port: dhtPort,
dht_bootstrap: dhtBoostrap,
dht_maxTables: maxDhtTables,
dht_maxValues: maxDhtValues,
dht_concurrency: maxDhtConcurrency,
dht_nodeLiveness: dhtNodeLiveness,
api_port: apiPort,
dht_peer_maxAge: maxDhtPeerAge,
cache_maxAge: maxCacheAge,
check_maxPayloadSize: maxPayloadSize
})

Expand Down
Loading