Skip to content

Commit

Permalink
Merge pull request #58 from AztecProtocol/master
Browse files Browse the repository at this point in the history
PR in preparation for release 2.1.97
  • Loading branch information
PhilWindle authored Dec 11, 2023
2 parents f82959a + 238e131 commit 1a72fa5
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 9 deletions.
1 change: 1 addition & 0 deletions yarn-project/end-to-end/scripts/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/falafel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions yarn-project/falafel/scripts/start_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions yarn-project/falafel/src/bridge/bridge_resolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 11 additions & 1 deletion yarn-project/falafel/src/bridge/bridge_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/falafel/src/bridge/bridge_stats_query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = {
[P in keyof T]: ReturnType<typeof jest.fn>;
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/falafel/src/cli/diagnostics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = {
[P in keyof T]: jest.Mock;
Expand Down
5 changes: 5 additions & 0 deletions yarn-project/falafel/src/configurator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -85,6 +87,7 @@ const defaultStartupConfig: StartupConfig = {
proverless: false,
exitOnly: false,
rollupCallDataLimit: 120 * 1024,
enableSubsidies: false,
};

const defaultRuntimeConfig: RuntimeConfig = {
Expand Down Expand Up @@ -131,6 +134,7 @@ function getStartupConfigEnvVars(): Partial<StartupConfig> {
TYPEORM_LOGGING,
SERVER_AUTH_TOKEN,
CALL_DATA_LIMIT_KB,
ENABLE_SUBSIDIES,
} = process.env;

const envVars: Partial<StartupConfig> = {
Expand Down Expand Up @@ -161,6 +165,7 @@ function getStartupConfigEnvVars(): Partial<StartupConfig> {
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));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = {
[P in keyof T]: jest.Mock;
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/falafel/src/rollup_creator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = {
[P in keyof T]: jest.Mock;
Expand Down
6 changes: 5 additions & 1 deletion yarn-project/falafel/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class Server {
numOuterRollupProofs,
proverless,
rollupCallDataLimit,
enableSubsidies,
runtimeConfig: {
publishInterval,
flushAfterIdle,
Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = {
[P in keyof T]: jest.Mock;
Expand Down

0 comments on commit 1a72fa5

Please sign in to comment.