contract migration refactor

This commit is contained in:
Blair Vanderlugt 2021-03-19 14:19:40 +00:00
parent 7fe5b6bea3
commit e4d1f5b65c
5 changed files with 24 additions and 31 deletions

View File

@ -52,8 +52,6 @@ RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh |
ENV NODE_PATH $NVM_DIR/versions/node//v$NODE_VERSION/lib/node_modules ENV NODE_PATH $NVM_DIR/versions/node//v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node//v$NODE_VERSION/bin:$PATH ENV PATH $NVM_DIR/versions/node//v$NODE_VERSION/bin:$PATH
# RUN pip install --user --extra-index-url $pip_extra_index_url cic-base[full_graph]==$cic_base_version
RUN useradd --create-home grassroots RUN useradd --create-home grassroots
WORKDIR /home/grassroots WORKDIR /home/grassroots
USER grassroots USER grassroots
@ -123,16 +121,13 @@ COPY --from=compile-image /home/grassroots/.local .local
ENV PATH=/home/grassroots/.local/bin:$PATH ENV PATH=/home/grassroots/.local/bin:$PATH
COPY contract-migration/testdata/pgp testdata/pgp COPY contract-migration/testdata/pgp testdata/pgp
COPY contract-migration/wait-for-it.sh .
COPY contract-migration/reset.sh reset.sh
COPY contract-migration/from_env.sh from_env.sh
COPY contract-migration/seed_cic_eth.sh seed_cic_eth.sh
COPY contract-migration/sarafu_declaration.json sarafu_declaration.json COPY contract-migration/sarafu_declaration.json sarafu_declaration.json
COPY contract-migration/keystore keystore COPY contract-migration/keystore keystore
COPY contract-migration/envlist . COPY contract-migration/envlist .
COPY contract-migration/*.sh ./
# RUN chown grassroots:grassroots .local/ # RUN chown grassroots:grassroots .local/
RUN chown grassroots:grassroots ./ RUN chown grassroots:grassroots ./*
RUN chmod gu+x *.sh RUN chmod gu+x *.sh
RUN mkdir -p /tmp/cic/config RUN mkdir -p /tmp/cic/config

View File

@ -19,6 +19,12 @@ echo \n
# pushd /usr/src # pushd /usr/src
init_level_file=${CIC_DATA_DIR}/.init init_level_file=${CIC_DATA_DIR}/.init
if [ ! -f ${CIC_DATA_DIR}/.init ]; then
echo "Creating .init file..."
mkdir -p $CIC_DATA_DIR
touch /tmp/cic/config/.init
# touch $init_level_file
fi
echo -n 1 > $init_level_file echo -n 1 > $init_level_file
# Abort on any error (including if wait-for-it fails). # Abort on any error (including if wait-for-it fails).
@ -61,7 +67,7 @@ export DEV_ETH_ACCOUNTS_INDEX_ADDRESS=$CIC_ACCOUNTS_INDEX_ADDRESS
export BANCOR_REGISTRY_ADDRESS=$BANCOR_REGISTRY_ADDRESS export BANCOR_REGISTRY_ADDRESS=$BANCOR_REGISTRY_ADDRESS
export CIC_REGISTRY_ADDRESS=$CIC_REGISTRY_ADDRESS export CIC_REGISTRY_ADDRESS=$CIC_REGISTRY_ADDRESS
export CIC_TRUST_ADDRESS=$DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER export CIC_TRUST_ADDRESS=$DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER
export CIC_DECLARATOR_ADDRESS=$CIC_DECLARATOR_ADDRESS
EOF EOF
cat ./envlist | bash from_env.sh > $CIC_DATA_DIR/.env_all cat ./envlist | bash from_env.sh > $CIC_DATA_DIR/.env_all

View File

@ -0,0 +1,11 @@
#! /bin/bash
if [[ $RUN_LEVEL -gt 0 ]]
then
./reset.sh
fi
if [[ $RUN_LEVEL -gt 1 ]]
then
./seed_cic_eth.sh
fi

View File

@ -26,6 +26,7 @@ env_out_file=${CIC_DATA_DIR}/.env_seed
init_level_file=${CIC_DATA_DIR}/.init init_level_file=${CIC_DATA_DIR}/.init
truncate $env_out_file -s 0 truncate $env_out_file -s 0
pip install --extra-index-url https://pip.grassrootseconomics.net:8433 chainlib==0.0.1a22
set -e set -e
set -a set -a
@ -125,6 +126,7 @@ export CIC_TOKEN_INDEX_ADDRESS=$CIC_TOKEN_INDEX_ADDRESS
>&2 echo "add declarations for sarafu token" >&2 echo "add declarations for sarafu token"
token_description_one=`sha256sum sarafu_declaration.json | awk '{ print $1; }'` token_description_one=`sha256sum sarafu_declaration.json | awk '{ print $1; }'`
token_description_two=0x54686973206973207468652053617261667520746f6b656e0000000000000000 token_description_two=0x54686973206973207468652053617261667520746f6b656e0000000000000000
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> foo $CIC_DECLARATOR_ADDRESSh"
>&2 eth-address-declarator-add -y $keystore_file -i $CIC_CHAIN_SPEC -p $ETH_PROVIDER -r $CIC_DECLARATOR_ADDRESS -w $debug $DEV_ETH_SARAFU_TOKEN_ADDRESS $token_description_one >&2 eth-address-declarator-add -y $keystore_file -i $CIC_CHAIN_SPEC -p $ETH_PROVIDER -r $CIC_DECLARATOR_ADDRESS -w $debug $DEV_ETH_SARAFU_TOKEN_ADDRESS $token_description_one
>&2 eth-address-declarator-add -y $keystore_file -i $CIC_CHAIN_SPEC -p $ETH_PROVIDER -r $CIC_DECLARATOR_ADDRESS -w $debug $DEV_ETH_SARAFU_TOKEN_ADDRESS $token_description_two >&2 eth-address-declarator-add -y $keystore_file -i $CIC_CHAIN_SPEC -p $ETH_PROVIDER -r $CIC_DECLARATOR_ADDRESS -w $debug $DEV_ETH_SARAFU_TOKEN_ADDRESS $token_description_two

View File

@ -77,24 +77,6 @@ services:
- bee-data:/tmp/cic/bee - bee-data:/tmp/cic/bee
contract-migration: contract-migration:
build:
context: apps/
dockerfile: contract-migration/docker/Dockerfile
environment:
# ETH_PROVIDER should be broken out into host/port but cic-eth expects this
ETH_PROVIDER: http://eth:8545
# And these two are for wait-for-it (could parse this)
ETH_PROVIDER_HOST: eth
ETH_PROVIDER_PORT: 8545
CIC_CHAIN_SPEC: ${CIC_CHAIN_SPEC:-evm:bloxberg:8996}
CIC_DATA_DIR: ${CIC_DATA_DIR:-/tmp/cic/config}
command: ["./reset.sh"]
depends_on:
- eth
volumes:
- contract-config:/tmp/cic/config
seed-cic-eth:
build: build:
context: apps/ context: apps/
dockerfile: contract-migration/docker/Dockerfile dockerfile: contract-migration/docker/Dockerfile
@ -118,10 +100,8 @@ services:
CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis:6379} CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis:6379}
CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis:6379} CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis:6379}
DEV_PIP_EXTRA_INDEX_URL: ${DEV_PIP_EXTRA_INDEX_URL:-https://pip.grassrootseconomics.net:8433} DEV_PIP_EXTRA_INDEX_URL: ${DEV_PIP_EXTRA_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
command: ["./seed_cic_eth.sh"] RUN_LEVEL: 2 #0: noop 1: contract migrations 2: seed data
# deploy: command: ["./run_job.sh"]
#restart_policy:
# condition: on-failure
depends_on: depends_on:
- eth - eth
- postgres - postgres
@ -130,7 +110,6 @@ services:
volumes: volumes:
- contract-config:/tmp/cic/config - contract-config:/tmp/cic/config
cic-cache-tracker: cic-cache-tracker:
build: build:
context: apps context: apps