diff --git a/yarn-project/end-to-end/scripts/docker-compose.yml b/yarn-project/end-to-end/scripts/docker-compose.yml index 295f61668..f9508e014 100644 --- a/yarn-project/end-to-end/scripts/docker-compose.yml +++ b/yarn-project/end-to-end/scripts/docker-compose.yml @@ -45,6 +45,7 @@ services: NUM_INNER_ROLLUP_TXS: ${NUM_INNER_ROLLUP_TXS:-3} NUM_OUTER_ROLLUP_PROOFS: ${NUM_OUTER_ROLLUP_PROOFS:-2} PROVERLESS: ${PROVERLESS:-true} + ENABLE_SUBSIDIES: ${ENABLE_SUBSIDIES:-true} NO_BUILD: 'true' PORT: 8081 depends_on: diff --git a/yarn-project/falafel/package.json b/yarn-project/falafel/package.json index 547e9a9d6..d2fde07d0 100644 --- a/yarn-project/falafel/package.json +++ b/yarn-project/falafel/package.json @@ -75,7 +75,7 @@ "@types/node": "^18.7.23", "@types/request-ip": "^0.0.37", "@types/source-map-support": "^0.5.4", - "jest": "^28.1.3", + "jest": "^29.7.0", "ts-jest": "^28.0.7", "ts-node": "^10.9.1", "tsc-watch": "^5.0.3", diff --git a/yarn-project/falafel/scripts/start_e2e.sh b/yarn-project/falafel/scripts/start_e2e.sh index 541a190a1..eaad12bd3 100755 --- a/yarn-project/falafel/scripts/start_e2e.sh +++ b/yarn-project/falafel/scripts/start_e2e.sh @@ -21,6 +21,7 @@ export FEE_GAS_PRICE_MULTIPLIER=0.01 export FEE_PAYING_ASSET_IDS=0,1 export PROVERLESS=${PROVERLESS:-true} export INITIAL_RUNTIME_CONFIG_PATH=${INITIAL_RUNTIME_CONFIG_PATH:-"./config/e2e_test_initial_config.json"} +export ENABLE_SUBSIDIES=true # Export contract addresses. . ./scripts/export_addresses.sh diff --git a/yarn-project/falafel/src/bridge/bridge_resolver.test.ts b/yarn-project/falafel/src/bridge/bridge_resolver.test.ts index 9a63a22de..67183f6dd 100644 --- a/yarn-project/falafel/src/bridge/bridge_resolver.test.ts +++ b/yarn-project/falafel/src/bridge/bridge_resolver.test.ts @@ -144,11 +144,41 @@ describe('Bridge Resolver', () => { getBlockchainStatus: jest.fn().mockReturnValue({ allowThirdPartyContracts: false, }), + getBridgeSubsidy: jest.fn((bridgeCallData: bigint) => { + const fullCallData = BridgeCallData.fromBigInt(bridgeCallData); + return { + criteria: 1n, + subsidyInGas: 10000, + subsidyInWei: 25000000n, + bridgeAddressId: fullCallData.bridgeAddressId, + }; + }), } as any; bridgeResolver = new BridgeResolver(bridgeConfigs, blockchain as any); }); + it('returns bridge subsidy from the data provider contract if contract not disabled', async () => { + const localBridgeResolver = new BridgeResolver(bridgeConfigs, blockchain as any); + const [cd] = generateSampleBridgeCallDatas(); + const result = await localBridgeResolver.getBridgeSubsidy(cd.callData); + expect(blockchain.getBridgeSubsidy).toHaveBeenCalledTimes(1); + expect(result).toEqual({ + criteria: 1n, + subsidyInGas: 10000, + subsidyInWei: 25000000n, + bridgeAddressId: BridgeCallData.fromBigInt(cd.callData).bridgeAddressId, + }); + }); + + it('returns undefined bridge subsidy if contract has been disabled', async () => { + const localBridgeResolver = new BridgeResolver(bridgeConfigs, blockchain as any, true); + const [cd] = generateSampleBridgeCallDatas(); + const result = await localBridgeResolver.getBridgeSubsidy(cd.callData); + expect(blockchain.getBridgeSubsidy).toHaveBeenCalledTimes(0); + expect(result).toBeUndefined(); + }); + it('returns correct bridge config', () => { const callDatas = generateSampleBridgeCallDatas(); for (const cd of callDatas) { diff --git a/yarn-project/falafel/src/bridge/bridge_resolver.ts b/yarn-project/falafel/src/bridge/bridge_resolver.ts index 2c6a40720..c3b0fb290 100644 --- a/yarn-project/falafel/src/bridge/bridge_resolver.ts +++ b/yarn-project/falafel/src/bridge/bridge_resolver.ts @@ -4,7 +4,12 @@ import { BridgeCallData } from '@aztec/barretenberg/bridge_call_data'; import { BridgeConfig } from '@aztec/barretenberg/rollup_provider'; export class BridgeResolver { - constructor(private bridgeConfigs: BridgeConfig[], private blockchain: Blockchain) {} + constructor( + private bridgeConfigs: BridgeConfig[], + private blockchain: Blockchain, + // Added to bypass the call to the data provider contract as we encountered problems with it after sunset + private disableBridgeSubsidy = false, + ) {} // The aim here is to find a bridge config that corresponds to the provided bridge call data // We match on the bridge id exactly and where all bridge call data assets exist @@ -27,6 +32,11 @@ export class BridgeResolver { } public async getBridgeSubsidy(bridgeCallData: bigint) { + // If the calls to the data provider have been disabled then just return undefined + // This is handled upstream + if (this.disableBridgeSubsidy) { + return Promise.resolve(undefined); + } return await this.blockchain.getBridgeSubsidy(bridgeCallData); } diff --git a/yarn-project/falafel/src/bridge/bridge_stats_query.test.ts b/yarn-project/falafel/src/bridge/bridge_stats_query.test.ts index 1c01f5f8e..2790734b4 100644 --- a/yarn-project/falafel/src/bridge/bridge_stats_query.test.ts +++ b/yarn-project/falafel/src/bridge/bridge_stats_query.test.ts @@ -8,7 +8,7 @@ import { TxFeeResolver } from '../tx_fee_resolver/index.js'; import { jest } from '@jest/globals'; import { BridgeStatsQueryHandler } from './bridge_stats_query.js'; -jest.useFakeTimers(); +jest.useFakeTimers({ doNotFake: ['performance'] }); type Mockify = { [P in keyof T]: ReturnType; diff --git a/yarn-project/falafel/src/cli/diagnostics.test.ts b/yarn-project/falafel/src/cli/diagnostics.test.ts index 3dc0a059c..c55e19b98 100644 --- a/yarn-project/falafel/src/cli/diagnostics.test.ts +++ b/yarn-project/falafel/src/cli/diagnostics.test.ts @@ -7,7 +7,7 @@ import { TxDao } from '../entity/index.js'; import { checkDuplicateNullifiers, checkNullifiersAgainstWorldState, findNearbyTxs } from './diagnostics.js'; import { jest } from '@jest/globals'; -jest.useFakeTimers(); +jest.useFakeTimers({ doNotFake: ['performance'] }); type Mockify = { [P in keyof T]: jest.Mock; diff --git a/yarn-project/falafel/src/configurator.ts b/yarn-project/falafel/src/configurator.ts index bf50782ce..7d2f3cf09 100644 --- a/yarn-project/falafel/src/configurator.ts +++ b/yarn-project/falafel/src/configurator.ts @@ -57,6 +57,8 @@ interface StartupConfig { rollupCallDataLimit: number; // To be turned on when Aztec Connect is sunset. Means that users are only allowed to exit AC. Env: EXIT_ONLY exitOnly: boolean; + // Added once subsidy retrieval started failing to allow us to disable it. + enableSubsidies: boolean; } export interface ConfVars extends StartupConfig { @@ -85,6 +87,7 @@ const defaultStartupConfig: StartupConfig = { proverless: false, exitOnly: false, rollupCallDataLimit: 120 * 1024, + enableSubsidies: false, }; const defaultRuntimeConfig: RuntimeConfig = { @@ -131,6 +134,7 @@ function getStartupConfigEnvVars(): Partial { TYPEORM_LOGGING, SERVER_AUTH_TOKEN, CALL_DATA_LIMIT_KB, + ENABLE_SUBSIDIES, } = process.env; const envVars: Partial = { @@ -161,6 +165,7 @@ function getStartupConfigEnvVars(): Partial { exitOnly: EXIT_ONLY ? EXIT_ONLY === 'true' : undefined, serverAuthToken: SERVER_AUTH_TOKEN, rollupCallDataLimit: CALL_DATA_LIMIT_KB ? +CALL_DATA_LIMIT_KB * 1024 : undefined, + enableSubsidies: ENABLE_SUBSIDIES ? ENABLE_SUBSIDIES === 'true' : false, }; return Object.fromEntries(Object.entries(envVars).filter(e => e[1] !== undefined)); } diff --git a/yarn-project/falafel/src/pipeline_coordinator/publish_time_manager.test.ts b/yarn-project/falafel/src/pipeline_coordinator/publish_time_manager.test.ts index 4989ddcb2..7293617c0 100644 --- a/yarn-project/falafel/src/pipeline_coordinator/publish_time_manager.test.ts +++ b/yarn-project/falafel/src/pipeline_coordinator/publish_time_manager.test.ts @@ -1,7 +1,7 @@ import { PublishTimeManager } from './publish_time_manager.js'; import { jest } from '@jest/globals'; -jest.useFakeTimers(); +jest.useFakeTimers({ doNotFake: ['performance'] }); const currentTime = '2021-11-11T09:30:00+00:00'; const rollupTimeoutDurationSecs = 3600; diff --git a/yarn-project/falafel/src/pipeline_coordinator/rollup_coordinator.test.ts b/yarn-project/falafel/src/pipeline_coordinator/rollup_coordinator.test.ts index 349a7d30d..23c1aa546 100644 --- a/yarn-project/falafel/src/pipeline_coordinator/rollup_coordinator.test.ts +++ b/yarn-project/falafel/src/pipeline_coordinator/rollup_coordinator.test.ts @@ -21,7 +21,7 @@ import { PublishTimeManager, RollupTimeouts } from './publish_time_manager.js'; import { RollupCoordinator } from './rollup_coordinator.js'; import { jest } from '@jest/globals'; -jest.useFakeTimers(); +jest.useFakeTimers({ doNotFake: ['performance'] }); type Mockify = { [P in keyof T]: jest.Mock; diff --git a/yarn-project/falafel/src/rollup_creator.test.ts b/yarn-project/falafel/src/rollup_creator.test.ts index bda431d0b..46739a6cf 100644 --- a/yarn-project/falafel/src/rollup_creator.test.ts +++ b/yarn-project/falafel/src/rollup_creator.test.ts @@ -16,7 +16,7 @@ import { RollupDb } from './rollup_db/index.js'; import { TxFeeResolver } from './tx_fee_resolver/index.js'; import { jest } from '@jest/globals'; -jest.useFakeTimers(); +jest.useFakeTimers({ doNotFake: ['performance'] }); type Mockify = { [P in keyof T]: jest.Mock; diff --git a/yarn-project/falafel/src/server.ts b/yarn-project/falafel/src/server.ts index fce43adc8..419c47284 100644 --- a/yarn-project/falafel/src/server.ts +++ b/yarn-project/falafel/src/server.ts @@ -60,6 +60,7 @@ export class Server { numOuterRollupProofs, proverless, rollupCallDataLimit, + enableSubsidies, runtimeConfig: { publishInterval, flushAfterIdle, @@ -77,7 +78,10 @@ export class Server { const noteAlgo = new NoteAlgorithms(barretenberg); this.blake = new Blake2s(barretenberg); - this.bridgeResolver = new BridgeResolver(bridgeConfigs, blockchain); + if (!enableSubsidies) { + this.log(`Starting with bridge subsidies disabled.`); + } + this.bridgeResolver = new BridgeResolver(bridgeConfigs, blockchain, !enableSubsidies); this.txFeeResolver = this.createTxFeeResolver(); diff --git a/yarn-project/falafel/src/tx_fee_resolver/tx_fee_resolver.test.ts b/yarn-project/falafel/src/tx_fee_resolver/tx_fee_resolver.test.ts index a2d34f472..7abc06a84 100644 --- a/yarn-project/falafel/src/tx_fee_resolver/tx_fee_resolver.test.ts +++ b/yarn-project/falafel/src/tx_fee_resolver/tx_fee_resolver.test.ts @@ -6,7 +6,7 @@ import { BridgeResolver } from '../bridge/index.js'; import { TxFeeResolver } from './index.js'; import { jest } from '@jest/globals'; -jest.useFakeTimers(); +jest.useFakeTimers({ doNotFake: ['performance'] }); type Mockify = { [P in keyof T]: jest.Mock;