Skip to content

Commit fed8529

Browse files
committed
Merge branch 'develop' into feat/csm/state-data-as-tuples
# Conflicts: # src/modules/csm/csm.py # src/modules/csm/state.py # tests/modules/csm/test_checkpoint.py # tests/modules/csm/test_csm_module.py # tests/modules/csm/test_state.py
2 parents af9b88a + 24a2219 commit fed8529

File tree

100 files changed

+4633
-3183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+4633
-3183
lines changed
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Mainnet Fork Tests
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
- edited
10+
- closed
11+
branches:
12+
- main
13+
- develop
14+
paths:
15+
- "src/**"
16+
17+
permissions:
18+
contents: read
19+
security-events: write
20+
21+
jobs:
22+
tests:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v3
27+
28+
- name: Set up Python 3.12
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: "3.12"
32+
33+
- name: Setup poetry
34+
run: >
35+
curl -sSL https://install.python-poetry.org | python - &&
36+
echo "$POETRY_HOME/bin" >> "$GITHUB_PATH"
37+
env:
38+
POETRY_HOME: "/opt/poetry"
39+
POETRY_VERSION: 1.3.2
40+
41+
- name: Install Python dependencies
42+
run: |
43+
poetry install --no-interaction --with=dev
44+
45+
- name: Install Foundry
46+
uses: foundry-rs/foundry-toolchain@v1
47+
48+
- name: Mainnet Fork Tests
49+
run: poetry run pytest -m 'fork' -n auto tests
50+
env:
51+
EXECUTION_CLIENT_URI: ${{ secrets.EXECUTION_CLIENT_URI }}
52+
CONSENSUS_CLIENT_URI: ${{ secrets.CONSENSUS_CLIENT_URI }}
53+
KEYS_API_URI: ${{ secrets.KEYS_API_URI }}
54+
LIDO_LOCATOR_ADDRESS: "0xC1d0b3DE6792Bf6b4b37EccdcC24e45978Cfd2Eb"
55+
CSM_MODULE_ADDRESS: "0xdA7dE2ECdDfccC6c3AF10108Db212ACBBf9EA83F"
56+

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM python:3.12.4-slim as base
33
RUN apt-get update && apt-get install -y --no-install-recommends -qq \
44
libffi-dev=3.4.4-1 \
55
g++=4:12.2.0-3 \
6-
curl=7.88.1-10+deb12u7 \
6+
curl=7.88.1-10+deb12u8 \
77
&& apt-get clean \
88
&& rm -rf /var/lib/apt/lists/*
99

README.md

+14-10
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Only Oracle:
5858
- Memory - 8 GB
5959

6060
Oracle + KAPI:
61+
6162
- vCPU - 4
6263
- Memory - 16 GB
6364

@@ -79,13 +80,13 @@ Oracle needs two weeks of archived data.
7980

8081
Also, to calculate some metrics for bunker mode Oracle needs [archive](https://ethereum.org/en/developers/docs/nodes-and-clients/#archive-node) consensus node.
8182

82-
| Client | Tested | Notes |
83-
|---------------------------------------------------|:------:|-------------------------------------------------------------------------------------------------------------------------------------------------|
84-
| [Lighthouse](https://lighthouse.sigmaprime.io/) | 🟢 | Use `--reconstruct-historic-states` param |
85-
| [Lodestar](https://lodestar.chainsafe.io) | 🔴 | Not tested yet |
86-
| [Nimbus](https://nimbus.team) | 🔴 | Not tested yet |
87-
| [Prysm](https://github.com/prysmaticlabs/prysm) | 🟢 | Use <br> `--grpc-max-msg-size=104857600` <br> `--enable-historical-state-representation=true` <br> `--slots-per-archive-point=1024` <br> params |
88-
| [Teku](https://docs.teku.consensys.net) | 🟢 | Use <br> `--data-storage-mode=archive` <br>`--data-storage-archive-frequency=1024`<br> `--reconstruct-historic-states=true`<br> params |
83+
| Client | Tested | Notes |
84+
|-------------------------------------------------|:------:|-------------------------------------------------------------------------------------------------------------------------------------------------|
85+
| [Lighthouse](https://lighthouse.sigmaprime.io/) | 🟢 | Use `--reconstruct-historic-states` param |
86+
| [Lodestar](https://lodestar.chainsafe.io) | 🔴 | Not tested yet |
87+
| [Nimbus](https://nimbus.team) | 🔴 | Not tested yet |
88+
| [Prysm](https://github.com/prysmaticlabs/prysm) | 🟢 | Use <br> `--grpc-max-msg-size=104857600` <br> `--enable-historical-state-representation=true` <br> `--slots-per-archive-point=1024` <br> params |
89+
| [Teku](https://docs.teku.consensys.net) | 🟢 | Use <br> `--data-storage-mode=archive` <br>`--data-storage-archive-frequency=1024`<br> `--reconstruct-historic-states=true`<br> params |
8990

9091
### Keys API Service
9192

@@ -281,9 +282,12 @@ Special metrics for ejector oracle:
281282
282283
Special metrics for CSM oracle:
283284
284-
| Metric name | Description | Labels |
285-
|-----------------------------------|---------------------------------------------|--------|
286-
| TBD | TBD | |
285+
| Metric name | Description | Labels |
286+
|---------------------------------|----------------------------------------|--------|
287+
| csm_current_frame_range_l_epoch | Left epoch of the current frame range | |
288+
| csm_current_frame_range_r_epoch | Right epoch of the current frame range | |
289+
| csm_unprocessed_epochs_count | Unprocessed epochs count | |
290+
| csm_min_unprocessed_epoch | Minimum unprocessed epoch | |
287291
288292
# Development
289293

assets/HashConsensus.json

+1-1
Large diffs are not rendered by default.
File renamed without changes.

assets/StakingRouterV1.json

-1
This file was deleted.

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "lido-oracle"
3-
version = "4.0.3"
3+
version = "4.1.0"
44
description = "Oracle daemon for Lido decentralized staking service. Collects and reports Ethereum 2.0 beacon chain states (the number of visible validators and their summarized balances) to the Lido dApp contract running on Ethereum 1.0 side."
55
authors = [
66
"Dmitry Chernukhin",
@@ -57,6 +57,7 @@ markers = [
5757
"integration: tests with using providers",
5858
"possible_integration: tests with using providers, but can be run using mocks",
5959
"e2e: complex tests with using providers and real Ethereum network",
60+
"fork: tests with using forked Ethereum network",
6061
]
6162
addopts = "-s -vv --pdbcls pudb.debugger:Debugger"
6263

src/constants.py

+28-13
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,46 @@
1+
from src.types import Gwei, SlotNumber
2+
13
# https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#misc
2-
FAR_FUTURE_EPOCH = 2 ** 64 - 1
4+
GENESIS_SLOT = SlotNumber(0)
5+
FAR_FUTURE_EPOCH = 2**64 - 1
36
# https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#time-parameters-1
47
MIN_VALIDATOR_WITHDRAWABILITY_DELAY = 2**8
5-
SHARD_COMMITTEE_PERIOD = 256
8+
SHARD_COMMITTEE_PERIOD = 2**8
69
MAX_SEED_LOOKAHEAD = 4
710
# https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#state-list-lengths
811
EPOCHS_PER_SLASHINGS_VECTOR = 2**13
912
# https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#rewards-and-penalties
1013
PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX = 3
1114
# https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#gwei-values
12-
EFFECTIVE_BALANCE_INCREMENT = 2 ** 0 * 10 ** 9
13-
MAX_EFFECTIVE_BALANCE = 32 * 10 ** 9
15+
EFFECTIVE_BALANCE_INCREMENT = Gwei(2**0 * 10**9)
16+
MAX_EFFECTIVE_BALANCE = Gwei(32 * 10**9)
17+
# https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/beacon-chain.md#gwei-values
18+
MAX_EFFECTIVE_BALANCE_ELECTRA = Gwei(2**11 * 10**9)
19+
MIN_ACTIVATION_BALANCE = Gwei(2**5 * 10**9)
1420
# https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#execution
15-
MAX_WITHDRAWALS_PER_PAYLOAD = 2 ** 4
21+
MAX_WITHDRAWALS_PER_PAYLOAD = 2**4
1622
# https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#withdrawal-prefixes
1723
ETH1_ADDRESS_WITHDRAWAL_PREFIX = '0x01'
24+
# https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/beacon-chain.md#withdrawal-prefixes
25+
COMPOUNDING_WITHDRAWAL_PREFIX = '0x02'
1826
# https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator-cycle
19-
MIN_PER_EPOCH_CHURN_LIMIT = 2 ** 2
20-
CHURN_LIMIT_QUOTIENT = 2 ** 16
27+
MIN_PER_EPOCH_CHURN_LIMIT = 2**2
28+
CHURN_LIMIT_QUOTIENT = 2**16
29+
# https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/beacon-chain.md#validator-cycle
30+
MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA = Gwei(2**7 * 10**9)
31+
MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT = Gwei(2**8 * 10**9)
2132
# https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#time-parameters
22-
SLOTS_PER_HISTORICAL_ROOT = 8192
33+
SLOTS_PER_HISTORICAL_ROOT = 2**13 # 8192
2334

24-
# Local constants
25-
GWEI_TO_WEI = 10 ** 9
26-
SHARE_RATE_PRECISION_E27 = 10 ** 27
35+
# https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/beacon-chain.md#withdrawals-processing
36+
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP = 2**3
37+
38+
# Lido contracts constants
39+
LIDO_DEPOSIT_AMOUNT = MIN_ACTIVATION_BALANCE
40+
SHARE_RATE_PRECISION_E27 = 10**27
2741
TOTAL_BASIS_POINTS = 10000
2842

43+
# Local constants
44+
GWEI_TO_WEI = 10**9
2945
MAX_BLOCK_GAS_LIMIT = 30_000_000
30-
31-
UINT64_MAX = 2 ** 64 - 1
46+
UINT64_MAX = 2**64 - 1

src/main.py

+6-19
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@
2424
KeysAPIClientModule,
2525
LidoValidatorsProvider,
2626
FallbackProviderModule,
27-
LazyCSM
27+
LazyCSM,
2828
)
2929
from src.web3py.middleware import metrics_collector
3030
from src.web3py.types import Web3
3131

3232
from src.web3py.contract_tweak import tweak_w3_contracts
3333

34-
3534
logger = logging.getLogger(__name__)
3635

3736

@@ -42,22 +41,10 @@ def main(module_name: OracleModule):
4241
'variables': {
4342
**build_info,
4443
'module': module_name,
45-
'ACCOUNT': variables.ACCOUNT.address if variables.ACCOUNT else 'Dry',
46-
'LIDO_LOCATOR_ADDRESS': variables.LIDO_LOCATOR_ADDRESS,
47-
'CSM_MODULE_ADDRESS': variables.CSM_MODULE_ADDRESS,
48-
'FINALIZATION_BATCH_MAX_REQUEST_COUNT': variables.FINALIZATION_BATCH_MAX_REQUEST_COUNT,
49-
'EL_REQUESTS_BATCH_SIZE': variables.EL_REQUESTS_BATCH_SIZE,
50-
'MAX_CYCLE_LIFETIME_IN_SECONDS': variables.MAX_CYCLE_LIFETIME_IN_SECONDS,
44+
**variables.PUBLIC_ENV_VARS,
5145
},
5246
})
53-
ENV_VARIABLES_INFO.info({
54-
"ACCOUNT": str(variables.ACCOUNT.address) if variables.ACCOUNT else 'Dry',
55-
"LIDO_LOCATOR_ADDRESS": str(variables.LIDO_LOCATOR_ADDRESS),
56-
"CSM_MODULE_ADDRESS": str(variables.CSM_MODULE_ADDRESS),
57-
"FINALIZATION_BATCH_MAX_REQUEST_COUNT": str(variables.FINALIZATION_BATCH_MAX_REQUEST_COUNT),
58-
"EL_REQUESTS_BATCH_SIZE": str(variables.EL_REQUESTS_BATCH_SIZE),
59-
"MAX_CYCLE_LIFETIME_IN_SECONDS": str(variables.MAX_CYCLE_LIFETIME_IN_SECONDS),
60-
})
47+
ENV_VARIABLES_INFO.info(variables.PUBLIC_ENV_VARS)
6148
BUILD_INFO.info(build_info)
6249

6350
logger.info({'msg': f'Start healthcheck server for Docker container on port {variables.HEALTHCHECK_SERVER_PORT}'})
@@ -171,18 +158,18 @@ def ipfs_providers() -> Iterator[IPFSProvider]:
171158

172159
if __name__ == '__main__':
173160
module_name_arg = sys.argv[-1]
174-
if module_name_arg not in iter(OracleModule):
161+
if module_name_arg not in OracleModule:
175162
msg = f'Last arg should be one of {[str(item) for item in OracleModule]}, received {module_name_arg}.'
176163
logger.error({'msg': msg})
177164
raise ValueError(msg)
178165

179166
module = OracleModule(module_name_arg)
180-
if module == OracleModule.CHECK:
167+
if module is OracleModule.CHECK:
181168
errors = variables.check_uri_required_variables()
182169
variables.raise_from_errors(errors)
183170

184171
sys.exit(check())
185172

186-
errors = variables.check_all_required_variables()
173+
errors = variables.check_all_required_variables(module)
187174
variables.raise_from_errors(errors)
188175
main(module)

0 commit comments

Comments
 (0)