-
Notifications
You must be signed in to change notification settings - Fork 106
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
test(rpc): Create a script that submits block proposals to zcashd #5944
Conversation
e0f3631
to
188d19a
Compare
188d19a
to
d9b838d
Compare
@arya2 I am also seeing these errors for some block templates:
So I think the bug might be in the |
This seems like a really big change when compared with the title of the original issue and , which is to do a manual test to check that we can create valid blocks, and the title of the PR... It also seems to be touching a lot of code that we were going to try to keep as stable as possible pending the zebra audit... In reviewing and merging this code I would like us to be mindful of this and evaluate whether the benefits of having this test outweigh the potential costs... could we use this code just for testing now and evaluate when might be a good time to merge? |
It's more substantial than I would've imagined, but practically all of the changes appear to be test-related. It's a little different from #5884, because it's using zcashd's block proposal implementation. |
Silver lining: at least Zebra's getblocktemplate behaviour in proposal mode matches zcashd. 🥲 |
This is a draft PR with a merge conflict, so the changes you see here don't represent what will be in the final PR. Let's re-evaluate once I've finished splitting the PR? |
d9b838d
to
28f48b8
Compare
28f48b8
to
bb437cc
Compare
4d9af88
to
7dec2ff
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #5944 +/- ##
==========================================
+ Coverage 77.95% 78.07% +0.11%
==========================================
Files 312 312
Lines 38988 38996 +8
==========================================
+ Hits 30394 30447 +53
+ Misses 8594 8549 -45 |
Mainnet test: BLOCK_TEMPLATE_TO_PROPOSAL="cargo run --bin block-template-to-proposal --features getblocktemplate-rpcs" ZCASH_CLI=../zcash/src/zcash-cli ./zebra-utils/zcash-rpc-block-template-to-proposal 3000 8232
Checking getblocktemplate node release info...
Connected to zebrad (port 3000) for getblocktemplate { "mode": "template" }
Checking proposal nodes release info...
Connected to zcashd (port 8232) for getblocktemplate { "mode": "proposal", "data": "..." }
Checking zebrad template network and tip height...
Checking proposal nodes network and tip height...
getblocktemplate template request (zebrad port 3000):
getblocktemplate { "mode": "template" }
Querying zebrad main chain at height >=1950841...
real 0m0.004s
user 0m0.003s
sys 0m0.000s
Block template data is in /tmp/tmp.PPDLXGIBeY.block-template-proposal/template-getblocktemplate-template.json
Turning the template into block proposal data using cargo run --bin block-template-to-proposal --features getblocktemplate-rpcs...
Finished dev [unoptimized + debuginfo] target(s) in 0.15s
Running `target/debug/block-template-to-proposal`
GetBlockTemplate { capabilities: ["proposal"], version: 4, .. }
Block proposal data is in /tmp/tmp.PPDLXGIBeY.block-template-proposal/proposal-data.json
04000000d96a ... 1c41d000000000000000000000000
getblocktemplate proposal submissions:
getblocktemplate { "mode": "proposal", "data": "..." }
real 0m0.014s
user 0m0.003s
sys 0m0.000s
Proposal response from port 8232: Full template: GetBlockTemplate {
capabilities: ["proposal"],
version: 4,
previous_block_hash: GetBlockHash(block::Hash("000000000047f4d4280fe070fcfa7d924291d339c3ab15bfacebec9ecb316ad9")),
block_commitments_hash: ChainHistoryBlockTxAuthCommitmentHash("86de498d33dd402834afdb2e8769b797eaf4e9110350b81f42451203e4ec4f41"),
light_client_root_hash: ChainHistoryBlockTxAuthCommitmentHash("86de498d33dd402834afdb2e8769b797eaf4e9110350b81f42451203e4ec4f41"),
final_sapling_root_hash: ChainHistoryBlockTxAuthCommitmentHash("86de498d33dd402834afdb2e8769b797eaf4e9110350b81f42451203e4ec4f41"),
default_roots: DefaultRoots {
merkle_root: Root("dc1b60c85bdb0b8989b6bce4b9d8b73385bfb342b84613b51a52d3c484d8e16e"),
chain_history_root: ChainHistoryMmrRootHash("50555b833a09861a7bc37d8e883dcbdd1453337c844138695b6b674b01a28128"),
auth_data_root: AuthRoot("40d5dfb8cd8953a6ce067ba6eb0d6d2de1bda87b00dd8d1b3187849cb6924df4"),
block_commitments_hash: ChainHistoryBlockTxAuthCommitmentHash("86de498d33dd402834afdb2e8769b797eaf4e9110350b81f42451203e4ec4f41")
},
transactions: [
TransactionTemplate {
data: SerializedTransaction("0400008085202f890146c0109bf5faef0aa0b2b1f0958c4adeddfedffa4aa0c67d81394f370d65ed1b000000006b483045022100bb55bce9e274efd61e9d77aeea47614b7603d4be549dcdb569a91cf805472de302204d3db2f5338d30f8eda62954caf0055550ad60190e814d046576079a5a09ae5a012102b8e907605a71822e18e57a212ee5602edadb8f13e968acc16e0bdb9af1dda6d6ffffffff01d012f876210000001976a9143baf2c65ae0c9171d40b988df1459ebee092224b88ac00000000a1c41d000000000000000000000000"),
hash: transaction::Hash("fda633b7b8967255553cf6c172b12df4cf9d8cbd6270a41c184436c8f5912ec0"),
auth_digest: AuthDigest("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
depends: [],
fee: Amount<zebra_chain::amount::NonNegative>(10000),
sigops: 1,
required: false
},
TransactionTemplate {
data: SerializedTransaction("0400008085202f890179a5cae0221894a7eb9062f1c71056aab3bf4110aaf9c90665460f909b2e287b030000006a473044022064a4623f0d66321d679661d51e63e032e230755f87fa0abadbd07ce34b578ecd02204022f1250494d9df2cb5fc61c4f7637c3442c089d92e766494bc1424266719fa012103bd69095266ca90d7d1d0f6d44d63cd95b23b5b374dde6fba1856165217df35a5ffffffff02bc1311c2000000001976a914eca15bec7e30194da5927474b5614ce11bea4b8d88acc4ec473a010000001976a91437396874ac875d0439b81ab86c19b3ec169ebfcd88ac00000000000000000000000000000000000000"),
hash: transaction::Hash("7f8df2001ad6001ed555ced57137c1567f89efb32f0d286ff2a12830b77e858a"),
auth_digest: AuthDigest("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
depends: [],
fee: Amount<zebra_chain::amount::NonNegative>(2450),
sigops: 2,
required: false
},
TransactionTemplate {
data: SerializedTransaction("0400008085202f89018b8a6ba301107f247cce4bbdb8fc2edbdcf606f2c4e5e8dce17aaf0c1c0bde06000000006b483045022100c092523b1d98a99e520333542eebcdfc09b9c2a5a49c8ae4df99a86aa7028e7d0220150ec3e2cb74daea6a72a0b5ff5204c517f7f9a45929bb7e9cf0682bcfaea673012102f1be916ca8106bbe43d7322593a96986c46354653d3d2802621abacbf0cfcb9effffffff018066ee38330000001976a9143baf2c65ae0c9171d40b988df1459ebee092224b88ac00000000a1c41d000000000000000000000000"),
hash: transaction::Hash("f628f7772961a01bde7bf55b05eac6f90c369cad8264244bf3b78227db168891"),
auth_digest: AuthDigest("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
depends: [],
fee: Amount<zebra_chain::amount::NonNegative>(10000),
sigops: 1,
required: false
},
TransactionTemplate {
data: SerializedTransaction("0400008085202f8901cdfb2aa6a40d4d3a423d66ac30e14e874e761ef4eb68dbd0479557e040be56bd300000006b483045022100c97ef88af8e5166acf2579c72c8ef49488c80fb54ce7951b06f9acdece550ffd022074eda311a92b19de12f1d20a94feb59639c7cf9346fd629d6702ab66ab9df3b30121025e29e036ef3af27b1c8869789a9b0b718d9824e7a0f1dfda6066c00bb742ce0dffffffff02ecfd3fed060000001976a914b112094423613d2773a7611a788aa9a03efdbdd988acee9c5234020000001976a91455b7c406698a68cd90c8b063463e3eab6397a2e188ac00000000000000000000000000000000000000"),
hash: transaction::Hash("352bd971ba11e6744d3b57943db5715ab2834d066cad25fe8082ca71b46f8e9f"),
auth_digest: AuthDigest("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
depends: [],
fee: Amount<zebra_chain::amount::NonNegative>(2450),
sigops: 2,
required: false
},
TransactionTemplate {
data: SerializedTransaction("0400008085202f8901edc4a7375e872bb341fb5e0a1bf1120679424bfae5a81d0581d6a0448728c112030000006a47304402205fe687edd593101ab14cde90cea18a0da63162d5851cd39cc61fbef2f4b7ce5e02202b10feaa348f9f799c2de81410ed27852f66da48082fb718fc5701381254fbcb012103be44db5bb4e994c65d5c1dc5a8ff5c2f09ed61b9361431e8c1d38aa5a3dee555ffffffff02358fa818000000001976a91485c779006a83e3c4341d9698e1b9fdbad1f35d6988ac632511c2000000001976a914eca15bec7e30194da5927474b5614ce11bea4b8d88ac00000000000000000000000000000000000000"),
hash: transaction::Hash("32c672adecbbe10f435dd72885869c455cf1203b34a3dd34888b7d7b0807cf7b"),
auth_digest: AuthDigest("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
depends: [],
fee: Amount<zebra_chain::amount::NonNegative>(2450),
sigops: 2,
required: false
},
TransactionTemplate {
data: SerializedTransaction("0400008085202f8905deec68cfc343149c30cfb4f3c4c77d0ffbfe8bb0b93cf7f6c5e8d6b255e1d325010000006b483045022100d0e7579db5611a30a32469919fa15a8b59cba5b552c5270fe816275e6bbed41102200e77ac5729d3aae979a7480a2fb1cbfa72d2269822141ee7f51bc2df1576a0a301210399017b60b8ad52c14bdb7b9e872d475a0cc202566a5500a162e8dba779a58f3effffffffabda17b3222e3500551f335d52929eaff659a2ccfafbe531bf88433ae488e12d0a0000006b483045022100dfaf7946067edb95751ad67fd5fa68985683100a91a44e346602333a421d8727022061265db09478ff98c51d7c83631498543e6bc33de5478909771303c8dec0dccd012103742d07bb91e3b34812807b3a669a3c31834ae030859f0ae024640c6acd348378ffffffff32bf328a32b113193049d637d8e4ff7105b31abc3f98d567ec2e0090334a9ebc4c0000006a47304402202239874372ec931e948b189b478f3148c86fdae63d5f71f0f56292eca589d39f022051208259fc6d0073a35ca8c25bc3b0c024ba5dba8cde348a0d885488ed9d20c00121030a86bed999d69229175331a1d7bd92cfa4b1c5113d7f28157b72b41c859b1cc0ffffffff32e47eb6a20895eda387be5d93fe461b2cab9da5918fdeff947cf39352072dee4a0000006a473044022020183f097b369558d9a3c5505c6c508815b2eaedbe9998b56868b39577ad900e02201043745172a0d3b9f62f2d49fadc2d3b1d9c88ee0a33e5a98e699cd321bf44c501210269ac58782b7494dd231040f71f9e7055167cde6bdfefc5359d62a87f59eb385affffffffc925722c5448bc31292ff25916aa2ed4ed8514c10ca81cc30dff1d6456f19f9c000000006b483045022100c6538ae13389e06c9249e7d0129307231d07500b579b859c422c7ce9a0ad728202202ae28ecdab0956eea57deb9dc70b20d330a1295b6a93499a7eba141b2d457d1d01210399017b60b8ad52c14bdb7b9e872d475a0cc202566a5500a162e8dba779a58f3effffffff010af0ed7f100000001976a9143baf2c65ae0c9171d40b988df1459ebee092224b88ac00000000a1c41d000000000000000000000000"),
hash: transaction::Hash("ebd7dfebb9e6bb2d29fe047c90e35c19d4c5f54a3cf51e6347a2a2f92103e805"),
auth_digest: AuthDigest("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
depends: [],
fee: Amount<zebra_chain::amount::NonNegative>(10000),
sigops: 1,
required: false
},
],
coinbase_txn: TransactionTemplate {
data: SerializedTransaction("0400008085202f89010000000000000000000000000000000000000000000000000000000000000000ffffffff05037ac41d00ffffffff0438c94d010000000017a9142e1fff58b8ec78077b50b7ffa2144267512b32bf876644e70e0000000017a9147d46a730d31f97b1930d3368a967c309bd4d136a8740787d010000000017a914931fec54c1fea86e574462cc32013f5400b8912987286bee000000000017a914d45cb1adffb5215a42720532a076f02c7c778c9087000000007ac41d000000000000000000000000"),
hash: transaction::Hash("875bb7d74ebbf5e03427fae745c1879d51cc5168341e53485b36ce30fa3a2582"),
auth_digest: AuthDigest("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
depends: [],
fee: Amount<zebra_chain::amount::NegativeOrZero>(-37350),
sigops: 0,
required: true
},
long_poll_id: LongPollId {
tip_height: 1950841,
tip_hash_checksum: 844245495,
max_timestamp: 1673902523,
mempool_transaction_count: 10,
mempool_transaction_content_checksum: 2047582634
},
target: ExpandedDifficulty("0000000001754700000000000000000000000000000000000000000000000000"),
min_time: DateTime32 {
timestamp: 1673897124,
calendar: 2023-01-16T19:25:24Z
},
mutable: [
"time",
"transactions",
"prevblock"
],
nonce_range: "00000000ffffffff",
sigop_limit: 20000,
size_limit: 2000000,
cur_time: DateTime32 {
timestamp: 1673897545,
calendar: 2023-01-16T19:32:25Z
},
bits: CompactDifficulty(0x1c017547, Some(ExpandedDifficulty("0000000001754700000000000000000000000000000000000000000000000000"))),
height: 1950842,
max_time: DateTime32 {
timestamp: 1673902523,
calendar: 2023-01-16T20:55:23Z
},
submit_old: None
} Full hex-encoded and serialized block proposal data:
|
f4deb90
to
a295fae
Compare
I made a mistake with yesterday's rebase, and forgot to change the upstream branch. (When you do |
Motivation
We want to make sure that Zebra's
getblocktemplate
can be used to create valid blocks. This script creates a block proposal from agetblocktemplate
response, and sends it tozcashd
for checking.Part of #5803, but we need multiple people to run the script a few times before we can close that ticket.
Depends-On: #5960
Merged dependencies:
Depends-On: #5925
Depends-On: #5953
Depends-On: #5884
Depends-On: #5961
Specifications
Block header:
https://zips.z.cash/protocol/protocol.pdf#blockheader
Block transactions:
https://developer.bitcoin.org/reference/block_chain.html#serialized-blocks
Complex Code or Requirements
This script uses the existing Rust implementation to turn a block template into a block proposal.
Solution
getblocktemplate
Review
This is ready for review, but it is failing due to some bugs in the
getblocktemplate
RPC implementation.Reviewer Checklist
Follow Up Work
Test actual mining on testnet, not just block proposals.