Skip to content

chore: narrow fork_database bmi using (F020) + pin submodules (F032)#123

Merged
On1x merged 3 commits into
masterfrom
chore/hygiene-namespaces-submodules
Jun 17, 2026
Merged

chore: narrow fork_database bmi using (F020) + pin submodules (F032)#123
On1x merged 3 commits into
masterfrom
chore/hygiene-namespaces-submodules

Conversation

@chiliec

@chiliec chiliec commented Jun 17, 2026

Copy link
Copy Markdown
Member

Hygiene sweep from the tech-debt audit. Scope narrowed after CI revealed load-bearing leaks — see below.

Done (verified green)

  • F020 fork_database.hppusing namespace boost::multi_index; → the 7 specific names the index typedef uses. Safe because bmi names are still provided namespace-wide by chain_object_types.hpp, so no downstream consumer loses them.
  • F032 .gitmodules — drop branch = lines so a stray git submodule update --remote cannot silently advance the pinned commits. CI/Docker use submodule update --init --recursive (recorded SHAs), so build behaviour is unchanged.

Attempted, then reverted (load-bearing transitive leak)

  • F023 / F024 block_log.hpp / dlt_block_log.hpp — narrowing their using namespace graphene::protocol; broke the build. These headers are pulled in transitively via database.hpp across most of the codebase; far-flung consumers (operation_history/plugin.hpp needs annotated_signed_transaction, json_rpc/utility.hpp, …) rely on the leak. Reverted after two CI cycles of whack-a-mole.

Not attempted (same load-bearing class)

  • F021 chain_object_types.hpp bmi using — relied on by 13+ object headers (account_object.hpp uses 58 bare bmi tokens with no own using).
  • F022 operation_util_impl.hpp — broad operation-visitor include.
  • F025 raw new/delete: descoped (pimpl.reset(new X()) has no benefit; fc::promise::ptr can't use make_unique). F026 already fixed.

Lesson recorded: removing using namespace from any header reachable via database.hpp is a major refactor, not a sweep. Only leaf headers (F018 wallet.hpp) and redundantly-provided names (F020) are safe to narrow.

Header hygiene (reduce namespace pollution leaked to every consumer):
- F020 fork_database.hpp: replace 'using namespace boost::multi_index;'
  with the 7 specific names the index typedef uses. Verified no consumer
  relies on the leak.
- F023/F024 dlt_block_log.hpp / block_log.hpp: replace
  'using namespace graphene::protocol;' with the only two names used
  (signed_block, optional).

Submodules (F032): drop 'branch =' from .gitmodules so a stray
'submodule update --remote' cannot silently advance the pinned commits.
CI/Docker use 'submodule update --init --recursive' (recorded SHAs), so
build behaviour is unchanged.

Deliberately NOT touched (load-bearing, the audit's 'move to .cpp' is
wrong for these):
- F021 chain_object_types.hpp 'using namespace boost::multi_index;' is
  relied on by 13+ object headers (account_object.hpp uses 58 bare bmi
  tokens with no using of its own). Removing it cascade-breaks the object
  layer; it needs per-consumer usings added first.
- F022 operation_util_impl.hpp: same risk class (broad visitor include).
chiliec added 2 commits June 17, 2026 17:53
The previous commit narrowed the blanket protocol using out of
block_log.hpp / dlt_block_log.hpp, but block_log.cpp and
dlt_block_log.cpp relied on that header leak for block_id_type and
block_header. Move the using into the .cpp files (the audit's intent):
headers stay minimal, the .cpp gets the full protocol namespace it
implements against. Verified other consumers (database.hpp via
fork_database.hpp/chain_object_types.hpp, p2p_plugin.cpp via its own
usings) do not depend on the removed leak.
block_log.hpp / dlt_block_log.hpp are pulled in transitively via
database.hpp across most of the codebase. Their 'using namespace
graphene::protocol;' leaks the whole protocol namespace into
graphene::chain, and far-flung consumers (operation_history/plugin.hpp
needs annotated_signed_transaction, json_rpc/utility.hpp, ...) rely on
that leak. Narrowing it cascades into widespread build breakage that
can't be fixed without a per-consumer using audit — the same
load-bearing situation as F021/F022, just transitive.

Keeping only the genuinely-safe items in this PR:
- F020 fork_database.hpp (bmi names still provided namespace-wide by
  chain_object_types.hpp, so no breakage)
- F032 submodule pinning (no compile impact).
@chiliec chiliec changed the title chore: narrow header namespace usings (F020/F023/F024) + pin submodules (F032) chore: narrow fork_database bmi using (F020) + pin submodules (F032) Jun 17, 2026
@chiliec

chiliec commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

Убрал строки branch = ... из .gitmodules, чтобы сабмодули были жёстко закреплены на конкретных коммитах и не могли молча «уехать» при git submodule update --remote (на сборку не влияет — CI использует --init, берущий зафиксированный SHA).

@On1x On1x left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ок

@On1x On1x merged commit 4299b6c into master Jun 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants