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

nightfall mainnet deployment #664

Merged
merged 2 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions cli/lib/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ export const DEFAULT_BLOCK_STAKE = 1;
export const WEBSOCKET_PING_TIME = 15000;

export const GAS_MULTIPLIER = Number(process.env.GAS_MULTIPLIER) || 2;
export const GAS = process.env.GAS || 8000000;
export const GAS_PRICE = process.env.GAS_PRICE || '20000000000';
14 changes: 13 additions & 1 deletion cli/lib/nf3.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
DEFAULT_FEE,
WEBSOCKET_PING_TIME,
GAS_MULTIPLIER,
GAS,
GAS_PRICE,
} from './constants.mjs';

// TODO when SDK is refactored such that these functions are split by user, proposer and challenger,
Expand Down Expand Up @@ -220,10 +222,20 @@ class Nf3 {
) {
// if (!this.nonce)
// this.nonce = await this.web3.eth.getTransactionCount(this.ethereumAddress, 'pending');
let gasPrice = 20000000000;

// let gasPrice = 200000000000;
/*
const gas = (await this.web3.eth.getBlock('latest')).gasLimit;
const blockGasPrice = GAS_MULTIPLIER * Number(await this.web3.eth.getGasPrice());
if (blockGasPrice > gasPrice) gasPrice = blockGasPrice;
*/
let gasPrice = GAS_PRICE;
const blockGasPrice = GAS_MULTIPLIER * Number(await this.web3.eth.getGasPrice());
if (blockGasPrice > gasPrice) gasPrice = blockGasPrice;
const gas = GAS;

// const gasPrice = GAS_PRICE;
// const gas = GAS;

const tx = {
from: this.ethereumAddress,
Expand Down
1 change: 1 addition & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
SHIELD_CONTRACT_NAME: 'Shield',
CHALLENGES_CONTRACT_NAME: 'Challenges',
STATE_CONTRACT_NAME: 'State',
STATE_GENESIS_BLOCK: process.env.STATE_GENESIS_BLOCK,
BLOCK_PROPOSED_EVENT_NAME: 'BlockProposed',
CIRCUITS_HOME: process.env.CIRCUITS_HOME || '/app/circuits/',
ALWAYS_DO_TRUSTED_SETUP: process.env.ALWAYS_DO_TRUSTED_SETUP || false,
Expand Down
11 changes: 9 additions & 2 deletions nightfall-client/src/services/state-sync.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ import { waitForContract } from '../event-handlers/subscribe.mjs';
import blockProposedEventHandler from '../event-handlers/block-proposed.mjs';
import rollbackEventHandler from '../event-handlers/rollback.mjs';

const { MONGO_URL, COMMITMENTS_DB, COMMITMENTS_COLLECTION, STATE_CONTRACT_NAME } = config;
const {
MONGO_URL,
COMMITMENTS_DB,
COMMITMENTS_COLLECTION,
STATE_CONTRACT_NAME,
STATE_GENESIS_BLOCK,
} = config;

const syncState = async (fromBlock = 'earliest', toBlock = 'latest', eventFilter = 'allEvents') => {
console.log('From block', fromBlock);
const stateContractInstance = await waitForContract(STATE_CONTRACT_NAME); // Rollback, BlockProposed

const pastStateEvents = await stateContractInstance.getPastEvents(eventFilter, {
Expand Down Expand Up @@ -50,6 +57,6 @@ export const initialClientSync = async () => {
const firstSeenBlockNumber = Math.min(...commitmentBlockNumbers);
logger.info(`firstSeenBlockNumber: ${firstSeenBlockNumber}`);
// fistSeenBlockNumber can be infinity if the commitmentBlockNumbers array is empty
if (firstSeenBlockNumber === Infinity) return syncState();
if (firstSeenBlockNumber === Infinity) return syncState(STATE_GENESIS_BLOCK);
return syncState(firstSeenBlockNumber);
};
Loading