Rehabilitate migration scripts
This commit is contained in:
parent
1047a1a487
commit
059191346e
@ -10,7 +10,7 @@ version = (
|
|||||||
0,
|
0,
|
||||||
10,
|
10,
|
||||||
1,
|
1,
|
||||||
'alpha.5',
|
'rc.1',
|
||||||
)
|
)
|
||||||
|
|
||||||
version_object = semver.VersionInfo(
|
version_object = semver.VersionInfo(
|
||||||
|
@ -19,23 +19,23 @@ from hexathon import (
|
|||||||
)
|
)
|
||||||
from chainsyncer.backend import MemBackend
|
from chainsyncer.backend import MemBackend
|
||||||
from chainsyncer.driver import HeadSyncer
|
from chainsyncer.driver import HeadSyncer
|
||||||
from chainlib.eth.connection import HTTPConnection
|
from chainlib.eth.connection import EthHTTPConnection
|
||||||
from chainlib.eth.block import (
|
from chainlib.eth.block import (
|
||||||
block_latest,
|
block_latest,
|
||||||
block_by_number,
|
block_by_number,
|
||||||
Block,
|
Block,
|
||||||
)
|
)
|
||||||
from chainlib.eth.hash import keccak256_string_to_hex
|
from chainlib.eth.hash import keccak256_string_to_hex
|
||||||
from chainlib.eth.address import to_checksum
|
from chainlib.eth.address import to_checksum_address
|
||||||
from chainlib.eth.erc20 import ERC20TxFactory
|
from chainlib.eth.erc20 import ERC20
|
||||||
from chainlib.eth.gas import DefaultGasOracle
|
from chainlib.eth.gas import OverrideGasOracle
|
||||||
from chainlib.eth.nonce import DefaultNonceOracle
|
from chainlib.eth.nonce import RPCNonceOracle
|
||||||
from chainlib.eth.tx import TxFactory
|
from chainlib.eth.tx import TxFactory
|
||||||
from chainlib.eth.rpc import jsonrpc_template
|
from chainlib.eth.rpc import jsonrpc_template
|
||||||
from chainlib.eth.error import EthException
|
from chainlib.eth.error import EthException
|
||||||
from chainlib.chain import ChainSpec
|
from chainlib.chain import ChainSpec
|
||||||
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
||||||
from crypto_dev_signer.keystore import DictKeystore
|
from crypto_dev_signer.keystore.dict import DictKeystore
|
||||||
from cic_types.models.person import Person
|
from cic_types.models.person import Person
|
||||||
|
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ class Handler:
|
|||||||
self.user_dir = user_dir
|
self.user_dir = user_dir
|
||||||
self.balances = balances
|
self.balances = balances
|
||||||
self.chain_spec = chain_spec
|
self.chain_spec = chain_spec
|
||||||
self.tx_factory = ERC20TxFactory(signer, gas_oracle, nonce_oracle, chain_spec.network_id())
|
self.tx_factory = ERC20(signer, gas_oracle, nonce_oracle, chain_spec.network_id())
|
||||||
|
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -131,7 +131,7 @@ class Handler:
|
|||||||
|
|
||||||
if tx.payload[:8] == self.account_index_add_signature:
|
if tx.payload[:8] == self.account_index_add_signature:
|
||||||
recipient = eth_abi.decode_single('address', bytes.fromhex(tx.payload[-64:]))
|
recipient = eth_abi.decode_single('address', bytes.fromhex(tx.payload[-64:]))
|
||||||
#original_address = to_checksum(self.addresses[to_checksum(recipient)])
|
#original_address = to_checksum_address(self.addresses[to_checksum_address(recipient)])
|
||||||
user_file = 'new/{}/{}/{}.json'.format(
|
user_file = 'new/{}/{}/{}.json'.format(
|
||||||
recipient[2:4].upper(),
|
recipient[2:4].upper(),
|
||||||
recipient[4:6].upper(),
|
recipient[4:6].upper(),
|
||||||
@ -159,7 +159,7 @@ class Handler:
|
|||||||
balance_full = balance * multiplier
|
balance_full = balance * multiplier
|
||||||
logg.info('registered {} originally {} ({}) tx hash {} balance {}'.format(recipient, original_address, u, tx.hash, balance_full))
|
logg.info('registered {} originally {} ({}) tx hash {} balance {}'.format(recipient, original_address, u, tx.hash, balance_full))
|
||||||
|
|
||||||
(tx_hash_hex, o) = self.tx_factory.erc20_transfer(self.token_address, signer_address, recipient, balance_full)
|
(tx_hash_hex, o) = self.tx_factory.transfer(self.token_address, signer_address, recipient, balance_full)
|
||||||
logg.info('submitting erc20 transfer tx {} for recipient {}'.format(tx_hash_hex, recipient))
|
logg.info('submitting erc20 transfer tx {} for recipient {}'.format(tx_hash_hex, recipient))
|
||||||
r = conn.do(o)
|
r = conn.do(o)
|
||||||
# except TypeError as e:
|
# except TypeError as e:
|
||||||
@ -178,7 +178,7 @@ class BlockGetter:
|
|||||||
|
|
||||||
def __init__(self, conn, gas_oracle, nonce_oracle, chain_id):
|
def __init__(self, conn, gas_oracle, nonce_oracle, chain_id):
|
||||||
self.conn = conn
|
self.conn = conn
|
||||||
self.tx_factory = ERC20TxFactory(signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle, chain_id=chain_id)
|
self.tx_factory = ERC20(signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle, chain_id=chain_id)
|
||||||
|
|
||||||
|
|
||||||
def get(self, n):
|
def get(self, n):
|
||||||
@ -203,9 +203,9 @@ def progress_callback(block_number, tx_index, s):
|
|||||||
def main():
|
def main():
|
||||||
global chain_str, block_offset, user_dir
|
global chain_str, block_offset, user_dir
|
||||||
|
|
||||||
conn = HTTPConnection(config.get('ETH_PROVIDER'))
|
conn = EthHTTPConnection(config.get('ETH_PROVIDER'))
|
||||||
gas_oracle = DefaultGasOracle(conn)
|
gas_oracle = OverrideGasOracle(conn=conn, limit=8000000)
|
||||||
nonce_oracle = DefaultNonceOracle(signer_address, conn)
|
nonce_oracle = RPCNonceOracle(signer_address, conn)
|
||||||
|
|
||||||
# Get Token registry address
|
# Get Token registry address
|
||||||
txf = TxFactory(signer=signer, gas_oracle=gas_oracle, nonce_oracle=None, chain_id=chain_spec.network_id())
|
txf = TxFactory(signer=signer, gas_oracle=gas_oracle, nonce_oracle=None, chain_id=chain_spec.network_id())
|
||||||
@ -221,7 +221,7 @@ def main():
|
|||||||
o['params'].append(txf.normalize(tx))
|
o['params'].append(txf.normalize(tx))
|
||||||
o['params'].append('latest')
|
o['params'].append('latest')
|
||||||
r = conn.do(o)
|
r = conn.do(o)
|
||||||
token_index_address = to_checksum(eth_abi.decode_single('address', bytes.fromhex(strip_0x(r))))
|
token_index_address = to_checksum_address(eth_abi.decode_single('address', bytes.fromhex(strip_0x(r))))
|
||||||
logg.info('found token index address {}'.format(token_index_address))
|
logg.info('found token index address {}'.format(token_index_address))
|
||||||
|
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ def main():
|
|||||||
o['params'].append('latest')
|
o['params'].append('latest')
|
||||||
r = conn.do(o)
|
r = conn.do(o)
|
||||||
try:
|
try:
|
||||||
sarafu_token_address = to_checksum(eth_abi.decode_single('address', bytes.fromhex(strip_0x(r))))
|
sarafu_token_address = to_checksum_address(eth_abi.decode_single('address', bytes.fromhex(strip_0x(r))))
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
logg.critical('lookup failed for token {}: {}'.format(token_symbol, e))
|
logg.critical('lookup failed for token {}: {}'.format(token_symbol, e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -279,7 +279,7 @@ def main():
|
|||||||
break
|
break
|
||||||
r = l.split(',')
|
r = l.split(',')
|
||||||
try:
|
try:
|
||||||
address = to_checksum(r[0])
|
address = to_checksum_address(r[0])
|
||||||
sys.stdout.write('loading balance {} {} {}'.format(i, address, r[1]).ljust(200) + "\r")
|
sys.stdout.write('loading balance {} {} {}'.format(i, address, r[1]).ljust(200) + "\r")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
break
|
break
|
||||||
|
@ -22,7 +22,7 @@ from hexathon import (
|
|||||||
from chainsyncer.backend import MemBackend
|
from chainsyncer.backend import MemBackend
|
||||||
from chainsyncer.driver import HeadSyncer
|
from chainsyncer.driver import HeadSyncer
|
||||||
from chainlib.chain import ChainSpec
|
from chainlib.chain import ChainSpec
|
||||||
from chainlib.eth.connection import HTTPConnection
|
from chainlib.eth.connection import EthHTTPConnection
|
||||||
from chainlib.eth.constant import ZERO_ADDRESS
|
from chainlib.eth.constant import ZERO_ADDRESS
|
||||||
from chainlib.eth.block import (
|
from chainlib.eth.block import (
|
||||||
block_latest,
|
block_latest,
|
||||||
@ -30,15 +30,12 @@ from chainlib.eth.block import (
|
|||||||
Block,
|
Block,
|
||||||
)
|
)
|
||||||
from chainlib.eth.hash import keccak256_string_to_hex
|
from chainlib.eth.hash import keccak256_string_to_hex
|
||||||
from chainlib.eth.address import to_checksum
|
from chainlib.eth.address import to_checksum_address
|
||||||
from chainlib.eth.erc20 import ERC20TxFactory
|
from chainlib.eth.erc20 import ERC20
|
||||||
from chainlib.eth.gas import DefaultGasOracle
|
from chainlib.eth.gas import OverrideGasOracle
|
||||||
from chainlib.eth.nonce import DefaultNonceOracle
|
|
||||||
from chainlib.eth.tx import TxFactory
|
from chainlib.eth.tx import TxFactory
|
||||||
from chainlib.eth.rpc import jsonrpc_template
|
from chainlib.eth.rpc import jsonrpc_template
|
||||||
from chainlib.eth.error import EthException
|
from chainlib.eth.error import EthException
|
||||||
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
|
||||||
from crypto_dev_signer.keystore import DictKeystore
|
|
||||||
from cic_eth.api.api_admin import AdminApi
|
from cic_eth.api.api_admin import AdminApi
|
||||||
from cic_types.models.person import (
|
from cic_types.models.person import (
|
||||||
Person,
|
Person,
|
||||||
@ -136,7 +133,7 @@ class Verifier:
|
|||||||
self.chain_spec = chain_spec
|
self.chain_spec = chain_spec
|
||||||
self.index_address = index_address
|
self.index_address = index_address
|
||||||
self.token_address = token_address
|
self.token_address = token_address
|
||||||
self.erc20_tx_factory = ERC20TxFactory(chain_id=chain_spec.chain_id(), gas_oracle=gas_oracle)
|
self.erc20_tx_factory = ERC20(chain_id=chain_spec.chain_id(), gas_oracle=gas_oracle)
|
||||||
self.tx_factory = TxFactory(chain_id=chain_spec.chain_id(), gas_oracle=gas_oracle)
|
self.tx_factory = TxFactory(chain_id=chain_spec.chain_id(), gas_oracle=gas_oracle)
|
||||||
self.api = cic_eth_api
|
self.api = cic_eth_api
|
||||||
self.data_dir = data_dir
|
self.data_dir = data_dir
|
||||||
@ -168,7 +165,7 @@ class Verifier:
|
|||||||
|
|
||||||
|
|
||||||
def verify_balance(self, address, balance):
|
def verify_balance(self, address, balance):
|
||||||
o = self.erc20_tx_factory.erc20_balance(self.token_address, address)
|
o = self.erc20_tx_factory.balance(self.token_address, address)
|
||||||
r = self.conn.do(o)
|
r = self.conn.do(o)
|
||||||
actual_balance = int(strip_0x(r), 16)
|
actual_balance = int(strip_0x(r), 16)
|
||||||
balance = int(balance / 1000000) * 1000000
|
balance = int(balance / 1000000) * 1000000
|
||||||
@ -178,7 +175,8 @@ class Verifier:
|
|||||||
|
|
||||||
|
|
||||||
def verify_local_key(self, address, balance=None):
|
def verify_local_key(self, address, balance=None):
|
||||||
r = self.api.have_account(address, str(self.chain_spec))
|
t = self.api.have_account(address, self.chain_spec)
|
||||||
|
r = t.get()
|
||||||
logg.debug('verify local key result {}'.format(r))
|
logg.debug('verify local key result {}'.format(r))
|
||||||
if r != address:
|
if r != address:
|
||||||
raise VerifierError((address, r), 'local key')
|
raise VerifierError((address, r), 'local key')
|
||||||
@ -252,8 +250,8 @@ class MockClient:
|
|||||||
def main():
|
def main():
|
||||||
global chain_str, block_offset, user_dir
|
global chain_str, block_offset, user_dir
|
||||||
|
|
||||||
conn = HTTPConnection(config.get('ETH_PROVIDER'))
|
conn = EthHTTPConnection(config.get('ETH_PROVIDER'))
|
||||||
gas_oracle = DefaultGasOracle(conn)
|
gas_oracle = OverrideGasOracle(conn=conn, limit=8000000)
|
||||||
|
|
||||||
# Get Token registry address
|
# Get Token registry address
|
||||||
txf = TxFactory(signer=None, gas_oracle=gas_oracle, nonce_oracle=None, chain_id=chain_spec.chain_id())
|
txf = TxFactory(signer=None, gas_oracle=gas_oracle, nonce_oracle=None, chain_id=chain_spec.chain_id())
|
||||||
@ -270,7 +268,7 @@ def main():
|
|||||||
o['params'].append('latest')
|
o['params'].append('latest')
|
||||||
r = conn.do(o)
|
r = conn.do(o)
|
||||||
print('r {}'.format(r))
|
print('r {}'.format(r))
|
||||||
token_index_address = to_checksum(eth_abi.decode_single('address', bytes.fromhex(strip_0x(r))))
|
token_index_address = to_checksum_address(eth_abi.decode_single('address', bytes.fromhex(strip_0x(r))))
|
||||||
logg.info('found token index address {}'.format(token_index_address))
|
logg.info('found token index address {}'.format(token_index_address))
|
||||||
|
|
||||||
data = add_0x(registry_addressof_method)
|
data = add_0x(registry_addressof_method)
|
||||||
@ -282,7 +280,7 @@ def main():
|
|||||||
o['params'].append(txf.normalize(tx))
|
o['params'].append(txf.normalize(tx))
|
||||||
o['params'].append('latest')
|
o['params'].append('latest')
|
||||||
r = conn.do(o)
|
r = conn.do(o)
|
||||||
account_index_address = to_checksum(eth_abi.decode_single('address', bytes.fromhex(strip_0x(r))))
|
account_index_address = to_checksum_address(eth_abi.decode_single('address', bytes.fromhex(strip_0x(r))))
|
||||||
logg.info('found account index address {}'.format(account_index_address))
|
logg.info('found account index address {}'.format(account_index_address))
|
||||||
|
|
||||||
|
|
||||||
@ -300,7 +298,7 @@ def main():
|
|||||||
o['params'].append('latest')
|
o['params'].append('latest')
|
||||||
r = conn.do(o)
|
r = conn.do(o)
|
||||||
print('r {}'.format(r))
|
print('r {}'.format(r))
|
||||||
sarafu_token_address = to_checksum(eth_abi.decode_single('address', bytes.fromhex(strip_0x(r))))
|
sarafu_token_address = to_checksum_address(eth_abi.decode_single('address', bytes.fromhex(strip_0x(r))))
|
||||||
logg.info('found token address {}'.format(sarafu_token_address))
|
logg.info('found token address {}'.format(sarafu_token_address))
|
||||||
|
|
||||||
balances = {}
|
balances = {}
|
||||||
@ -312,7 +310,7 @@ def main():
|
|||||||
break
|
break
|
||||||
r = l.split(',')
|
r = l.split(',')
|
||||||
try:
|
try:
|
||||||
address = to_checksum(r[0])
|
address = to_checksum_address(r[0])
|
||||||
#sys.stdout.write('loading balance {} {}'.format(i, address).ljust(200) + "\r")
|
#sys.stdout.write('loading balance {} {}'.format(i, address).ljust(200) + "\r")
|
||||||
logg.debug('loading balance {} {}'.format(i, address).ljust(200))
|
logg.debug('loading balance {} {}'.format(i, address).ljust(200))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -101,7 +101,7 @@ 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}
|
||||||
RUN_MASK: 2 #0: nohp 1: contract migrations 2: seed data
|
RUN_MASK: ${RUN_MASK:-0} # bit flags; 1: contract migrations 2: seed data
|
||||||
command: ["./run_job.sh"]
|
command: ["./run_job.sh"]
|
||||||
#command: ["./reset.sh"]
|
#command: ["./reset.sh"]
|
||||||
depends_on:
|
depends_on:
|
||||||
|
Loading…
Reference in New Issue
Block a user