Skip to content
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

[feat] Using scarb get_block to generate test blocks #52

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/data/block_filter.jq
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def txin_coinbase:
previous_output: OutPoint {
txid: 0_u256,
vout: 0xffffffff_u32,
txo_index: 0, // TODO: implement
Copy link
Collaborator

Choose a reason for hiding this comment

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

The point of the comment was to make it clear that it is not fully implemented.

txo_index: 0,
},
}"
;
Expand All @@ -17,7 +17,7 @@ def txin_regular:
previous_output: OutPoint {
txid: 0x\(.txid),
vout: \(.vout),
txo_index: 0, // TODO: implement
txo_index: 0,
},
}"
;
Expand Down
4 changes: 2 additions & 2 deletions scripts/data/get_block.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ curl \
-H 'content-type: text/plain;' $BITCOIN_RPC \
| jq -r -f scripts/data/block_filter.jq > tests/blocks/block_${HEIGHT}.cairo

validate_target, validate_timestamp, validate_proof_of_work, compute_block_reward,
compute_total_work,
# validate_target, validate_timestamp, validate_proof_of_work, compute_block_reward,
# compute_total_work,
1 change: 0 additions & 1 deletion src/state.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ pub struct TxIn {
pub witness: Span<ByteArray>,
}


/// A reference to a transaction output.
#[derive(Drop, Copy)]
pub struct OutPoint {
Expand Down
1 change: 0 additions & 1 deletion src/utils.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use core::sha256::{compute_sha256_byte_array, compute_sha256_u32_array};
use core::num::traits::{Zero, One, BitSize};
use core::starknet::secp256_trait::Secp256PointTrait;

pub fn shl<
T,
Expand Down
4 changes: 3 additions & 1 deletion tests/blocks/block_0.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use super::state::{Block, Header, Transaction, OutPoint, TxIn, TxOut};

// genesis block

pub fn block_0() -> Block {
// block hash: 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
Block {
Expand All @@ -15,7 +17,7 @@ pub fn block_0() -> Block {
),
sequence: 4294967295,
previous_output: OutPoint {
txid: 0_u256, vout: 0xffffffff_u32, txo_index: 0, // TODO: implement
txid: 0_u256, vout: 0xffffffff_u32, txo_index: 0,
},
}
]
Expand Down
6 changes: 4 additions & 2 deletions tests/blocks/block_170.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use super::state::{Block, Header, Transaction, OutPoint, TxIn, TxOut};

// block containing first P2P tx to Hal Finney
TAdev0 marked this conversation as resolved.
Show resolved Hide resolved

pub fn block_170() -> Block {
// block hash: 00000000d1145790a8694403d4063f323d499e655c83426834d4ce2f8dd4a2ee
Block {
Expand All @@ -13,7 +15,7 @@ pub fn block_170() -> Block {
script: from_base16("04ffff001d0102"),
sequence: 4294967295,
previous_output: OutPoint {
txid: 0_u256, vout: 0xffffffff_u32, txo_index: 0, // TODO: implement
txid: 0_u256, vout: 0xffffffff_u32, txo_index: 0,
},
}
]
Expand Down Expand Up @@ -41,7 +43,7 @@ pub fn block_170() -> Block {
previous_output: OutPoint {
txid: 0x0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9,
vout: 0,
txo_index: 0, // TODO: implement
txo_index: 0,
},
}
]
Expand Down
Loading