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

types migration #2478

Merged
merged 69 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
7ac8ec9
consensus storage migration
imabdulbasit Jan 14, 2025
d58bb1d
fix migrations and commit transaction after batch insert
imabdulbasit Jan 14, 2025
d1dd38e
sqlite migration fixes and fix deserialization errors
imabdulbasit Jan 15, 2025
dbecff3
test
imabdulbasit Jan 15, 2025
27ab511
fs migration
imabdulbasit Jan 20, 2025
471f7ca
fix queries and tests
imabdulbasit Jan 20, 2025
00d48b5
merge main
imabdulbasit Jan 20, 2025
ff3d533
sequencer sqlite lock file
imabdulbasit Jan 20, 2025
c573ea6
fix postgres epoch migration
imabdulbasit Jan 20, 2025
5802184
fix undecided_state2 migration
imabdulbasit Jan 20, 2025
3885e21
bincode deserialize for migrated hashset
imabdulbasit Jan 23, 2025
2d75307
Merge remote-tracking branch 'origin/main' into ab/leaf2-migration
imabdulbasit Feb 6, 2025
0152568
query service leaf2 migration
imabdulbasit Feb 6, 2025
28063b6
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Feb 6, 2025
9b80a9a
fix quorum proposal migration and storage
imabdulbasit Feb 6, 2025
4745aa6
fix fetching
imabdulbasit Feb 6, 2025
a84549d
fix leaf from proposal
imabdulbasit Feb 6, 2025
a6df3db
fix import
imabdulbasit Feb 6, 2025
946cd78
fix test_fetching_providers
imabdulbasit Feb 6, 2025
270bf0b
use TestVersions from hotshot-example-types
imabdulbasit Feb 6, 2025
bc74fd8
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Feb 6, 2025
f0e9b41
fix migration completed check
imabdulbasit Feb 7, 2025
f0f9f49
call v2 methods
imabdulbasit Feb 10, 2025
d8485e2
Merge remote-tracking branch 'origin/main' into ab/leaf2-migration
imabdulbasit Feb 10, 2025
26fbdad
fix VID errors
imabdulbasit Feb 10, 2025
c01b8bf
lint
imabdulbasit Feb 10, 2025
ab4013d
cargo sort
imabdulbasit Feb 10, 2025
3b42047
fix recursion
imabdulbasit Feb 10, 2025
d8d460c
v0 and v1 availability modules
imabdulbasit Feb 10, 2025
e56475f
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Feb 10, 2025
8fe27d1
cargo sort
imabdulbasit Feb 10, 2025
04dbac0
fix tests
imabdulbasit Feb 10, 2025
51adee6
Merge remote-tracking branch 'origin/main' into ab/leaf2-migration
imabdulbasit Feb 17, 2025
a6af030
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Feb 17, 2025
068cf55
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Feb 17, 2025
1b97c3b
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Feb 18, 2025
5324304
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Feb 18, 2025
4a03c95
Merge remote-tracking branch 'origin/main' into ab/leaf2-migration
imabdulbasit Feb 19, 2025
2845634
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Feb 20, 2025
727e751
lockfile
imabdulbasit Feb 20, 2025
ff9ed3a
clippy
imabdulbasit Feb 20, 2025
ab54402
sqlite lockfile
imabdulbasit Feb 20, 2025
67eace0
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Feb 21, 2025
1e8cd5c
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Feb 25, 2025
949a345
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Feb 25, 2025
48bd158
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Feb 26, 2025
9304be5
Merge remote-tracking branch 'origin/main' into ab/leaf2-migration
imabdulbasit Feb 27, 2025
253cd69
fix: vid2 in tests
imabdulbasit Feb 27, 2025
4f8b968
fix tests
imabdulbasit Feb 27, 2025
5db859b
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Feb 27, 2025
9f2eedd
remove field
imabdulbasit Feb 27, 2025
3ba28d1
migrate vid
imabdulbasit Feb 27, 2025
3119958
add logs
imabdulbasit Feb 27, 2025
9f98a6d
more logging
imabdulbasit Feb 27, 2025
0d9e5eb
use vid2 table
imabdulbasit Feb 27, 2025
028b9a9
test for vid migration
imabdulbasit Feb 27, 2025
669f3a1
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Feb 27, 2025
e15b2b8
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Mar 3, 2025
0d272a3
replace from trait impl with a function for leaf2querydata to leaf1qu…
imabdulbasit Mar 4, 2025
82155b5
fix logging
imabdulbasit Mar 4, 2025
0ea3d2b
address comments
imabdulbasit Mar 4, 2025
8a905ee
use info logging level for progress
imabdulbasit Mar 4, 2025
cab7823
increase batch size to 10k
imabdulbasit Mar 4, 2025
f44543c
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Mar 4, 2025
bf369d1
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Mar 5, 2025
c98401b
merge main
imabdulbasit Mar 6, 2025
21116a1
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Mar 6, 2025
e428d77
Merge branch 'main' into ab/leaf2-migration
imabdulbasit Mar 6, 2025
e537b5a
Trigger Build
imabdulbasit Mar 6, 2025
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
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ libp2p-swarm-derive = { version = "0.35" }
typenum = "1"
cbor4ii = { version = "1.0", features = ["serde1"] }
serde_bytes = { version = "0.11" }
semver = "1"
num_cpus = "1"
dashmap = "6"
memoize = { version = "0.4", features = ["full"] }
Expand Down
6 changes: 2 additions & 4 deletions hotshot-builder-core-refactored/src/testing/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use hotshot_example_types::state_types::{TestInstanceState, TestValidatedState};
use hotshot_types::data::VidCommitment;
use hotshot_types::data::{Leaf2, QuorumProposal2, QuorumProposalWrapper, ViewNumber};
use hotshot_types::event::LeafInfo;
use hotshot_types::simple_certificate::QuorumCertificate;
use hotshot_types::simple_certificate::QuorumCertificate2;
use hotshot_types::traits::block_contents::BlockHeader;
use hotshot_types::traits::node_implementation::{ConsensusTime, NodeType};
use hotshot_types::utils::BuilderCommitment;
Expand Down Expand Up @@ -186,9 +186,7 @@ async fn test_pruning() {
// everything else is boilerplate.

let mock_qc =
QuorumCertificate::genesis::<TestVersions>(&Default::default(), &Default::default())
.await
.to_qc2();
QuorumCertificate2::genesis::<TestVersions>(&Default::default(), &Default::default()).await;
let leaf = Leaf2::from_quorum_proposal(&QuorumProposalWrapper {
proposal: QuorumProposal2 {
block_header: <TestBlockHeader as BlockHeader<TestTypes>>::genesis(
Expand Down
17 changes: 7 additions & 10 deletions hotshot-builder-core/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1552,12 +1552,12 @@ mod test {
use hotshot_types::data::EpochNumber;
use hotshot_types::data::Leaf2;
use hotshot_types::data::{QuorumProposal2, QuorumProposalWrapper};
use hotshot_types::simple_certificate::QuorumCertificate2;
use hotshot_types::traits::block_contents::Transaction;
use hotshot_types::traits::node_implementation::Versions;
use hotshot_types::{
data::{vid_commitment, Leaf, ViewNumber},
message::Proposal,
simple_certificate::QuorumCertificate,
traits::{node_implementation::ConsensusTime, signature_key::BuilderSignatureKey},
utils::BuilderCommitment,
};
Expand Down Expand Up @@ -4099,12 +4099,11 @@ mod test {
proposal: QuorumProposal2::<TestTypes> {
block_header: leaf.block_header().clone(),
view_number,
justify_qc: QuorumCertificate::genesis::<TestVersions>(
justify_qc: QuorumCertificate2::genesis::<TestVersions>(
&TestValidatedState::default(),
&TestInstanceState::default(),
)
.await
.to_qc2(),
.await,
upgrade_certificate: None,
view_change_evidence: None,
next_epoch_justify_qc: None,
Expand Down Expand Up @@ -4175,12 +4174,11 @@ mod test {
proposal: QuorumProposal2::<TestTypes> {
block_header: leaf.block_header().clone(),
view_number,
justify_qc: QuorumCertificate::genesis::<TestVersions>(
justify_qc: QuorumCertificate2::genesis::<TestVersions>(
&TestValidatedState::default(),
&TestInstanceState::default(),
)
.await
.to_qc2(),
.await,
upgrade_certificate: None,
view_change_evidence: None,
next_epoch_justify_qc: None,
Expand Down Expand Up @@ -4242,12 +4240,11 @@ mod test {
proposal: QuorumProposal2::<TestTypes> {
block_header: leaf.block_header().clone(),
view_number,
justify_qc: QuorumCertificate::genesis::<TestVersions>(
justify_qc: QuorumCertificate2::genesis::<TestVersions>(
&TestValidatedState::default(),
&TestInstanceState::default(),
)
.await
.to_qc2(),
.await,
upgrade_certificate: None,
view_change_evidence: None,
next_epoch_justify_qc: None,
Expand Down
7 changes: 3 additions & 4 deletions hotshot-builder-core/src/testing/basic_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub use hotshot_types::{
data::{EpochNumber, Leaf, ViewNumber},
message::Proposal,
signature_key::BLSPubKey,
simple_certificate::{QuorumCertificate, SimpleCertificate, SuccessThreshold},
simple_certificate::{QuorumCertificate2, SimpleCertificate, SuccessThreshold},
traits::{
block_contents::BlockPayload,
node_implementation::{ConsensusTime, NodeType},
Expand Down Expand Up @@ -172,12 +172,11 @@ mod tests {
let mut previous_commitment = initial_commitment;
let mut previous_view = ViewNumber::new(0);
let mut previous_quorum_proposal = {
let previous_jc = QuorumCertificate::<TestTypes>::genesis::<TestVersions>(
let previous_jc = QuorumCertificate2::<TestTypes>::genesis::<TestVersions>(
&TestValidatedState::default(),
&TestInstanceState::default(),
)
.await
.to_qc2();
.await;

QuorumProposalWrapper::<TestTypes> {
proposal: QuorumProposal2::<TestTypes> {
Expand Down
7 changes: 3 additions & 4 deletions hotshot-builder-core/src/testing/finalization_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ use hotshot_example_types::{
node_types::{TestTypes, TestVersions},
state_types::{TestInstanceState, TestValidatedState},
};
use hotshot_types::simple_certificate::QuorumCertificate2;
use hotshot_types::{
data::{vid_commitment, DaProposal2, QuorumProposal2, QuorumProposalWrapper, ViewNumber},
message::Proposal,
simple_certificate::QuorumCertificate,
traits::{
block_contents::BlockHeader,
node_implementation::{ConsensusTime, Versions},
Expand Down Expand Up @@ -332,12 +332,11 @@ async fn progress_round_with_transactions(
proposal: QuorumProposal2::<TestTypes> {
block_header,
view_number: next_view,
justify_qc: QuorumCertificate::<TestTypes>::genesis::<TestVersions>(
justify_qc: QuorumCertificate2::<TestTypes>::genesis::<TestVersions>(
&TestValidatedState::default(),
&TestInstanceState::default(),
)
.await
.to_qc2(),
.await,
upgrade_certificate: None,
view_change_evidence: None,
next_epoch_justify_qc: None,
Expand Down
15 changes: 8 additions & 7 deletions hotshot-builder-core/src/testing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use hotshot_types::{
vid_commitment, DaProposal2, Leaf2, QuorumProposal2, QuorumProposalWrapper, ViewNumber,
},
message::Proposal,
simple_certificate::{QuorumCertificate, SimpleCertificate, SuccessThreshold},
simple_certificate::{QuorumCertificate2, SimpleCertificate, SuccessThreshold},
simple_vote::QuorumData2,
traits::{
node_implementation::{ConsensusTime, Versions},
Expand Down Expand Up @@ -186,12 +186,13 @@ pub async fn calc_proposal_msg<V: Versions>(
};

let justify_qc = match prev_quorum_proposal.as_ref() {
None => QuorumCertificate::<TestTypes>::genesis::<TestVersions>(
&TestValidatedState::default(),
&TestInstanceState::default(),
)
.await
.to_qc2(),
None => {
QuorumCertificate2::<TestTypes>::genesis::<TestVersions>(
&TestValidatedState::default(),
&TestInstanceState::default(),
)
.await
}
Some(prev_proposal) => {
let prev_justify_qc = prev_proposal.justify_qc();
let quorum_data = QuorumData2::<TestTypes> {
Expand Down
10 changes: 2 additions & 8 deletions hotshot-example-types/src/storage_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use hotshot_types::{
QuorumProposalWrapper, VidCommitment,
},
event::HotShotAction,
message::Proposal,
message::{convert_proposal, Proposal},
simple_certificate::{NextEpochQuorumCertificate2, QuorumCertificate2, UpgradeCertificate},
traits::{
node_implementation::{ConsensusTime, NodeType},
Expand Down Expand Up @@ -362,13 +362,7 @@ impl<TYPES: NodeType> Storage<TYPES> for TestStorage<TYPES> {
Ok(())
}

async fn migrate_consensus(
&self,
_convert_leaf: fn(Leaf<TYPES>) -> Leaf2<TYPES>,
convert_proposal: fn(
Proposal<TYPES, QuorumProposal<TYPES>>,
) -> Proposal<TYPES, QuorumProposal2<TYPES>>,
) -> Result<()> {
async fn migrate_consensus(&self) -> Result<()> {
let mut storage_writer = self.inner.write().await;

for (view, proposal) in storage_writer.proposals.clone().iter() {
Expand Down
1 change: 1 addition & 0 deletions hotshot-query-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ jf-vid = { version = "0.1.0", git = "https://github.com/EspressoSystems/jellyfis
] }
lazy_static = "1"
prometheus = "0.13"
semver = { workspace = true }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
snafu = "0.8"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CREATE TABLE leaf2
(
height BIGINT PRIMARY KEY REFERENCES header (height) ON DELETE CASCADE,
hash VARCHAR NOT NULL UNIQUE,
block_hash VARCHAR NOT NULL REFERENCES header (hash) ON DELETE CASCADE,
leaf JSONB NOT NULL,
qc JSONB NOT NULL
);

CREATE TABLE types_migration (
id SERIAL PRIMARY KEY,
completed bool NOT NULL DEFAULT false
);

INSERT INTO types_migration ("completed") VALUES (false);


CREATE TABLE vid2
(
height BIGINT PRIMARY KEY REFERENCES header (height) ON DELETE CASCADE,
common BYTEA NOT NULL,
share BYTEA
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CREATE TABLE leaf2
(
height BIGINT PRIMARY KEY REFERENCES header (height) ON DELETE CASCADE,
hash VARCHAR NOT NULL UNIQUE,
block_hash VARCHAR NOT NULL REFERENCES header (hash) ON DELETE CASCADE,
leaf JSONB NOT NULL,
qc JSONB NOT NULL
);

CREATE TABLE types_migration (
id INTEGER PRIMARY KEY AUTOINCREMENT,
completed bool NOT NULL DEFAULT false
);

INSERT INTO types_migration ("completed") VALUES (false);

CREATE TABLE vid2
(
height BIGINT PRIMARY KEY REFERENCES header (height) ON DELETE CASCADE,
common BYTEA NOT NULL,
share BYTEA
);
Loading
Loading