Skip to content

Commit 1e628f7

Browse files
committed
removed getblockbyhash
1 parent ce533e0 commit 1e628f7

File tree

5 files changed

+5
-152
lines changed

5 files changed

+5
-152
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
1414
- Add `block_commit_delay_ms` to the config file to control the time to wait after seeing a new burn block, before submitting a block commit, to allow time for the first Nakamoto block of the new tenure to be mined, allowing this miner to avoid the need to RBF the block commit.
1515
- Add `tenure_cost_limit_per_block_percentage` to the miner config file to control the percentage remaining tenure cost limit to consume per nakamoto block.
1616
- Add `/v3/blockbyhash` and `/v3/blockbyheight` rpc endpoints
17+
- Add `/v3/blocks/height/:block_height` rpc endpoint
1718

1819
## [3.0.0.0.1]
1920

docs/rpc-endpoints.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -503,20 +503,16 @@ data.
503503

504504
This will return 404 if the block does not exist.
505505

506-
### GET /v3/blockbyhash/[Block Hash]
507-
508-
Fetch a Nakamoto block given its block hash. This returns the raw block
509-
data.
510-
511-
This will return 404 if the block does not exist.
512-
513-
### GET /v3/blockbyheight/[Block Height]
506+
### GET /v3/blocks/height/[Block Height]
514507

515508
Fetch a Nakamoto block given its block height. This returns the raw block
516509
data.
517510

518511
This will return 404 if the block does not exist.
519512

513+
This endpoint also accepts a querystring parameter `?tip=` which when supplied will return the
514+
block relative to the specified tip.
515+
520516
### GET /v3/tenures/[Block ID]
521517

522518
Fetch a Nakamoto block and all of its ancestors in the same tenure, given its

stackslib/src/chainstate/nakamoto/staging_blocks.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -302,25 +302,6 @@ impl<'a> NakamotoStagingBlocksConnRef<'a> {
302302
.optional()?)
303303
}
304304

305-
/// Get the block ID of a staging block from block hash.
306-
/// Used for downloads
307-
pub fn get_block_id_by_block_hash(
308-
&self,
309-
block_hash: &BlockHeaderHash,
310-
) -> Result<Option<StacksBlockId>, ChainstateError> {
311-
let sql = "SELECT index_block_hash FROM nakamoto_staging_blocks WHERE block_hash = ?1";
312-
let args = params![block_hash];
313-
314-
let mut stmt = self.deref().prepare(sql)?;
315-
Ok(stmt
316-
.query_row(args, |row| {
317-
let block_id: StacksBlockId = row.get(0)?;
318-
319-
Ok(block_id)
320-
})
321-
.optional()?)
322-
}
323-
324305
/// Get a Nakamoto block by index block hash, as well as its size.
325306
/// Verifies its integrity.
326307
/// Returns Ok(Some(block, size)) if the block was present

stackslib/src/net/api/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ pub mod getattachment;
4242
pub mod getattachmentsinv;
4343
pub mod getblock;
4444
pub mod getblock_v3;
45-
pub mod getblockbyhash;
4645
pub mod getblockbyheight;
4746
pub mod getconstantval;
4847
pub mod getcontractabi;
@@ -94,7 +93,6 @@ impl StacksHttp {
9493
self.register_rpc_endpoint(getattachmentsinv::RPCGetAttachmentsInvRequestHandler::new());
9594
self.register_rpc_endpoint(getblock::RPCBlocksRequestHandler::new());
9695
self.register_rpc_endpoint(getblock_v3::RPCNakamotoBlockRequestHandler::new());
97-
self.register_rpc_endpoint(getblockbyhash::RPCNakamotoBlockByHashRequestHandler::new());
9896
self.register_rpc_endpoint(getblockbyheight::RPCNakamotoBlockByHeightRequestHandler::new());
9997
self.register_rpc_endpoint(getconstantval::RPCGetConstantValRequestHandler::new());
10098
self.register_rpc_endpoint(getcontractabi::RPCGetContractAbiRequestHandler::new());

testnet/stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 0 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -9303,129 +9303,6 @@ fn v3_signer_api_endpoint() {
93039303
run_loop_thread.join().unwrap();
93049304
}
93059305

9306-
/// Test `/v3/blockbyhash` API endpoint
9307-
///
9308-
/// This endpoint returns the block blob given a height
9309-
#[test]
9310-
#[ignore]
9311-
fn v3_blockbyhash_api_endpoint() {
9312-
if env::var("BITCOIND_TEST") != Ok("1".into()) {
9313-
return;
9314-
}
9315-
9316-
let (mut conf, _miner_account) = naka_neon_integration_conf(None);
9317-
let password = "12345".to_string();
9318-
conf.connection_options.auth_token = Some(password.clone());
9319-
conf.miner.wait_on_interim_blocks = Duration::from_secs(1);
9320-
let stacker_sk = setup_stacker(&mut conf);
9321-
let signer_sk = Secp256k1PrivateKey::new();
9322-
let signer_addr = tests::to_addr(&signer_sk);
9323-
let sender_sk = Secp256k1PrivateKey::new();
9324-
// setup sender + recipient for some test stx transfers
9325-
// these are necessary for the interim blocks to get mined at all
9326-
let sender_addr = tests::to_addr(&sender_sk);
9327-
let send_amt = 100;
9328-
let send_fee = 180;
9329-
conf.add_initial_balance(
9330-
PrincipalData::from(sender_addr).to_string(),
9331-
send_amt + send_fee,
9332-
);
9333-
conf.add_initial_balance(PrincipalData::from(signer_addr).to_string(), 100000);
9334-
9335-
// only subscribe to the block proposal events
9336-
test_observer::spawn();
9337-
test_observer::register(&mut conf, &[EventKeyType::BlockProposal]);
9338-
9339-
let mut btcd_controller = BitcoinCoreController::new(conf.clone());
9340-
btcd_controller
9341-
.start_bitcoind()
9342-
.expect("Failed starting bitcoind");
9343-
let mut btc_regtest_controller = BitcoinRegtestController::new(conf.clone(), None);
9344-
btc_regtest_controller.bootstrap_chain(201);
9345-
9346-
let mut run_loop = boot_nakamoto::BootRunLoop::new(conf.clone()).unwrap();
9347-
let run_loop_stopper = run_loop.get_termination_switch();
9348-
let Counters {
9349-
blocks_processed,
9350-
naka_submitted_commits: commits_submitted,
9351-
naka_proposed_blocks: proposals_submitted,
9352-
..
9353-
} = run_loop.counters();
9354-
9355-
let coord_channel = run_loop.coordinator_channels();
9356-
9357-
let run_loop_thread = thread::spawn(move || run_loop.start(None, 0));
9358-
let mut signers = TestSigners::new(vec![signer_sk]);
9359-
wait_for_runloop(&blocks_processed);
9360-
boot_to_epoch_3(
9361-
&conf,
9362-
&blocks_processed,
9363-
&[stacker_sk],
9364-
&[signer_sk],
9365-
&mut Some(&mut signers),
9366-
&mut btc_regtest_controller,
9367-
);
9368-
9369-
info!("------------------------- Reached Epoch 3.0 -------------------------");
9370-
9371-
blind_signer(&conf, &signers, proposals_submitted);
9372-
9373-
wait_for_first_naka_block_commit(60, &commits_submitted);
9374-
9375-
// Mine 1 nakamoto tenure
9376-
next_block_and_mine_commit(
9377-
&mut btc_regtest_controller,
9378-
60,
9379-
&coord_channel,
9380-
&commits_submitted,
9381-
)
9382-
.unwrap();
9383-
9384-
let burnchain = conf.get_burnchain();
9385-
let sortdb = burnchain.open_sortition_db(true).unwrap();
9386-
let (chainstate, _) = StacksChainState::open(
9387-
conf.is_mainnet(),
9388-
conf.burnchain.chain_id,
9389-
&conf.get_chainstate_path_str(),
9390-
None,
9391-
)
9392-
.unwrap();
9393-
9394-
info!("------------------------- Setup finished, run test -------------------------");
9395-
9396-
let http_origin = format!("http://{}", &conf.node.rpc_bind);
9397-
9398-
let get_v3_block_by_hash = |block_hash: &str| {
9399-
let url = &format!("{http_origin}/v3/blockbyhash/{block_hash}");
9400-
info!("Send request: GET {url}");
9401-
reqwest::blocking::get(url).unwrap_or_else(|e| panic!("GET request failed: {e}"))
9402-
};
9403-
9404-
let tip = NakamotoChainState::get_canonical_block_header(chainstate.db(), &sortdb)
9405-
.unwrap()
9406-
.unwrap();
9407-
9408-
let block_hash = tip
9409-
.anchored_header
9410-
.as_stacks_nakamoto()
9411-
.unwrap()
9412-
.block_hash()
9413-
.to_string();
9414-
let block_data = get_v3_block_by_hash(&block_hash);
9415-
assert!(block_data.status().is_success());
9416-
assert!(block_data.bytes().unwrap().len() > 0);
9417-
9418-
info!("------------------------- Test finished, clean up -------------------------");
9419-
9420-
coord_channel
9421-
.lock()
9422-
.expect("Mutex poisoned")
9423-
.stop_chains_coordinator();
9424-
run_loop_stopper.store(false, Ordering::SeqCst);
9425-
9426-
run_loop_thread.join().unwrap();
9427-
}
9428-
94299306
/// Test `/v3/blocks/height` API endpoint
94309307
///
94319308
/// This endpoint returns the block blob given a height

0 commit comments

Comments
 (0)