Skip to content

fix: optimist resync over a bad block, tidy docker-compose yml #870

New issue

Have a question about this project? Sign up for a free account to open an issue and contact its maintainers and the community.

By clicking “Sign up for ”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on ? Sign in to your account

Merged
merged 33 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
fb35fa5
feat: recover from bad block on resync
WestladAug 2, 2022
ff24a77
feat: adds a bad block
WestladAug 4, 2022
109dbb0
fix: recover block using sdk
WestladAug 5, 2022
e2b8b0c
feat: docker compose control
WestladAug 9, 2022
bf0d4d8
fix: merge issues
WestladAug 9, 2022
21bff47
fix: rebase issues
WestladAug 9, 2022
94db03b
feat: resync works over bad block
WestladAug 11, 2022
03394b1
feat: remove unnecessary containers
WestladAug 11, 2022
cf209df
fix: remove unused exports
WestladAug 11, 2022
fac28ab
fix: remove unused exports
WestladAug 11, 2022
e009d33
fix: merge issues
WestladAug 12, 2022
6f640f8
fix: rebase issues
WestladAug 12, 2022
4dbec83
fix: ci test
WestladAug 12, 2022
3eb4bca
fix: remove references to redundant containers
WestladAug 12, 2022
5e559b0
fix: remove challenger registration from adversary test
WestladAug 12, 2022
0c804e7
fix: adversary test
WestladAug 12, 2022
e5e0033
fix: adversary test
WestladAug 12, 2022
82b07f2
fix: gas test
WestladAug 15, 2022
e769346
fix: partial adversary fix
WestladAug 15, 2022
f580aca
fix: package lock
WestladAug 15, 2022
680dba9
fix: dependencies
WestladAug 15, 2022
7f1f4bb
fix: re-add docker-compose dependency - fixes got issue
WestladAug 16, 2022
5850207
fix: re-add optimist sync test
WestladAug 16, 2022
7afc359
fix: start challenger after optimist sync is done in all cases
WestladAug 16, 2022
9edbd83
fix: merge conflicts
WestladSep 5, 2022
8576ffe
fix: docker-compose does not build in parallel well
WestladSep 5, 2022
daa4ef7
fix: package lock
WestladSep 5, 2022
01500f3
fix: merge
WestladSep 6, 2022
67e01fa
fix: adverary test
WestladSep 6, 2022
5e219bb
fix: update insecure package
WestladSep 6, 2022
7c33a49
fix: package issues
WestladSep 6, 2022
bec3d11
Merge branch 'master' into westlad/challenge-sync
WestladSep 6, 2022
e1fa280
fix: circuits tests
WestladSep 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
Next Next commit
fix: recover block using sdk
  • Loading branch information
@Westlad
Westlad committedAug 15, 2022
commit 109dbb00a1b3ceccefb13ec6000274e44521e1d2
2 changes: 1 addition & 1 deletion package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"test-erc721-tokens": "LOG_LEVEL=error mocha --timeout 0 --bail --exit test/e2e/tokens/erc721.test.mjs ",
"test-erc1155-tokens": "LOG_LEVEL=error mocha --timeout 0 --bail --exit test/e2e/tokens/erc1155.test.mjs ",
"test-erc20-cli": "LOG_LEVEL=debug mocha --timeout 0 --bail --exit test/client/erc20.test.mjs ",
"test-optimist-sync": "LOG_LEVEL=debug mocha --timeout 0 --bail --exit test/optimist-resync.test.mjs",
"test-optimist-sync": "LOG_LEVEL=error mocha --timeout 0 --bail --exit test/optimist-resync.test.mjs",
"lint": "eslint . --ext js,mjs,jsx,ts,tsx && find-unused-exports",
"prepare": "husky install",
"doc:build:sdk": "jsdoc -c jsdoc.json cli/lib/nf3.mjs",
Expand Down
26 changes: 9 additions & 17 deletions test/optimist-resync.test.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,10 +6,6 @@ import config from 'config';
import Nf3 from '../cli/lib/nf3.mjs';
import { depositNTransactions, Web3Client } from './utils.mjs';
import logger from '../common-files/utils/logger.mjs';
import {
getProposeBlockCalldata,
setWeb3,
} from '../nightfall-optimist/src/services/process-calldata.mjs';
import { buildBlockSolidityStruct } from '../nightfall-optimist/src/services/block-utils.mjs';
import Transaction from '../common-files/classes/transaction.mjs';
// so we can use require with mjs file
Expand DownExpand Up@@ -38,7 +34,6 @@ const web3Client = new Web3Client();
let erc20Address;
let stateAddress;
let eventLogs = [];
let eventsSeen = [];

/*
This function tries to zero the number of unprocessed transactions in the optimist node
Expand DownExpand Up@@ -99,7 +94,6 @@ describe('ERC20 tests', () => {
web3Client.subscribeTo('logs', eventLogs, { address: stateAddress });

await emptyL2(nf3Users[0]);
setWeb3(web3Client.getWeb3());
});

afterEach(async () => {
Expand All@@ -110,7 +104,7 @@ describe('ERC20 tests', () => {
it('should make a block of two deposit transactions, then a bad block containing the same deposit transactions', async function () {
console.log(` Sending ${txPerBlock} deposits...`);
// We create enough transactions to fill blocks full of deposits.
const depositTransactions = await depositNTransactions(
await depositNTransactions(
nf3Users[0],
txPerBlock,
erc20Address,
Expand All@@ -119,15 +113,13 @@ describe('ERC20 tests', () => {
tokenId,
fee,
);
({ eventLogs, eventsSeen } = await web3Client.waitForEvent(eventLogs, ['blockProposed']));
const totalGas = depositTransactions.reduce((acc, { gasUsed }) => acc + Number(gasUsed), 0);
logger.debug(` Average Gas used was ${Math.ceil(totalGas / txPerBlock)}`);
// now we have a single block proposed, full of deposits. the next job is to make a bad blocks
// we can do that by recovering the blockPropsed transaction that's just happened, messing with it,
// re-signing it with the proposer's key and sending it in again.
const { block, transactions } = await getProposeBlockCalldata({
transactionHash: eventsSeen[0].log.transactionHash,
});
// we can use the emitter than nf3 provides to get the block and transactions we've just made.
// The promise resolves once the block is on-chain.
const { block, transactions } = await new Promise(resolve =>
blockProposeEmitter.on('receipt', (receipt, b, t) =>
resolve({ receipt, block: b, transactions: t }),
),
);
// update the block so we can submit it again
block.previousBlockHash = block.blockHash;
block.blockNumberL2++;
Expand All@@ -143,7 +135,7 @@ describe('ERC20 tests', () => {
const newTx = `0xa9cb3b6f${encodedParams.slice(2)}`;
logger.debug('Resubmitting the same transactions in the next block');
web3Client.submitTransaction(newTx, signingKeys.proposer1, stateAddress, 8000000, 1);
({ eventLogs, eventsSeen } = await web3Client.waitForEvent(eventLogs, ['blockProposed']));
({ eventLogs } = await web3Client.waitForEvent(eventLogs, ['blockProposed']));
});
});

Expand Down