Run multiple Ponder indexers in payment stack (#588)

* Separate ponder indexer and ponder watcher and add second ponder indexer

* Handle review changes

* Update config to point ponder watcher to indexer 2 to indexer 1

* Update Ponder demo

* Use deployed ERC20 contract in second Ponder indexer

* Add order by timestamp in Ponder watcher app entities query

* Upgrade go-nitro version to v0.1.2-ts-port-0.1.9

* Decrease Ponder start block to process contract transfer event at deployment

---------

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
This commit is contained in:
2023-10-19 12:26:10 +05:30
committed by GitHub
co-authored by Shreerang Kale
parent 2402220273
commit 4a90cedeb2
11 changed files with 326 additions and 133 deletions
@@ -2,7 +2,9 @@
"freeQueriesLimit": 10,
"freeQueriesList": [],
"queries": {
"getLogEvents": "50"
"getLogEvents": "50",
"getEthLogs": "50",
"getEthBlock": "50"
},
"mutations": {}
}
@@ -7,11 +7,16 @@ fi
erc20_address_file="/app/deployment/erc20-address.json"
# Check and exit if a deployment already exists (on restarts)
echo ETH_RPC_URL=${CERC_ETH_RPC_ENDPOINT} > .env
echo ACCOUNT_PRIVATE_KEY=${CERC_PRIVATE_KEY_DEPLOYER} >> .env
# Check and keep container running if a deployment already exists (on restarts)
if [ -f ${erc20_address_file} ]; then
echo "${erc20_address_file} already exists, skipping ERC20 contract deployment"
cat ${erc20_address_file}
exit
# Keep the container running
tail -f
fi
wait_for_chain_endpoint() {
@@ -46,8 +51,6 @@ wait_for_chain_endpoint
echo "Using CERC_PRIVATE_KEY_DEPLOYER from env"
echo ETH_RPC_URL=${CERC_ETH_RPC_ENDPOINT} > .env
echo ACCOUNT_PRIVATE_KEY=${CERC_PRIVATE_KEY_DEPLOYER} >> .env
yarn token:deploy:docker --file ${erc20_address_file}
# Keep the container running
@@ -35,7 +35,7 @@ export const config: Config = {
network: "fixturenet",
abi: "./abis/AdventureGold.json",
address: process.env.ERC20_CONTRACT,
startBlock: 5,
startBlock: 1,
maxBlockRange: 100,
},
],
@@ -0,0 +1,64 @@
import { type Config, AppMode } from "@ponder/core";
import contractAddresses from "./nitro-addresses.json" assert { type: "json" };
export const config: Config = {
networks: [
{
name: "fixturenet",
chainId: Number(process.env.PONDER_CHAIN_ID),
indexerUrl: process.env.INDEXER_GQL_ENDPOINT,
maxRpcRequestConcurrency: 1,
pollingInterval: 5000,
payments: {
nitro: {
address: process.env.INDEXER_NITRO_ADDRESS!,
fundingAmounts: {
// TODO: Pass amounts from env
directFund: "1000000000000",
virtualFund: "1000000000",
},
},
paidRPCMethods: [
"eth_getLogs",
"eth_getBlockByNumber",
"eth_getBlockByHash",
],
amount: process.env.UPSTREAM_NITRO_PAY_AMOUNT!,
},
},
],
contracts: [
{
name: "AdventureGold",
network: "fixturenet",
abi: "./abis/AdventureGold.json",
address: process.env.ERC20_CONTRACT,
startBlock: 1,
maxBlockRange: 100,
},
],
options: {
mode: AppMode.Indexer,
},
nitro: {
privateKey: process.env.PONDER_NITRO_PK!,
chainPrivateKey: process.env.PONDER_NITRO_CHAIN_PK!,
chainUrl: process.env.PONDER_NITRO_CHAIN_URL!,
contractAddresses,
relayMultiAddr: process.env.RELAY_MULTIADDR!,
store: "./.ponder/nitro-db",
payments: {
cache: {
maxAccounts: 1000,
accountTTLInSecs: 1800,
maxVouchersPerAccount: 1000,
voucherTTLInSecs: 300,
maxPaymentChannels: 10000,
paymentChannelTTLInSecs: 1800,
},
ratesFile: "./base-rates-config.json",
requestTimeoutInSecs: 10,
},
},
};
@@ -15,7 +15,7 @@ export const config: Config = {
network: "fixturenet",
abi: "./abis/AdventureGold.json",
address: process.env.ERC20_CONTRACT,
startBlock: 5,
startBlock: 1,
maxBlockRange: 100,
},
],