Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Merged
merged 33 commits into from
Sep 9, 2022
Merged
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
Westlad Aug 2, 2022
ff24a77
feat: adds a bad block
Westlad Aug 4, 2022
109dbb0
fix: recover block using sdk
Westlad Aug 5, 2022
e2b8b0c
feat: docker compose control
Westlad Aug 9, 2022
bf0d4d8
fix: merge issues
Westlad Aug 9, 2022
21bff47
fix: rebase issues
Westlad Aug 9, 2022
94db03b
feat: resync works over bad block
Westlad Aug 11, 2022
03394b1
feat: remove unnecessary containers
Westlad Aug 11, 2022
cf209df
fix: remove unused exports
Westlad Aug 11, 2022
fac28ab
fix: remove unused exports
Westlad Aug 11, 2022
e009d33
fix: merge issues
Westlad Aug 12, 2022
6f640f8
fix: rebase issues
Westlad Aug 12, 2022
4dbec83
fix: ci test
Westlad Aug 12, 2022
3eb4bca
fix: remove references to redundant containers
Westlad Aug 12, 2022
5e559b0
fix: remove challenger registration from adversary test
Westlad Aug 12, 2022
0c804e7
fix: adversary test
Westlad Aug 12, 2022
e5e0033
fix: adversary test
Westlad Aug 12, 2022
82b07f2
fix: gas test
Westlad Aug 15, 2022
e769346
fix: partial adversary fix
Westlad Aug 15, 2022
f580aca
fix: package lock
Westlad Aug 15, 2022
680dba9
fix: dependencies
Westlad Aug 15, 2022
7f1f4bb
fix: re-add docker-compose dependency - fixes got issue
Westlad Aug 16, 2022
5850207
fix: re-add optimist sync test
Westlad Aug 16, 2022
7afc359
fix: start challenger after optimist sync is done in all cases
Westlad Aug 16, 2022
9edbd83
fix: merge conflicts
Westlad Sep 5, 2022
8576ffe
fix: docker-compose does not build in parallel well
Westlad Sep 5, 2022
daa4ef7
fix: package lock
Westlad Sep 5, 2022
01500f3
fix: merge
Westlad Sep 6, 2022
67e01fa
fix: adverary test
Westlad Sep 6, 2022
5e219bb
fix: update insecure package
Westlad Sep 6, 2022
7c33a49
fix: package issues
Westlad Sep 6, 2022
bec3d11
Merge branch 'master' into westlad/challenge-sync
Westlad Sep 6, 2022
e1fa280
fix: circuits tests
Westlad Sep 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
Prev Previous commit
Next Next commit
fix: partial adversary fix
  • Loading branch information
Westlad committed Aug 15, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit e7693463c12178fb1551ce00377483861b9b0484
10 changes: 5 additions & 5 deletions cli/lib/nf3.mjs
Original file line number Diff line number Diff line change
@@ -219,7 +219,7 @@ class Nf3 {
data: unsignedTransaction,
});
} catch (error) {
logger.warn(`estimateGas failed. Falling back to constant value`);
// logger.warn(`estimateGas failed. Falling back to constant value`);
gasLimit = GAS; // backup if estimateGas failed
}
return Math.ceil(Number(gasLimit) * GAS_MULTIPLIER); // 50% seems a more than reasonable buffer.
@@ -232,11 +232,11 @@ class Nf3 {
const res = (await axios.get(GAS_ESTIMATE_ENDPOINT)).data.result;
proposedGasPrice = Number(res?.ProposeGasPrice) * 10 ** 9;
} catch (error) {
logger.warn('Gas Estimation Failed, using previous block gasPrice');
// logger.warn('Gas Estimation Failed, using previous block gasPrice');
try {
proposedGasPrice = Number(await this.web3.eth.getGasPrice());
} catch (err) {
logger.warn('Failed to get previous block gasprice. Falling back to default');
// logger.warn('Failed to get previous block gasprice. Falling back to default');
proposedGasPrice = GAS_PRICE;
}
}
@@ -272,14 +272,14 @@ class Nf3 {
gas,
gasPrice,
};
logger.debug(`nf3 processing submitTransaction with transaction data ${tx.data}`);
// logger.debug(`nf3 processing submitTransaction with transaction data ${tx.data}`);
if (this.ethereumSigningKey) {
const signed = await this.web3.eth.accounts.signTransaction(tx, this.ethereumSigningKey);
const promiseTest = new Promise((resolve, reject) => {
this.web3.eth
.sendSignedTransaction(signed.rawTransaction)
.once('receipt', receipt => {
logger.debug(`Transaction ${receipt.transactionHash} has been receipted.`);
// logger.debug(`Transaction ${receipt.transactionHash} has been receipted.`);
resolve(receipt);
})
.on('error', err => {
2 changes: 1 addition & 1 deletion config/default.js
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ module.exports = {
// Keep keepalive interval small so that socket doesn't die
keepaliveInterval: 1500,
},
timeout: 3600000,
timeout: 0,
reconnect: {
auto: true,
delay: 5000, // ms
1 change: 1 addition & 0 deletions setup-nightfall
Original file line number Diff line number Diff line change
@@ -10,3 +10,4 @@ docker-compose -f docker-compose.yml -f docker-compose.dev.yml build client
docker-compose -f docker-compose.yml -f docker-compose.dev.yml build optimist
docker-compose -f docker-compose.yml -f docker-compose.dev.yml build worker
docker-compose -f docker-compose.yml -f docker-compose.dev.yml build hosted-utils-api-server
docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.adversary.yml build adversary1
4 changes: 3 additions & 1 deletion test/adversary.test.mjs
Original file line number Diff line number Diff line change
@@ -163,7 +163,7 @@ describe('Testing with an adversary', () => {
nDeposits++;
expectedBalance += value2;
}

console.log('Number of deposits', nDeposits);
for (let i = 0; i < TEST_LENGTH; i++) {
await waitForSufficientBalance(
nf3User,
@@ -202,11 +202,13 @@ describe('Testing with an adversary', () => {
nTransfers++;
}
}
console.log('Number of transfers', nTransfers);
for (let k = 0; k < TRANSACTIONS_PER_BLOCK - 1; k++) {
await nf3User.deposit(ercAddress, tokenType, value2, tokenId, fee);
nDeposits++;
expectedBalance += value2;
}
console.log('Number of deposits', nDeposits);
await new Promise(resolve => setTimeout(resolve, TX_WAIT)); // this may need to be longer on a real blockchain
console.log(`Completed ${i + 1} pings`);
}
5 changes: 2 additions & 3 deletions test/adversary/transpile-adversary.mjs
Original file line number Diff line number Diff line change
@@ -43,11 +43,10 @@ const transpileBlockProposed = _pathToSrc => {
let srcFile = fs.readFileSync(_pathToSrc, 'utf-8');

// We need to take into account variable NONSTOP_QUEUE_AFTER_INVALID_BLOCK
const regexReplaceComponents =
/(await enqueueEvent\(\(\) => logger.info\('Stop Until Rollback'\), 2\);)/g;
const regexReplaceComponents = /(await enqueueEvent\(commitToChallenge, 2, txDataToSign\);)/g;
const reComponent = `logger.info(\`NONSTOP_QUEUE_AFTER_INVALID_BLOCK: \${process.env.NONSTOP_QUEUE_AFTER_INVALID_BLOCK}\`);
if (!process.env.NONSTOP_QUEUE_AFTER_INVALID_BLOCK)
await enqueueEvent(() => logger.info('Stop Until Rollback'), 2);`;
await enqueueEvent(commitToChallenge, 2, txDataToSign);`;
srcFile = `/* THIS FILE CONTAINS CODE THAT HAS BEEN AUTOGENERATED DO NOT MODIFY MANUALLY */\n${srcFile.replace(
regexReplaceComponents,
reComponent,