WIP implement chaind-eth on chainlib 0.3.0 structure
This commit is contained in:
parent
96f58c5f41
commit
acbbebd8da
@ -4,3 +4,6 @@ runtime_dir =
|
|||||||
id =
|
id =
|
||||||
data_dir =
|
data_dir =
|
||||||
dispatch_delay = 0.01
|
dispatch_delay = 0.01
|
||||||
|
|
||||||
|
[tx]
|
||||||
|
digest_size = 32
|
||||||
|
@ -4,6 +4,7 @@ import logging
|
|||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
import chainlib.cli
|
import chainlib.cli
|
||||||
|
import chainlib.eth.cli
|
||||||
import chainsyncer.cli
|
import chainsyncer.cli
|
||||||
import chaind.cli
|
import chaind.cli
|
||||||
from chaind.setup import Environment
|
from chaind.setup import Environment
|
||||||
@ -13,13 +14,32 @@ from hexathon import strip_0x
|
|||||||
from chainsyncer.store.fs import SyncFsStore
|
from chainsyncer.store.fs import SyncFsStore
|
||||||
from chainsyncer.driver.chain_interface import ChainInterfaceDriver
|
from chainsyncer.driver.chain_interface import ChainInterfaceDriver
|
||||||
from chainsyncer.error import SyncDone
|
from chainsyncer.error import SyncDone
|
||||||
|
from chainlib.eth.cli.arg import (
|
||||||
# local imports
|
Arg,
|
||||||
from chaind.eth.settings import ChaindEthSettings
|
ArgFlag,
|
||||||
|
process_args,
|
||||||
|
)
|
||||||
|
from chainlib.eth.cli.config import (
|
||||||
|
Config,
|
||||||
|
process_config,
|
||||||
|
)
|
||||||
|
from chainsyncer.cli.arg import (
|
||||||
|
apply_arg as apply_arg_sync,
|
||||||
|
apply_flag as apply_flag_sync,
|
||||||
|
)
|
||||||
|
from chainsyncer.data import config_dir as chainsyncer_config_dir
|
||||||
|
from chaind.data import config_dir as chaind_config_dir
|
||||||
|
from chaind.cli.arg import (
|
||||||
|
apply_arg,
|
||||||
|
apply_flag,
|
||||||
|
)
|
||||||
|
from chainlib.eth.cli.log import process_log
|
||||||
|
from chaind.settings import ChaindSettings
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from chaind.eth.cache import EthCacheTx
|
from chaind.eth.cache import EthCacheTx
|
||||||
|
from chaind.eth.settings import process_settings
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
logging.basicConfig(level=logging.WARNING)
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
@ -29,33 +49,38 @@ config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
|||||||
|
|
||||||
env = Environment(domain='eth', env=os.environ)
|
env = Environment(domain='eth', env=os.environ)
|
||||||
|
|
||||||
arg_flags = chainlib.cli.argflag_std_base | chainlib.cli.Flag.CHAIN_SPEC
|
arg_flags = ArgFlag()
|
||||||
argparser = chainlib.cli.ArgumentParser(arg_flags)
|
arg_flags = apply_flag_sync(arg_flags)
|
||||||
|
arg_flags = apply_flag(arg_flags)
|
||||||
|
|
||||||
local_arg_flags = chaind.cli.argflag_local_base
|
arg = Arg(arg_flags)
|
||||||
chaind.cli.process_flags(argparser, local_arg_flags)
|
arg = apply_arg_sync(arg)
|
||||||
|
arg = apply_arg(arg)
|
||||||
|
|
||||||
sync_flags = chainsyncer.cli.SyncFlag.RANGE | chainsyncer.cli.SyncFlag.HEAD
|
flags = arg_flags.STD_BASE | arg_flags.CHAIN_SPEC | arg_flags.PROVIDER
|
||||||
chainsyncer.cli.process_flags(argparser, sync_flags)
|
flags = arg_flags.more(flags, arg_flags.SYNC_RANGE_EXT)
|
||||||
|
flags = arg_flags.more(flags, arg_flags.CHAIND_BASE)
|
||||||
|
|
||||||
|
argparser = chainlib.eth.cli.ArgumentParser()
|
||||||
|
argparser = process_args(argparser, arg, flags)
|
||||||
args = argparser.parse_args()
|
args = argparser.parse_args()
|
||||||
|
|
||||||
base_config_dir = [
|
logg = process_log(args, logg)
|
||||||
chainsyncer.cli.config_dir,
|
|
||||||
chaind.cli.config_dir,
|
config = Config()
|
||||||
]
|
config.add_schema_dir(chainsyncer_config_dir)
|
||||||
config = chainlib.cli.Config.from_args(args, arg_flags, base_config_dir=base_config_dir)
|
config.add_schema_dir(chaind_config_dir)
|
||||||
config = chainsyncer.cli.process_config(config, args, sync_flags)
|
config = process_config(config, arg, args, flags)
|
||||||
config = chaind.cli.process_config(config, args, local_arg_flags)
|
#config = process_config_local(config, arg, args, flags)
|
||||||
config.add('eth', 'CHAIND_ENGINE', False)
|
config.add('eth', 'CHAIND_ENGINE', False)
|
||||||
config.add('sync', 'CHAIND_COMPONENT', False)
|
config.add('sync', 'CHAIND_COMPONENT', False)
|
||||||
logg.debug('config loaded:\n{}'.format(config))
|
logg.debug('config loaded:\n{}'.format(config))
|
||||||
|
|
||||||
settings = ChaindEthSettings(include_sync=True)
|
settings = ChaindSettings()
|
||||||
settings.process(config)
|
settings = process_settings(settings, config)
|
||||||
|
logg.debug('settings loaded:\n{}'.format(settings))
|
||||||
logg.debug('settings:\n{}'.format(settings))
|
|
||||||
|
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
fltr = StateFilter(settings.get('CHAIN_SPEC'), settings.dir_for('queue'), EthCacheTx)
|
fltr = StateFilter(settings.get('CHAIN_SPEC'), settings.dir_for('queue'), EthCacheTx)
|
||||||
|
@ -1,18 +1,44 @@
|
|||||||
# external imports
|
# external imports
|
||||||
from chainlib.eth.connection import EthHTTPConnection
|
from chainlib.eth.connection import EthHTTPConnection
|
||||||
from chaind.settings import ChaindSettings
|
from chainlib.settings import process_settings as base_process_settings
|
||||||
from chaind.eth.chain import EthChainInterface
|
from chaind.eth.chain import EthChainInterface
|
||||||
|
from chaind.settings import *
|
||||||
|
|
||||||
|
|
||||||
class ChaindEthSettings(ChaindSettings):
|
def process_sync_interface(settings, config):
|
||||||
|
settings.set('SYNCER_INTERFACE', EthChainInterface())
|
||||||
def process_sync_interface(self, config):
|
return settings
|
||||||
self.o['SYNCER_INTERFACE'] = EthChainInterface()
|
|
||||||
|
|
||||||
|
|
||||||
def process_common(self, config):
|
def process_common(settings, config):
|
||||||
super(ChaindEthSettings, self).process_common(config)
|
rpc_provider = config.get('RPC_PROVIDER')
|
||||||
rpc_provider = config.get('RPC_PROVIDER')
|
if rpc_provider == None:
|
||||||
if rpc_provider == None:
|
rpc_provider = 'http://localhost:8545'
|
||||||
rpc_provider = 'http://localhost:8545'
|
conn = EthHTTPConnection(url=rpc_provider, chain_spec=settings.get('CHAIN_SPEC'))
|
||||||
self.o['RPC'] = EthHTTPConnection(url=rpc_provider, chain_spec=self.o['CHAIN_SPEC'])
|
settings.set('RPC', conn)
|
||||||
|
return settings
|
||||||
|
|
||||||
|
|
||||||
|
def process_settings(settings, config):
|
||||||
|
settings = base_process_settings(settings, config)
|
||||||
|
settings = process_common(settings, config)
|
||||||
|
settings = process_sync_interface(settings, config)
|
||||||
|
|
||||||
|
if settings.include_queue:
|
||||||
|
settings = process_queue_backend(settings, config)
|
||||||
|
if settings.include_sync:
|
||||||
|
settings = process_sync_backend(settings, config)
|
||||||
|
|
||||||
|
settings = process_backend(settings, config)
|
||||||
|
settings = process_session(settings, config)
|
||||||
|
|
||||||
|
if settings.include_sync:
|
||||||
|
settings = process_sync(settings, config)
|
||||||
|
if settings.include_queue:
|
||||||
|
settings = process_chaind_queue(settings, config)
|
||||||
|
settings = process_dispatch(settings, config)
|
||||||
|
settings = process_token(settings, config)
|
||||||
|
|
||||||
|
settings = process_socket(settings, config)
|
||||||
|
|
||||||
|
return settings
|
||||||
|
@ -1 +1 @@
|
|||||||
eth-erc20~=0.3.1
|
eth-erc20~=0.3.2
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
chaind~=0.2.12
|
chaind~=0.2.13
|
||||||
hexathon~=0.1.7
|
hexathon~=0.1.7
|
||||||
chainlib-eth~=0.2.0
|
chainlib-eth~=0.3.0
|
||||||
pyxdg~=0.27
|
pyxdg~=0.27
|
||||||
funga-eth~=0.6.1
|
funga-eth~=0.6.1
|
||||||
|
Loading…
Reference in New Issue
Block a user