Skip to content

Commit 40825cc

Browse files
authored
Merge pull request #6344 from Jiloc/fix/rpc-return-stacks-canonical-height
fix: RPC endpoint always return stacks canonical height
2 parents 6a2f682 + 72caf0c commit 40825cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+239
-403
lines changed

stackslib/src/chainstate/stacks/db/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,9 @@ const CHAINSTATE_INITIAL_SCHEMA: &[&str] = &[
661661
tx_merkle_root TEXT NOT NULL,
662662
state_index_root TEXT NOT NULL,
663663
microblock_pubkey_hash TEXT NOT NULL,
664-
664+
665665
block_hash TEXT NOT NULL, -- NOTE: this is *not* unique, since two burn chain forks can commit to the same Stacks block.
666-
index_block_hash TEXT UNIQUE NOT NULL, -- NOTE: this is the hash of the block hash and consensus hash of the burn block that selected it,
666+
index_block_hash TEXT UNIQUE NOT NULL, -- NOTE: this is the hash of the block hash and consensus hash of the burn block that selected it,
667667
-- and is guaranteed to be globally unique (across all Stacks forks and across all PoX forks).
668668
-- index_block_hash is the block hash fed into the MARF index.
669669
@@ -698,7 +698,7 @@ const CHAINSTATE_INITIAL_SCHEMA: &[&str] = &[
698698
burnchain_commit_burn INT NOT NULL,
699699
burnchain_sortition_burn INT NOT NULL,
700700
miner INT NOT NULL,
701-
701+
702702
-- internal use
703703
stacks_block_height INTEGER NOT NULL,
704704
index_block_hash TEXT NOT NULL, -- NOTE: can't enforce UNIQUE here, because there will be multiple entries per block
@@ -799,7 +799,7 @@ const CHAINSTATE_SCHEMA_3: &[&str] = &[
799799
-- * one that records the coinbase, anchored tx fee, and confirmed streamed tx fees, and
800800
-- * one that records only the produced streamed tx fees.
801801
-- The latter is determined once this block's stream gets subsequently confirmed.
802-
-- You query this table by passing both the parent and the child block hashes, since both the
802+
-- You query this table by passing both the parent and the child block hashes, since both the
803803
-- parent and child blocks determine the full reward for the parent block.
804804
CREATE TABLE matured_rewards(
805805
address TEXT NOT NULL, -- address of the miner who produced the block
@@ -810,7 +810,7 @@ const CHAINSTATE_SCHEMA_3: &[&str] = &[
810810
tx_fees_streamed_confirmed TEXT NOT NULL,
811811
tx_fees_streamed_produced TEXT NOT NULL,
812812
813-
-- fork identifier
813+
-- fork identifier
814814
child_index_block_hash TEXT NOT NULL,
815815
parent_index_block_hash TEXT NOT NULL,
816816

stackslib/src/net/api/callreadonly.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ use crate::net::http::{
3333
HttpResponsePreamble,
3434
};
3535
use crate::net::httpcore::{
36-
request, HttpPreambleExtensions, HttpRequestContentsExtensions, RPCRequestHandler,
37-
StacksHttpRequest, StacksHttpResponse,
36+
request, HttpRequestContentsExtensions as _, RPCRequestHandler, StacksHttpRequest,
37+
StacksHttpResponse,
3838
};
3939
use crate::net::{Error as NetError, StacksNodeState, TipRequest};
4040

@@ -307,8 +307,7 @@ impl RPCRequestHandler for RPCCallReadOnlyRequestHandler {
307307
}
308308
};
309309

310-
let mut preamble = HttpResponsePreamble::ok_json(&preamble);
311-
preamble.set_canonical_stacks_tip_height(Some(node.canonical_stacks_tip_height()));
310+
let preamble = HttpResponsePreamble::ok_json(&preamble);
312311
let body = HttpResponseContents::try_from_json(&data_resp)?;
313312
Ok((preamble, body))
314313
}

stackslib/src/net/api/fastcallreadonly.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ use crate::net::http::{
3737
HttpResponsePayload, HttpResponsePreamble,
3838
};
3939
use crate::net::httpcore::{
40-
request, HttpPreambleExtensions, HttpRequestContentsExtensions, RPCRequestHandler,
41-
StacksHttpRequest, StacksHttpResponse,
40+
request, HttpRequestContentsExtensions as _, RPCRequestHandler, StacksHttpRequest,
41+
StacksHttpResponse,
4242
};
4343
use crate::net::{Error as NetError, StacksNodeState, TipRequest};
4444

@@ -312,8 +312,7 @@ impl RPCRequestHandler for RPCFastCallReadOnlyRequestHandler {
312312
}
313313
};
314314

315-
let mut preamble = HttpResponsePreamble::ok_json(&preamble);
316-
preamble.set_canonical_stacks_tip_height(Some(node.canonical_stacks_tip_height()));
315+
let preamble = HttpResponsePreamble::ok_json(&preamble);
317316
let body = HttpResponseContents::try_from_json(&data_resp)?;
318317
Ok((preamble, body))
319318
}

stackslib/src/net/api/get_tenures_fork_info.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ impl RPCRequestHandler for GetTenuresForkInfo {
304304
None,
305305
HttpContentType::JSON,
306306
);
307-
308307
Ok((
309308
resp_preamble,
310309
HttpResponseContents::try_from_json(&tenures)?,

stackslib/src/net/api/getaccount.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ use crate::net::http::{
2727
HttpResponse, HttpResponseContents, HttpResponsePayload, HttpResponsePreamble,
2828
};
2929
use crate::net::httpcore::{
30-
HttpPreambleExtensions, HttpRequestContentsExtensions, RPCRequestHandler, StacksHttpRequest,
31-
StacksHttpResponse,
30+
HttpRequestContentsExtensions as _, RPCRequestHandler, StacksHttpRequest, StacksHttpResponse,
3231
};
3332
use crate::net::{Error as NetError, StacksNodeState, TipRequest};
3433

@@ -219,8 +218,7 @@ impl RPCRequestHandler for RPCGetAccountRequestHandler {
219218
.map_err(NetError::from);
220219
};
221220

222-
let mut preamble = HttpResponsePreamble::ok_json(&preamble);
223-
preamble.set_canonical_stacks_tip_height(Some(node.canonical_stacks_tip_height()));
221+
let preamble = HttpResponsePreamble::ok_json(&preamble);
224222
let body = HttpResponseContents::try_from_json(&account)?;
225223
Ok((preamble, body))
226224
}

stackslib/src/net/api/getattachment.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ use crate::net::http::{
2323
parse_json, Error, HttpNotFound, HttpRequest, HttpRequestContents, HttpRequestPreamble,
2424
HttpResponse, HttpResponseContents, HttpResponsePayload, HttpResponsePreamble,
2525
};
26-
use crate::net::httpcore::{
27-
HttpPreambleExtensions, RPCRequestHandler, StacksHttpRequest, StacksHttpResponse,
28-
};
26+
use crate::net::httpcore::{RPCRequestHandler, StacksHttpRequest, StacksHttpResponse};
2927
use crate::net::{Error as NetError, StacksNodeState};
3028

3129
#[derive(Clone)]
@@ -126,8 +124,7 @@ impl RPCRequestHandler for RPCGetAttachmentRequestHandler {
126124
}
127125
};
128126

129-
let mut preamble = HttpResponsePreamble::ok_json(&preamble);
130-
preamble.set_canonical_stacks_tip_height(Some(node.canonical_stacks_tip_height()));
127+
let preamble = HttpResponsePreamble::ok_json(&preamble);
131128
let body = HttpResponseContents::try_from_json(&attachment)?;
132129
Ok((preamble, body))
133130
}

stackslib/src/net/api/getattachmentsinv.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ use crate::net::http::{
2929
HttpRequestPreamble, HttpResponse, HttpResponseContents, HttpResponsePayload,
3030
HttpResponsePreamble,
3131
};
32-
use crate::net::httpcore::{
33-
HttpPreambleExtensions, RPCRequestHandler, StacksHttpRequest, StacksHttpResponse,
34-
};
32+
use crate::net::httpcore::{RPCRequestHandler, StacksHttpRequest, StacksHttpResponse};
3533
use crate::net::{Error as NetError, StacksNodeState};
3634

3735
#[derive(Clone)]
@@ -214,8 +212,7 @@ impl RPCRequestHandler for RPCGetAttachmentsInvRequestHandler {
214212
pages,
215213
};
216214

217-
let mut preamble = HttpResponsePreamble::ok_json(&preamble);
218-
preamble.set_canonical_stacks_tip_height(Some(node.canonical_stacks_tip_height()));
215+
let preamble = HttpResponsePreamble::ok_json(&preamble);
219216
let body = HttpResponseContents::try_from_json(&content)?;
220217
Ok((preamble, body))
221218
}

stackslib/src/net/api/getblock.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ impl RPCRequestHandler for RPCBlocksRequestHandler {
167167
None,
168168
HttpContentType::Bytes,
169169
);
170-
171170
Ok((
172171
resp_preamble,
173172
HttpResponseContents::from_stream(Box::new(stream)),

stackslib/src/net/api/getblock_v3.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ impl RPCRequestHandler for RPCNakamotoBlockRequestHandler {
209209
None,
210210
HttpContentType::Bytes,
211211
);
212-
213212
Ok((
214213
resp_preamble,
215214
HttpResponseContents::from_stream(Box::new(stream)),

stackslib/src/net/api/getblockbyheight.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::net::http::{
2626
HttpResponsePreamble, HttpServerError,
2727
};
2828
use crate::net::httpcore::{
29-
HttpRequestContentsExtensions, RPCRequestHandler, StacksHttpRequest, StacksHttpResponse,
29+
HttpRequestContentsExtensions as _, RPCRequestHandler, StacksHttpRequest, StacksHttpResponse,
3030
};
3131
use crate::net::{Error as NetError, StacksNodeState, TipRequest};
3232

@@ -179,7 +179,6 @@ impl RPCRequestHandler for RPCNakamotoBlockByHeightRequestHandler {
179179
None,
180180
HttpContentType::Bytes,
181181
);
182-
183182
Ok((
184183
resp_preamble,
185184
HttpResponseContents::from_stream(Box::new(stream)),

0 commit comments

Comments
 (0)