Replay Contract

As a DSP, you will want the ability to replay a contractโ€™s vRAM (IPFS) related transactions to load that data into your IPFS cluster. We provide a file that does just that replay-contract.js.

To do this you will need to sign up for an API key from dfuse.io, you can select the Server to Server option from the dropdown when creating it. Dfuse offers free keys that last 24 hours, so thereโ€™s no need to pay.

There are some mandatory and optional environment variables.

Hyperion may also be used thanks to Christoph Michel: replay-contract-hyperion.js. List of endpoints here: https://hyperion.docs.eosrio.io/endpoint/, status of endpoint (UP/DOWN) here: https://bloks.io/hyperion

The dfuse GET /v0/search/transactions API has been discontinued, so Hyperion is currently the only option unless you have access to your own dfuse API.

Mandatory:

# contract to replay
export CONTRACT=
export NODEOS_CHAINID="aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906" # < mainnet | kylin > "5fff1dae8dc8e2fc4d5b23b2c7665c97f9e9d8edf2b6485a86ba311c25639191"
# make sure NO TRAILING FORWARD SLASH
# this good: export DSP_ENDPOINT=https://kylin-dsp-1.liquidapps.io
# this leads to an error export DSP_ENDPOINT=https://kylin-dsp-1.liquidapps.io/
export DSP_ENDPOINT=
# using Dfuse?
export DFUSE_API_KEY=
# using Hyperion?
export HYPERION_ENDPOINT=https://eos.hyperion.eosrio.io
export HYPERION_SORT_DIRECTION=asc # can also be desc, ascending starts from first block, descending starts from head block of chains

In Config.toml

Enable:

# under [dsp] section
allow_api_non_broadcast = true
# under [ipfs] section
postgresql = true # if wanting to replay to also fill PostgreSQL db in addition to IPFS
postgresql_force_replay = true # if wanting to replay to also fill PostgreSQL db in addition to IPFS

Restart the DSP with these.

Be sure to set allow_api_non_broadcast and postgresql_force_replay to false and restart the DSP after running the replay script. This is to prevent external actors from pushing unauthorized transactions to the DSP to drain CPU and to allow cache retrieval of IPFS data. As a note, the sign service will never process externally sourced transactions as a safety precaution.

Sidechain:

If replaying an account on a sidechain, must add the following environment variables.

  • SIDECHAIN if using a sidechain, must specify sidechain name (sidechain names can be found here)

  • SIDECHAIN_DSP_PORT if using a sidechain, must specify sidechain DSPโ€™s port

  • DSP_LIQUIDX_CONTRACT the liquidx contract name must be set liquidx.dsp on mainnet if cleaning a sidechain

  • NODEOS_MAINNET_ENDPOINT set mainnet nodeos endpoint

Optional:

export LAST_BLOCK= # defaults to 35000000, this is the last block to sync from, find the first vRAM transaction for the contract and set the block before it
export DFUSE_ENDPOINT= # defaults to 'eos.dfuse.eosnation.io', can set to `kylin.dfuse.eosnation.io`
export BLOCK_COUNT_PER_QUERY= # defaults to 1000000
export NODEOS_SECURED= # defaults to true
export NODEOS_HOST= # defaults to localhost
export NODEOS_PORT= # defaults to 13115

Once youโ€™ve set those, simply run with:

sudo find / -name replay-contract.js
node /root/.nvm/versions/node/v10.16.0/lib/node_modules/@liquidapps/dsp/utils/ipfs-service/replay-contract.js
# or hyperion
node /root/.nvm/versions/node/v10.16.0/lib/node_modules/@liquidapps/dsp/utils/ipfs-service/replay-contract-hyperion.js

# sent 6513 saved 7725.26KB 6.42KB/s Block:77756949

How to know if it is running correctly:

In the IPFS logs, you SHOULD see this log because this is a replay. You will not see this log for normal IPFS related transactions, only ones sent from the replay script.

logger.warn(`commit PASSIVE_DSP_NODE ${process.env.PASSIVE_DSP_NODE} || replay: ${replay} || exception ${exception}`)

You should NOT see this log because you have set DSP_ALLOW_API_NON_BROADCAST=true.

logger.warn(`Attempt to broadcast event for non broadcastable request, not processing trx, to enable non-broadcast events, set the allow_api_non_broadcast config.toml var to true under [dsp] section - ${JSON.stringify(act.event)}`);

Last updated