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

[3.2] Implement JSON Snapshot Reader #732

Closed
wants to merge 7 commits into from

Conversation

ClaytonCalabrese
Copy link
Contributor

@ClaytonCalabrese ClaytonCalabrese commented Jul 27, 2022

#710 ports a way to convert a snapshot to json. This PR enhances the --snapshot option to support reading a snapshot in JSON format if the snapshot has .json extension.

Resolves: #771

@ClaytonCalabrese ClaytonCalabrese added 3.2 Candidate OCI OCI working this issue... labels Jul 27, 2022
@ClaytonCalabrese ClaytonCalabrese self-assigned this Jul 27, 2022
@ClaytonCalabrese ClaytonCalabrese marked this pull request as draft July 27, 2022 18:52
@ClaytonCalabrese ClaytonCalabrese marked this pull request as ready for review July 28, 2022 16:03
,cur_row(0)
{
std::stringstream my_buffer;
my_buffer << snapshot.rdbuf();
Copy link
Member

Choose a reason for hiding this comment

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

This looks like it reads the entire file in to memory? How much memory does this take for something like an EOS or WAX snapshot? It almost seems like that's going to be impractical.


EOS_ASSERT( options.count( "genesis-timestamp" ) == 0,
plugin_config_exception,
"--snapshot is incompatible with --genesis-timestamp as the snapshot contains genesis information");
Copy link
Member

Choose a reason for hiding this comment

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

--json-snapshot not --snapshot. But more generally this looks like 40 lines copy pasted (almost?) verbatim. Is there a better way?

…erge snapshot and jsonsnapshot code handling
@spoonincode
Copy link
Member

Have we (manually) tested that we can load something like a WAX snapshot in JSON format with this?

@ClaytonCalabrese
Copy link
Contributor Author

ClaytonCalabrese commented Aug 5, 2022

Have we (manually) tested that we can load something like a WAX snapshot in JSON format with this?

I doubled my WSL max storage yesterday and attempted to run WAX but the snapshot-to-json ran my VM out of space at this row:
,"row_288346839":{"primary_key":"1099801935006","payer":"farmersworld","value":"nrxNEQABAACQ4qUcXyWvWQAAAAAAHCnNbh

I can allocate some more space as well as delete some stuff to try and fit all of wax's JSON Snapshot tonight but I have no idea how much space the full thing is going to take to create.

@@ -5,6 +5,7 @@
#include <fc/variant_object.hpp>
#include <boost/core/demangle.hpp>
#include <ostream>
#include "../rapidjson/include/rapidjson/document.h"
Copy link
Member

Choose a reason for hiding this comment

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

it really should be added to cmake as an INTERFACE library and properly set up so only need to #include <rapidjson/document.h>

@spoonincode
Copy link
Member

I think only one version of rapidjson should be in the global namespace so we avoid any ODR wonkiness . Right now, I believe abieos includes it in the global namespace too.

…d of adding a new option. Improved memory usage so current WAX snapshot can be supported. Modified the JSON output so that table rows are an array which reduces file size and memory usage. Put rapidjson inside an eosio_rapidjson namespace to avoid ODR issues. Change CMakeLists to not compile rapidjson but only include it as it is a header only library.
@@ -131,6 +131,7 @@ target_link_libraries( eosio_chain PUBLIC fc chainbase Logging IR WAST WASM Runt
target_include_directories( eosio_chain
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../wasm-jit/Include"
"${CMAKE_CURRENT_SOURCE_DIR}/../rapidjson/include"
Copy link
Member

Choose a reason for hiding this comment

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

This really needs to be an INTERFACE library

Copy link
Member

Choose a reason for hiding this comment

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

Can you provide an example of what that would look like. I didn't see an example in our code.

Copy link
Member

Choose a reason for hiding this comment

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

something like (I'm just winging this so may not be fully correct)

add_library(rapidjson INTERFACE)
target_include_directories(rapidjson INTERFACE rapidjson/include)
target_compile_definitions(rapidjson INTERFACE -DRAPIDJSON_NAMESPACE=eosio_rapidjson)

then wherever you want to use it just

target_link_libraries(eosio_chain rapidjson)

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if making the RAPIDJSON_NAMESPACE thing part of the interface is a good idea or not though.

@ClaytonCalabrese
Copy link
Contributor Author

closing due to migration to leap AntelopeIO/leap#25

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

Successfully merging this pull request may close these issues.

3 participants