Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Gh#3030 enable mongodb #4304

Merged
merged 59 commits into from
Jul 9, 2018
Merged

Gh#3030 enable mongodb #4304

merged 59 commits into from
Jul 9, 2018

Conversation

heifner
Copy link
Contributor

@heifner heifner commented Jun 23, 2018

Resolves #3030

The mongo db plugin has been updated to work with 1.1 release.

It is recommended that a large --abi-serializer-max-time-ms value be passed into the nodeos running the mongo_db_plugin as the default abi serializer time limit may not be large enough to serialize large blocks.

It will create the following collections:

  • accounts - created on accepted transaction
    -- Currently limited to just name and ABI if contract on account

  • actions - created on accepted transaction
    -- action_num - the # of the action in its transaction
    -- trx_id
    -- account
    -- name
    -- authorization
    --- actor
    --- permission
    -- data
    -- hex_data

  • block_states - created on accepted block
    -- block_num
    -- block_id
    -- block_header_state
    -- validated
    -- in_current_chain

  • blocks - created on accepted block
    -- block_num
    -- block_id
    -- irreversible - updated to true on irreversible block
    -- block

  • transaction_traces - created on applied transaction
    -- transaction_trace

  • transactions - created on accepted transaction
    -- trx_id
    -- irreversible - updated to true on irreversible block
    -- transaction_header
    -- signing_keys
    -- actions
    -- context_free_actions
    -- transaction_extensions
    -- signatures
    -- context_free_data

if( !trx.context_free_actions.empty()) {
bsoncxx::builder::basic::array action_array;
for( const auto& cfa : trx.context_free_actions ) {
process_action( trx_id_str, cfa, action_array );
Copy link
Contributor Author

@heifner heifner Jun 23, 2018

Choose a reason for hiding this comment

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

context_free_actions need to be marked with something to distinguish them from non-contrext-free-actions (actions).

@heifner heifner added this to the Version 1.1 milestone Jun 23, 2018
@trungtt198x
Copy link

trungtt198x commented Jun 24, 2018

Great news!
Wonderfully
Please inform the exact revision merged into the master branch?

@noprom
Copy link
Contributor

noprom commented Jun 25, 2018

Hi @heifner , have you build successfully?
Got error when building in branch gh#3030-enable-mongodb:

[1276/1348] Building CXX object plugins/wallet_api_plugin/CMakeFiles/wallet_api_plugin.dir/wallet_api_plugin.cpp.o
[1277/1348] Linking CXX static library plugins/wallet_api_plugin/libwallet_api_plugin.a
[1278/1348] Building CXX object plugins/db_size_api_plugin/CMakeFiles/db_size_api_plugin.dir/db_size_api_plugin.cpp.o
[1279/1348] Building CXX object plugins/chain_plugin/CMakeFiles/chain_plugin.dir/chain_plugin.cpp.o
[1280/1348] Linking CXX static library plugins/chain_plugin/libchain_plugin.a
[1281/1348] Linking CXX static library plugins/bnet_plugin/libbnet_plugin.a
[1282/1348] Linking CXX static library plugins/chain_api_plugin/libchain_api_plugin.a
[1283/1348] Linking CXX static library plugins/producer_plugin/libproducer_plugin.a
[1284/1348] Linking CXX static library plugins/net_plugin/libnet_plugin.a
[1285/1348] Linking CXX static library plugins/net_api_plugin/libnet_api_plugin.a
[1286/1348] Linking CXX static library plugins/producer_api_plugin/libproducer_api_plugin.a
[1287/1348] Linking CXX static library plugins/db_size_api_plugin/libdb_size_api_plugin.a
[1288/1348] Building CXX object plugins/mongo_db_plugin/CMakeFiles/mongo_db_plugin.dir/mongo_db_plugin.cpp.o
FAILED: plugins/mongo_db_plugin/CMakeFiles/mongo_db_plugin.dir/mongo_db_plugin.cpp.o
/usr/bin/clang++  -DBSONCXX_STATIC -DMONGOCXX_STATIC -I/usr/local/include/mongocxx/v_noabi -I/usr/local/include/bsoncxx/v_noabi -I/eos/plugins/mongo_db_plugin/include -I/eos/plugins/chain_plugin/include -I/eos/plugins/chain_plugin/../chain_interface/include -I/eos/plugins/chain_plugin/../../libraries/appbase/include -I/eos/libraries/chain/include -Ilibraries/chain/include -I/eos/libraries/chain/../wasm-jit/Include -I/eos/libraries/chain/../../externals/binaryen/src -I/eos/libraries/utilities/include -I/eos/libraries/utilities/../wasm-jit/Include -I/eos/libraries/fc/include -I/usr/local/include -I/usr/include/openssl/include -I/eos/libraries/fc/vendor/websocketpp -I/eos/libraries/chainbase/include -I/eos/libraries/wasm-jit/Source/Runtime/../../../chain/include -I/eos/libraries/softfloat/source/include -I/eos/libraries/softfloat/source/8086-SSE -I/eos/libraries/softfloat/build/Linux-x86_64-GCC -I/eos/libraries/builtins -I/eos/libraries/builtins../softfloat/source/include -I/eos/libraries/appbase/include -Wall -Wno-invalid-partial-specialization -fcolor-diagnostics -O3 -DNDEBUG   -std=gnu++14 -MD -MT plugins/mongo_db_plugin/CMakeFiles/mongo_db_plugin.dir/mongo_db_plugin.cpp.o -MF plugins/mongo_db_plugin/CMakeFiles/mongo_db_plugin.dir/mongo_db_plugin.cpp.o.d -o plugins/mongo_db_plugin/CMakeFiles/mongo_db_plugin.dir/mongo_db_plugin.cpp.o -c /eos/plugins/mongo_db_plugin/mongo_db_plugin.cpp
/eos/plugins/mongo_db_plugin/mongo_db_plugin.cpp:674:37: error: no member named 'execute' in 'mongocxx::v_noabi::bulk_write'
         auto result = bulk_actions.execute();
                       ~~~~~~~~~~~~ ^
/eos/plugins/mongo_db_plugin/mongo_db_plugin.cpp:832:26: error: no member named 'execute' in 'mongocxx::v_noabi::bulk_write'
      auto result = bulk.execute();
                    ~~~~ ^
2 errors generated.
[1289/1348] Building CXX object plugins/txn_test_gen_plugin/CMakeFiles/txn_test_gen_plugin.dir/txn_test_gen_plugin.cpp.o
[1290/1348] Building CXX object plugins/history_plugin/CMakeFiles/history_plugin.dir/history_plugin.cpp.o
[1291/1348] Building CXX object programs/nodeos/CMakeFiles/nodeos.dir/main.cpp.o
[1292/1348] Building CXX object programs/cleos/CMakeFiles/cleos.dir/httpc.cpp.o
[1293/1348] Building CXX object programs/cleos/CMakeFiles/cleos.dir/main.cpp.o
ninja: build stopped: subcommand failed.
The command '/bin/sh -c git clone -b $branch https://github.com/EOSIO/eos.git --recursive     && cd eos && echo "$branch:$(git rev-parse HEAD)" > /etc/eosio-version     && cmake -H. -B"/tmp/build" -GNinja -DCMAKE_BUILD_TYPE=Release -DWASM_ROOT=/opt/wasm -DCMAKE_CXX_COMPILER=clang++        -DCMAKE_C_COMPILER=clang -DCMAKE_INSTALL_PREFIX=/tmp/build  -DSecp256k1_ROOT_DIR=/usr/local -DBUILD_MONGO_DB_PLUGIN=true -DCORE_SYMBOL_NAME=$symbol     && cmake --build /tmp/build --target install && rm /tmp/build/bin/eosiocpp' returned a non-zero code: 1

Dockerfile:

FROM eosio/builder as builder
ARG branch=master
ARG symbol=SYS

RUN git clone -b $branch https://github.com/EOSIO/eos.git --recursive \
    && cd eos && echo "$branch:$(git rev-parse HEAD)" > /etc/eosio-version \
    && cmake -H. -B"/tmp/build" -GNinja -DCMAKE_BUILD_TYPE=Release -DWASM_ROOT=/opt/wasm -DCMAKE_CXX_COMPILER=clang++ \
       -DCMAKE_C_COMPILER=clang -DCMAKE_INSTALL_PREFIX=/tmp/build  -DSecp256k1_ROOT_DIR=/usr/local -DBUILD_MONGO_DB_PLUGIN=true -DCORE_SYMBOL_NAME=$symbol \
    && cmake --build /tmp/build --target install && rm /tmp/build/bin/eosiocpp


FROM ubuntu:18.04

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install openssl ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/lib/* /usr/local/lib/
COPY --from=builder /tmp/build/bin /opt/eosio/bin
COPY --from=builder /tmp/build/contracts /contracts
COPY --from=builder /eos/Docker/config.ini /
COPY --from=builder /etc/eosio-version /etc
COPY --from=builder /eos/Docker/nodeosd.sh /opt/eosio/bin/nodeosd.sh
ENV EOSIO_ROOT=/opt/eosio
RUN chmod +x /opt/eosio/bin/nodeosd.sh
ENV LD_LIBRARY_PATH /usr/local/lib
VOLUME /opt/eosio/bin/data-dir
ENV PATH /opt/eosio/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Build command:

docker build -t noprom/eos:mongo --build-arg branch=gh#3030-enable-mongodb --build-arg symbol=EOS .

Can you look into this or am I missing something?

@liamcurry
Copy link
Contributor

I'm seeing the same error @noprom

@heifner
Copy link
Contributor Author

heifner commented Jun 26, 2018

@noprom @liamcurry You need to upgrade your mongo drivers. See the eosio_build scripts.

@noprom
Copy link
Contributor

noprom commented Jun 26, 2018

Hi @heifner , will try that immediately.
If this PR were merged, can I make another PR when the Dockerfile build succeed?

@liamcurry
Copy link
Contributor

I am able to compile and populate Mongo by modifying the Dockerfile to use the eosio_build.sh script from the release/1.1 branch. Here is what it looks like:

FROM ubuntu:18.04

RUN apt-get update \
    && apt-get install -y git sudo

RUN git clone -b release/1.1 https://github.com/EOSIO/eos.git

WORKDIR /eos

RUN git fetch --all --tags --prune \
    && git merge -m "merge" --commit origin/gh#3030-enable-mongodb

RUN git submodule update --init --recursive

RUN echo 1 | ./eosio_build.sh

The MongoDB plugin is showing Unknown struct errors when creating accounts with cleos, but the accounts still show up in the DB:

image

@heifner
Copy link
Contributor Author

heifner commented Jun 26, 2018

@liamcurry Did you run without a --hard-replay-blockchain, --replay-blockchain, and --delete-all-blocks? The information log is telling you that it could not decode the action.data hex data into json because it doesn't have the ABI for eosio::newaccount which it would get from the setabi of eosio.system. If mongo has all the data from genesis on it will be able to decode these.

Looks like I should remove that info log message as I see it can be rather annoying.

I need to think of how to load the abi if you want to start without processing everything from genesis.

UPDATE: I noticed your block numbers are very low. So what did you do?

@heifner
Copy link
Contributor Author

heifner commented Jun 26, 2018

@liamcurry I believe I was able to duplicate your issue. Please try again now.

@noprom
Copy link
Contributor

noprom commented Jun 27, 2018

Hi @heifner , I was able to build the mongo_db_plugin by upgrading the builder/Dockerfile :

builder/Dockerfile

FROM ubuntu:18.04

LABEL author="xiaobo <peterwillcn@gmail.com>" maintainer="Xiaobo <peterwillcn@gmail.com> Huang-Ming Huang <huangh@objectcomputing.com>" version="0.1.1" \
  description="This is a base image for building eosio/eos"

RUN echo 'APT::Install-Recommends 0;' >> /etc/apt/apt.conf.d/01norecommends \
  && echo 'APT::Install-Suggests 0;' >> /etc/apt/apt.conf.d/01norecommends \
  && apt-get update \
  && DEBIAN_FRONTEND=noninteractive apt-get install -y sudo wget curl net-tools ca-certificates unzip gnupg

RUN echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic main" >> /etc/apt/sources.list.d/llvm.list \
  && wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - \
  && apt-get update \
  && DEBIAN_FRONTEND=noninteractive apt-get install -y git-core automake autoconf libtool build-essential pkg-config libtool \
     mpi-default-dev libicu-dev python-dev python3-dev libbz2-dev zlib1g-dev libssl-dev libgmp-dev \
     clang-4.0 lldb-4.0 lld-4.0 llvm-4.0-dev libclang-4.0-dev ninja-build \
  && rm -rf /var/lib/apt/lists/*

RUN update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-4.0/bin/clang 400 \
  && update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-4.0/bin/clang++ 400

RUN wget https://cmake.org/files/v3.9/cmake-3.9.6-Linux-x86_64.sh \
    && bash cmake-3.9.6-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir --skip-license \
    && rm cmake-3.9.6-Linux-x86_64.sh

ENV CC clang
ENV CXX clang++

RUN wget https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.bz2 -O - | tar -xj \
    && cd boost_1_67_0 \
    && ./bootstrap.sh --prefix=/usr/local \
    && echo 'using clang : 4.0 : clang++-4.0 ;' >> project-config.jam \
    && ./b2 -d0 -j$(nproc) --with-thread --with-date_time --with-system --with-filesystem --with-program_options \
       --with-signals --with-serialization --with-chrono --with-test --with-context --with-locale --with-coroutine --with-iostreams toolset=clang link=static install \
    && cd .. && rm -rf boost_1_67_0

RUN wget https://github.com/mongodb/mongo-c-driver/releases/download/1.10.2/mongo-c-driver-1.10.2.tar.gz -O - | tar -xz \
    && cd mongo-c-driver-1.10.2 \
    && mkdir cmake-build && cd cmake-build \
    && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_BSON=ON \
		-DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON .. \
    && make -j$(nproc) \
    && make install \
    && cd ../../ && rm -rf mongo-c-driver-1.10.2

RUN git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git \
    && git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git llvm/tools/clang \
    && cd llvm \
    && cmake -H. -Bbuild -GNinja -DCMAKE_INSTALL_PREFIX=/opt/wasm -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release  \
    && cmake --build build --target install \
    && cd .. && rm -rf llvm

RUN wget https://github.com/WebAssembly/binaryen/archive/1.37.21.tar.gz -O - | tar -xz \
    && cd binaryen-1.37.21 \
    && cmake -H. -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release \
    && cmake --build build --target install \
    && cd .. && rm -rf binaryen-1.37.21

RUN git clone --depth 1 https://github.com/cryptonomex/secp256k1-zkp \
    && cd secp256k1-zkp \
    && ./autogen.sh \
    && ./configure --prefix=/usr/local \
    && make -j$(nproc) install \
    && cd .. && rm -rf secp256k1-zkp

RUN git clone --depth 1 -b releases/v3.3 https://github.com/mongodb/mongo-cxx-driver \
    && cd mongo-cxx-driver/build \
    && cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. \
    && make -j$(nproc) \
    && make install \
    && cd ../../ && rm -rf mongo-cxx-driver

RUN git clone --depth 1 --single-branch --branch master https://github.com/ucb-bar/berkeley-softfloat-3.git \
    && cd berkeley-softfloat-3/build/Linux-x86_64-GCC \
    && make -j${nproc} SPECIALIZE_TYPE="8086-SSE" SOFTFLOAT_OPS="-DSOFTFLOAT_ROUND_EVEN -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV32TO16 -DSOFTFLOAT_FAST_DIV64TO32" \
    && mkdir -p /opt/berkeley-softfloat-3 && cp softfloat.a /opt/berkeley-softfloat-3/libsoftfloat.a \
    && mv ../../source/include /opt/berkeley-softfloat-3/include && cd - && rm -rf berkeley-softfloat-3

ENV SOFTFLOAT_ROOT /opt/berkeley-softfloat-3

So I made a PR: #4356

Build my image with mongo

cd Docker
docker build -t noprom/eos:mongo --build-arg branch=gh#3030-enable-mongodb --build-arg symbol=EOS .

And it builds successfully.

Start my nodeos with mongo_db_plugin

I use my docker-compose file with my own built image: noprom/eos:mongo:

docker-compose-eosblock-init.yml

version: "3"

services:
  mongo:
    image: mongo:latest
    hostname: mongo
    ports:
      - 27017:27017
    volumes:
      - /data/app/data/mongo:/data/db
  nodeosd:
    image: noprom/eos:mongo
    command: /opt/eosio/bin/nodeos --data-dir=/data --genesis-json=/etc/nodeos/genesis.json --config-dir=/etc/nodeos --delete-all-blocks --mongodb-wipe --mongodb-uri mongodb://mongo:27017/EOS
    hostname: nodeosd
    links:
      - mongo
    ports:
      - 8891:8888
      - 9880:9876
    expose:
      - "8888"
    volumes:
      - /data/eos/nodeos-data-volume:/etc/nodeos
      - /data/eos/nodeos-data-volume/data:/data

Enable mongo_db_plugin in my config.ini

plugin = eosio::producer_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::http_plugin
plugin = eosio::history_api_plugin
plugin = eosio::mongo_db_plugin

Start nodeos using my docker-compose file

docker-compose -f docker-compose-eosblock-init.yml up -d

And got error:

2724020ms thread-0   chain_plugin.cpp:208          plugin_initialize    ] initializing chain plugin
2724020ms thread-0   chain_plugin.cpp:312          plugin_initialize    ] Deleting state database and blocks
2724020ms thread-0   chain_plugin.cpp:375          plugin_initialize    ] Using genesis state provided in '/etc/nodeos/genesis.json'
2724020ms thread-0   chain_plugin.cpp:381          plugin_initialize    ] Starting up fresh blockchain with provided genesis state.
CHAINBASE:   Failed to pin chainbase shared memory (of size 8192 MB) in RAM. Performance degradation is possible.
CHAINBASE:   Failed to pin chainbase shared memory (of size 340 MB) in RAM. Performance degradation is possible.
2724058ms thread-0   http_plugin.cpp:290           plugin_initialize    ] configured http to listen on 0.0.0.0:8888
2724059ms thread-0   mongo_db_plugin.cpp:968       plugin_initialize    ] initializing mongo_db_plugin
2724059ms thread-0   mongo_db_plugin.cpp:973       plugin_initialize    ] Wiping mongo database on startup
2724059ms thread-0   mongo_db_plugin.cpp:992       plugin_initialize    ] connecting to mongodb://mongo:27017/EOS
2724059ms thread-0   mongo_db_plugin.cpp:881       wipe_database        ] mongo db wipe_database
2724061ms thread-0   mongo_db_plugin.cpp:1029      plugin_initialize    ] 13 N8mongocxx7v_noabi19operation_exceptionE: No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on 'mongo:27017']: generic server error
rethrow No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on 'mongo:27017']: generic server error:
    {"what":"No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on 'mongo:27017']: generic server error"}
    thread-0  mongo_db_plugin.cpp:1029 plugin_initialize
2724061ms thread-0   main.cpp:122                  main                 ] 13 N8mongocxx7v_noabi19operation_exceptionE: No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on 'mongo:27017']: generic server error
rethrow No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on 'mongo:27017']: generic server error:
    {"what":"No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on 'mongo:27017']: generic server error"}
    thread-0  mongo_db_plugin.cpp:1029 plugin_initialize
2724062ms thread-0   mongo_db_plugin.cpp:870       ~mongo_db_plugin_imp ] mongo_db_plugin shutdown in process please be patient this can take a few minutes

Is that the mongo_db_plugin issue or the mongo database issue?

@heifner
Copy link
Contributor Author

heifner commented Jun 27, 2018

@noprom Looks like a connection issue. The plugin is unable to connect to the mongo database.

@wanderingbort wanderingbort modified the milestone: Version 1.1 Jun 27, 2018
@noprom
Copy link
Contributor

noprom commented Jun 27, 2018

Hi @heifner , are you able to connect to the mongo database using my builder/Dockerfile?482841e

@liamcurry
Copy link
Contributor

@heifner that fixed the log errors, thanks. I am running a local dev chain with --replay-blockchain, --delete-all-blocks, --enable-stale-production, and --mongodb-wipe, and those errors were being shown when creating the eosio.* accounts.

@noprom do you see any log messages from MongoDB after you see that error from nodeosd? Your Mongo server needs to be available before nodeosd is brought up.

@heifner
Copy link
Contributor Author

heifner commented Jun 27, 2018

@noprom Sorry I don't use docker.

@heifner
Copy link
Contributor Author

heifner commented Jun 27, 2018

@liamcurry Thanks that was my guess.

@liamcurry
Copy link
Contributor

@heifner I'm not concerned about this, but FYI I see the error message again when setting contracts:

image

@noprom
Copy link
Contributor

noprom commented Jun 27, 2018

Hi @liamcurry , I do setup a mongo instance before running nodeos, can you show me your commands when starting nodeos?

@liamcurry
Copy link
Contributor

@noprom using links just checks that the container is up and running, it doesn't guarantee that Mongo is ready to accept connections. To get around this you can use a custom script to delay starting up nodeosd.

In the same directory as your docker-compose-eosblock-init.yml file, create a file called start_nodeosd.sh:

#!/bin/sh

sleep 20

exec /opt/eosio/bin/nodeos --data-dir=/data --genesis-json=/etc/nodeos/genesis.json --config-dir=/etc/nodeos --delete-all-blocks --mongodb-wipe --mongodb-uri mongodb://mongo:27017/EOS

Make sure this file is executable by running chmod +x ./start_nodeosd.sh

Then in your docker-compose-eosblock-init.yml file, change the nodeosd entry:

  nodeosd:
    image: noprom/eos:mongo
    command: /start_nodeosd.sh
    hostname: nodeosd
    links:
      - mongo
    ports:
      - 8891:8888
      - 9880:9876
    expose:
      - "8888"
    volumes:
      - /data/eos/nodeos-data-volume:/etc/nodeos
      - /data/eos/nodeos-data-volume/data:/data
      - ./start_nodeosd.sh:/start_nodeosd.sh:ro

@noprom
Copy link
Contributor

noprom commented Jun 28, 2018

@liamcurry , cool! Thanks! Already syncing the data to the mongo database:

> show tables;
accounts
actions
block_states
blocks
transaction_traces
transactions
> db.transactions.count()
1907
> db.accounts.count()
8488

@trungtt198x
Copy link

trungtt198x commented Jul 4, 2018

@heifner
I've currently got the following error when trying to build your branch by using script eosio_build.sh

Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/libbson-1.0.so.0.0.0
-- Up-to-date: /usr/local/lib/libbson-1.0.so.0
-- Up-to-date: /usr/local/lib/libbson-1.0.so
-- Installing: /usr/local/lib/libbson-static-1.0.a
-- Installing: /usr/local/include/libbson-1.0/bson-config.h
-- Installing: /usr/local/include/libbson-1.0/bson-version.h
-- Up-to-date: /usr/local/include/libbson-1.0/bcon.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-atomic.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-clock.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-compat.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-context.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-decimal128.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-endian.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-error.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-iter.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-json.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-keys.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-macros.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-md5.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-memory.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-oid.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-reader.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-string.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-types.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-utf8.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-value.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-version-functions.h
-- Up-to-date: /usr/local/include/libbson-1.0/bson-writer.h
-- Installing: /usr/local/lib/pkgconfig/libbson-1.0.pc
-- Installing: /usr/local/lib/pkgconfig/libbson-static-1.0.pc
-- Installing: /usr/local/lib/cmake/libbson-1.0/libbson-1.0-config.cmake
-- Installing: /usr/local/lib/cmake/libbson-1.0/libbson-1.0-config-version.cmake
-- Installing: /usr/local/lib/cmake/libbson-static-1.0/libbson-static-1.0-config.cmake
-- Installing: /usr/local/lib/cmake/libbson-static-1.0/libbson-static-1.0-config-version.cmake
-- Installing: /usr/local/bin/mongoc-stat
-- Installing: /usr/local/lib/libmongoc-1.0.so.0.0.0
-- Up-to-date: /usr/local/lib/libmongoc-1.0.so.0
-- Up-to-date: /usr/local/lib/libmongoc-1.0.so
-- Set runtime path of "/usr/local/lib/libmongoc-1.0.so.0.0.0" to ""
-- Up-to-date: /usr/local/lib/libmongoc-1.0.so.0.0.0
-- Up-to-date: /usr/local/lib/libmongoc-1.0.so.0
-- Up-to-date: /usr/local/lib/libmongoc-1.0.so
-- Installing: /usr/local/lib/libmongoc-static-1.0.a
-- Installing: /usr/local/include/libmongoc-1.0/mongoc-config.h
-- Installing: /usr/local/include/libmongoc-1.0/mongoc-version.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-apm.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-bulk-operation.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-change-stream.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-client.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-client-pool.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-collection.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-cursor.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-database.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-error.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-flags.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-find-and-modify.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-gridfs.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-gridfs-file.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-gridfs-file-page.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-gridfs-file-list.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-handshake.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-host-list.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-init.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-index.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-iovec.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-log.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-macros.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-matcher.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-opcode.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-read-concern.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-read-prefs.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-server-description.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-client-session.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-socket.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-stream-tls-libressl.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-stream-tls-openssl.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-stream.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-stream-buffered.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-stream-file.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-stream-gridfs.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-stream-socket.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-topology-description.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-uri.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-version-functions.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-write-concern.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-rand.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-stream-tls.h
-- Up-to-date: /usr/local/include/libmongoc-1.0/mongoc-ssl.h
-- Installing: /usr/local/lib/pkgconfig/libmongoc-1.0.pc
-- Installing: /usr/local/lib/pkgconfig/libmongoc-static-1.0.pc
-- Installing: /usr/local/lib/pkgconfig/libmongoc-ssl-1.0.pc
-- Installing: /usr/local/lib/cmake/libmongoc-1.0/libmongoc-1.0-config.cmake
-- Installing: /usr/local/lib/cmake/libmongoc-1.0/libmongoc-1.0-config-version.cmake
-- Installing: /usr/local/lib/cmake/libmongoc-static-1.0/libmongoc-static-1.0-config.cmake
-- Installing: /usr/local/lib/cmake/libmongoc-static-1.0/libmongoc-static-1.0-config-version.cmake
fatal: destination path 'mongo-cxx-driver' already exists and is not an empty directory.
	Unable to clone MongoDB C++ driver at this time.
	Exiting now.
git branch -vv
* gh#3030-enable-mongodb 1bc9644 [origin/gh#3030-enable-mongodb] Merge pull request #4367 from cj-oci/enable-mongodb-tests-gh3030
  release/1.1            670970a [origin/release/1.1] Merge pull request #4424 from EOSIO/read-mode-irreversible

This error happens only on:

lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.4 LTS
Release:	16.04
Codename:	xenial

However, this error does not happen on:

sw_vers
ProductName:	Mac OS X
ProductVersion:	10.13.5
BuildVersion:	17F77

After having upgraded to Ubuntu 17.10, I can build EOS successfully.

@heifner
Copy link
Contributor Author

heifner commented Jul 11, 2018

@jafri Not sure the use case for running with a database that already has blocks? You can wipe the database manually or via command line --mongodb-wipe. upserts are slower than insert, in what use case is that useful?

There is an onblock for each block, so yes millions of them. Maybe it would be helpful to add an option to exclude them since many users may not find them useful.

There does seem to be an issue with the irreversible. Can you file a Github issue for that.

@heifner
Copy link
Contributor Author

heifner commented Jul 11, 2018

@jafri Created issue #4601 for the irreversible issue.

@jafri
Copy link
Contributor

jafri commented Jul 12, 2018

I was thinking more of running through the database and finding any inconsistencies (missed block somewhere perhaps) in which case the indexer would upsert it.

The exclusion of onblock would make action collection more manageable.

@maixiaohe
Copy link

@heifner I want to ask you a question:

When executing: git merge -m "merge" –commit origin/gh#3030-enable-mongodb command,
an error occurred saying: merge: origin/gh#3030-enable-mongodb - not Something we can merge.
Do you know how to solve it? If you can solve it, thank you very much.

@jafri
Copy link
Contributor

jafri commented Jul 13, 2018

@maixiaohe its already merged into release/1.1

@maixiaohe
Copy link

@jafri Means I can skip this step? Execute ./eosio_build.sh?

@trungtt198x
Copy link

@maixiaohe
Simply switch to use the "release/1.1" branch.

@trungtt198x
Copy link

To all who may have been encountering all issues on the branch release/1.1

Never ever use this buggy revision ca2c3d48207c01eee916e305c58b58e0d8a69c83.

The stable revision that I've been using is:

    branch      release/1.1
    rev:        47b1c311ac411cb1e095d74af56e3e9251eeb0af
    nodeos -v   1202832145

@jafri
Copy link
Contributor

jafri commented Jul 14, 2018

@heifner does this not pick up inline actions?

For example transfers from vpay, the query { 'data.from': 'eosio.vpay'} has 0 finds.

@heifner
Copy link
Contributor Author

heifner commented Jul 14, 2018

@jafri
db.transaction_traces.find({"action_traces.inline_traces.act.data.from":"eosio.vpay"})

@jafri
Copy link
Contributor

jafri commented Jul 15, 2018

@heifner The plugin seems to insert a document twice using replay. Here is an example:

screen shot 2018-07-15 at 11 55 05 pm

This was run with the following command:

    --data-dir=$DATADIR \
    --config-dir=$DATADIR \
    --replay-blockchain \
    --abi-serializer-max-time-ms 5000 \
    --hard-replay-blockchain \
    --mongodb-wipe \
    --mongodb-uri $URI \

@Jeiwan
Copy link

Jeiwan commented Jul 16, 2018

Block number 1 is missing from the blocks collection:

Is there any way to get it there without inserting manually?

@heifner
Copy link
Contributor Author

heifner commented Jul 16, 2018

@Jeiwan genesis block 1 is not signaled to accepted_block. Is there something in the genesis block you need?

@heifner
Copy link
Contributor Author

heifner commented Jul 16, 2018

@jafri The insert instead of upsert was by design. However, I think I'll give upsert a try and see how it goes.

@Jeiwan
Copy link

Jeiwan commented Jul 17, 2018

@heifner I'm building a blockchain explorer and want to have block 1 in the database. But I think it'll be ok to just put it there manually.

Another question. It feels that the node synchronizes much slower when the plugin is enabled. I mean bare node without blocks and other data. For example, I received this message several minutes ago:

Received block ddc03486114e6a1c... #1000 @ 2018-06-09T12:06:33.000 signed by eosio [trxs: 1, lib: 999, conf: 0, latency: 3268964352 ms]

But there are only 956 blocks in Mongo. And it keeps saving transaction traces and actions. Is it true that the plugin blocks the synchronization until all the previous data is saved? And saving (or parsing?) the data to Mongo is computationally difficult? The node uses just one core on my laptop and the load is 100%.

@Jeiwan
Copy link

Jeiwan commented Jul 17, 2018

I did some tests and, yes, the plugin slows down the synchronization: without it the first 1000 blocks are synchronized much faster. Is there a way to improve this? Maybe via adjusting the queue size between node and MongoDB?

If I fully synchronize the node without the plugin and then replay all blocks with the plugin enabled, will it be faster?

@Jeiwan
Copy link

Jeiwan commented Jul 17, 2018

So it seems like transaction traces and actions parsing takes a lot of time and CPU. New blocks won't be saved until all previous traces are parsed and saved. It's likely that the node won't be able to process new blocks in less than 500 milliseconds, and it's already so for some blocks.

@heifner
Copy link
Contributor Author

heifner commented Jul 17, 2018

@Jeiwan The mongo plugin is cpu intensive. In future versions, we may add some additional threads or otherwise optimize it. As it is there is a separate thread for serialization and pushing to mongo. However, on replay (and if slow machine) it will push back on the main thread if the queue fills up. Giving it a larger queue size gives it more room before it pushes back on the main thread.

@Jeiwan
Copy link

Jeiwan commented Jul 17, 2018

@heifner Got it, thanks!
Do you know of any other way of getting inline actions for all transactions? Chain API doesn't provide them and history API is memory limited, so I thought I could use the MongoDB plugin to get them.

@heifner
Copy link
Contributor Author

heifner commented Jul 17, 2018

@Jeiwan Other than mongo or other public block explorers, no.

@winlin
Copy link

winlin commented Jul 19, 2018

if you get error something like: error: no member named 'execute' in 'mongocxx::v_noabi::bulk_write'
when call docker build,
you should run docker image rm eos/builder to clean local cache and then run docker build again.

@jafri
Copy link
Contributor

jafri commented Jul 20, 2018

@heifner I am seeing duplicate creation of accounts after the node is fully synced sometimes

screen shot 2018-07-20 at 6 31 03 pm

@heifner
Copy link
Contributor Author

heifner commented Jul 20, 2018

@jafri I can see how that could happen. I will get a fix in.

@DenisCarriere
Copy link
Contributor

DenisCarriere commented Jul 21, 2018

EDIT: Solution #4304 (comment)

image

@heifner You mention that data should be available in the EOS/actions table

EOS/actions

  • actions - created on accepted transaction
    -- action_num - the # of the action in its transaction
    -- trx_id
    -- account
    -- name
    -- authorization
    --- actor
    --- permission
    -- data
    -- hex_data

image

@firesWu
Copy link
Contributor

firesWu commented Jul 23, 2018

accpeted transaction is irreversible? if not, how to rollback account's abi when the transaction is fail?

@firesWu
Copy link
Contributor

firesWu commented Jul 25, 2018

When the node is fully synced, same transaction was emit accepted_transaction singal twice so that data is duplicate. appiled_transcation is same case. How to slove it? @heifner

@heifner
Copy link
Contributor Author

heifner commented Jul 27, 2018

@qq1032246642 Can you create an issue and provide some examples.

@elnoxvie
Copy link

elnoxvie commented Aug 6, 2018

At this time of writing, the current block that were collected is at 6,535,852 on the machine i used. However, the latest block height is at 9,664,262. Not sure if this is due to the machine used as a nodeos or mongodb plugin issue. could anyone advise on this or how to speed up the sync? The machine has been running around 1 week plus.

The machine specs:
n1-standard-1 (1 vCPU, 3.75 GB memory)

Thanks.

@TamirTian
Copy link

TamirTian commented Aug 22, 2018

i can't find the block_num 1 in mongoplugin's blocks by init genesis.json.
eos version: 1.1、1.2.1

{
  "initial_timestamp": "2018-06-08T08:08:08.888",
  "initial_key": "EOS7EarnUhcyYqmdnPon8rm7mBCTnBoot6o7fE2WzjvEX2TdggbL3",
  "initial_configuration": {
    "max_block_net_usage": 1048576,
    "target_block_net_usage_pct": 1000,
    "max_transaction_net_usage": 524288,
    "base_per_transaction_net_usage": 12,
    "net_usage_leeway": 500,
    "context_free_discount_net_usage_num": 20,
    "context_free_discount_net_usage_den": 100,
    "max_block_cpu_usage": 200000,
    "target_block_cpu_usage_pct": 1000,
    "max_transaction_cpu_usage": 150000,
    "min_transaction_cpu_usage": 100,
    "max_transaction_lifetime": 3600,
    "deferred_trx_expiration_window": 600,
    "max_transaction_delay": 3888000,
    "max_inline_action_size": 4096,
    "max_inline_action_depth": 4,
    "max_authority_depth": 6
  },
  "initial_chain_id": "0000000000000000000000000000000000000000000000000000000000000000"
}

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

Successfully merging this pull request may close these issues.