rpc: enforce BIP 145 SegWit rules in getblocktemplate#2569
Open
TechLateef wants to merge 1 commit into
Open
Conversation
This commit updates the getblocktemplate RPC to enforce the SegWit rules specified in BIP 145. Specifically, it ensures that: - Client requests are rejected with ErrRPCInvalidParameter if SegWit is active but the client does not explicitly support the 'segwit' rule. - The 'rules' array in the response conditionally includes '!segwit' if the generated block template contains transactions with witness data (indicating a witness commitment is required). - The 'rules' array includes 'segwit' (without the '!' prefix) when SegWit is active but the template does not contain any witness transactions. Additionally, integration tests have been added to verify that rule signaling and SegWit activation behave correctly during block template generation.
894300b to
550927a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Description
This PR addresses issue #1738 by enforcing BIP 145 SegWit rules within the
getblocktemplateRPC response.Specifically, this PR updates
rpcserver.goto ensure that:ErrRPCInvalidParameterif SegWit is active but the client does not explicitly include thesegwitrule in their request.rulesarray in the response conditionally includes!segwitif the generated block template contains transactions with witness data (indicating a witness commitment is required).rulesarray includessegwit(without the!prefix) when SegWit is active but the template does not contain any witness transactions.Steps to Test
go test -v -tags=rpctest -run=TestRpcServer ./integrationtestGetBlockTemplateSegwitActiveNoRule,testGetBlockTemplateSegwitActiveWithRule, andtestGetBlockTemplateResponseRulestests pass successfully.Pull Request Checklist
Testing
Code Style and Documentation