Code Monkey home page Code Monkey logo

indra's Introduction

Indra

Connext is the protocol for p2p micropayments. To learn more about this project, check out our docs. This monorepo contains all the core pieces necessary to run a node in or interact with the Connext Network.

For any unanswered questions, open a new issue or reach out on our Discord channel & we'll be happy to help.

Architecture Overivew

Indra contains several packages to help developers interact with the Connext state channel network:

Launch Indra Locally

Prerequisites:

  • make: Probably already installed, otherwise install w brew install make or apt install make or similar.
  • jq: Probably not installed yet, install w brew install jq or apt install jq or similar.
  • docker: sadly, Docker is kinda annoying to install. See website for instructions.

To start, clone & enter the Indra repo:

git clone https://github.com/ConnextProject/indra.git
cd indra

To build everything and deploy Indra in dev-mode, run the following:

make start

# view the node logs
bash ops/logs.sh node

That's all! But beware: the first time make start is run, it will take a very long time (maybe 10 minutes, depends on your internet speed) but have no fear: downloads will be cached & most build steps won't ever need to be repeated again so subsequent make start runs will go much more quickly. Get this started asap & browse the rest of the README while the first make start runs.

By default, Indra will launch using two local chains (ganache with chain id 1337 and 1338) but you can also run a local Indra stack against a public chain (or multiple chains!) such as Rinkeby. To do so, run make start with a custom INDRA_CHAIN_PROVIDERS environment variable. The variable is formatted as a JSON string with a chainId:providerUrl mapping:

INDRA_CHAIN_PROVIDERS='{"4":"https://rinkeby.infura.io/abc123","42":"https://kovan.infura.io/abc123"}' make start

Note: this will start a local Connext node pointed at a remote chain, so make sure the mnemonic used to start your node is funded in the appropriate native currencies and supported chain assets. By default, the node starts with the account:

mnemonic: "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat";
privateKey: "0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
address: "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";

For more information on developing with Indra stack, see the quickstart.

Resources

Further Reading

Developer Resources and Guides

Contributing

If you're interested in contributing, great! See this guide before starting.

indra's People

Contributors

arjunbhuptani avatar balasan avatar cf19drofxots avatar ch4r10t33r avatar dependabot[bot] avatar erkarl avatar heikofisch avatar hthillman avatar kthomas avatar laynehaber avatar mslipper avatar pedrouid avatar probablyangg avatar renovate-bot avatar rhlsthrm avatar timfaner avatar yahgwai avatar yazzyyaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

indra's Issues

Precommit hook for client (hub)

We need a pre-commit hook that checks if the hub has local client changes that the client module does not. If so, block commit.

Pay users who don't have channels

Expected Behavior

Should be able to pay users who don't have channels open

Current Behavior

Collateralization for tipping breaks

Steps to Reproduce (for bugs)

  1. Start Indra hub.
  2. Load up wallet UI (http://localhost).
  3. Get 1 token from MetaMask (make sure MetaMask is set to the Ganache [0] address, since that's the only one that has the tokens).
  4. Deposit some amount of tokens.
  5. Attempt to pay user who hasn't opened a channel and deposited

Pay Wrapper

Should take an optional fee parameter, and wrap the buy controller's functionality. The optional fee will come from outside of the thread balance, and that should be reflected in the algorithm for floor of collateral when creating threads and displayed/operational balances.

Thread Controller Collateral

Should make sure that the collateral is managed appropriately with thread opening and closing in the "bouncer"

Withdraw tokens

Expected Behavior

Right now we only withdraw ETH, with an exchange. We need to be able to withdraw tokens as well.

Current Behavior

Withdraw exchanges tokens into ETH based on the exchange rate.

Possible Solution

I think everything exists to make this happen, we just need to pass in the correct parameters.

account is not defined

Having an issue starting up a Hub using the instructions in the Readme. This is on Debian 9.

Followed the Readme steps to the letter. Ganache is running fine at the same time.

#truffle migrate --reset --network development
ReferenceError: account is not defined
    at Object.<anonymous> (/root/Indra/truffle.js:19:13)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Function.Config.load (/usr/lib/node_modules/truffle/build/webpack:/packages/truffle-config/index.js:254:1)
    at Function.Config.detect (/usr/lib/node_modules/truffle/build/webpack:/packages/truffle-config/index.js:243:1)
    at Object.run (/usr/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/commands/migrate.js:35:1)
    at Command.run (/usr/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/command.js:101:1)
    at Object.<anonymous> (/usr/lib/node_modules/truffle/build/webpack:/packages/truffle-core/cli.js:22:1)
    at __webpack_require__ (/usr/lib/node_modules/truffle/build/webpack:/webpack/bootstrap b393854eec71a4a28b46:19:1)
    at /usr/lib/node_modules/truffle/build/webpack:/webpack/bootstrap b393854eec71a4a28b46:65:1
    at Object.<anonymous> (/usr/lib/node_modules/truffle/build/cli.bundled.js:71:10)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3

Seems that despite trying to use the development configuration the lack of a defined account in truffle.js is causing the error:

    ropsten: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "3",
      from: account,
      gas: 4700000
    },

Removing the from: account, line fixes the error.

Local client dev in wallet

Wallet is currently using the NPM version of the Connext package. This is probably okay for now, but we may want to have yalc or some way to dev with a local client.

Create script to copy wallet code to PSK

Expected Behavior

A script should take the code from the wallet module in Indra and copy it to Payment Starter Kit

Context

Versioning issues are arising between PSK and the wallet in indra. We should develop in one place and then pull into the other on a regular basis.

Automatically Deposit

Automatically deposit balances associated with signing address into the channel. This functionality should be run on a poller, much like in existing AddressBalanceController

ETH deposit doesn't get confirmed

Expected Behavior

After deposit, I should receive confirmPending status and then the transaction should get confirmed, and funds should show up in the channel.

Current Behavior

When I deposit, i get a proposependingdeposit back, everything gets signed correctly, the console tells me the update was sent to chain. But nothing shows up in chainsaw, I don't get confirmPending, then eventually it times out and nothing ever gets deposited to channel.

Sending userAuthorizedUpdate to 0x9fbda871d559710256a2502a2517b794b482db40: in mempool: 0x1001f5856382df053221a5b8ae06511135d315113b012dfdf68438e094143038

Steps to Reproduce (for bugs)

  1. Launch indra from branch UI-flow
  2. Deposit ETH

Context

Trying to bundle some actions together to improve UX.

Depositing only tokens isn't working

Expected Behavior

Tokens should correctly deposit without depositing ETH.

Current Behavior

Console shows ProposePending is generated and sent to hub, but the userAuthorizedDeposit does not happen on chain.

Possible Solution

Not sure why the deposit isn't happening, everything works if you deposit ETH too.

Steps to Reproduce (for bugs)

  1. Start Indra hub.
  2. Load up wallet UI (http://localhost).
  3. Get 1 token from MetaMask (make sure MetaMask is set to the Ganache [0] address, since that's the only one that has the tokens).
  4. Deposit some amount of tokens and 0 ETH.

Context

Demo needs to work end to end.

Your Environment

  • Version used: Latest
  • Browser Name and version: Chrome
  • Operating System and version (desktop or mobile): MacOS
  • Link to your project: This repo.

Contract Updates

All tests, and any requisite updates. Also includes any internal peer reviews, code walkthroughs, requisite updates. External audits should be in process as well. See here for the full test spec.

Verify Validator Test Cases

Test case for requires in contract verified. Here is full test spec to verify. Include:

  • final balance always increases recipient balance on closeThread
  • cannot open channel with contract

Business Logic for Thread Update

The following changes still need to be made in order to allow the hub to handle threads

  • Collateralization algorithm needs to be tweaked (@rhlsthrm what needs to happen here?)
  • Add a tunable fee on each payment. Thread updates should be rejected if they don't include fee.

Pay directly to a Metamask account

Expected Behavior

Should be able to pay tokens and eth directly to a metamask account that has no channel open

Current Behavior

Can only pay counterparties with channels

Authorize

Make auth function in the client so that it can make calls to the hub. This should happen on a poller when the appropriate AuthController.

Noncustodial (Thread) Payments

User should be able to send a noncustodial P2P payment

Includes any updates relevant to:

  • Client code
  • Contracts
  • Database schema/migrations
  • Chainsaw
  • Any business logic (i.e. collateralization)

Add leftover ETH for gas heuristic in demo

Heuristic will be as follows:

On deposit:

  • Check if 10FIN in browser wallet
  • If not, deposit up to 40FIN + desired deposit

On balance poller:

  • Do not deposit if under 40FIN
  • Deposit everything above 40FIN

Setup better e2e tests

Expected Behavior

Manually clicking through channel operations after every code change is tedious and lazy people like me tend to just not do it.

We need an automated way to test the wallet's logic and it's interactions with the hub code.

Given my painful experiences writing selenium-based e2e tests, I'm going to suggest we explore Cypress as an alternative first before trying to incorporate the traditional e2e test stack.

Run npm install cypress and then figure it out from there

BuyController

Updates to make sure not all payments happen in channel.

Should reflect configurable "fee" on per-payment basis

Metamask as client user

Expected Behavior

Users should be able to use metamask rather than the browser wallet to interact with their channel

Current Behavior

Sample payment UX defaults to browser wallet (done this way so that autosigning works)

Possible Solution

Need toggle that lets users instantiate the client with metamask's web3 injection rather than the custom one

Get modules to run locally

We need to be able to run the individual modules (hub, chainsaw, ethprovider) locally without Docker.

Need way to see autosigner address

Turns out we do need to see the address, since that's where the counterparty would send you money and right now it only shows up in the console. We should add a display somewhere.

Metamask Demo Deposit Borked

Expected Behavior

Depositing into channel from metamask using the deposit button is broken.

Current Behavior

Does not allow for ETH deposits, or token deposits to channel from metamask. Currently, metamask will say the transaction failed, while there is no indication of that in the application.

Create new autosigner is inconsistent

Sometimes when you click create new autosigner, it defaults back to the previous one. This behavior hasn't been consistent for me, so I'll dig deeper.

Reconcile migrations

Camsite repo got some updates to structure things into migrations. We need to implement this in Indra.

Client Updates

Should include

  • Validator, Utils, and StateGenerator updates
  • Controller updates
  • Any wrapper updates

Thread Validator Verification

  • Remove timeout check in thread verification
  • Add address checks for the parties in thread state
  • Verify recipient balance increases at every opportunity

Autosigner reset not working properly

Expected Behavior

After resetting auto signer, it should pop up a better message than "You have an autosigner set up already! You can either use it, recover an old one, or set up an entirely new one.". This behavior is confusing, since I just reset so I want to use the existing one but that's not clear.

Current Behavior

Described above.

Possible Solution

Maybe you can add a storage state like resetHappened so on the next reload it defaults to the signer it just created?

Steps to Reproduce (for bugs)

  1. Choose "Select Signer"
  2. Choose "Autosigner"
  3. Choose "Create New Signer"
  4. Wait for page reload.

Unilateral Disputes

Expected Behavior

Hub should be able to unilaterally close disputes, client should handle this appropriately and recover channel as needed.

Context

Allows hub to reclaim collateral from offline users unilaterally.

Intermittent Yarn issues

We are seeing a variety of yarn related issues mostly from running yarn start. Some of the errors we have seen include:

warning machinomy > @types/[email protected]: This is a stub types definition for commander (https://github.com/tj/commander.js). commander provides its own type definitions, so you don't need @types/commander installed!
warning machinomy > @machinomy/contracts > @machinomy/hdwallet-provider > web3-provider-engine > ethereumjs-block > merkle-patricia-tree > level-ws > xtend > [email protected]:
[2/4] Fetching packages...
[3/4] Linking dependencies...
error An unexpected error occurred: "ENOENT: no such file or directory, lstat '/root/.cache/yarn/v4/npm-@machinomy-hdwallet-provider-1.3.1-a7ecf4b70dfb1f59d550856b8e1884ac0ff6591f/node_modules/@machinomy/hdwallet-provider/
=============
[Makefile] => Start building hub-node-modules
docker run --name=connext_buidler --tty --rm --user 501:20 --volume=/Users/rahul/Desktop/connext/connext/indra/modules/hub:/root connext_builder:dev 501:20 "yarn install --network-timeout 1000000"
Running command as user 501:20
yarn install v1.12.3
info No lockfile found.
[1/4] Resolving packages...
warning connext > web3 > web3-bzz > swarm-js > [email protected]: Use mz or fs-extra^3.0 with Promise Support
warning connext > web3 > web3-bzz > swarm-js > [email protected]: ⚠️  WARNING ⚠️ tar.gz module has been deprecated and your application is vulnerable. Please use tar module instead: https://npmjs.com/tar
warning machinomy > @types/[email protected]: This is a stub types definition for commander (https://github.com/tj/commander.js). commander provides its own type definitions, so you don't need @types/commander installed!
error Received malformed response from registry for "mocha". The registry may be down.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Same user, skipping permission fix
make: *** [hub-node-modules] Error 1
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[2/4] Fetching packages...
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
error https://registry.yarnpkg.com/scrypt.js/-/scrypt.js-0.2.1.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "EEXIST: file already exists, mkdir '/root/.cache/yarn/v4/npm-scrypt-js-0.2.1-cc3f751933d6bac7a4bedf5301d7596e8146cdcd/node_modules/scrypt.js'"
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Same user, skipping permission fix
make: *** [hub-node-modules] Error 1
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The errors appear intermittent and some combination of purging, clearing yarn cache, and simply retrying makes them go away usually. However, this is an annoying issue and needs to be addressed.

Add snapshot helper scripts

Import the snapshot-create and snapshot-restore scripts from the camsite hub & make sure they work in the indra env.

"Reveal Browser Wallet Mnemonic" not working

Expected Behavior

When I click "Reveal Browser Wallet Mnemonic" in the wallet UX, it should reveal the 12-word recovery phrase.

Current Behavior

I click and nothing happens, although the console registers that getKey() was called. It's possible that this is a weird issue with my web3 injection rather than the function, but we should take a look.

Possible Solution

Steps to Reproduce (for bugs)

  1. Start Indra
  2. navigate to localhost
  3. click "reveal browser wallet mnemonic" under Wallet utilities

Channel Status

Verify channel statuses in the controllers of the client

Demo Wallet UI Updates

We should make the UI for the wallet a little cleaner prior to demoing it further. UI mockups coming here soon.

This one's high priority so that we can get it out asap.

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.