Skip to content

Commit

Permalink
Merge pull request #107 from lidofinance/fix-lightnouse-api-statuses
Browse files Browse the repository at this point in the history
Fix after Lightnouse statuses change
  • Loading branch information
ujenjt committed Mar 11, 2021
2 parents f602857 + 0c173ba commit 90d4e5a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ See **Other examples** below for transactable modes.
* `POOL_CONTRACT` - Lido contract in EIP-55 (mixed-case) hex format. **Required**. Example: `0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84`
* `DAEMON` - with `DAEMON=0` runs the single iteration then quits. `DAEMON=0` in combination with `MEMBER_PRIV_KEY` runs interactively and asks user for confirmation before sending each TX. With `DAEMON=1` runs autonomously (without confirmation) in an indefinite loop. **Optional**. Default: `0`
* `MEMBER_PRIV_KEY` - Hex-encoded private key of Oracle Quorum Member address. **Optional**. If omitted, the oracle runs in read-only (dry-run) mode. WARNING: Keep `MEMBER_PRIV_KEY` safe. Since it keeps real Ether to pay gas, it should never be exposed outside.
* `FORCE` - The oracle makes the sanity checks on the collected data before reporting. Running in `DAEMON` mode, if data look suspicious, it skips sending TX. In enforced mode it gets reported even if it looks suspicious. It's unsafe and used for smoke testing purposes, NEVER use it in production! **Optional**. Default: `0`
* `FORCE_DO_NOT_USE_IN_PRODUCTION` - **Do not use in production!** The oracle makes the sanity checks on the collected data before reporting. Running in `DAEMON` mode, if data look suspicious, it skips sending TX. In enforced mode it gets reported even if it looks suspicious.
It's unsafe and used for smoke testing purposes, NEVER use it in production! **Optional**. Default: `0`
* `SLEEP` seconds - The interval between iterations in Daemon mode. Default value: 60 s. Effective with `DAEMON=1` only.
* `GAS_LIMIT` - The pre-defined gasLimit for composed transaction. Defaulf value: 1 500 000. Effective in transactable mode (with given `MEMBER_PRIV_KEY`)
* `ORACLE_FROM_BLOCK` - The earlist block to check for oracle events. Needed on mainnet first run to skip 5 minutes of scanning blockchain for events that are not there, recommended to be set to 11595281 on mainnet deployments
Expand Down
2 changes: 1 addition & 1 deletion app/beacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_balances(self, slot, key_list):
if pubkey in pubkeys:
validator_balance = int(validator['balance'])

if validator['status'] == 'active':
if validator['status'] in ['active', 'active_ongoing']:
active_validators_balance += validator_balance

balance_list.append(validator_balance)
Expand Down
12 changes: 9 additions & 3 deletions app/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
'BEACON_NODE',
'POOL_CONTRACT',
]
if os.getenv('FORCE'):
logging.error('The flag "FORCE" is obsolete in favour of '
'"FORCE_DO_NOT_USE_IN_PRODUCTION", '
'please NEVER use it in production')
exit(1)

missing = []
for env in envs:
if env not in os.environ or os.environ[env] == '':
Expand Down Expand Up @@ -59,7 +65,7 @@
await_time_in_sec = int(os.getenv('SLEEP', DEFAULT_SLEEP))

run_as_daemon = int(os.getenv('DAEMON', 0))
force = int(os.getenv('FORCE', 0))
force = int(os.getenv('FORCE_DO_NOT_USE_IN_PRODUCTION', 0))

dry_run = member_privkey is None

Expand Down Expand Up @@ -141,7 +147,7 @@
logging.info('DAEMON=0 Running in single iteration mode (will exit after reporting).')

if force:
logging.info('FORCE=1 Running in enforced mode.')
logging.info('FORCE_DO_NOT_USE_IN_PRODUCTION=1 Running in enforced mode.')
logging.warning("In enforced mode TX gets always sent even if it looks suspicious. NEVER use it in production!")

logging.info(f'ETH1_NODE={eth1_provider}')
Expand Down Expand Up @@ -229,7 +235,7 @@ def prompt(prompt_message, prompt_end):
else:
logging.warning('Cannot report suspicious data in DAEMON mode for safety reasons.')
logging.warning('You can submit it interactively (with DAEMON=0) and interactive [y/n] prompt.')
logging.warning("In DAEMON mode it's possible with enforcement flag (FORCE=1). Never use it in production.")
logging.warning("In DAEMON mode it's possible with enforcement flag (FORCE_DO_NOT_USE_IN_PRODUCTION=1). Never use it in production.")
else:
sign_and_send_tx(tx)
else:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_with_priv_key_with_daemon_no_sleep():
assert env.get('MEMBER_PRIV_KEY'), 'MEMBER_PRIV_KEY must be set in environment variables'
assert 'SLEEP' not in env, 'SLEEP must not be set in environment variables'
env['DAEMON'] = '1'
env['FORCE'] = '1'
env['FORCE_DO_NOT_USE_IN_PRODUCTION'] = '1'
with subprocess.Popen(
['python3', '-u', './app/oracle.py'],
bufsize=0,
Expand Down Expand Up @@ -151,7 +151,7 @@ def test_with_priv_key_with_daemon_with_sleep():
env = os.environ.copy()
assert env.get('MEMBER_PRIV_KEY'), 'MEMBER_PRIV_KEY must be set in environment variables'
env['DAEMON'] = '1'
env['FORCE'] = '1'
env['FORCE_DO_NOT_USE_IN_PRODUCTION'] = '1'
custom_sleep = 42
env['SLEEP'] = f'{custom_sleep}'
with subprocess.Popen(
Expand Down

0 comments on commit 90d4e5a

Please sign in to comment.