Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: graphprotocol/indexer
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0742866850844d8f4eaf0602f71882e473c88611
Choose a base ref
..
head repository: graphprotocol/indexer
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5f3d1e88804883820be669ed672a756394d1534a
Choose a head ref
Showing with 1,464 additions and 797 deletions.
  1. +2 −0 docs/feature-support-matrix.md
  2. +4 −5 package.json
  3. +1 −1 packages/indexer-agent/package.json
  4. +9 −3 packages/indexer-agent/src/db/migrations/17-edit-cost-models-trigger.ts
  5. +2 −2 packages/indexer-cli/package.json
  6. +21 −18 packages/indexer-cli/src/actions.ts
  7. +11 −8 packages/indexer-cli/src/cost.ts
  8. +4 −4 packages/indexer-common/package.json
  9. +67 −0 packages/indexer-common/src/allocations/__tests__/escrow-accounts.test.ts
  10. +229 −0 packages/indexer-common/src/allocations/__tests__/tap-pagination.test.ts
  11. +56 −24 packages/indexer-common/src/allocations/__tests__/tap.test.ts
  12. +90 −0 packages/indexer-common/src/allocations/__tests__/validate-queries.test.ts
  13. +67 −0 packages/indexer-common/src/allocations/escrow-accounts.ts
  14. +2 −0 packages/indexer-common/src/allocations/index.ts
  15. +0 −536 packages/indexer-common/src/allocations/query-fees.ts
  16. +724 −0 packages/indexer-common/src/allocations/tap-collector.ts
  17. +13 −36 packages/indexer-common/src/graph-node.ts
  18. +1 −1 packages/indexer-common/src/indexer-management/__tests__/helpers.test.ts
  19. +49 −56 packages/indexer-common/src/indexer-management/__tests__/resolvers/cost-models.test.ts
  20. +29 −4 packages/indexer-common/src/network.ts
  21. +2 −0 packages/indexer-common/src/tap-subgraph.ts
  22. +1 −1 packages/indexer-native/package.json
  23. +2 −2 packages/indexer-service/package.json
  24. +57 −60 packages/indexer-service/src/query-fees/allocations.ts
  25. +0 −14 scripts/update-common-ts.sh
  26. +21 −22 yarn.lock
2 changes: 2 additions & 0 deletions docs/feature-support-matrix.md
Original file line number Diff line number Diff line change
@@ -27,6 +27,8 @@ The matrix below reflects the canonical Council-ratified version. As outlined in
| eip155:534352 | scroll | Yes | Yes | Yes | Yes | Yes |
| eip155:59144 | linea | Yes | Yes | Yes | Yes | Yes |
| eip155:56 | bsc | Yes | Yes | Yes | Yes | Yes |
| eip155:122 | fuse | Yes | Yes | Yes | Yes | Yes |
| eip155:81457 | blast | Yes | Yes | Yes | Yes | Yes |
| **Data Source Features** | | | | | | |
| ipfs.cat in mappings | | Yes | Yes | No | No | No |
| ENS | | Yes | Yes | Yes | Yes | Yes |
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@
"release": "./scripts/release.sh",
"test": "lerna --concurrency 1 run test --stream --ignore @graphprotocol/indexer-service",
"test:ci": "lerna --concurrency 1 run test:ci --stream --ignore @graphprotocol/indexer-service",
"update-common-ts": "./scripts/update-common-ts.sh 1.8.3",
"clean": "lerna run clean && rm -rf ./node_modules",
"compile": "lerna run compile"
},
@@ -29,8 +28,8 @@
"sequelize": "6.33.0",
"@ethersproject/bignumber": "5.7.0",
"@ethersproject/providers": "5.7.0",
"@urql/core": "2.4.4",
"@urql/exchange-execute": "1.2.2",
"@urql/core": "3.1.0",
"@urql/exchange-execute": "2.1.0",
"punycode": "2.3.1",
"uri-js": "4.2.2"
},
@@ -39,8 +38,8 @@
"sequelize": "6.33.0",
"@ethersproject/bignumber": "5.7.0",
"@ethersproject/providers": "5.7.0",
"@urql/core": "2.4.4",
"@urql/exchange-execute": "1.2.2",
"@urql/core": "3.1.0",
"@urql/exchange-execute": "2.1.0",
"graphql": "16.8.0"
},
"engines": {
2 changes: 1 addition & 1 deletion packages/indexer-agent/package.json
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@
"graph-indexer-agent": "bin/graph-indexer-agent"
},
"dependencies": {
"@graphprotocol/common-ts": "2.0.9",
"@graphprotocol/common-ts": "2.0.10",
"@graphprotocol/indexer-common": "^0.21.4",
"@thi.ng/heaps": "^1.3.1",
"@uniswap/sdk": "3.0.3",
Original file line number Diff line number Diff line change
@@ -31,10 +31,10 @@ export async function up({ context }: Context): Promise<void> {
PERFORM pg_notify('cost_models_update_notification', format('{"tg_op": "DELETE", "deployment": "%s"}', OLD.deployment));
RETURN OLD;
ELSIF TG_OP = 'INSERT' THEN
PERFORM pg_notify('cost_models_update_notification', format('{"tg_op": "INSERT", "deployment": "%s", "model": "%s"}', NEW.deployment, NEW.model));
PERFORM pg_notify('cost_models_update_notification', format('{"tg_op": "INSERT", "deployment": "%s", "model": "%s", "variables": "%s"}', NEW.deployment, NEW.model, NEW.variables));
RETURN NEW;
ELSE
PERFORM pg_notify('cost_models_update_notification', format('{"tg_op": "%s", "deployment": "%s", "model": "%s"}', NEW.deployment, NEW.model));
PERFORM pg_notify('cost_models_update_notification', format('{"tg_op": "%s", "deployment": "%s", "model": "%s", "variables": "%s" }', NEW.deployment, NEW.model, NEW.variables));
RETURN NEW;
END IF;
END;
@@ -52,5 +52,11 @@ export async function up({ context }: Context): Promise<void> {
export async function down({ context }: Context): Promise<void> {
const { queryInterface, logger } = context
logger.info(`Drop function, trigger, indices, and table`)
queryInterface.removeColumn('scalar_tap_receipts_invalid', 'error_log')
await queryInterface.sequelize.query(
'DROP TRIGGER IF EXISTS cost_models_update ON "CostModelsHistory" CASCADE;',
)

await queryInterface.sequelize.query(
'DROP FUNCTION IF EXISTS cost_models_update_notify() CASCADE;',
)
}
4 changes: 2 additions & 2 deletions packages/indexer-cli/package.json
Original file line number Diff line number Diff line change
@@ -26,11 +26,11 @@
"test:watch": "jest --watch --detectOpenHandles --verbose"
},
"dependencies": {
"@graphprotocol/common-ts": "2.0.9",
"@graphprotocol/common-ts": "2.0.10",
"@graphprotocol/indexer-common": "^0.21.4",
"@iarna/toml": "2.2.5",
"@thi.ng/iterators": "5.1.74",
"@urql/core": "2.4.4",
"@urql/core": "3.1.0",
"chalk": "4.1.2",
"env-paths": "2.2.1",
"ethers": "5.7.0",
39 changes: 21 additions & 18 deletions packages/indexer-cli/src/actions.ts
Original file line number Diff line number Diff line change
@@ -236,25 +236,28 @@ export async function executeApprovedActions(
client: IndexerManagementClient,
): Promise<ActionResult[]> {
const result = await client
.mutation(gql`
mutation executeApprovedActions {
executeApprovedActions {
id
protocolNetwork
status
type
deploymentID
allocationID
amount
poi
force
source
reason
transaction
failureReason
.mutation(
gql`
mutation executeApprovedActions {
executeApprovedActions {
id
protocolNetwork
status
type
deploymentID
allocationID
amount
poi
force
source
reason
transaction
failureReason
}
}
}
`)
`,
undefined,
)
.toPromise()

if (result.error) {
19 changes: 11 additions & 8 deletions packages/indexer-cli/src/cost.ts
Original file line number Diff line number Diff line change
@@ -193,15 +193,18 @@ export const costModels = async (
client: IndexerManagementClient,
): Promise<Partial<CostModelAttributes>[]> => {
const result = await client
.query(gql`
{
costModels {
deployment
model
variables
.query(
gql`
{
costModels {
deployment
model
variables
}
}
}
`)
`,
undefined,
)
.toPromise()

if (result.error) {
8 changes: 4 additions & 4 deletions packages/indexer-common/package.json
Original file line number Diff line number Diff line change
@@ -22,15 +22,15 @@
"clean": "rm -rf ./node_modules ./dist ./tsconfig.tsbuildinfo"
},
"dependencies": {
"@graphprotocol/common-ts": "2.0.9",
"@graphprotocol/common-ts": "2.0.10",
"@graphprotocol/cost-model": "0.1.18",
"@semiotic-labs/tap-contracts-bindings": "^1.2.1",
"@thi.ng/heaps": "1.2.38",
"@types/lodash.clonedeep": "^4.5.7",
"@types/lodash.intersection": "^4.4.7",
"@types/lodash.xor": "^4.5.7",
"@urql/core": "2.4.4",
"@urql/exchange-execute": "1.2.2",
"@urql/core": "3.1.0",
"@urql/exchange-execute": "2.1.0",
"axios": "1.6.2",
"body-parser": "1.20.2",
"cors": "2.8.5",
@@ -84,7 +84,7 @@
"ethers": "5.7.0",
"sequelize": "6.33.0",
"@ethersproject/bignumber": "5.7.0",
"@urql/exchange-execute/@urql/core": "2.4.4"
"@urql/exchange-execute/@urql/core": "3.1.0"
},
"babel": {
"presets": [],
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Address, toAddress } from '@graphprotocol/common-ts'
import { EscrowAccountResponse, EscrowAccounts } from '../escrow-accounts'

const timeout = 30000

const SENDER_ADDRESS_1 = toAddress('ffcf8fdee72ac11b5c542428b35eef5769c409f0')
const SENDER_ADDRESS_2 = toAddress('dead47df40c29949a75a6693c77834c00b8ad624')
const SENDER_ADDRESS_3 = toAddress('6aea8894b5ab5a36cdc2d8be9290046801dd5fed')

describe('EscrowAccounts', () => {
test(
'fromResponse should create correctly EscrowAccount',
() => {
const response: EscrowAccountResponse = {
escrowAccounts: [
{
sender: {
id: SENDER_ADDRESS_1,
},
balance: '1000',
},
{
sender: {
id: SENDER_ADDRESS_2,
},
balance: '2000',
},
],
}

const escrowAccounts = EscrowAccounts.fromResponse(response)

expect(escrowAccounts.getBalanceForSender(SENDER_ADDRESS_1)).toEqual(1000n)
expect(escrowAccounts.getBalanceForSender(SENDER_ADDRESS_2)).toEqual(2000n)
expect(() => escrowAccounts.getBalanceForSender(SENDER_ADDRESS_3)).toThrowError()
},
timeout,
)
test('test subtractSenderBalance', () => {
const balances = new Map<Address, bigint>()
balances.set(SENDER_ADDRESS_1, 1000n)
balances.set(SENDER_ADDRESS_2, 1000n)
balances.set(SENDER_ADDRESS_3, 1000n)
const escrowAccounts = new EscrowAccounts(balances)

expect(escrowAccounts.getBalanceForSender(SENDER_ADDRESS_1)).toEqual(1000n)

escrowAccounts.subtractSenderBalance(SENDER_ADDRESS_1, 100n)
expect(escrowAccounts.getBalanceForSender(SENDER_ADDRESS_1)).toEqual(900n)

escrowAccounts.subtractSenderBalance(SENDER_ADDRESS_1, 100n)
expect(escrowAccounts.getBalanceForSender(SENDER_ADDRESS_1)).toEqual(800n)

escrowAccounts.subtractSenderBalance(SENDER_ADDRESS_1, 600n)
expect(escrowAccounts.getBalanceForSender(SENDER_ADDRESS_1)).toEqual(200n)

expect(() =>
escrowAccounts.subtractSenderBalance(SENDER_ADDRESS_1, 400n),
).toThrowError()

escrowAccounts.subtractSenderBalance(SENDER_ADDRESS_1, 200n)

expect(escrowAccounts.getBalanceForSender(SENDER_ADDRESS_1)).toEqual(0n)
expect(escrowAccounts.getBalanceForSender(SENDER_ADDRESS_2)).toEqual(1000n)
expect(escrowAccounts.getBalanceForSender(SENDER_ADDRESS_3)).toEqual(1000n)
})
})
Loading