Compare commits

..

3 commits

Author SHA1 Message Date
AlienTornadosaurusHex
9e3861c56f enable avax
Signed-off-by: AlienTornadosaurusHex <>
2023-07-04 18:25:01 +00:00
AlienTornadosaurusHex
03543f87a8 update README
Signed-off-by: AlienTornadosaurusHex <>
2023-07-04 18:20:44 +00:00
AlienTornadosaurusHex
02f79a0de0 allow setting sync interval for blocks
Signed-off-by: AlienTornadosaurusHex <>
2023-07-04 13:57:33 +00:00
9 changed files with 44 additions and 30 deletions

View file

@ -1,6 +1,6 @@
# Tornado Cash Classic UI # Tornado Cash Classic UI
> UI for non-custodial Ethereum Privacy solution > Self-hostable Tornado Cash UI software for interacting with the protocol
## Building locally ## Building locally
@ -31,29 +31,42 @@ For detailed explanation on how things work, checkout [Nuxt.js docs](https://nux
## Update cached files ## Update cached files
- For update deposits and withdrawals events use `yarn update:events {chainId}` - To update deposit and withdrawal events use `yarn update:events {chainId} {optional: tokenOrEvent} {optional: tokenOrEvent}`
- For update encrypted notes use `yarn update:encrypted {chainId}` - To update encrypted notes use `yarn update:encrypted {chainId}`
- For update merkle tree use `yarn update:tree {chainId}` - To update merkle tree use `yarn update:tree {chainId}`
#### NOTE! #### NOTE!
After update cached files do not forget to use `yarn update:zip` After updating cached files do not forget to use `yarn update:zip`.
### Example for Ethereum Mainnet: ### Example for Ethereum Mainnet:
``` You may set in [`networkConfig.js`](./networkConfig.js) the `blockSyncInterval` (def: 10_000) to the maximum value allowed by your RPC provider. Command usage follows below.
yarn update:events 1
yarn update:encrypted 1
yarn update:tree 1
```bash
# Updating events with just the required chain id parameter
yarn update:events 1
# Updating events for only one token across all instances on that network
yarn update:events 1 dai
# Updating events for only one event on only some network
yarn update:events 1 deposit
# Both
yarn update:events 1 dai deposit
# Updating encrypted notes for some chain id
yarn update:encrypted 1
# Updating trees for some chain id
yarn update:tree 1
# Finally zips must be updated
yarn update:zip yarn update:zip
``` ```
### Example for Binance Smart Chain: ### Example for Binance Smart Chain:
``` ```bash
yarn update:events 56 yarn update:events 56
yarn update:events 56 bnb
yarn update:events 56 bnb deposit
yarn update:encrypted 56 yarn update:encrypted 56
yarn update:tree 56
yarn update:zip yarn update:zip
``` ```

View file

@ -1,4 +1,5 @@
export const enabledChains = ['1', '10', '56', '100', '137', '42161'] export const blockSyncInterval = 10000
export const enabledChains = ['1', '10', '56', '100', '137', '43114', '42161']
export const chainsWithEncryptedNotes = ['1', '5', '56', '100', '137'] export const chainsWithEncryptedNotes = ['1', '5', '56', '100', '137']
export default { export default {
netId1: { netId1: {

View file

@ -3,7 +3,7 @@ import { loadCachedEvents } from './helpers'
const EVENTS_PATH = './static/events/' const EVENTS_PATH = './static/events/'
async function main() { function main() {
for (const netId of enabledChains) { for (const netId of enabledChains) {
const config = networkConfig[`netId${netId}`] const config = networkConfig[`netId${netId}`]
const { constants, tokens, nativeCurrency, deployedBlock } = config const { constants, tokens, nativeCurrency, deployedBlock } = config
@ -14,7 +14,7 @@ async function main() {
for (const [instance] of Object.entries(CONTRACTS)) { for (const [instance] of Object.entries(CONTRACTS)) {
console.log(`\n instanceDenomation - ${instance}`) console.log(`\n instanceDenomation - ${instance}`)
const withdrawalCachedEvents = await loadCachedEvents({ const withdrawalCachedEvents = loadCachedEvents({
name: `withdrawals_${netId}_${nativeCurrency}_${instance}.json`, name: `withdrawals_${netId}_${nativeCurrency}_${instance}.json`,
directory: EVENTS_PATH, directory: EVENTS_PATH,
deployedBlock deployedBlock
@ -24,7 +24,7 @@ async function main() {
console.log('cachedEvents count - ', withdrawalCachedEvents.events.length) console.log('cachedEvents count - ', withdrawalCachedEvents.events.length)
console.log('lastBlock - ', withdrawalCachedEvents.lastBlock) console.log('lastBlock - ', withdrawalCachedEvents.lastBlock)
const depositCachedEvents = await loadCachedEvents({ const depositCachedEvents = loadCachedEvents({
name: `deposits_${netId}_${nativeCurrency}_${instance}.json`, name: `deposits_${netId}_${nativeCurrency}_${instance}.json`,
directory: EVENTS_PATH, directory: EVENTS_PATH,
deployedBlock deployedBlock
@ -34,7 +34,7 @@ async function main() {
console.log('cachedEvents count - ', depositCachedEvents.events.length) console.log('cachedEvents count - ', depositCachedEvents.events.length)
console.log('lastBlock - ', depositCachedEvents.lastBlock) console.log('lastBlock - ', depositCachedEvents.lastBlock)
const notesCachedEvents = await loadCachedEvents({ const notesCachedEvents = loadCachedEvents({
name: `encrypted_notes_${netId}.json`, name: `encrypted_notes_${netId}.json`,
directory: EVENTS_PATH, directory: EVENTS_PATH,
deployedBlock: constants.ENCRYPTED_NOTES_BLOCK deployedBlock: constants.ENCRYPTED_NOTES_BLOCK

View file

@ -2,9 +2,9 @@ import fs from 'fs'
import zlib from 'zlib' import zlib from 'zlib'
import Web3 from 'web3' import Web3 from 'web3'
import networkConfig from '../../networkConfig' import networkConfig, { blockSyncInterval } from '../../networkConfig'
export async function download({ name, directory }) { export function download({ name, directory }) {
const path = `${directory}${name}.gz`.toLowerCase() const path = `${directory}${name}.gz`.toLowerCase()
const data = fs.readFileSync(path, { flag: 'as+' }) const data = fs.readFileSync(path, { flag: 'as+' })
@ -13,9 +13,9 @@ export async function download({ name, directory }) {
return content return content
} }
export async function loadCachedEvents({ name, directory, deployedBlock }) { export function loadCachedEvents({ name, directory, deployedBlock }) {
try { try {
const module = await download({ contentType: 'string', directory, name }) const module = download({ contentType: 'string', directory, name })
if (module) { if (module) {
const events = JSON.parse(module) const events = JSON.parse(module)
@ -53,7 +53,7 @@ export async function getPastEvents({ type, fromBlock, netId, events, contractAt
const blockDifference = Math.ceil(blockNumberBuffer - fromBlock) const blockDifference = Math.ceil(blockNumberBuffer - fromBlock)
// eth_logs and eth_filter are restricted > 10,000 block queries // eth_logs and eth_filter are restricted > 10,000 block queries
const blockRange = 10000 const blockRange = blockSyncInterval ? blockSyncInterval : 10_000
let chunksCount = blockDifference === 0 ? 1 : Math.ceil(blockDifference / blockRange) let chunksCount = blockDifference === 0 ? 1 : Math.ceil(blockDifference / blockRange)
const chunkSize = Math.ceil(blockDifference / chunksCount) const chunkSize = Math.ceil(blockDifference / chunksCount)

View file

@ -1,11 +1,11 @@
import fs from 'fs' import fs from 'fs'
import zlib from 'zlib' import zlib from 'zlib'
export async function save(filePath) { export function save(filePath) {
try { try {
const data = fs.readFileSync(`${filePath}`) const data = fs.readFileSync(`${filePath}`)
const payload = await zlib.deflateSync(data, { const payload = zlib.deflateSync(data, {
level: zlib.constants.Z_BEST_COMPRESSION, level: zlib.constants.Z_BEST_COMPRESSION,
strategy: zlib.constants.Z_FILTERED strategy: zlib.constants.Z_FILTERED
}) })

View file

@ -23,7 +23,7 @@ async function saveEncryptedNote(netId) {
let encryptedEvents = [] let encryptedEvents = []
const name = `encrypted_notes_${netId}.json` const name = `encrypted_notes_${netId}.json`
const cachedEvents = await loadCachedEvents({ const cachedEvents = loadCachedEvents({
name, name,
directory: EVENTS_PATH, directory: EVENTS_PATH,
deployedBlock: constants.ENCRYPTED_NOTES_BLOCK deployedBlock: constants.ENCRYPTED_NOTES_BLOCK

View file

@ -73,7 +73,7 @@ async function main(netId, chosenToken, chosenEvent) {
const address = data[1] const address = data[1]
// Now load cached events // Now load cached events
const cachedEvents = await loadCachedEvents({ const cachedEvents = loadCachedEvents({
name: `${eventName.toLowerCase()}s_${netId}_${tokenSymbol}_${denom}.json`, name: `${eventName.toLowerCase()}s_${netId}_${tokenSymbol}_${denom}.json`,
directory: EVENTS_PATH, directory: EVENTS_PATH,
deployedBlock deployedBlock

View file

@ -78,7 +78,7 @@ async function createTree(netId) {
console.log('createTree', { type, instance }) console.log('createTree', { type, instance })
const { events } = await loadCachedEvents({ const { events } = loadCachedEvents({
name: `${type}s_${netId}_${nativeCurrency}_${instance}.json`, name: `${type}s_${netId}_${nativeCurrency}_${instance}.json`,
directory: EVENTS_PATH, directory: EVENTS_PATH,
deployedBlock deployedBlock
@ -152,7 +152,7 @@ async function main() {
await createTree(chain) await createTree(chain)
await createTreeZip(chain) createTreeZip(chain)
} }
main() main()

View file

@ -29,7 +29,7 @@ async function updateCommon(netId) {
if (isSaved) { if (isSaved) {
try { try {
await testCommon(netId, type, filename) testCommon(netId, type, filename)
} catch (err) { } catch (err) {
console.error(err.message) console.error(err.message)
} }
@ -38,10 +38,10 @@ async function updateCommon(netId) {
} }
} }
async function testCommon(netId, type, filename) { function testCommon(netId, type, filename) {
const { deployedBlock } = networkConfig[`netId${netId}`] const { deployedBlock } = networkConfig[`netId${netId}`]
const cachedEvents = await loadCachedEvents({ const cachedEvents = loadCachedEvents({
name: filename, name: filename,
directory: EVENTS_PATH, directory: EVENTS_PATH,
deployedBlock deployedBlock