Skip to content

Add support for Testnet4#1034

Open
thecodefactory wants to merge 1 commit into
libbitcoin:masterfrom
thecodefactory:testnet4
Open

Add support for Testnet4#1034
thecodefactory wants to merge 1 commit into
libbitcoin:masterfrom
thecodefactory:testnet4

Conversation

@thecodefactory

Copy link
Copy Markdown
Member

Comment thread src/chasers/chaser_block.cpp
setting.timestamp_limit_seconds,
setting.proof_of_work_limit,
state.height(),
state.timestamp(),

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.

These 2 are problematic here, as this is a context free check override (there is no contextual header::check(..)). So this needs to move to header::accept(...) where these values are passed via context.

setting.proof_of_work_limit,
state.height(),
state.timestamp(),
state.previous_block_timestamp(),

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.

This is a more significant issue, since it is runtime context that is not part of context. Making it part of runtime context has an impact on query (database) for population of context for chain_state initialization (and possibly elsewhere).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In an earlier version of this code, I did make the database changes (locally) to add previous_block_time (pbt) so that it could be used by the context in header::accept. If that's the route we need to go, I can modernize that, but mostly I thought of it as a learning exercise

@evoskuil evoskuil Jun 7, 2026

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.

This is simpler actually, no database impact. The population queries already always populate the required state because of the MTP requirement. So just add this to context and obtain the context from the chain_state for header validation (already the case) and it's populated:
chain::context chain::chain_state::context() const NOEXCEPT;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not sure I'm following this last part. I think if we add anything to the context (i.e. new members), it will affect the database and those changes will be needed (i.e. previous_block_timestamp and retargeting_interval).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Adding members to the context and using header::accept along with this https://github.com/thecodefactory/libbitcoin-database/tree/testnet4 allows me to also sync testnet4

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If there's a way to do it w/o changing anything in database, I'd prefer that, so let me know

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.

chain_state already populates the last 11 blocks worth of timestamps in order to maintain a rolling (no database hit) MTP value. So the value is already present, just needs to be set into context is is is obtained from chain_state.

state.height(),
state.timestamp(),
state.previous_block_timestamp(),
settings().retargeting_interval(),

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.

Same comments as above.

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