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

NetworkDatabase impl with new ssv_types system #67

Merged
merged 59 commits into from
Jan 9, 2025
Merged
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
1f58607
new types
Zacholme7 Dec 5, 2024
017d287
From for operator conversion from db, operator db functionality & tests
Zacholme7 Dec 5, 2024
07e49b4
all tables added, operator tests fixed, share operations added, clust…
Zacholme7 Dec 5, 2024
c14a2f4
move metadata to cluster, insertion test passing, fix cascade deletio…
Zacholme7 Dec 5, 2024
594bf36
proper error, migrate table to sql file
Zacholme7 Dec 6, 2024
1ac1b16
more testing utils, cluster deletion cascade test passing
Zacholme7 Dec 6, 2024
5bddc0b
potential memory stores
Zacholme7 Dec 6, 2024
ed67bd5
top level SQL statment defs with prepare cached
Zacholme7 Dec 6, 2024
d346977
simplify member insertion
Zacholme7 Dec 6, 2024
01fee71
flesh out some helpers
Zacholme7 Dec 6, 2024
c6da601
Merge branch 'unstable' into clean-newtypes-database
Zacholme7 Dec 6, 2024
debf324
Merge branch 'unstable' into clean-newtypes-database
Zacholme7 Dec 9, 2024
a1ca54e
migrate from rsa to openssl for rsa keys
Zacholme7 Dec 9, 2024
54a19da
migrate and fix tests
Zacholme7 Dec 9, 2024
18af780
state store rebuild mvp
Zacholme7 Dec 11, 2024
c857e1c
Merge branch 'unstable' into clean-newtypes-database
Zacholme7 Dec 11, 2024
1652528
restructure test
Zacholme7 Dec 11, 2024
e99b7ef
refactor entire test utilities, setup generalized testing framework
Zacholme7 Dec 11, 2024
05650ab
removed unused code
Zacholme7 Dec 11, 2024
6a39998
validator tests
Zacholme7 Dec 11, 2024
2c84a52
clippy fix
Zacholme7 Dec 11, 2024
896117e
merge types
Zacholme7 Dec 12, 2024
897a318
database with pubkey
Zacholme7 Dec 12, 2024
daed0c1
validator metadata insertion
Zacholme7 Dec 12, 2024
60438e2
more tests and general functionality
Zacholme7 Dec 12, 2024
32c179a
fix and test block processing
Zacholme7 Dec 12, 2024
05a4c24
additional tests & bugfix on validator generation
Zacholme7 Dec 13, 2024
f8999b6
break up assertions, basic comments
Zacholme7 Dec 13, 2024
9e4f289
migrate to immutable api with fine grained state locking
Zacholme7 Dec 13, 2024
f358ce5
fmt and clippy
Zacholme7 Dec 13, 2024
7a855a0
load in block number even if we have not found id
Zacholme7 Dec 16, 2024
9fd6c5e
merge
Zacholme7 Dec 17, 2024
95731fa
cargo sort
Zacholme7 Dec 17, 2024
de5be8d
mvp multi index map
Zacholme7 Dec 19, 2024
69652e7
type rework
Zacholme7 Dec 19, 2024
487a200
multi index map integration, type rewrite integration, start on test fix
Zacholme7 Dec 19, 2024
90ae6c5
integrate all tests
Zacholme7 Dec 21, 2024
c5d1ff1
fix up testing
Zacholme7 Dec 21, 2024
35a79ec
clusterId to bytes 32
Zacholme7 Dec 21, 2024
aabbcdf
lints
Zacholme7 Dec 21, 2024
a9ac7a5
clippy
Zacholme7 Dec 21, 2024
3ff12ed
make multistate pub
Zacholme7 Dec 21, 2024
c61becd
Merge branch 'unstable' into clean-newtypes-database
Zacholme7 Dec 23, 2024
5635838
re-export and save all metadata and clusters
Zacholme7 Dec 23, 2024
d2648d1
clean getters for multi state
Zacholme7 Dec 23, 2024
e69fb3a
rebuild all clusters and share-metadata information upon restart
Zacholme7 Dec 23, 2024
431d4eb
remove print
Zacholme7 Dec 23, 2024
43b2e71
fix state reconstruction
Zacholme7 Dec 24, 2024
5b653dd
remove print
Zacholme7 Dec 24, 2024
a147516
error msg fix
Zacholme7 Jan 2, 2025
4e77bd0
Merge branch 'unstable' into clean-newtypes-database
Zacholme7 Jan 3, 2025
ebd79ab
merge & update
Zacholme7 Jan 3, 2025
c8eb685
spelling and formatting
Zacholme7 Jan 3, 2025
10f014f
nonce logic
Zacholme7 Jan 6, 2025
1f246e6
nonce insertion fix and tests
Zacholme7 Jan 6, 2025
661c148
spelling
Zacholme7 Jan 7, 2025
5b874cf
Merge branch 'unstable' into clean-newtypes-database
Zacholme7 Jan 8, 2025
e20b00f
Merge branch 'clean-newtypes-database' of github.com:Zacholme7/anchor…
Zacholme7 Jan 8, 2025
5a5c7a1
initial README draft
Zacholme7 Jan 8, 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
Prev Previous commit
Next Next commit
clippy
Zacholme7 committed Dec 21, 2024
commit a9ac7a5df17c12348d07b9e42f33e0df29d8f18e
4 changes: 2 additions & 2 deletions anchor/database/src/cluster_operations.rs
Original file line number Diff line number Diff line change
@@ -111,12 +111,12 @@ impl NetworkDatabase {
.execute(params![validator_pubkey.to_string()])?;

// remove the validators share and its metadata
self.state.multi_state.shares.remove(&validator_pubkey);
self.state.multi_state.shares.remove(validator_pubkey);
let metadata = self
.state
.multi_state
.validator_metadata
.remove(&validator_pubkey)
.remove(validator_pubkey)
.expect("Data should have existed");

// if this cluster no longer contains any validators, remove it from the cluster map
45 changes: 21 additions & 24 deletions anchor/database/src/tests/utils.rs
Original file line number Diff line number Diff line change
@@ -210,13 +210,12 @@ pub mod queries {
let mut stmt = conn
.prepare(GET_OPERATOR)
.expect("Failed to prepare statement");
let operators = stmt
.query_row(params![*id], |row| {
let operator = Operator::try_from(row).expect("Failed to create operator");
Ok(operator)
})
.ok();
operators

stmt.query_row(params![*id], |row| {
let operator = Operator::try_from(row).expect("Failed to create operator");
Ok(operator)
})
.ok()
}

// Get a Cluster from the database
@@ -226,13 +225,12 @@ pub mod queries {
let mut stmt = conn
.prepare(GET_CLUSTER)
.expect("Failed to prepare statement");
let cluster = stmt
.query_row(params![*id], |row| {
let cluster = Cluster::try_from((row, members))?;
Ok(cluster)
})
.ok();
cluster

stmt.query_row(params![*id], |row| {
let cluster = Cluster::try_from((row, members))?;
Ok(cluster)
})
.ok()
}

// Get a share from the database
@@ -299,13 +297,12 @@ pub mod queries {
let mut stmt = conn
.prepare(GET_VALIDATOR)
.expect("Failed to prepare statement");
let validator = stmt
.query_row(params![validator_pubkey], |row| {
let validator = ValidatorMetadata::try_from(row)?;
Ok(validator)
})
.ok();
validator

stmt.query_row(params![validator_pubkey], |row| {
let validator = ValidatorMetadata::try_from(row)?;
Ok(validator)
})
.ok()
}
}

@@ -418,7 +415,7 @@ pub mod assertions {
}
// Verifies that the cluster is in memory
pub fn exists_in_memory(db: &NetworkDatabase, c: &Cluster) {
assert!(db.member_of_cluster(&c.cluster_id) == true);
assert!(db.member_of_cluster(&c.cluster_id));
let stored_cluster = db
.state
.multi_state
@@ -430,7 +427,7 @@ pub mod assertions {

// Verifies that the cluster is not in memory
pub fn exists_not_in_memory(db: &NetworkDatabase, cluster_id: ClusterId) {
assert!(db.member_of_cluster(&cluster_id) == false);
assert!(!db.member_of_cluster(&cluster_id));
let stored_cluster = db.state.multi_state.clusters.get_by(&cluster_id);
assert!(stored_cluster.is_none());
}
@@ -469,7 +466,7 @@ pub mod assertions {
}

// Verifies that all of the shares for a validator are in the database
pub fn exists_in_db(db: &NetworkDatabase, validator_pubkey: &PublicKey, s: &Vec<Share>) {
pub fn exists_in_db(db: &NetworkDatabase, validator_pubkey: &PublicKey, s: &[Share]) {
let db_shares =
queries::get_shares(db, validator_pubkey).expect("Shares should exist in db");
// have to pair them up since we dont know what order they will be returned from db in
4 changes: 2 additions & 2 deletions anchor/database/src/validator_operations.rs
Original file line number Diff line number Diff line change
@@ -48,14 +48,14 @@ impl NetworkDatabase {
.state
.multi_state
.validator_metadata
.get_by(&validator_pubkey)
.get_by(validator_pubkey)
{
// update graffiti and insert back in to update
validator.graffiti = graffiti;
self.state
.multi_state
.validator_metadata
.update(&validator_pubkey, validator);
.update(validator_pubkey, validator);
}
Ok(())
}