Smart contracts for the Besu permissioning system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Sally MacFarlane b1a5afbc33
updated repo links (#211)
3 years ago
.circleci Added Mythx workflow step (#189) 4 years ago
contracts make functions external where possible (#207) 4 years ago
docker renamed environment variable since network ID is overloaded (#167) 5 years ago
migrations changes to match EEA client spec V6 (#200) 4 years ago
public updated colors and images (#185) 4 years ago
scripts fixed bug in processing environment variables (#204) 4 years ago
src upgraded dependencies (#205) 4 years ago
test changes to match EEA client spec V6 (#200) 4 years ago
.dockerignore [OP-15] contracts and dapp restructure (#85) 5 years ago
.editorconfig [OP-15] contracts and dapp restructure (#85) 5 years ago
.gitignore [OP-15] typescript contracts and tests (#91) 5 years ago
.istanbul.yml Add a release job to run when the repo has a tag created on it (#161) 5 years ago
.mythx.yml Add MythX Vulnerability scanning to CI (#187) 4 years ago
.prettierignore Added prettier for code style checking (#102) 5 years ago
.solcover.js [OP-15] contracts and dapp restructure (#85) 5 years ago
.soliumignore solium linting (#9) 6 years ago
.soliumrc.json PIE-1515: Rules contract with linked list library (#39) 6 years ago
.yarnrc [OP-62] release job (#117) 5 years ago
CLA.md Update links (#182) 4 years ago
CODE-OF-CONDUCT.md Update links (#182) 4 years ago
CONTRIBUTING.md updated repo links (#211) 3 years ago
GOVERNANCE.md Update links (#182) 4 years ago
LICENSE Setting up (#1) 6 years ago
README.md added instructions for how to update snapshots (#195) 4 years ago
genesis.json changes to match EEA client spec V6 (#200) 4 years ago
jest.config.js [OP-15] typescript contracts and tests (#91) 5 years ago
mocha-reporter-config.json Jenkins recording test results (#25) 6 years ago
package.json yarn add --dev enzyme (#194) 4 years ago
truffle-box.json Setting up (#1) 6 years ago
truffle-config.js [OP-95] Update dependencies for Node >= 12 (#166) 5 years ago
tsconfig.json [OP-15] contracts and dapp restructure (#85) 5 years ago
yarn.lock upgraded dependencies (#205) 4 years ago

README.md

Permissioning Smart Contracts

Note: The contracts herein have been third party audited. Please contact us if you would like more information, or if you are considering using this Dapp in a production environment.

Important: The dependency chain for this implementation of onchain permissioning includes web3js which is LGPL licensed.

Using

You probably got here from Besu. The Besu documentation describes how to use the contracts for onchain permissioning with Besu.

We recommend you use the latest released version of this project.

Development

Note: The build process for the Dapp is currently not supported on Windows. Please use the provided distribution available at the projects release page if on Windows.

Initialize dependencies

Run yarn install to initialize project dependencies. This step is only required when setting up the project for the first time.

Linting

Linting is set up using solium. To run it over your code execute yarn run lint.

Testing

yarn test

Permissioning Management Dapp

The Dapp will facilitate managing permissioning rules and maintaining the list of admin accounts that can edit rules.

Note: if you want to run against Besu, follow the Besu docs.

ONLY use these instructions if you are doing development work on the Dapp itself, in which case connecting to a development server (Ganache) will enable faster development.

This is the easiest way to get started for development with the permissioning Dapp:

Compile and migrate the contracts (Development mode)

  1. Delete your environment variables named NODE_INGRESS_CONTRACT_ADDRESS, ACCOUNT_INGRESS_CONTRACT_ADDRESS AND CHAIN_ID - you might need to restart your terminal session to have your changes applied. If you are using a .env file, you can comment out the variables.
  2. Start a terminal session and start a Truffle Ganache node running truffle develop. This will start a Ganache node and create a Truffle console session.
  3. In the truffle console, run all migrations from scratch with migrate --reset. Keep this terminal session open to maintain your Ganache node running.

Start the development server

  1. Run yarn run build to build the Dapp.
  2. Run yarn run start to start the web server that is serving our Dapp.
  3. In your browser, connect MetaMask to the Ganache network (the default endpoint is http://127.0.0.1:9545/)
  4. When you start Ganache, it gives you a list of accounts and private keys. Import the first one in MetaMask to impersonate the first admin of the system.
  5. Navigate to http://localhost:3000 to access the Permissioning Dapp.
  6. All changes made to the smart contracts or to the Dapp code are automatically refreshed on the website. There is no need to restart the web server after making changes.

Snapshots

Snapshots are compared as part of the test suite, to check any changes made to the Dapp are sensible. If you change the Dapp, you also need to update the snapshots.

  1. yarn jest -u
  2. or if using npm: npm run test:app -- -u

Build the permissioning Dapp for deployment

  1. Compile and migrate the contracts
  2. Run yarn run build will assemble index.html and all other files in build/
  3. You can use your preferred web server technology to serve the contents of build/ as static files.
  4. You will need to set up MetaMask as for the development server

Deployment

Deploying the contracts

  1. The Besu documentation describes how to use the contracts for onchain permissioning with Besu, including setting environment variables.
  2. The following additional environment variables are optional and can be used to prevent redeployment of rules contracts. If set to true, that contract will not be redeployed and current list data will be preserved. If absent or not set to true, the specified contract will be redeployed. This allows you, for instance, to retain the Admin contract while redeploying NodeRules and AccountRules, or any other combination.
  • RETAIN_ADMIN_CONTRACT=true
  • RETAIN_NODE_RULES_CONTRACT=true
  • RETAIN_ACCOUNT_RULES_CONTRACT=true
  1. The following additional environment variables are optional and can be used to permit accounts and nodes during initial contract deployment
  • INITIAL_ADMIN_ACCOUNTS: The admin account addresses. Comma-separated multiple addresses can be specified
  • INITIAL_ALLOWLISTED_ACCOUNTS: The permitted account addresses. Comma-separated multiple addresses can be specified
  • INITIAL_ALLOWLISTED_NODES: The enode URLs of permitted nodes. Comma-separated multiple nodes can be specified
  1. If this is the first time setting up the project, run yarn install to initialize project dependencies, otherwise skip this step
  2. With these environment variables provided run truffle migrate --reset to deploy the contracts

Deploying the Dapp

  1. Obtain the most recent release (tarball or zip) from the projects release page
  2. Unpack the distribution into a folder that will be available to your webserver
  3. Add to the root of that folder a file config.json with the following contents

Note: The networkID is defined as the chainID in the genesis file.

{
        "accountIngressAddress":  "<Address of the account ingress contract>",
        "nodeIngressAddress": "<Address of the node ingress contract>",
        "networkId": "<ID of your ethereum network>"
}
  1. Use a webserver of your choice to host the contents of the folder as static files directing root requests to index.html