Giter VIP home page Giter VIP logo

ilp-plugin-bells's People

Contributors

adrianhopebailie avatar alandotcom avatar emschwartz avatar justmoon avatar matthewphinney avatar michielbdejong avatar sentientwaffle avatar vhpoet avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ilp-plugin-bells's Issues

4 generators missing yield statements

SonarQube shows 4errors in the ilp-plugin-bells code

all 4 are the same: "Add a "yield" statement to this generator."

Example code missing a yield in src/errors/external-error.js, line 7:
class ExternalError extends BaseError {
handler (ctx, log) {
log.warn('External Error: ' + this.message)
ctx.status = 502
ctx.body = {
id: this.name,
message: this.message,
owner: this.accountIdentifier
}
}
}
src/errors/external-error.js
L7

src/errors/unprocessable-entity-error.js
L6

src/errors/unrelated-notification-error.js
L8

src/lib/factory.js
L117

Don't retry http requests forever

It seems like if you give the plugin an incorrect or malformatted URL to send a request to (e.g. blah), it will continue retrying the request forever. It may do it with an increasing backoff but it should have an absolute cutoff or some point when it will just give up.

Incompatibility between version 10.2.6 and five-bells-ledger version 19

Currently, we can probably expect all five-bells-ledger instances to run version 19.4.2, which means they use version 21.0.2 of five-bells-shared. This means the execution_condition field in FiveBellsTransfer objects should start with cc:

Yet, ilp-plugin-bells version 10.2.6 is not prepending this prefix to the base64 executionCondition that is coming from the plugin interface

I'm still looking for ways to confirm that this is actually what happened, but it seems that this incompatibility was not detected by our integration tests (they only look at the latest version of each component, not on the version of each component that is currently used by ilp-kit), and that this is what brought down the Interledger community network. :/

Token needs to be refreshed after 7 days

Currently, the plugin will fetch an auth token and reconnect with it whenever its connection is dropped. For long-term ledger connections, this is not sufficient. After 7 days, the token will no longer be valid, and so all reconnection attempts will fail. The plugin needs to re-fetch the auth token after some amount of time, so it can retain its subscription.

Change error message when account doesn't exist

If the plugin tries to connect to an account that doesn't exist it will throw Failed to resolve ledger URI from account URI. If GETting the account returns a 404 it should throw a more specific error.

Login by identifier is broken

This commit in ilp-kit removed the ledgerAccount rel from webfinger which broke login via identifier.

interledger-deprecated/ilp-kit@35b7377#diff-70b4ca4f42e3ae499c1764dd3cf2bea8L121

Logging in by account URI is very unintuitive, so we should add some way to log in knowing only the SPSP identifier.

As I see it, there are two options:

  1. Re-add ledgerAccount to the webfinger in ilp-kit.
  2. Split the SPSP identifier at the @, webfinger the hostname to get the ledger uri, then insert the account name into the account url template.

Option no 1 is cleaner, but I don't like adding extra rels if they're not strictly needed.

Option no 2 is more complicated, but might be more robust since it is using only commonly used features.

Thoughts?

WebSocket error handling

There are three places where ws.send is called, and none of them use an error callback.

In particular, if the ledger was restarted but the process in which the plugin runs was not, I would expect all subsequent ws.send attempts to fail. When this happens, it should close the current WebSocket and try to connect a new one.

I'll assign this to myself and have a look at it today/tomorrow.

Remove dependency on f-b-shared

Including five-bells-shared causes ed25519 to be compiled, which is totally unnecessary considering that ilp-plugin-bells is only using a couple of error types.

Duplicate Code

src/lib/plugin.js has two duplicate sections. The first is from line 450-475, which repeats from line 497 to 522.

Get prefix from ledger

We shouldn't need to configure plugin bells with the prefix because it should be able to get it from the ledger

document api

The readme only gives an example of how to use this plugin as an admin, to listen to all ledger messages. Even if this package just implements the standard ILP plugin API, we should still document what the options for constructor arguments are.

Reduce dependency size

Reducing the dependency size would make it more reasonable to include ilp-plugin-bells by default in libraries like ilp.

According to cost-of-modules, we could dramatically reduce the size by using the broken out lodash packages that we need and switching from co-request to superagent (which is 1.13 Mb instead of 4.42):

┌────────────────┬─────────────┬───────┐
│ name           │ children    │ size  │
├────────────────┼─────────────┼───────┤
│ lodash         │ 0           │ 4.84M │
├────────────────┼─────────────┼───────┤
│ co-request     │ 63          │ 4.42M │
├────────────────┼─────────────┼───────┤
│ ws             │ 2           │ 0.21M │
├────────────────┼─────────────┼───────┤
│ reconnect-core │ 2           │ 0.17M │
├────────────────┼─────────────┼───────┤
│ debug          │ 1           │ 0.09M │
├────────────────┼─────────────┼───────┤
│ path-to-regexp │ 1           │ 0.06M │
├────────────────┼─────────────┼───────┤
│ eventemitter2  │ 0           │ 0.05M │
├────────────────┼─────────────┼───────┤
│ co             │ 0           │ 0.03M │
├────────────────┼─────────────┼───────┤
│ 8 modules      │ 66 children │ 9.79M │
└────────────────┴─────────────┴───────┘

Refactor connect method and options handling

The connect method is currently used as an asynchronous constructor of sorts. There are a lot of paths through this code and many are probably not safe.

  • Move asynchronous options resolution, sanitization and normalization into a separate method (currently in connect.)
  • Before connecting successfully, much of the plugin's internal state is incomplete, so it should refuse all calls to its other methods until connect has been called successfully.

Error module

I think it would make sense for errors specified in the plugin interface specification to be extracted from this project into a plugin error module since they will be used in every plugin implementation.

use strict

Hi guys,

Are you not missing 'use strict' in some of the files of this plugin?

model/transferlog.js
util/log.js
model/balance.js
test/helpers/sqliteStore.js
test/helpers/objStore.js

disconnect takes a full 60 seconds

Save this as test.js:

// const log = require('why-is-node-running') // should be your first require
const FiveBellsLedgerPlugin = require('ilp-plugin-bells')

let plugin = new FiveBellsLedgerPlugin({
  account: 'https://red.ilpdemo.org/ledger/accounts/alice',
  password: 'alice'
});

plugin.connect().then(() => {
  console.log('connected!')
  return plugin.disconnect()
}).then(() => {
  console.log('disconnected, expecting process to exit now...')
  plugin = null
  // log() // logs out active handles that are keeping node running
})

Now run (the --expose-internals is needed because of mafintosh/why-is-node-running#7):

npm install ilp-plugin-bells why-is-node-running
node --expose-internals test.js

You will see the process hangs after the 'disconnected, expecting process to exit now...' statement.
Unfortunately, if you uncomment the first line, the process crashes with an error in net.js, so I haven't been able yet to acually use why-is-node-running to find out why node is running..

@sentientwaffle any idea why the node process keeps running even after you call plugin.disconnect()? Seems to me it's probably related to the whole WebSocket reconnect logic, which is now properly complex in https://github.com/interledgerjs/ilp-plugin-bells/blob/master/src/lib/plugin.js#L211-L330

getPrefix call throws an exception

Connector is calling getPrefix which throws an exception.

Here's the plugin-bells instance when the getPrefix is called.

FiveBellsLedger {
  _events:
   { '_rpc:notification': [Function],
     incoming_transfer: [Function],
     incoming_prepare: [Function],
     incoming_fulfill: [Function],
     incoming_cancel: [Function],
     incoming_reject: [Function],
     outgoing_transfer: [Function],
     outgoing_prepare: [Function],
     outgoing_fulfill: [Function],
     outgoing_cancel: [Function],
     outgoing_reject: [Function],
     incoming_message: [Function] },
  newListener: false,
  configPrefix: 'us.usd.red.',
  host: null,
  account: 'https://red.ilpdemo.org/ledger/accounts/connie',
  username: undefined,
  identifier: undefined,
  credentials:
   { account: 'https://red.ilpdemo.org/ledger/accounts/connie',
     username: undefined,
     password: '***',
     cert: undefined,
     key: undefined,
     ca: undefined },
  connector: null,
  debugReplyNotifications: false,
  rpcId: 1,
  info: null,
  connection: null,
  connected: false,
  ws: null,
  urls: null }

Here's the exception

2016-12-01T01:23:35.760Z connector:app error Error: Prefix has not been set
    at FiveBellsLedger.getPrefix (/var/app/five-bells-wallet/node_modules/ilp-plugin-bells/src/lib/plugin.js:328:29)
    at RouteBroadcaster._crawlClient (/var/app/five-bells-wallet/node_modules/ilp-connector/src/lib/route-broadcaster.js:100:45)
    at next (native)
    at onFulfilled (/var/app/five-bells-wallet/node_modules/co/index.js:65:19)
    at /var/app/five-bells-wallet/node_modules/co/index.js:54:5
    at co (/var/app/five-bells-wallet/node_modules/co/index.js:50:10)
    at toPromise (/var/app/five-bells-wallet/node_modules/co/index.js:118:63)
    at Array.map (native)
    at arrayToPromise (/var/app/five-bells-wallet/node_modules/co/index.js:154:26)
    at toPromise (/var/app/five-bells-wallet/node_modules/co/index.js:120:49)
    at next (/var/app/five-bells-wallet/node_modules/co/index.js:99:29)
    at onFulfilled (/var/app/five-bells-wallet/node_modules/co/index.js:69:7)
    at /var/app/five-bells-wallet/node_modules/co/index.js:54:5
    at co (/var/app/five-bells-wallet/node_modules/co/index.js:50:10)
    at toPromise (/var/app/five-bells-wallet/node_modules/co/index.js:118:63)
    at next (/var/app/five-bells-wallet/node_modules/co/index.js:99:29)
npm run start-prod-connector exited with code 0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.