Skip to content

Commit 1a72fa5

Browse files
authored
Merge pull request #58 from AztecProtocol/master
PR in preparation for release 2.1.97
2 parents f82959a + 238e131 commit 1a72fa5

File tree

13 files changed

+60
-9
lines changed

13 files changed

+60
-9
lines changed

yarn-project/end-to-end/scripts/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ services:
4545
NUM_INNER_ROLLUP_TXS: ${NUM_INNER_ROLLUP_TXS:-3}
4646
NUM_OUTER_ROLLUP_PROOFS: ${NUM_OUTER_ROLLUP_PROOFS:-2}
4747
PROVERLESS: ${PROVERLESS:-true}
48+
ENABLE_SUBSIDIES: ${ENABLE_SUBSIDIES:-true}
4849
NO_BUILD: 'true'
4950
PORT: 8081
5051
depends_on:

yarn-project/falafel/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"@types/node": "^18.7.23",
7676
"@types/request-ip": "^0.0.37",
7777
"@types/source-map-support": "^0.5.4",
78-
"jest": "^28.1.3",
78+
"jest": "^29.7.0",
7979
"ts-jest": "^28.0.7",
8080
"ts-node": "^10.9.1",
8181
"tsc-watch": "^5.0.3",

yarn-project/falafel/scripts/start_e2e.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export FEE_GAS_PRICE_MULTIPLIER=0.01
2121
export FEE_PAYING_ASSET_IDS=0,1
2222
export PROVERLESS=${PROVERLESS:-true}
2323
export INITIAL_RUNTIME_CONFIG_PATH=${INITIAL_RUNTIME_CONFIG_PATH:-"./config/e2e_test_initial_config.json"}
24+
export ENABLE_SUBSIDIES=true
2425

2526
# Export contract addresses.
2627
. ./scripts/export_addresses.sh

yarn-project/falafel/src/bridge/bridge_resolver.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,41 @@ describe('Bridge Resolver', () => {
144144
getBlockchainStatus: jest.fn().mockReturnValue({
145145
allowThirdPartyContracts: false,
146146
}),
147+
getBridgeSubsidy: jest.fn((bridgeCallData: bigint) => {
148+
const fullCallData = BridgeCallData.fromBigInt(bridgeCallData);
149+
return {
150+
criteria: 1n,
151+
subsidyInGas: 10000,
152+
subsidyInWei: 25000000n,
153+
bridgeAddressId: fullCallData.bridgeAddressId,
154+
};
155+
}),
147156
} as any;
148157

149158
bridgeResolver = new BridgeResolver(bridgeConfigs, blockchain as any);
150159
});
151160

161+
it('returns bridge subsidy from the data provider contract if contract not disabled', async () => {
162+
const localBridgeResolver = new BridgeResolver(bridgeConfigs, blockchain as any);
163+
const [cd] = generateSampleBridgeCallDatas();
164+
const result = await localBridgeResolver.getBridgeSubsidy(cd.callData);
165+
expect(blockchain.getBridgeSubsidy).toHaveBeenCalledTimes(1);
166+
expect(result).toEqual({
167+
criteria: 1n,
168+
subsidyInGas: 10000,
169+
subsidyInWei: 25000000n,
170+
bridgeAddressId: BridgeCallData.fromBigInt(cd.callData).bridgeAddressId,
171+
});
172+
});
173+
174+
it('returns undefined bridge subsidy if contract has been disabled', async () => {
175+
const localBridgeResolver = new BridgeResolver(bridgeConfigs, blockchain as any, true);
176+
const [cd] = generateSampleBridgeCallDatas();
177+
const result = await localBridgeResolver.getBridgeSubsidy(cd.callData);
178+
expect(blockchain.getBridgeSubsidy).toHaveBeenCalledTimes(0);
179+
expect(result).toBeUndefined();
180+
});
181+
152182
it('returns correct bridge config', () => {
153183
const callDatas = generateSampleBridgeCallDatas();
154184
for (const cd of callDatas) {

yarn-project/falafel/src/bridge/bridge_resolver.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import { BridgeCallData } from '@aztec/barretenberg/bridge_call_data';
44
import { BridgeConfig } from '@aztec/barretenberg/rollup_provider';
55

66
export class BridgeResolver {
7-
constructor(private bridgeConfigs: BridgeConfig[], private blockchain: Blockchain) {}
7+
constructor(
8+
private bridgeConfigs: BridgeConfig[],
9+
private blockchain: Blockchain,
10+
// Added to bypass the call to the data provider contract as we encountered problems with it after sunset
11+
private disableBridgeSubsidy = false,
12+
) {}
813

914
// The aim here is to find a bridge config that corresponds to the provided bridge call data
1015
// We match on the bridge id exactly and where all bridge call data assets exist
@@ -27,6 +32,11 @@ export class BridgeResolver {
2732
}
2833

2934
public async getBridgeSubsidy(bridgeCallData: bigint) {
35+
// If the calls to the data provider have been disabled then just return undefined
36+
// This is handled upstream
37+
if (this.disableBridgeSubsidy) {
38+
return Promise.resolve(undefined);
39+
}
3040
return await this.blockchain.getBridgeSubsidy(bridgeCallData);
3141
}
3242

yarn-project/falafel/src/bridge/bridge_stats_query.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { TxFeeResolver } from '../tx_fee_resolver/index.js';
88
import { jest } from '@jest/globals';
99
import { BridgeStatsQueryHandler } from './bridge_stats_query.js';
1010

11-
jest.useFakeTimers();
11+
jest.useFakeTimers({ doNotFake: ['performance'] });
1212

1313
type Mockify<T> = {
1414
[P in keyof T]: ReturnType<typeof jest.fn>;

yarn-project/falafel/src/cli/diagnostics.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { TxDao } from '../entity/index.js';
77
import { checkDuplicateNullifiers, checkNullifiersAgainstWorldState, findNearbyTxs } from './diagnostics.js';
88
import { jest } from '@jest/globals';
99

10-
jest.useFakeTimers();
10+
jest.useFakeTimers({ doNotFake: ['performance'] });
1111

1212
type Mockify<T> = {
1313
[P in keyof T]: jest.Mock;

yarn-project/falafel/src/configurator.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ interface StartupConfig {
5757
rollupCallDataLimit: number;
5858
// To be turned on when Aztec Connect is sunset. Means that users are only allowed to exit AC. Env: EXIT_ONLY
5959
exitOnly: boolean;
60+
// Added once subsidy retrieval started failing to allow us to disable it.
61+
enableSubsidies: boolean;
6062
}
6163

6264
export interface ConfVars extends StartupConfig {
@@ -85,6 +87,7 @@ const defaultStartupConfig: StartupConfig = {
8587
proverless: false,
8688
exitOnly: false,
8789
rollupCallDataLimit: 120 * 1024,
90+
enableSubsidies: false,
8891
};
8992

9093
const defaultRuntimeConfig: RuntimeConfig = {
@@ -131,6 +134,7 @@ function getStartupConfigEnvVars(): Partial<StartupConfig> {
131134
TYPEORM_LOGGING,
132135
SERVER_AUTH_TOKEN,
133136
CALL_DATA_LIMIT_KB,
137+
ENABLE_SUBSIDIES,
134138
} = process.env;
135139

136140
const envVars: Partial<StartupConfig> = {
@@ -161,6 +165,7 @@ function getStartupConfigEnvVars(): Partial<StartupConfig> {
161165
exitOnly: EXIT_ONLY ? EXIT_ONLY === 'true' : undefined,
162166
serverAuthToken: SERVER_AUTH_TOKEN,
163167
rollupCallDataLimit: CALL_DATA_LIMIT_KB ? +CALL_DATA_LIMIT_KB * 1024 : undefined,
168+
enableSubsidies: ENABLE_SUBSIDIES ? ENABLE_SUBSIDIES === 'true' : false,
164169
};
165170
return Object.fromEntries(Object.entries(envVars).filter(e => e[1] !== undefined));
166171
}

yarn-project/falafel/src/pipeline_coordinator/publish_time_manager.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { PublishTimeManager } from './publish_time_manager.js';
22
import { jest } from '@jest/globals';
33

4-
jest.useFakeTimers();
4+
jest.useFakeTimers({ doNotFake: ['performance'] });
55

66
const currentTime = '2021-11-11T09:30:00+00:00';
77
const rollupTimeoutDurationSecs = 3600;

yarn-project/falafel/src/pipeline_coordinator/rollup_coordinator.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { PublishTimeManager, RollupTimeouts } from './publish_time_manager.js';
2121
import { RollupCoordinator } from './rollup_coordinator.js';
2222
import { jest } from '@jest/globals';
2323

24-
jest.useFakeTimers();
24+
jest.useFakeTimers({ doNotFake: ['performance'] });
2525

2626
type Mockify<T> = {
2727
[P in keyof T]: jest.Mock;

0 commit comments

Comments
 (0)