diff --git a/README.md b/README.md index 834f076fd..d5ee55cd6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/app/beacon.py b/app/beacon.py index abb26107f..680c75568 100644 --- a/app/beacon.py +++ b/app/beacon.py @@ -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) diff --git a/app/oracle.py b/app/oracle.py index 8e5d7a107..926b88d1c 100644 --- a/app/oracle.py +++ b/app/oracle.py @@ -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] == '': @@ -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 @@ -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}') @@ -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: diff --git a/tests/test_configurations.py b/tests/test_configurations.py index 6067db07b..d4a800d9e 100644 --- a/tests/test_configurations.py +++ b/tests/test_configurations.py @@ -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, @@ -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(