/private-chain

⛓An Ethereum PoA private-chain environment on AWS.

Primary LanguageShell

ALIS
An Ethereum private-chain environment for the ALIS that using Parity PoA.

Prerequisite

  • aws-cli
  • packer
  • ansible
  • jq
  • direnv

Environment valuables

# Create .envrc to suit your environment.
cp -pr .envrc.sample .envrc
direnv edit

Preparation

Packer

Build an AMI that the nodes of Parity PoA.

Parity resources

You have to change ETH account keys when you use this in production.

  • ./packer/ansible/roles/parity/templates/PCParityPoA*_key.j2

Also spec.json.

  • ./packer/ansible/roles/parity/templates/spec.json.j2

Build

cd ./packer/
packer build ./parity-poa.json

Create EC2 KeyPair

aws ec2 create-key-pair --key-name private-chain

Create EIP

./create_eip.sh

Set SSM valuables

You have to specify SSM valuables as can as possible.
Such as IAM and EIP information you created above.

CloudFormation

Deployment

./deploy.sh

Fix API settings via a script

# Get API ID
aws apigateway get-rest-apis | jq -r --arg ALIS_API_NAME "${ALIS_APP_ID}api" '.items[] | select(.name==$ALIS_API_NAME).id'

# Set API ID to PRIVATE_CHAIN_REST_API_ID in .envrc
direnv edit

./fix_api.sh

After deployment

Connect Instances via Bastion

cp -p .ec2ssh ~/
vi ~/.ec2ssh

Fix some point for your environment.
Then execute ec2ssh update.

echo -e \\nHost PC*\\n  ProxyCommand ssh -W %h:%p Bastion >> ~/.ssh/config 
ec2ssh update

Now you can connect:

ssh PCParityPoA2a

Also you can use tmuxinator.

cp -p ./private_chain.yml ~/.tmuxinator/
mux private_chain

Configure servers.

# You have to edit HostNames.
vi ./ansible/roles/common/files/config

# Also you have to specify your hosts.
cd ansible
cp -p hosts.sample hosts
vi hosts

# Run ansible
ansible-galaxy install -p ./roles -r requirements.yml
ansible-playbook -i hosts site.yml

Connect Parity nodes each other

You can use [parity dir]/enode.sh.

Migrate private chain contracts from Bastion server

See: Private chain contracts

Fix template.yaml's FIXME: tags and deploy again

Such as IAM Policies, and others.

Set SSM valuables again