-
Notifications
You must be signed in to change notification settings - Fork 5
ChainStore module #138
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
Open
SupernaviX
wants to merge
42
commits into
main
Choose a base branch
from
sg/chain-store
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
ChainStore module #138
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
750ff58
feat: first pass at a chain store
SupernaviX 49d0888
feat: wire block queries up to API
SupernaviX 3bacc44
feat: store block cbor
SupernaviX ce3a99b
feat: add BlockInfo fields
SupernaviX f895149
feat: populate remaining BlockInfo fields
SupernaviX 62cba55
feat: support getting blocks by epoch+slot
SupernaviX 704ad6a
feat: support getting next and previous blocks
SupernaviX 1e9f1a1
feat: return transactions and transactions cbor
SupernaviX 2c21d6b
feat: accept hash or number in state query
SupernaviX f0183fe
Add blocks/latest blockfrost REST endpoint
alexwoods 642e0fa
Implement some serialization for BlockInfo
alexwoods 89ae89b
Add more handlers for blocks endpoints
alexwoods 07866db
Add blocks endpoints for txs and txs/cbor
alexwoods dcae45d
Add blocks next and previous endpoints for blockfrost
alexwoods 3fddbd7
Standardise some blocks handler function names
alexwoods d161cc5
Merge branch 'main' into sg/chain-store
alexwoods f307dfe
Correct placement of use for tests
alexwoods 92cc028
cargo fmt of uses
alexwoods 8c8d23d
Add paging to blocks /next and /previous endpoints
alexwoods 651fc55
Correct function parameters for previous
alexwoods b228345
Add missing paging parameters to queries (still need implementing)
alexwoods c35850f
Apply paging and ordering to /txs and /txs/cbor endpoints
alexwoods 7ccbb9f
Add /blocks/{hash_or_number}/addresses endpoint
alexwoods e542e38
Merge remote-tracking branch 'origin/main' into sg/chain-store
alexwoods 60ada5d
Add delegates to protocol params
alexwoods 61a3464
Merge remote-tracking branch 'origin/main' into sg/chain-store
alexwoods eb5942c
Add serde serialisation hints to fix Shelley params read/write
alexwoods 5120ce7
cargo fmt cleanup
alexwoods e50bd8c
Correct matching of byron and shelley genesis slot issuers
alexwoods e1c5d24
Add clear-on-start option to chain store module
alexwoods 368f201
Create a type for VRFKey
alexwoods 575d094
Add lookups for block hashes and tx hashes
alexwoods c29152d
Merge remote-tracking branch 'origin/main' into sg/chain-store
alexwoods b24bd0f
Restore setting
alexwoods 1e6c620
Move codec lib to top
alexwoods 8daf1d8
Use crypto::keyhash_244 instead of cryptoxide
alexwoods cec7395
Make import of GenesisDelegate consistent with other types imports
alexwoods 251fd26
Add comments for params message reading
alexwoods ab113f2
Get block number from key if possible
alexwoods 80d42ce
Tidy up redundant code
alexwoods 70005d5
Add unit test for get_blocks_by_number_range
alexwoods 4c89113
Add a helper function for REST queries
alexwoods File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "acropolis_codec" | ||
version = "0.1.0" | ||
edition = "2024" | ||
|
||
[dependencies] | ||
acropolis_common = { path = "../common" } | ||
|
||
anyhow = { workspace = true } | ||
pallas = { workspace = true } | ||
pallas-primitives = { workspace = true } | ||
pallas-traverse = { workspace = true } | ||
tracing = { workspace = true } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use acropolis_common::{ | ||
GenesisDelegate, HeavyDelegate, crypto::keyhash_224, queries::blocks::BlockIssuer, | ||
}; | ||
use pallas_primitives::byron::BlockSig::DlgSig; | ||
use pallas_traverse::MultiEraHeader; | ||
use std::collections::HashMap; | ||
|
||
pub fn map_to_block_issuer( | ||
header: &MultiEraHeader, | ||
byron_heavy_delegates: &HashMap<Vec<u8>, HeavyDelegate>, | ||
shelley_genesis_delegates: &HashMap<Vec<u8>, GenesisDelegate>, | ||
) -> Option<BlockIssuer> { | ||
match header.issuer_vkey() { | ||
Some(vkey) => match header { | ||
MultiEraHeader::ShelleyCompatible(_) => { | ||
let digest = keyhash_224(vkey); | ||
if let Some(issuer) = shelley_genesis_delegates | ||
.values() | ||
.find(|v| v.delegate == digest) | ||
.map(|i| BlockIssuer::GenesisDelegate(i.clone())) | ||
{ | ||
Some(issuer) | ||
} else { | ||
Some(BlockIssuer::SPO(vkey.to_vec())) | ||
} | ||
} | ||
_ => Some(BlockIssuer::SPO(vkey.to_vec())), | ||
}, | ||
None => match header { | ||
MultiEraHeader::Byron(_) => match header.as_byron() { | ||
Some(block_head) => match &block_head.consensus_data.3 { | ||
DlgSig(sig) => byron_heavy_delegates | ||
.values() | ||
.find(|v| v.issuer_pk == *sig.0.issuer) | ||
.map(|i| BlockIssuer::HeavyDelegate(i.clone())), | ||
_ => None, | ||
}, | ||
None => None, | ||
}, | ||
_ => None, | ||
}, | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod block; | ||
pub mod map_parameters; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only just noticed these were already workspace dependencies on Pallas... Can we avoid this? I was hoping if we didn't expose Pallas in any common/ interfaces we could protect modules from this dependency unless they absolutely need it.