Skip to content

Commit 2dd35d7

Browse files
authored
Npg 3274 explorer tx initial fragment # revised (#4106)
* fix merge conflict issues * ci fix * ci fix
1 parent 5d7f312 commit 2dd35d7

File tree

12 files changed

+181
-47
lines changed

12 files changed

+181
-47
lines changed

explorer/src/api/graphql/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,18 @@ impl Transaction {
855855
Ok(blocks.iter().map(|b| Block::from(Arc::clone(b))).collect())
856856
}
857857

858+
/// Initial bootstrap config params (initial fragments), only present in Block0
859+
pub async fn initial_configuration_params(
860+
&self,
861+
context: &Context<'_>,
862+
) -> FieldResult<Option<config_param::ConfigParams>> {
863+
let transaction = self.get_contents(context).await?;
864+
match transaction.config_params {
865+
Some(params) => Ok(Some(config_param::ConfigParams::from(&params))),
866+
None => Ok(None),
867+
}
868+
}
869+
858870
pub async fn inputs(&self, context: &Context<'_>) -> FieldResult<Vec<TransactionInput>> {
859871
let transaction = self.get_contents(context).await?;
860872
Ok(transaction

explorer/src/db/indexing.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use chain_impl_mockchain::{
88
certificate::{
99
Certificate, ExternalProposalId, PoolId, PoolRegistration, PoolRetirement, VotePlanId,
1010
},
11-
fragment::{Fragment, FragmentId},
11+
fragment::{ConfigParams, Fragment, FragmentId},
1212
header::{BlockDate, ChainLength, Epoch, HeaderId as HeaderHash},
1313
key::BftLeaderId,
1414
transaction::{InputEnum, TransactionSlice, Witness},
@@ -70,6 +70,7 @@ pub struct ExplorerTransaction {
7070
pub outputs: Vec<ExplorerOutput>,
7171
pub certificate: Option<Certificate>,
7272
pub offset_in_block: u32,
73+
pub config_params: Option<ConfigParams>,
7374
}
7475

7576
/// Unified Input representation for utxo and account inputs as used in the graphql API
@@ -161,6 +162,14 @@ impl ExplorerBlock {
161162
let fragment_id = fragment.id();
162163
let offset: u32 = offset.try_into().unwrap();
163164
let metx = match fragment {
165+
Fragment::Initial(config) => Some(ExplorerTransaction {
166+
id: fragment_id,
167+
inputs: vec![],
168+
outputs: vec![],
169+
certificate: None,
170+
offset_in_block: offset,
171+
config_params: Some(config.clone()),
172+
}),
164173
Fragment::Transaction(tx) => {
165174
let tx = tx.as_slice();
166175
Some(ExplorerTransaction::from(
@@ -277,6 +286,7 @@ impl ExplorerBlock {
277286
outputs,
278287
certificate: None,
279288
offset_in_block: offset,
289+
config_params: None,
280290
})
281291
}
282292
_ => None,
@@ -429,6 +439,7 @@ impl ExplorerTransaction {
429439
outputs: new_outputs,
430440
certificate,
431441
offset_in_block,
442+
config_params: None,
432443
}
433444
}
434445

explorer/src/settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const DEFAULT_LOG_SETTINGS_ENTRY: LogSettingsEntry = LogSettingsEntry {
1818
};
1919

2020
const DEFAULT_QUERY_DEPTH_LIMIT: usize = 15;
21-
const DEFAULT_QUERY_COMPLEXITY_LIMIT: usize = 40;
21+
const DEFAULT_QUERY_COMPLEXITY_LIMIT: usize = 100;
2222

2323
lazy_static! {
2424
pub static ref LOG_FILTER_LEVEL_POSSIBLE_VALUES: Vec<&'static str> = {

explorer/src/tests.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,23 @@ pub fn get_valid_block(explorer: &Explorer, genesis_block: Hash) {
6767
assert_eq!(block_id, genesis_block.to_string());
6868
}
6969

70+
pub fn verify_config_params_present(explorer: &Explorer, jormungandr: JormungandrProcess) {
71+
let binding = jormungandr.block0_configuration().to_block();
72+
73+
// first fragment txs should contain config params
74+
let block0fragment = binding.fragments().next().unwrap();
75+
76+
let params = explorer
77+
.transaction(Hash::from_str(&block0fragment.hash().to_string()).unwrap())
78+
.unwrap()
79+
.data
80+
.unwrap()
81+
.transaction
82+
.initial_configuration_params;
83+
84+
assert!(params.is_some());
85+
}
86+
7087
#[test]
7188
pub fn explorer_tests() {
7289
let config = ExplorerTestConfig::default();
@@ -75,4 +92,5 @@ pub fn explorer_tests() {
7592

7693
get_invalid_block(explorer.client());
7794
get_valid_block(explorer.client(), jormungandr.genesis_block_hash());
95+
verify_config_params_present(explorer.client(), jormungandr);
7896
}

testing/jormungandr-automation/resources/explorer/graphql/schema.graphql

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ type BlockConnection {
4444
pageInfo: PageInfo!
4545

4646
"""A list of edges."""
47-
edges: [BlockEdge]
47+
edges: [BlockEdge!]!
48+
49+
"""A list of nodes."""
50+
nodes: [Block!]!
4851
totalCount: Int!
4952
}
5053

@@ -60,11 +63,11 @@ type BlockDate {
6063

6164
"""An edge in a connection."""
6265
type BlockEdge {
63-
"""The item at the end of the edge"""
64-
node: Block!
65-
6666
"""A cursor for use in pagination"""
6767
cursor: String!
68+
69+
"""The item at the end of the edge"""
70+
node: Block!
6871
}
6972

7073
type Branch {
@@ -222,17 +225,20 @@ type PoolConnection {
222225
pageInfo: PageInfo!
223226

224227
"""A list of edges."""
225-
edges: [PoolEdge]
228+
edges: [PoolEdge!]!
229+
230+
"""A list of nodes."""
231+
nodes: [Pool!]!
226232
totalCount: Int!
227233
}
228234

229235
"""An edge in a connection."""
230236
type PoolEdge {
231-
"""The item at the end of the edge"""
232-
node: Pool!
233-
234237
"""A cursor for use in pagination"""
235238
cursor: String!
239+
240+
"""The item at the end of the edge"""
241+
node: Pool!
236242
}
237243

238244
scalar PoolId
@@ -283,7 +289,6 @@ type Proposal {
283289

284290
"""
285291
get the vote options range
286-
287292
this is the available range of choices to make for the given
288293
proposal. all casted votes for this proposals ought to be in
289294
within the given range
@@ -409,6 +414,11 @@ type Transaction {
409414

410415
"""All the blocks this transaction is included in"""
411416
blocks: [Block!]!
417+
418+
"""
419+
Initial bootstrap config params (initial fragments), only present in Block0
420+
"""
421+
initialConfigurationParams: ConfigParams
412422
inputs: [TransactionInput!]!
413423
outputs: [TransactionOutput!]!
414424
certificate: Certificate
@@ -419,17 +429,20 @@ type TransactionConnection {
419429
pageInfo: PageInfo!
420430

421431
"""A list of edges."""
422-
edges: [TransactionEdge]
432+
edges: [TransactionEdge!]!
433+
434+
"""A list of nodes."""
435+
nodes: [Transaction!]!
423436
totalCount: Int!
424437
}
425438

426439
"""An edge in a connection."""
427440
type TransactionEdge {
428-
"""The item at the end of the edge"""
429-
node: Transaction!
430-
431441
"""A cursor for use in pagination"""
432442
cursor: String!
443+
444+
"""The item at the end of the edge"""
445+
node: Transaction!
433446
}
434447

435448
type TransactionInput {
@@ -534,17 +547,20 @@ type VotePlanStatusConnection {
534547
pageInfo: PageInfo!
535548

536549
"""A list of edges."""
537-
edges: [VotePlanStatusEdge]
550+
edges: [VotePlanStatusEdge!]!
551+
552+
"""A list of nodes."""
553+
nodes: [VotePlanStatus!]!
538554
totalCount: Int!
539555
}
540556

541557
"""An edge in a connection."""
542558
type VotePlanStatusEdge {
543-
"""The item at the end of the edge"""
544-
node: VotePlanStatus!
545-
546559
"""A cursor for use in pagination"""
547560
cursor: String!
561+
562+
"""The item at the end of the edge"""
563+
node: VotePlanStatus!
548564
}
549565

550566
type VoteProposalStatus {
@@ -564,17 +580,20 @@ type VoteStatusConnection {
564580
pageInfo: PageInfo!
565581

566582
"""A list of edges."""
567-
edges: [VoteStatusEdge]
583+
edges: [VoteStatusEdge!]!
584+
585+
"""A list of nodes."""
586+
nodes: [VoteStatus!]!
568587
totalCount: Int!
569588
}
570589

571590
"""An edge in a connection."""
572591
type VoteStatusEdge {
573-
"""The item at the end of the edge"""
574-
node: VoteStatus!
575-
576592
"""A cursor for use in pagination"""
577593
cursor: String!
594+
595+
"""The item at the end of the edge"""
596+
node: VoteStatus!
578597
}
579598

580599
type VoteTally {

testing/jormungandr-automation/resources/explorer/graphql/transaction_by_id.graphql

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
query TransactionById($id: String!){
22
transaction(id: $id) {
33
id
4+
__typename
5+
initialConfigurationParams { configParams {...configParam}}
46
blocks{id date{...blockDate}}
57
inputs{amount address{id}}
68
outputs{amount address{id}}}}
@@ -9,3 +11,83 @@ fragment blockDate on BlockDate{
911
epoch{id}
1012
slot
1113
}
14+
15+
fragment configParam on ConfigParam
16+
{
17+
__typename
18+
... on Block0Date { block0Date }
19+
... on Discrimination { discrimination }
20+
... on ConsensusType { consensusType }
21+
... on SlotsPerEpoch { slotsPerEpoch }
22+
... on SlotDuration { slotDuration}
23+
... on EpochStabilityDepth { epochStabilityDepth }
24+
... on Milli { milli}
25+
... on BlockContentMaxSize { blockContentMaxSize}
26+
... on AddBftLeader { addBftLeader{ id }}
27+
... on RemoveBftLeader { removeBftLeader { id }}
28+
... on LinearFee {
29+
constant
30+
coefficient
31+
certificate
32+
perCertificateFees {
33+
certificatePoolRegistration
34+
certificateStakeDelegation
35+
certificateOwnerStakeDelegation
36+
}
37+
perVoteCertificateFees {
38+
certificateVotePlan
39+
certificateVoteCast
40+
}}
41+
... on ProposalExpiration{ proposalExpiration }
42+
... on KesUpdateSpeed { kesUpdateSpeed}
43+
... on TreasuryAdd { treasuryAdd }
44+
... on TreasuryParams { treasuryParams {
45+
fixed
46+
ratio {
47+
numerator
48+
denominator
49+
}
50+
maxLimit
51+
}}
52+
... on RewardPot { rewardPot }
53+
... on RewardParams { rewardParams {
54+
__typename
55+
... on LinearRewardParams{
56+
constant
57+
ratio {
58+
numerator
59+
denominator
60+
}
61+
epochStart
62+
epochRate
63+
}
64+
... on HalvingRewardParams {
65+
constant
66+
ratio {
67+
numerator
68+
denominator
69+
}
70+
epochStart
71+
epochRate
72+
}
73+
}}
74+
... on PerCertificateFee{
75+
certificatePoolRegistration
76+
certificateStakeDelegation
77+
certificateOwnerStakeDelegation
78+
}
79+
... on FeesInTreasury { feesInTreasury}
80+
... on RewardLimitNone { rewardLimitNone }
81+
... on RewardLimitByAbsoluteStake { rewardLimitByAbsoluteStake {
82+
numerator
83+
denominator
84+
}}
85+
... on PoolRewardParticipationCapping { min max }
86+
... on AddCommitteeId { addCommitteeId}
87+
... on RemoveCommitteeId { removeCommitteeId }
88+
... on PerVoteCertificateFee {
89+
certificateVotePlan
90+
certificateVoteCast
91+
}
92+
... on TransactionMaxExpiryEpochs { transactionMaxExpiryEpochs }
93+
}

testing/jormungandr-automation/src/jormungandr/explorer/verifiers/block_by_id_verifier.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ impl ExplorerVerifier {
109109

110110
if !block.contents().is_empty() {
111111
for fragment in block.fragments() {
112-
for edge in explorer_block.transactions.edges.as_ref().unwrap() {
113-
let explorer_transaction = &edge.as_ref().unwrap().node;
112+
for edge in &explorer_block.transactions.edges {
113+
let explorer_transaction = &edge.node;
114114
if fragment.hash().to_string() == explorer_transaction.id {
115115
matching_fragments_count += 1;
116116
match &explorer_transaction.certificate {

testing/jormungandr-automation/src/jormungandr/explorer/verifiers/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,10 @@ impl ExplorerVerifier {
105105
);
106106
};
107107

108-
assert!(explorer_transactions.edges.is_some());
108+
assert_eq!(fragment_statuses.len(), explorer_transactions.edges.len());
109109

110-
assert_eq!(
111-
fragment_statuses.len(),
112-
explorer_transactions.edges.as_ref().unwrap().len()
113-
);
114-
115-
for edges in explorer_transactions.edges.unwrap().iter() {
116-
let node = &edges.as_ref().unwrap().node;
110+
for edges in explorer_transactions.edges.iter() {
111+
let node = &edges.node;
117112
assert!(fragment_statuses.get(&node.id.to_string()).is_some());
118113
let fragment_status = fragment_statuses.get(&node.id.to_string()).unwrap().1;
119114
assert!(

testing/jormungandr-automation/src/jormungandr/explorer/verifiers/vote_plan_verifier.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,17 @@ impl ExplorerVerifier {
134134
explorer_proposal.votes.total_count as usize
135135
);
136136
if vote_proposal_status.votes_cast == 0 {
137-
assert!(explorer_proposal.votes.edges.unwrap().is_empty());
137+
assert!(explorer_proposal.votes.edges.is_empty());
138138
} else {
139-
let explorer_votes = explorer_proposal.votes.edges.unwrap();
139+
let explorer_votes = explorer_proposal.votes.edges;
140140
assert_eq!(explorer_votes.len(), vote_proposal_status.votes_cast);
141141
let votes = proposal_votes
142142
.get(&vote_proposal_status.proposal_id.to_string())
143143
.unwrap();
144144
for vote in votes {
145145
for explorer_vote in &explorer_votes {
146-
if vote.0.public_key().to_string()
147-
== explorer_vote.as_ref().unwrap().node.address.id
148-
{
149-
match &explorer_vote.as_ref().unwrap().node.payload {
146+
if vote.0.public_key().to_string() == explorer_vote.node.address.id {
147+
match &explorer_vote.node.payload {
150148
VotePayloadPublicStatus(choice) => {
151149
assert_eq!(choice.choice as u8, vote.1.as_byte())
152150
}

0 commit comments

Comments
 (0)