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

Rework of storage [mtg-868] #310

Open
wants to merge 145 commits into
base: main
Choose a base branch
from
Open

Conversation

StanChe
Copy link
Contributor

@StanChe StanChe commented Nov 12, 2024

No description provided.

StanChe and others added 30 commits October 10, 2024 13:32
* feat: add more metrics to the synchronizer

* feat: more metrics
* feat: move fung dump to different thread

* feat: add more metrics
* feat: save fungible updates in regular sync

* feat: change migration file and add indexes drop/create during dump load

* fix: fungible tokens

* chore: code style
Now all the assets-related data is persisted in a single column
…ment over the reference, or over 50% over the initial merge
Current benchmarking results for 1M assets:
Dumping Group/2k batch size
                        time:   [4.8857 s 4.9288 s 4.9785 s]
Dumping Group/get_assets
                        time:   [5.0407 ms 5.0694 ms 5.0968 ms]
Dumping Group/get_assets_individually (taking 1000 assets in a loop one after another)
                        time:   [31.137 ms 33.730 ms 38.050 ms]
let mut static_details = existing_val.and_then(|a| a.static_details());
// creating a copy of every single field of the rest of the asset fields including the pubkeys to properly select the latest ones and reconstruct the asset
let mut dynamic_details_pubkey = existing_val
.and_then(|a| a.dynamic_details())
Copy link
Contributor

@kstepanovdev kstepanovdev Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure I understand what a and d mean here. Asset and Details?

Comment on lines +1946 to +1953
if (existing_static_details.specification_asset_class()
== fb::SpecificationAssetClass::FungibleToken
|| existing_static_details.specification_asset_class()
== fb::SpecificationAssetClass::FungibleAsset)
&& (new_static_details.specification_asset_class()
== fb::SpecificationAssetClass::Nft
|| new_static_details.specification_asset_class()
== fb::SpecificationAssetClass::ProgrammableNft)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe some sort of array's any()? would be more convenient to read?

// Merge authority
if let Some(new_authority) = new_val.authority() {
if authority.map_or(true, |current_authority| {
new_authority.compare(&current_authority) == Ordering::Greater
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fb::AssetAuthority::compare() looks like a manual implementation of Ord


fn merge_field<'a, T>(existing_field: &mut Option<T>, new_field: Option<T>)
where
T: PartialOrd + 'a,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that lifetime annotation is needed.

.cloned()
.rev() // Reverse the iterator for max_by to get the first-most element for the case of multiple equal values
.max_by(|a, b| {
if let (Some(a_write_version), Some(b_write_version)) = unsafe {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at least a couple of comments regarding unsafe (also, below) would be useful

builder: &mut FlatBufferBuilder<'a>,
iter: Vec<fb::AssetOwner<'a>>,
) -> Option<WIPOffset<fb::AssetOwner<'a>>> {
let pk = iter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iter.iter looks weird, Vec isn't Iter

.filter_map(|owner| owner.pubkey())
.next()
.map(|k| builder.create_vector(k.bytes()));
pk?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to ensure that pk is Some then pass it later as Option. Why?

StanChe and others added 14 commits November 25, 2024 17:34
…-support

[MTG-868] support for IPFS files
…reship-fix

[MTG-964] Ownership model fix using a history of owners
&& called cleaning up from the ingester instead of the synchronizer
* fix: a few issues with core assets

* fix: add missed None
* fix: a few issues with core assets

* fix: add missed None

* feat: add integration e to e tests

* fix: add cfg and link to original tests in readme

* Update integration_tests/README.md

Co-authored-by: Stanislav Cherviakov <[email protected]>

* chore: change log to tracing loging crate

---------

Co-authored-by: Stanislav Cherviakov <[email protected]>
…-storage

# Conflicts:
#	nft_ingester/Cargo.toml
#	nft_ingester/src/api/backfilling_state_consistency.rs
#	nft_ingester/src/bin/ingester/main.rs
#	nft_ingester/src/index_syncronizer.rs
#	nft_ingester/tests/api_tests.rs
#	postgre-client/src/asset_index_client.rs
#	rocks-db/src/asset_client.rs
#	rocks-db/src/batch_client.rs
#	rocks-db/src/dump_client.rs
#	rocks-db/src/lib.rs
#	rocks-db/src/storage_traits.rs
…MTG-868-slots-storage

# Conflicts:
#	nft_ingester/src/bin/ingester/main.rs
#	nft_ingester/tests/api_tests.rs
#	rocks-db/src/asset_client.rs
* feat: fix a few issues with cNFT assets

* feat: comments fixes

* feat: add new 2 test cases for cNFT (#328)
@StanChe StanChe marked this pull request as ready for review December 6, 2024 14:35
@@ -3,11 +3,14 @@
SHELL := /bin/bash

build:
@docker compose -f docker-compose.yaml build ingester raw-backfiller das-api synchronizer core-indexing
@docker compose -f docker-compose.yaml build ingester raw-backfiller das-api synchronizer core-indexing slot-persister
Copy link
Contributor

@RequescoS RequescoS Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need core-indexing as a separate bin?

print_max_supply: e.max_supply,
edition_number: e.edition_number,
}),
Interface::V1NFT => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is V1NFT the only Interface that can have editions?

@@ -952,7 +617,6 @@ where
slot: u64,
block: solana_transaction_status::UiConfirmedBlock,
) -> Result<(), BlockConsumeError> {
self.rocks_client.consume_block(slot, block.clone()).await?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to consume the block in slot storage?

@@ -280,6 +270,10 @@ pub struct SynchronizerConfig {
pub heap_path: String,
}

fn default_native_mint() -> String {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: maybe it's better to import it from some Solana crate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants