mirror of
https://github.com/logos-blockchain/logos-blockchain-e2e-tests.git
synced 2026-01-02 13:13:08 +00:00
Merge pull request #19 from logos-co/test-dispersal-resilience
Test/dispersal resilience
This commit is contained in:
commit
e24ea02fc7
30
README.md
30
README.md
@ -1,6 +1,6 @@
|
||||
# nomos-e2e-tests
|
||||
|
||||
Nomos e2e framework used to test various implementations of the Nomos node.
|
||||
Nomos E2E framework used to test various implementations of the Nomos node.
|
||||
|
||||
## Setup and contribute
|
||||
|
||||
@ -16,12 +16,36 @@ pre-commit install
|
||||
(optional) Overwrite default vars from src/env_vars.py via env vars or by adding a .env file
|
||||
pytest
|
||||
```
|
||||
Set optional environment variable to search logs for errors after each tests:
|
||||
|
||||
### Additional instructions for dispersal resilience tests
|
||||
|
||||
1. Build prerequisites
|
||||
```sh
|
||||
git clone https://github.com/logos-co/nomos-security-tests.git
|
||||
cd nomos-security-tests
|
||||
git fetch; git switch test-dispersal-resilience
|
||||
|
||||
git checkout d8bbc464420ef86337df963c64ac2f7c3fd97008
|
||||
docker build --no-cache -f testnet/Dockerfile.debug -t nomos-mod-da-d8bbc46:testnet .
|
||||
# (x86_64) docker build --no-cache -f testnet/Dockerfile -t nomos-mod-da-d8bbc46:testnet .
|
||||
|
||||
git checkout d19a1f3d8c80f654e6cf6139641519f16fe670ec
|
||||
docker build --no-cache -f testnet/Dockerfile.debug -t nomos-executor-mod-da-d19a1f3:testnet .
|
||||
|
||||
git checkout 7f54114b6c320dc32577b0e8bb85c2d543b4bd56
|
||||
docker build --no-cache -f testnet/Dockerfile.debug -t nomos-executor-mod-da-7f54114:testnet .
|
||||
|
||||
git checkout 4a58376ac4956d87502b9fd72b64a756396f2a8d
|
||||
docker build --no-cache -f testnet/Dockerfile.debug -t nomos-executor-mod-da-4a58376:testnet .
|
||||
```
|
||||
|
||||
2. Run tests with `pytest --run-with-mod-da-node tests/dispersal_resilience/test_dispersal_resilience.py`
|
||||
|
||||
### Enable node log search with environment variable:
|
||||
```shell
|
||||
export CHECK_LOG_ERRORS=True
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Licensed and distributed under either of
|
||||
|
||||
14
cluster_config/scripts/run_nomos_executor_debug.sh
Executable file
14
cluster_config/scripts/run_nomos_executor_debug.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
export CFG_FILE_PATH="/config.yaml" \
|
||||
CFG_SERVER_ADDR="http://cfgsync:4400" \
|
||||
CFG_HOST_IP=$(hostname -i) \
|
||||
CFG_HOST_KIND="executor" \
|
||||
CFG_HOST_IDENTIFIER="executor-$(hostname -i)" \
|
||||
LOG_LEVEL="DEBUG" \
|
||||
RISC0_DEV_MODE=true
|
||||
|
||||
/usr/bin/cfgsync-client && \
|
||||
exec /usr/bin/nomos-executor /config.yaml
|
||||
13
cluster_config/scripts/run_nomos_node_debug.sh
Executable file
13
cluster_config/scripts/run_nomos_node_debug.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
export CFG_FILE_PATH="/config.yaml" \
|
||||
CFG_SERVER_ADDR="http://cfgsync:4400" \
|
||||
CFG_HOST_IP=$(hostname -i) \
|
||||
CFG_HOST_IDENTIFIER="validator-$(hostname -i)" \
|
||||
LOG_LEVEL="DEBUG" \
|
||||
RISC0_DEV_MODE=true
|
||||
|
||||
/usr/bin/cfgsync-client && \
|
||||
exec /usr/bin/nomos-node /config.yaml
|
||||
@ -14,10 +14,25 @@ def get_env_var(var_name, default=None):
|
||||
return env_var
|
||||
|
||||
|
||||
def make_mod_da_var(node_type, version, is_image=False):
|
||||
base = "nomos_executor_mod_da" if node_type == "executor" else "nomos_mod_da"
|
||||
value = f"{base}_{version}"
|
||||
|
||||
if is_image:
|
||||
return value.replace("_", "-") + ":testnet"
|
||||
else:
|
||||
return value
|
||||
|
||||
|
||||
# Configuration constants. Need to be upercase to appear in reports
|
||||
DEFAULT_NOMOS_IMAGE = "ghcr.io/logos-co/nomos:testnet"
|
||||
NOMOS_IMAGE = get_env_var("NOMOS_IMAGE", DEFAULT_NOMOS_IMAGE)
|
||||
|
||||
NOMOS_MOD_DA_IMAGE_d8bbc46 = make_mod_da_var("validator", "d8bbc46", True)
|
||||
NOMOS_EXECUTOR_MOD_DA_IMAGE_d19a1f3 = make_mod_da_var("executor", "d19a1f3", True)
|
||||
NOMOS_EXECUTOR_MOD_DA_IMAGE_7f54114 = make_mod_da_var("executor", "7f54114", True)
|
||||
NOMOS_EXECUTOR_MOD_DA_IMAGE_4a58376 = make_mod_da_var("executor", "4a58376", True)
|
||||
|
||||
DEFAULT_PROXY_IMAGE = "bitnami/configurable-http-proxy:latest"
|
||||
HTTP_PROXY_IMAGE = get_env_var("HTTP_PROXY_IMAGE", DEFAULT_PROXY_IMAGE)
|
||||
|
||||
@ -26,6 +41,10 @@ NOMOS = "nomos"
|
||||
NOMOS_EXECUTOR = "nomos_executor"
|
||||
CFGSYNC = "cfgsync"
|
||||
|
||||
NOMOS_EXECUTOR_MOD_DA_d19a1f3 = make_mod_da_var("executor", "d19a1f3")
|
||||
NOMOS_EXECUTOR_MOD_DA_7f54114 = make_mod_da_var("executor", "7f54114")
|
||||
NOMOS_EXECUTOR_MOD_DA_4a58376 = make_mod_da_var("executor", "4a58376")
|
||||
|
||||
NODE_1 = get_env_var("NODE_1", NOMOS)
|
||||
NODE_2 = get_env_var("NODE_2", NOMOS_EXECUTOR)
|
||||
NODE_3 = get_env_var("NODE_3", CFGSYNC)
|
||||
|
||||
@ -1,6 +1,36 @@
|
||||
from src.env_vars import NOMOS_IMAGE
|
||||
from src.env_vars import (
|
||||
NOMOS_IMAGE,
|
||||
NOMOS_MOD_DA_IMAGE_d8bbc46,
|
||||
NOMOS_EXECUTOR_MOD_DA_IMAGE_d19a1f3,
|
||||
NOMOS_EXECUTOR_MOD_DA_IMAGE_7f54114,
|
||||
NOMOS_EXECUTOR_MOD_DA_IMAGE_4a58376,
|
||||
)
|
||||
|
||||
nomos_nodes = {
|
||||
"nomos_mod_da_d8bbc46": {
|
||||
"image": NOMOS_MOD_DA_IMAGE_d8bbc46,
|
||||
"volumes": ["cluster_config:/etc/nomos", "./kzgrs/kzgrs_test_params:/kzgrs_test_params:z"],
|
||||
"ports": ["3000/udp", "18080/tcp"],
|
||||
"entrypoint": "/etc/nomos/scripts/run_nomos_node_debug.sh",
|
||||
},
|
||||
"nomos_executor_mod_da_d19a1f3": {
|
||||
"image": NOMOS_EXECUTOR_MOD_DA_IMAGE_d19a1f3,
|
||||
"volumes": ["cluster_config:/etc/nomos", "./kzgrs/kzgrs_test_params:/kzgrs_test_params:z"],
|
||||
"ports": ["3000/udp", "18080/tcp"],
|
||||
"entrypoint": "/etc/nomos/scripts/run_nomos_executor_debug.sh",
|
||||
},
|
||||
"nomos_executor_mod_da_7f54114": {
|
||||
"image": NOMOS_EXECUTOR_MOD_DA_IMAGE_7f54114,
|
||||
"volumes": ["cluster_config:/etc/nomos", "./kzgrs/kzgrs_test_params:/kzgrs_test_params:z"],
|
||||
"ports": ["3000/udp", "18080/tcp"],
|
||||
"entrypoint": "/etc/nomos/scripts/run_nomos_executor_debug.sh",
|
||||
},
|
||||
"nomos_executor_mod_da_4a58376": {
|
||||
"image": NOMOS_EXECUTOR_MOD_DA_IMAGE_4a58376,
|
||||
"volumes": ["cluster_config:/etc/nomos", "./kzgrs/kzgrs_test_params:/kzgrs_test_params:z"],
|
||||
"ports": ["3000/udp", "18080/tcp"],
|
||||
"entrypoint": "/etc/nomos/scripts/run_nomos_executor_debug.sh",
|
||||
},
|
||||
"nomos_custom": {
|
||||
"image": NOMOS_IMAGE,
|
||||
"volumes": ["cluster_config:/etc/nomos", "./kzgrs/kzgrs_test_params:/kzgrs_test_params:z"],
|
||||
|
||||
@ -4,7 +4,7 @@ import os
|
||||
import pytest
|
||||
|
||||
from src.client.proxy_client import ProxyClient
|
||||
from src.env_vars import CFGSYNC, NOMOS, NOMOS_EXECUTOR, CONSENSUS_SLOT_TIME
|
||||
from src.env_vars import CFGSYNC, NOMOS, NOMOS_EXECUTOR, CONSENSUS_SLOT_TIME, make_mod_da_var
|
||||
from src.libs.common import delay
|
||||
from src.libs.custom_logger import get_custom_logger
|
||||
from src.node.nomos_node import NomosNode
|
||||
@ -112,3 +112,27 @@ class StepsCommon:
|
||||
@pytest.fixture(params=["setup_2_node_cluster", "setup_4_node_cluster"])
|
||||
def setup_cluster_variant(self, request):
|
||||
return request.getfixturevalue(request.param)
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def setup_2_node_mod_da_cluster(self, request):
|
||||
logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}")
|
||||
|
||||
subnet_size = get_param_or_default(request, "subnet_size", 2)
|
||||
dispersal_factor = get_param_or_default(request, "dispersal_factor", 2)
|
||||
min_dispersal_peers = get_param_or_default(request, "min_dispersal_peers", 1)
|
||||
prepare_cluster_config(2, subnet_size, dispersal_factor, min_dispersal_peers)
|
||||
|
||||
validator_version = get_param_or_default(request, "validator_version", "")
|
||||
validator = make_mod_da_var("validator", validator_version)
|
||||
|
||||
executor_version = get_param_or_default(request, "executor_version", "")
|
||||
executor = make_mod_da_var("executor", executor_version)
|
||||
|
||||
self.node1 = NomosNode(CFGSYNC, "cfgsync")
|
||||
self.node2 = NomosNode(validator, "nomos_node_0")
|
||||
self.node3 = NomosNode(executor, "nomos_node_1")
|
||||
self.main_nodes.extend([self.node1, self.node2, self.node3])
|
||||
start_nodes(self.main_nodes)
|
||||
ensure_nodes_ready(self.main_nodes[1:])
|
||||
|
||||
delay(CONSENSUS_SLOT_TIME)
|
||||
|
||||
@ -48,7 +48,7 @@ class StepsDataAvailability(StepsCommon):
|
||||
def find_executor_node(self):
|
||||
executor = {}
|
||||
for node in self.main_nodes:
|
||||
if node.node_type() == NOMOS_EXECUTOR:
|
||||
if "nomos_executor" in node.node_type():
|
||||
executor = node
|
||||
return executor
|
||||
|
||||
|
||||
@ -17,6 +17,21 @@ from src.data_storage import DS
|
||||
logger = get_custom_logger(__name__)
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption("--run-with-mod-da-node", action="store_true", default=False, help="Run tests requiring nodes with modified da layer")
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
config.addinivalue_line("markers", "mod_da_node: Mark test as requiring --run-with-mod-da-node")
|
||||
|
||||
|
||||
def pytest_collection_modifyitems(config, items):
|
||||
run_mod_da_node = config.getoption("--run-with-mod-da-node")
|
||||
for item in items:
|
||||
if "mod_da_node" in item.keywords and not run_mod_da_node:
|
||||
item.add_marker(pytest.mark.skip(reason="Requires --run-with-mod-da-node option"))
|
||||
|
||||
|
||||
# See https://docs.pytest.org/en/latest/example/simple.html#making-test-result-information-available-in-fixtures
|
||||
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
|
||||
def pytest_runtest_makereport(item):
|
||||
|
||||
0
tests/data_confidentiality/__init__.py
Normal file
0
tests/data_confidentiality/__init__.py
Normal file
0
tests/dispersal_resilience/__init__.py
Normal file
0
tests/dispersal_resilience/__init__.py
Normal file
48
tests/dispersal_resilience/test_dispersal_resilience.py
Normal file
48
tests/dispersal_resilience/test_dispersal_resilience.py
Normal file
@ -0,0 +1,48 @@
|
||||
import pytest
|
||||
|
||||
from src.env_vars import CONSENSUS_SLOT_TIME
|
||||
from src.libs.common import to_app_id, to_index, delay
|
||||
from src.steps.da import StepsDataAvailability
|
||||
from src.test_data import DATA_TO_DISPERSE
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("setup_2_node_mod_da_cluster")
|
||||
@pytest.mark.mod_da_node
|
||||
class TestDispersalResilience(StepsDataAvailability):
|
||||
main_nodes = []
|
||||
|
||||
@pytest.mark.parametrize("setup_2_node_mod_da_cluster", [{"validator_version": "d8bbc46", "executor_version": "d19a1f3"}], indirect=True)
|
||||
def test_integrity_kzg_commitments(self):
|
||||
# Confirm validator node has rejected dispersal request from executor - there is a mismatch between
|
||||
# column data and proofs.
|
||||
self.disperse_data(DATA_TO_DISPERSE[3], to_app_id(1), to_index(0))
|
||||
delay(CONSENSUS_SLOT_TIME)
|
||||
try:
|
||||
rcv_data = self.get_data_range(self.node2, to_app_id(1), to_index(0), to_index(5))
|
||||
except AssertionError as ae:
|
||||
assert "Get data range response is empty" in str(ae), "Get data range response should be empty"
|
||||
|
||||
if rcv_data:
|
||||
raise AssertionError("Get data range response should be empty")
|
||||
|
||||
@pytest.mark.parametrize("setup_2_node_mod_da_cluster", [{"validator_version": "d8bbc46", "executor_version": "7f54114"}], indirect=True)
|
||||
def test_chunkification_robustness_different_chunk_size(self):
|
||||
# Confirm validator node has rejected dispersal request from executor with different data alignment
|
||||
try:
|
||||
self.disperse_data(DATA_TO_DISPERSE[4], to_app_id(1), to_index(0), timeout_duration=0)
|
||||
except Exception as e:
|
||||
assert "does not match destination slice length" in str(e), "Send dispersal request with different data alignment should fail"
|
||||
return
|
||||
|
||||
raise AssertionError("Send dispersal request with different data alignment should fail")
|
||||
|
||||
@pytest.mark.parametrize("setup_2_node_mod_da_cluster", [{"validator_version": "d8bbc46", "executor_version": "4a58376"}], indirect=True)
|
||||
def test_rs_encoding_resistance_to_manipulation(self):
|
||||
# Confirm validator node has rejected dispersal request from executor with inconsistent RS encoding
|
||||
try:
|
||||
self.disperse_data(DATA_TO_DISPERSE[5], to_app_id(1), to_index(0), timeout_duration=0)
|
||||
except Exception as e:
|
||||
assert "blob sampling timed out for" in str(e), "Send dispersal request with inconsistent RS encoding should fail"
|
||||
return
|
||||
|
||||
raise AssertionError("Send dispersal request with inconsistent RS encoding should fail")
|
||||
Loading…
x
Reference in New Issue
Block a user