-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Add decompression traits and a test case #2295
base: master
Are you sure you want to change the base?
Conversation
fb37322
to
72dd40d
Compare
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.
LGTM, one question from me.
on_chain: Database::rocksdb_temp(state_rewind_policy)?, | ||
off_chain: Database::rocksdb_temp(state_rewind_policy)?, | ||
relayer: Database::rocksdb_temp(state_rewind_policy)?, | ||
gas_price: Default::default(), |
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.
out of curiosity, why the difference for the gas_price
database?
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.
@xgreenx might know, I have no idea
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.
Because gas price table and relayer table doesn't need to support state rewind in the case of the temporary database(right now at least). Because we don't have any logic around it.
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.
WIP. I want to give it another, deeper pass.
@@ -94,6 +94,19 @@ impl CombinedDatabase { | |||
}) | |||
} | |||
|
|||
/// A test-only temporary rocksdb database with given rewind policy. | |||
#[cfg(feature = "rocksdb")] |
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.
Should this also be "test-helpers"
if it's "test-only"?
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.
Done in 5251318
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.
I reverted this in beaee56 since it seems like we're using it with when empty path is provided, and I'm not sure if we need that outside tests as well.
}; | ||
let decompressed = decompress(compression_config, db_tx, block).await.unwrap(); | ||
|
||
assert!(decompressed.transactions.len() == 2); |
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.
Might as well check that the second tx matches the one submitted.
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.
Some fields will differ, as the returned tx would have to be executed to generate full values
let db = &srv.shared.database; | ||
let mut tx_inner = db.off_chain().clone().into_transaction(); | ||
let db_tx = DecompressDbTx { | ||
db_tx: DbTx { | ||
db_tx: &mut tx_inner, | ||
}, | ||
onchain_db: db.on_chain().view_at(&0u32.into()).unwrap(), | ||
}; | ||
let decompressed = decompress(compression_config, db_tx, block).await.unwrap(); |
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.
I guess I'm a little confused by using the shared db for decompressing the info. Shouldn't we be able to decompress it with an isolated, clean db?
Maybe that's not the point of this test.
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.
decompression requires some previous indexation to be done on the data, it can't be done from an empty database afaiu
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.
LGTM 👍
state_rewind_policy: StateRewindPolicy, | ||
) -> DatabaseResult<Self> { | ||
Ok(Self { | ||
on_chain: Database::rocksdb_temp(state_rewind_policy)?, |
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.
perhaps we should use ShallowTempDir
here? we moved it from fuel-core to the benches crate but if the use case is the same we can use it
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.
What's the reason behind this?
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.
because we have a way to clean up the directory after shutdown.. not sure if this method deletes the db after we are done with it.
let db = &srv.shared.database; | ||
let mut tx_inner = db.off_chain().clone().into_transaction(); | ||
let db_tx = DecompressDbTx { | ||
db_tx: DbTx { | ||
db_tx: &mut tx_inner, | ||
}, | ||
onchain_db: db.on_chain().view_at(&0u32.into()).unwrap(), | ||
}; | ||
let decompressed = decompress(compression_config, db_tx, block).await.unwrap(); |
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.
decompression requires some previous indexation to be done on the data, it can't be done from an empty database afaiu
Co-authored-by: Rafał Chabowski <[email protected]>
This PR extends the `fuel-core` too make public some functionality that could be useful to reuse in the watchtower https://github.com/FuelLabs/network-watchtower. ### Before requesting review - [x] I have reviewed the code myself
on_chain: Database::rocksdb_temp(state_rewind_policy)?, | ||
off_chain: Database::rocksdb_temp(state_rewind_policy)?, | ||
relayer: Database::rocksdb_temp(state_rewind_policy)?, | ||
gas_price: Default::default(), |
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.
Because gas price table and relayer table doesn't need to support state rewind in the case of the temporary database(right now at least). Because we don't have any logic around it.
db_tx: DbTx { | ||
db_tx: &mut tx_inner, | ||
}, | ||
onchain_db: db.on_chain().view_at(&0u32.into()).unwrap(), |
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.
It would be nice if in the test you highlighted somehow that we use the previous state of the database because it is important detail=)
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.
Added a comment to that effect in aca530a
#1609 (comment)
Add a test case for decompressing DA-compressed blocks. FIx
CombinedDb::from_config
to respectsstate_rewind_policy
with tmp RocksDB.