Add support for Testnet4#1034
Conversation
| setting.timestamp_limit_seconds, | ||
| setting.proof_of_work_limit, | ||
| state.height(), | ||
| state.timestamp(), |
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
There was a problem hiding this comment.
If there's a way to do it w/o changing anything in database, I'd prefer that, so let me know
There was a problem hiding this comment.
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(), |
Depends on libbitcoin/libbitcoin-system#1866