-
Notifications
You must be signed in to change notification settings - Fork 167
fix(config): Conditionally process governance events #2000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The insertNewEpochLedgerEvents function was attempting to process LedgerGovInfo events even when governance was explicitly disabled in the configuration. This led to a runtime error when trying to look up governance actions that were never inserted into the database. This commit fixes the issue by adding a conditional check to the LedgerGovInfo handler, ensuring that the related database operations are only performed when governance is enabled (ioGov iopts is true).
Looks like this change caused issue with "double rewards" error: [db-sync-node:Info:81] [2025-09-10 14:50:05.06 UTC] Starting epoch 169
[db-sync-node:Info:81] [2025-09-10 14:50:05.06 UTC] Insert Conway Block: epoch 169, slot 71366403, block 2715813, hash a7bb0420f0eb7ad5092621ca76f3e81f500106f3ebdecdc4aae2f649ba6d18d8
[db-sync-node:Info:81] [2025-09-10 14:50:05.67 UTC]
Replaced epoch 169 from updateEpochWhenSyncing with Cache.
epoch: Epoch {epochOutSum = 2031794138, epochFees = DbLovelace 208489, epochTxCount = 1, epochBlkCount = 1, epochNo = 169, epochStartTime = 2024-09-23 00:00:03 UTC, epochEndTime = 2024-09-23 00:00:03 UTC}
[db-sync-node:Info:90] [2025-09-10 14:50:13.82 UTC] Asynchronously wrote a ledger snapshot to ledger-state/preprod_gov_disabled_fixed_.txt/71366322-e1d2e6b226-168.lstate in 8.820540233s.
[db-sync-node:Info:81] [2025-09-10 14:50:21.95 UTC] Inserted 40126 EpochStake for EpochNo 170
[db-sync-node:Info:81] [2025-09-10 14:50:30.22 UTC] Insert Conway Block: epoch 169, slot 71479871, block 2720000, hash db8f9e707e1c1e5cd79826d9cf85c86d5e4d03bf75720c1dc6c96894fffe2951
[db-sync-node:Info:81] [2025-09-10 14:50:30.22 UTC] Pool Offchain metadata fetch: 4 results, 4 fetch errors
[db-sync-node:Info:81] [2025-09-10 14:51:02.31 UTC] Insert Conway Block: epoch 169, slot 71615561, block 2725000, hash 48696329e6cbed6d7670028887fa7277e37bebb1a8d70eb9364925f626ac59d4
[db-sync-node:Info:81] [2025-09-10 14:51:26.98 UTC] Insert Conway Block: epoch 169, slot 71748021, block 2730000, hash f24f255558b7cf30b12495a6250f28d7494de40952af384487da48e18d3560f3
[db-sync-node:Info:81] [2025-09-10 14:51:34.65 UTC] Removing old epoch boundary file ledger-state/preprod_gov_disabled_fixed_.txt/58838384-3800764212-139.lstate
[db-sync-node:Info:81] [2025-09-10 14:51:34.71 UTC] Removing 7 orphaned rewards
[db-sync-node:Warning:81] [2025-09-10 14:51:34.71 UTC] validateEpochRewards: rewards spendable in epoch 170 expected total of 4674 but got 9348
Error: Switchboard's queue full, dropping log items!
[db-sync-node:Error:81] [2025-09-10 14:51:34.96 UTC] diffRewardMap:
[db-sync-node:Error:81] [2025-09-10 14:51:34.96 UTC] "\224\NUL\n\220\143\ETX.\159nc\DC4\250\219\198\224\149\235z\191un<\192\217\143c\131\\\153": [(RwdMember,DbLovelace 688),(RwdMember,DbLovelace 688)] /= [(RwdMember,Coin 688)]
[db-sync-node:Error:81] [2025-09-10 14:51:34.96 UTC] "\224\NUL\v\160\207&\CAN\218\FS@\250{z\239\146\209\206O\209d\129xK(@\ETB\169\164\219": [(RwdMember,DbLovelace 6845762),(RwdMember,DbLovelace 6845762)] /= [(RwdMember,Coin 6845762)]
... Not sure if the list of ledger events passed to the event handler should be deduplicated or this approach to solve |
Looks like there are no errors when syncing from scratch on db_sync_preview_gov_disabled_fix_logs.txt db_sync_preprod_gov_disabled_fix_logs.txt Automated tests are also passing: (.venv) artur@workstation:~/Projects/cnt/cardano-node-tests$ pytest -s -k test_dbsync_config cardano_node_tests/tests/
WARNING: Using `cardano-cli` from custom path!
WARNING: Using `cardano-node` from custom path!
=============================================================================================================== test session starts ===============================================================================================================
platform linux -- Python 3.11.13, pytest-8.4.1, pluggy-1.5.0 -- /home/artur/Projects/cnt/cardano-node-tests/dev_workdir/.venv/bin/python
cachedir: .pytest_cache
metadata: {'Python': '3.11.13', 'Platform': 'Linux-5.15.0-153-generic-x86_64-with-glibc2.40', 'Packages': {'pytest': '8.4.1', 'pluggy': '1.5.0'}, 'Plugins': {'html': '4.1.1', 'xdist': '3.7.0', 'metadata': '3.1.1', 'select': '0.1.2', 'order': '1.3.0', 'subtests': '0.14.2', 'allure-pytest': '2.14.3', 'hypothesis': '6.135.17'}, 'cardano-node': '10.3.1', 'cardano-node rev': 'b3f237b75e64f4d8142af95b053e2828221d707f', 'cardano-node ghc': 'ghc-9.6', 'cardano-cli': '10.7.0.0', 'cardano-cli rev': 'b3f237b75e64f4d8142af95b053e2828221d707f', 'cardano-cli ghc': 'ghc-9.6', 'CLUSTER_ERA': 'conway', 'COMMAND_ERA': 'conway', 'TESTNET_VARIANT': 'conway_fast', 'ENABLE_LEGACY': 'False', 'MIXED_P2P': 'False', 'NUM_POOLS': '3', 'UTXO_BACKEND': '', 'MAX_TESTS_PER_CLUSTER': 8, 'CLUSTERS_COUNT': 1, 'HAS_CC': 'True', 'cardano-node-tests rev': 'da219df12055498dd7d0b0d3c93bfa902bf39729', 'cardano-node-tests url': 'https://github.com/IntersectMBO/cardano-node-tests/tree/da219df12055498dd7d0b0d3c93bfa902bf39729', 'CARDANO_NODE_SOCKET_PATH': '/home/artur/Projects/cnt/cardano-node-tests/dev_workdir/state-cluster0/bft1.socket', 'cardano-cli exe': '/home/artur/.local/bin/cardano-cli', 'cardano-node exe': '/home/artur/.local/bin/cardano-node', 'cardano-submit-api exe': '', 'network magic': 42, 'HAS_DBSYNC': 'True', 'db-sync': '13.6.0.5', 'db-sync rev': '0000000000000000000000000000000000000000', 'db-sync ghc': 'ghc-8.10', 'db-sync exe': '/home/artur/.local/bin/cardano-db-sync', 'HAS_SMASH': 'False'}
hypothesis profile 'default'
rootdir: /home/artur/Projects/cnt/cardano-node-tests
configfile: pyproject.toml
plugins: html-4.1.1, xdist-3.7.0, metadata-3.1.1, select-0.1.2, order-1.3.0, subtests-0.14.2, allure-pytest-2.14.3, hypothesis-6.135.17
collecting ...
--------------------------------------------------------------------------------------------------------------- live log collection ---------------------------------------------------------------------------------------------------------------
WARNING cardano_node_tests.utils.blockers:blockers.py:80 No GitHub token provided, cannot check if issue 'IntersectMBO/cardano-cli#1199' is blocked
collected 1735 items / 1734 deselected / 1 selected
cardano_node_tests/tests/test_dbsync_config.py::TestDBSyncConfig::test_dbsync_config
----------------------------------------------------------------------------------------------------------------- live log setup ------------------------------------------------------------------------------------------------------------------
INFO cardano_node_tests.tests.conftest:conftest.py:237 Changed CWD to '/home/artur/Projects/cnt/cardano-node-tests/dev_workdir/tmp/pytest-of-artur/pytest-33'.
------------------------------------------------------------------------------------------------------------------ live log call ------------------------------------------------------------------------------------------------------------------
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'stop' action on services ['dbsync'].
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'start' action on services ['dbsync'].
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 3s before repeating query for the 1 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 6s before repeating query for the 2 time.
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 91.79%
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 100.00%
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'stop' action on services ['dbsync'].
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'start' action on services ['dbsync'].
INFO cardano_node_tests.utils.dbsync_conn:dbsync_conn.py:34 Closing connection to db-sync database dbsync0.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 3s before repeating query for the 1 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 6s before repeating query for the 2 time.
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 96.30%
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 100.00%
(scenario='basic_tx_out') SUBPASS--------------------------------------------------------------------------------------------------------------- live log logreport ----------------------------------------------------------------------------------------------------------------
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'stop' action on services ['dbsync'].
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'start' action on services ['dbsync'].
INFO cardano_node_tests.utils.dbsync_conn:dbsync_conn.py:34 Closing connection to db-sync database dbsync0.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 3s before repeating query for the 1 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 6s before repeating query for the 2 time.
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 100.00%
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 3s before repeating query for the 1 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 6s before repeating query for the 2 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 11s before repeating query for the 3 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 18s before repeating query for the 4 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 27s before repeating query for the 5 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 38s before repeating query for the 6 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 51s before repeating query for the 7 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 66s before repeating query for the 8 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 83s before repeating query for the 9 time.
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'stop' action on services ['dbsync'].
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'start' action on services ['dbsync'].
INFO cardano_node_tests.utils.dbsync_conn:dbsync_conn.py:34 Closing connection to db-sync database dbsync0.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 3s before repeating query for the 1 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 6s before repeating query for the 2 time.
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 98.25%
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 100.00%
cardano_node_tests/tests/test_dbsync_config.py::TestDBSyncConfig::test_dbsync_config (scenario='governance') SUBPASS--------------------------------------------------------------------------------------------------------------- live log logreport ----------------------------------------------------------------------------------------------------------------
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'stop' action on services ['dbsync'].
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'start' action on services ['dbsync'].
INFO cardano_node_tests.utils.dbsync_conn:dbsync_conn.py:34 Closing connection to db-sync database dbsync0.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 3s before repeating query for the 1 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 6s before repeating query for the 2 time.
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 92.28%
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 100.00%
cardano_node_tests/tests/test_dbsync_config.py::TestDBSyncConfig::test_dbsync_config (scenario='tx_cbor_value_enable') SUBPASS--------------------------------------------------------------------------------------------------------------- live log logreport ----------------------------------------------------------------------------------------------------------------
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'stop' action on services ['dbsync'].
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'start' action on services ['dbsync'].
INFO cardano_node_tests.utils.dbsync_conn:dbsync_conn.py:34 Closing connection to db-sync database dbsync0.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 3s before repeating query for the 1 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 6s before repeating query for the 2 time.
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 92.72%
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 100.00%
cardano_node_tests/tests/test_dbsync_config.py::TestDBSyncConfig::test_dbsync_config (scenario='tx_cbor_value_disable') SUBPASS--------------------------------------------------------------------------------------------------------------- live log logreport ----------------------------------------------------------------------------------------------------------------
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'stop' action on services ['dbsync'].
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'start' action on services ['dbsync'].
INFO cardano_node_tests.utils.dbsync_conn:dbsync_conn.py:34 Closing connection to db-sync database dbsync0.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 3s before repeating query for the 1 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 6s before repeating query for the 2 time.
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 92.57%
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 100.00%
cardano_node_tests/tests/test_dbsync_config.py::TestDBSyncConfig::test_dbsync_config (scenario='multi_asset_enable') SUBPASS--------------------------------------------------------------------------------------------------------------- live log logreport ----------------------------------------------------------------------------------------------------------------
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'stop' action on services ['dbsync'].
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'start' action on services ['dbsync'].
INFO cardano_node_tests.utils.dbsync_conn:dbsync_conn.py:34 Closing connection to db-sync database dbsync0.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 3s before repeating query for the 1 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 6s before repeating query for the 2 time.
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 95.55%
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 100.00%
cardano_node_tests/tests/test_dbsync_config.py::TestDBSyncConfig::test_dbsync_config (scenario='multi_asset_disable') SUBPASS
cardano_node_tests/tests/test_dbsync_config.py::TestDBSyncConfig::test_dbsync_config PASSED
---------------------------------------------------------------------------------------------------------------- live log teardown ----------------------------------------------------------------------------------------------------------------
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'stop' action on services ['dbsync'].
INFO cardano_node_tests.utils.cluster_nodes:cluster_nodes.py:420 Performing 'start' action on services ['dbsync'].
INFO cardano_node_tests.utils.dbsync_conn:dbsync_conn.py:34 Closing connection to db-sync database dbsync0.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 3s before repeating query for the 1 time.
WARNING cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:508 Sleeping 6s before repeating query for the 2 time.
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 85.73%
INFO cardano_node_tests.utils.dbsync_utils:dbsync_utils.py:1588 Progress of db-sync: 100.00%
INFO cardano_node_tests.utils.dbsync_conn:dbsync_conn.py:34 Closing connection to db-sync database dbsync0.
======================================================================================== 1 passed, 1734 deselected, 6 subtests passed in 522.53s (0:08:42) ======================================================================================== |
The
insertNewEpochLedgerEvents
function was attempting to processLedgerGovInfo
events even when governance was explicitly disabled in the configuration. This led to a runtime error when trying to look up governance actions that were never inserted into the database:This commit attempts to fix the issue by adding a conditional check to the
LedgerGovInfo
handler, ensuring that the related database operations are only performed when governance is enabled (ioGov iopts
is true).