eos icon indicating copy to clipboard operation
eos copied to clipboard

Mongodb plugin store transfer info as binary format,can select stoer in json format?

Open yaanhyy opened this issue 8 years ago • 15 comments

I want search the transaction by receiver account,but the recerver account contained in the data feild (etc: "actions" : [ { "account" : "eosio.token", "name" : "transfer", "authorization" : [ { "actor" : "krakenkraken", "permission" : "active" } ], "data" : "301534174e05cd8540b38b5e4d2aaf81ec6535000000000004454f53000000000773756363657373" } ]) as binanry format. Can I config the options of mongodb plugin to make plugin to store json format?

Now I need use /v1/chain/abi_bin_to_json to change data: 301534174e05cd8540b38b5e4d2aaf81ec6535000000000004454f53000000000773756363657373 to json format { "args": { "from": "krakenkraken", "to": "karmoneylito", "quantity": "349.9500 EOS", "memo": "success" } } ,but bin format make me impossible use mongodb find command to filter the receiver account

yaanhyy avatar Sep 07 '18 02:09 yaanhyy

They should be stored as json. What version are you running?

heifner avatar Sep 07 '18 02:09 heifner

eos verison 1.2.3 release. btw:The sync speed is so so slow. 10000 block/hour. We estimate need more than one month to sync down data. We use --mongodb-filter-on as default *. We server is 16GB ram, 4 core Intel(R) Xeon(R) Platinum 8168 CPU @ 2.70GHz

yaanhyy avatar Sep 07 '18 04:09 yaanhyy

I guess you need to figure out what is the bottleneck for your sync up performance. CPU? harddisk? network? 16GB RAM is ok at the moment but it possibly not able to store the states in the near future.

taokayan avatar Sep 07 '18 07:09 taokayan

@taokayan Do you build full node, sync data from mainnet by history plugin and mongodb plugin? How many blocks can your node sync per hour?

yaanhyy avatar Sep 07 '18 07:09 yaanhyy

same as @yaanhyy

we use history plugin with filter-on = * and in 'act' section of the 'action-trace' , the 'data' is formated as json , as : "data": { "from": "gy4temjrhage", "to": "williamoony5", "quantity": "119.0010 EOS", "memo": " " } that's ok; but with the plugin of mongodb( --mongodb-filter-on = *) , we can only get the binanry formated 'data' just like this : "data": "a09861fa499abf67a09869f84a94846350c3000000000000044345544f530000136365746f7320746f6b656e2061697264726f70"

why ? and how to implement the '/v1/history/get_actions' query by mongodb just like the history plugin does ?

beykery avatar Sep 08 '18 09:09 beykery

We currently we are not planning to add rpc as there are many existing ways to query mongo.

The transfers should be json in mongo. They are in all my testing. Can you provide your config.ini and your command line.

heifner avatar Sep 08 '18 15:09 heifner

Hi ,my version is: v1.2.3-2-g9a56222

comand line is use script :

DATADIR="/mnt/EOS-MainNet"
#DATADIR="/mnt/eos_rep"
NODEOSBINDIR="/mnt/eos/build/programs"


$DATADIR/stop.sh
echo -e "Starting Nodeos \n";

ulimit -c unlimited
ulimit -n 65535
ulimit -s 64000

$NODEOSBINDIR/nodeos/nodeos --data-dir $DATADIR --config-dir $DATADIR "$@" > $DATADIR/stdout.txt 2> $DATADIR/stderr.txt &  echo $! > $DATADIR/nodeos.pid

config.ini:

    #producer-name = !!!!YOUR_BP_NAME!!!!!!!!
    #signature-provider = YOUR_BLOCK_SIGN_PUB_KEY=KEY:YOUR_BLOCK_SIGN_PRIV_KEY

    agent-name = AgentName

    #blocks-dir = "blocks"
    chain-state-db-size-mb = 8192
    reversible-blocks-db-size-mb = 640
    contracts-console = false


    http-server-address = 0.0.0.0:8888
    p2p-listen-endpoint = 0.0.0.0:9876
    p2p-server-address = 127.0.0.1:9876
    #bnet-endpoint = !!YOUR_ENDPOINT_IP_ADDRESS!!:9875
    #bnet_threads = 4

    http-validate-host = false
    verbose-http-errors = true  
    abi-serializer-max-time-ms = 2000  

    access-control-allow-origin = *
    # access-control-allow-headers =
    # access-control-max-age =
    #access-control-allow-credentials = false



    #p2p-max-nodes-per-host = 4

    # actor-whitelist =
    # actor-blacklist =
    # contract-whitelist =
    # contract-blacklist =

    mongodb-block-start = 13600000
    mongodb-filter-on = eosio.token:transfer: 	
    mongodb-filter-on = eosio:newaccount:
    mongodb-filter-on = eosio:buyrambytes:
    mongodb-filter-on = eosio:buyram:
    mongodb-filter-on = eosio:sellram:
    mongodb-filter-on = eosio:delegatebw:
    mongodb-filter-on = eosio:undelegatebw:
    mongodb-filter-on = eosio:refund:

    #  mongodb-filter-on = *
      	
      mongodb-uri = mongodb://localhost:27017/eosmain	



    # SSL
    # Filename with https private key in PEM format. Required for https (eosio::http_plugin)
    # https-server-address =
    # Filename with the certificate chain to present on https connections. PEM format. Required for https. (eosio::http_plugin)
    # https-certificate-chain-file =
    # Filename with https private key in PEM format. Required for https (eosio::http_plugin)
    # https-private-key-file =


    allowed-connection = any

    log-level-net-plugin = info
    max-clients = 150
    connection-cleanup-period = 30
    network-version-match = 1
    sync-fetch-span = 2000
    enable-stale-production = false

    max-implicit-request = 1500
    pause-on-startup = false
    max-transaction-time = 30
    max-irreversible-block-age = -1
    txn-reference-block-lag = 0
    unlock-timeout = 90000

    plugin = eosio::chain_api_plugin
    plugin = eosio::mongo_db_plugin
    plugin = eosio::chain_plugin
    plugin = eosio::bnet_plugin
    plugin = eosio::history_api_plugin
    plugin = eosio::history_plugin

    #plugin = net_plugin
    #plugin = net_api_plugin


    #bnet-connect =
    #bnet-connect =
    #bnet-connect =

    #p2p-peer-address =
    #p2p-peer-address =
    #p2p-peer-address =

    #p2p-peer-address = 172.2.0.100:9876
    #p2p-peer-address = 172.2.0.200:9876

    #Other Pub BP nodes
    #p2p-peer-address =
    #p2p-peer-address =


    p2p-peer-address = node2.starteos.io:9876
    p2p-peer-address = eos-bp.bitfinex.com:9876

    p2p-peer-address = api-full2.eoseoul.io:9876
    p2p-peer-address = bp.eosbeijing.one:8080
    p2p-peer-address = mars.fnp2p.eosbixin.com:443
    p2p-peer-address = peer2.mainnet.helloeos.com.cn:80
    p2p-peer-address = peer2.eosphere.io:9876
    p2p-peer-address = api.eosrio.io:9876
    p2p-peer-address = br.eosrio.io:9876
    p2p-peer-address = 130.211.59.178:9876
    p2p-peer-address = p2p.eossocal.io:9999
    p2p-peer-address = peer1.mainnet.eos.store:80
    p2p-peer-address = bp.cryptolions.io:9876
    p2p-peer-address = bp.eosbeijing.one:8080
    p2p-peer-address = 47.104.169.45:9876
    p2p-peer-address = eu2.eosdac.io:9876

yaanhyy avatar Sep 09 '18 03:09 yaanhyy

I find the data as binary format because config.ini add below options,comment these options ,then sync data as json format. But what do the below options means. I can't find in documents.

mongodb-raw-blocks = false
mongodb-block-state = false
mongodb-store-act-via-txtraces = true
mongodb-cache-abis = true
mongodb-filter-on  = *
mongodb-filter-out = spammer::
mongodb-queue-size = 2048
abi-serializer-max-time-ms = 5000

yaanhyy avatar Sep 10 '18 07:09 yaanhyy

@yaanhyy How to solve it ? But i haven't options mentioned like yours.

aiguo186 avatar Sep 10 '18 11:09 aiguo186

@yaanhyy Thank you for the config info. Your abi-serializer-max-time is set way to small. For your nodeos with the mongo-db-plugin I recommend setting this to a very large value, for example: 999900000.

I recommend you run with read-mode = read-only.

The following options are ignored, my guess is these are from when you were running a non-released patch:

mongodb-raw-blocks = false
mongodb-block-state = false
mongodb-store-act-via-txtraces = true
mongodb-cache-abis = true

See here for currently supported options: https://developers.eos.io/eosio-nodeos/docs/mongo_db_plugin

Providing the correct options for not storing blocks and block-state will greatly increase your performance.

heifner avatar Sep 10 '18 14:09 heifner

@heifner Thank you very much!

yaanhyy avatar Sep 11 '18 01:09 yaanhyy

@heifner @yaanhyy HELP!!!! I also meet this problem! eosio.token transfer info(act.data) is binary format in action_traces collection. I had set valueabi-serializer-max-time-ms to 999900000 . The following is my config.ini and cmd!

get-transactions-time-limit = 30 max-transaction-time=3000 http-server-address = 0.0.0.0:9876 p2p-listen-endpoint = 0.0.0.0:14422 p2p-server-address = 172.26.247.121:14422 access-control-allow-origin = * chain-state-db-size-mb = 2048 http-validate-host = 0 allowed-connection = any log-level-net-plugin = info max-clients = 120 connection-cleanup-period = 30 network-version-match = 0 sync-fetch-span = 2000 enable-stale-production = false required-participation = 33 plugin = eosio::chain_api_plugin plugin = eosio::history_plugin plugin = eosio::history_api_plugin plugin = eosio::chain_plugin ########################################### plugin = eosio::mongo_db_plugin mongodb-uri = mongodb://47.92.86.161:27017/eosmain mongodb-store-blocks = false mongodb-store-block-states = false mongodb-store-transaction-traces = false mongodb-filter-out = spammer:: mongodb-filter-out = eosio:onblock: mongodb-queue-size = 2048 mongodb-abi-cache-size = 10240 abi-serializer-max-time-ms = 999900000 ########################################## p2p-peer-address = bp.superone.io:57576 p2p-peer-address = onedapp.oneeos.org:9000 p2p-peer-address = mainnet.eos.ren:9376 p2p-peer-address = eos.nodepacific.com:9876 p2p-peer-address = fullnode.eoslaomao.com:443 p2p-peer-address = mainnet.eoseco.com:10010 p2p-peer-address = eosbp.eosvillage.io:8181 p2p-peer-address = testnode.eosgalaxy.io:9876 p2p-peer-address = node1.eoscannon.io:59876 p2p-peer-address = bp.eosmedi.com:9877 p2p-peer-address = bp.eosbeijing.one:8080 p2p-peer-address = mainnet.eosbattles.com:9875 p2p-peer-address = 807534da.eosnodeone.io:19872

$ cat start.sh #!/bin/bash NODEOS=/eos/home/disk1/mainnet/eos/build/programs/nodeos/nodeos DATADIR=/eos/home/disk1/mainnet $DATADIR/stop.sh $NODEOS --max-irreversible-block-age 500000 --data-dir $DATADIR/data/ --config-dir $DATADIR "$@" > $DATADIR/stdout.txt 2> $DATADIR/stderr.txt & echo $! > $DATADIR/nodeos.pid

$./start.sh

aiguo186 avatar Sep 11 '18 07:09 aiguo186

你好,找到原因了,反序列化数据是需要accounts表中对应账户的abi数据支持,所以如果accounts表中的数据不完全,解析不成功,就会返回十六进制格式的字符串。所以不要从一般开始使用mongo插件,从一开始就打开mongo插件。

aiguo186 avatar Sep 12 '18 13:09 aiguo186

@aiguo186 Can you provide an example action_trace?

heifner avatar Sep 12 '18 14:09 heifner

@heifner @yaanhyy You need to synchronize the Mongo data from scratch, and if you synchronize from halfway through, you will make an error (due to incomplete "accounts" collection) .Of course abi-serializer-max-time-ms must big enough

aiguo186 avatar Sep 13 '18 02:09 aiguo186