refactor: parallel contract definition and intractions loading
This commit is contained in:
committed by
Piotr Pędziwiatr
parent
276a40b5cb
commit
2cd999a509
3
.gitignore
vendored
3
.gitignore
vendored
@@ -13,4 +13,5 @@ lib/
|
||||
|
||||
yarn-error.log
|
||||
cache/
|
||||
_scripts/**/*.json
|
||||
|
||||
.experiments/
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
{
|
||||
"accounts": {
|
||||
"regulator": {
|
||||
"balance": 999.999,
|
||||
"vaults": []
|
||||
},
|
||||
"Pq6OBljxlpypNuE0O1eL92Kr9U1Ok4USfcc0aJcUAzs": {
|
||||
"balance": 69.0005,
|
||||
"vaults": [
|
||||
{
|
||||
"amount": 0.005,
|
||||
"start": 649390,
|
||||
"end": 650390
|
||||
}
|
||||
],
|
||||
"stake": 69
|
||||
},
|
||||
"DfCXDjdxcTIg1-FQDZ5jDclk1shKIpMlshe0IXodApc": {
|
||||
"balance": 69.0005,
|
||||
"vaults": [],
|
||||
"stake": 69
|
||||
}
|
||||
},
|
||||
"executables": {
|
||||
"Ms6RRl0eh96F_lcKYyiJhWRdRIiB6z0VaThCvBZDOAc": {
|
||||
"_discriminator": "validated",
|
||||
"bids": [
|
||||
{
|
||||
"bidder": "Pq6OBljxlpypNuE0O1eL92Kr9U1Ok4USfcc0aJcUAzs",
|
||||
"quantity": 0.01
|
||||
}
|
||||
],
|
||||
"caller": "Pq6OBljxlpypNuE0O1eL92Kr9U1Ok4USfcc0aJcUAzs",
|
||||
"executable": {
|
||||
"birth_height": 649382,
|
||||
"executable_address": "is9cDN3ZKPun0F2KmEHnhiRuUcYOO3Dzfef-B5ZAQeQ",
|
||||
"executable_kind": "wasm"
|
||||
},
|
||||
"accepted_bid": {
|
||||
"bidder": "Pq6OBljxlpypNuE0O1eL92Kr9U1Ok4USfcc0aJcUAzs",
|
||||
"quantity": 0.01
|
||||
},
|
||||
"validation_linked_list": {
|
||||
"value": [
|
||||
{
|
||||
"_discriminator": "release",
|
||||
"validator": "Pq6OBljxlpypNuE0O1eL92Kr9U1Ok4USfcc0aJcUAzs",
|
||||
"encrypted_hash": "af8e9c76fc012934cd3009c0cb7cac697da634350aa7dd6a063ccc3fdbc533f815799ed08d72d06a84961e468cd2af3fec5549350ce582c74eea7c29e020acf052c3e619cc69aa98e6e5b43bd10574dce88bb204289891c97a535d1da69f32e0e42dd906159b47acb3d435679b9c61dc",
|
||||
"symm_key": "sokka"
|
||||
},
|
||||
{
|
||||
"_discriminator": "release",
|
||||
"validator": "DfCXDjdxcTIg1-FQDZ5jDclk1shKIpMlshe0IXodApc",
|
||||
"encrypted_hash": "af8e9c76fc012934cd3009c0cb7cac697da634350aa7dd6a063ccc3fdbc533f815799ed08d72d06a84961e468cd2af3fec5549350ce582c74eea7c29e020acf052c3e619cc69aa98e6e5b43bd10574dce88bb204289891c97a535d1da69f32e0e42dd906159b47acb3d435679b9c61dc",
|
||||
"symm_key": "sokka"
|
||||
}
|
||||
]
|
||||
},
|
||||
"result": {
|
||||
"address": "OTWNmd9aSARYg1X4ds8CwSVmx_dNYHb_ka-W2VAJ7NQ",
|
||||
"giver": "Pq6OBljxlpypNuE0O1eL92Kr9U1Ok4USfcc0aJcUAzs",
|
||||
"height": 649390
|
||||
},
|
||||
"is_correct": true
|
||||
},
|
||||
"Xstw2Ss9TMCkV92ozHTsvIDPsPXnMDZVzfKPTPxgAq0": {
|
||||
"_discriminator": "proposed",
|
||||
"bids": [],
|
||||
"caller": "Pq6OBljxlpypNuE0O1eL92Kr9U1Ok4USfcc0aJcUAzs",
|
||||
"executable": {
|
||||
"birth_height": 649387,
|
||||
"executable_address": "is9cDN3ZKPun0F2KmEHnhiRuUcYOO3Dzfef-B5ZAQeQ",
|
||||
"executable_kind": "wasm"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ticker": "FEA"
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/* eslint-disable */
|
||||
import Arweave from 'arweave';
|
||||
import { SmartWeaveNodeFactory, LoggerFactory } from '@smartweave';
|
||||
import fs from 'fs';
|
||||
import { readContract } from 'smartweave';
|
||||
|
||||
const contracts = [
|
||||
'gepLlre8wG8K3C15rNjpdKZZv_9pWsurRoEB6ir_EC4',
|
||||
'dNXaqE_eATp2SRvyFjydcIPHbsXAe9UT-Fktcqs7MDk',
|
||||
'KXeqPReolrKuSKCqFaemdt4hGzp9F5FdzpdZnoPW-Gs',
|
||||
'YkvsC-BgdxdRSvYg48nIakEzDXq91JvMZoGodKpiwD8',
|
||||
'q-KEZPOoWXAoo21hMNcuVeRLSXe99-YAjlVXfDcOhSQ',
|
||||
'TMkCZKYO3GwcTLEKGgWSJegIlYCHi_UArtG0unCi2xA',
|
||||
'yscNec3CnlXDbI99-KooeetQfISqBh5kmxouBrI9pcQ',
|
||||
'hf4jA5IToo10XULwTZ_vFP6WYD-j8cr33j3UbtvUC4M',
|
||||
'W_njBtwDRyltjVU1RizJtZfF0S_4X3aSrrrA0HUEhUs'
|
||||
];
|
||||
|
||||
async function main() {
|
||||
const arweave = Arweave.init({
|
||||
host: 'arweave.net', // Hostname or IP address for a Arweave host
|
||||
port: 443, // Port
|
||||
protocol: 'https', // Network protocol http or https
|
||||
timeout: 60000, // Network request timeouts in milliseconds
|
||||
logging: false // Enable network request logging
|
||||
});
|
||||
|
||||
const smartWeave = SmartWeaveNodeFactory.memCached(arweave);
|
||||
const contract1 = smartWeave.contract('YLVpmhSq5JmLltfg6R-5fL04rIRPrlSU22f6RQ6VyYE');
|
||||
//const contract2 = smartWeave.contract('TMkCZKYO3GwcTLEKGgWSJegIlYCHi_UArtG0unCi2xA');
|
||||
const { state } = await contract1.readState();
|
||||
//await contract2.readState();
|
||||
const state2 = await readContract(arweave, 'YLVpmhSq5JmLltfg6R-5fL04rIRPrlSU22f6RQ6VyYE');
|
||||
console.log;
|
||||
}
|
||||
|
||||
function readJSON(path) {
|
||||
const content = fs.readFileSync(path, 'utf-8');
|
||||
try {
|
||||
return JSON.parse(content);
|
||||
} catch (e) {
|
||||
throw new Error(`File "${path}" does not contain a valid JSON`);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -1,88 +0,0 @@
|
||||
/* eslint-disable */
|
||||
import Arweave from 'arweave';
|
||||
import * as fs from 'fs';
|
||||
import {
|
||||
CacheableExecutorFactory,
|
||||
CacheableStateEvaluator,
|
||||
ContractDefinitionLoader,
|
||||
ContractInteractionsLoader,
|
||||
DebuggableExecutorFactory,
|
||||
EvalStateResult,
|
||||
EvolveCompatibleState,
|
||||
HandlerBasedContract,
|
||||
HandlerExecutorFactory,
|
||||
LexicographicalInteractionsSorter,
|
||||
LoggerFactory,
|
||||
MemBlockHeightSwCache,
|
||||
MemCache
|
||||
} from '@smartweave';
|
||||
|
||||
// note: this ofc. should be imported from the given SWC source code.
|
||||
interface ProvidersRegistryState extends EvolveCompatibleState {
|
||||
contractAdmins: string[];
|
||||
}
|
||||
|
||||
export function timeout(ms: number): Promise<any> {
|
||||
return new Promise((resolve) => setTimeout(() => resolve('timeout'), ms));
|
||||
}
|
||||
|
||||
const logger = LoggerFactory.INST.create(__filename);
|
||||
LoggerFactory.INST.logLevel('silly', 'example-usage');
|
||||
|
||||
async function readContractState() {
|
||||
const arweave = Arweave.init({
|
||||
host: 'arweave.net', // Hostname or IP address for a Arweave host
|
||||
port: 443, // Port
|
||||
protocol: 'https', // Network protocol http or https
|
||||
timeout: 20000, // Network request timeouts in milliseconds
|
||||
logging: false // Enable network request logging
|
||||
});
|
||||
|
||||
logger.trace('arweave created');
|
||||
|
||||
const changedSrc = `function handle(state, action) {
|
||||
console.log("hello world from the new source:", SmartWeave.transaction.id);
|
||||
return {state}
|
||||
}`;
|
||||
|
||||
const cacheableExecutorFactory = new CacheableExecutorFactory<any, any>(
|
||||
arweave,
|
||||
new HandlerExecutorFactory(arweave),
|
||||
new MemCache()
|
||||
);
|
||||
|
||||
const debuggableExecutorFactory = new DebuggableExecutorFactory(cacheableExecutorFactory, {
|
||||
'OrO8n453N6bx921wtsEs-0OCImBLCItNU5oSbFKlFuU': changedSrc
|
||||
});
|
||||
|
||||
const swcClient = new HandlerBasedContract(
|
||||
arweave,
|
||||
new ContractDefinitionLoader<ProvidersRegistryState>(arweave, new MemCache()),
|
||||
new ContractInteractionsLoader(arweave),
|
||||
debuggableExecutorFactory,
|
||||
new CacheableStateEvaluator(arweave, new MemBlockHeightSwCache<EvalStateResult<ProvidersRegistryState>>()),
|
||||
new LexicographicalInteractionsSorter(arweave)
|
||||
);
|
||||
|
||||
logger.trace('swcClient created');
|
||||
|
||||
const jwk = readJSON('../../redstone-node/.secrets/redstone-dev-jwk.json');
|
||||
const jwkAddress = await arweave.wallets.jwkToAddress(jwk);
|
||||
|
||||
logger.trace('jwkAddress:', jwkAddress);
|
||||
|
||||
const { state, validity } = await swcClient.readState('OrO8n453N6bx921wtsEs-0OCImBLCItNU5oSbFKlFuU');
|
||||
|
||||
function readJSON(path) {
|
||||
const content = fs.readFileSync(path, 'utf-8');
|
||||
try {
|
||||
return JSON.parse(content);
|
||||
} catch (e) {
|
||||
throw new Error(`File "${path}" does not contain a valid JSON`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readContractState().catch((e) => {
|
||||
logger.error(e);
|
||||
});
|
||||
@@ -1,54 +0,0 @@
|
||||
/* eslint-disable */
|
||||
import { LoggerFactory, SmartWeaveNodeFactory } from '@smartweave';
|
||||
import Arweave from 'arweave';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { readContract } from 'smartweave';
|
||||
|
||||
async function main() {
|
||||
const arweave = Arweave.init({
|
||||
host: 'arweave.net', // Hostname or IP address for a Arweave host
|
||||
port: 443, // Port
|
||||
protocol: 'https', // Network protocol http or https
|
||||
timeout: 60000, // Network request timeouts in milliseconds
|
||||
logging: false // Enable network request logging
|
||||
});
|
||||
const logger = LoggerFactory.INST.create(__filename);
|
||||
const smartWeave = SmartWeaveNodeFactory.memCached(arweave);
|
||||
|
||||
const contractTxId = 'YLVpmhSq5JmLltfg6R-5fL04rIRPrlSU22f6RQ6VyYE';
|
||||
// Kyve:
|
||||
// C_1uo08qRuQAeDi9Y1I8fkaWYUC9IWkOrKDNe9EphJo
|
||||
// OFD4GqQcqp-Y_Iqh8DN_0s3a_68oMvvnekeOEu_a45I
|
||||
// 8cq1wbjWHNiPg7GwYpoDT2m9HX99LY7tklRQWfh1L6c
|
||||
|
||||
const resultDiffs = [];
|
||||
|
||||
try {
|
||||
logger.info('readContract');
|
||||
const { state, validity } = await readContract(arweave, contractTxId, undefined, true);
|
||||
logger.debug('readContract validity', validity);
|
||||
const resultString = JSON.stringify(state);
|
||||
|
||||
logger.info('readState');
|
||||
const result2 = await smartWeave.contract(contractTxId).readState();
|
||||
logger.debug('readState validity', result2.validity);
|
||||
const result2String = JSON.stringify(result2.state);
|
||||
|
||||
if (resultString.localeCompare(result2String) !== 0) {
|
||||
console.error('\n\n ====== States differ ======\n\n');
|
||||
resultDiffs.push(contractTxId);
|
||||
const targetPath = path.join(__dirname, 'diffs', contractTxId);
|
||||
if (!fs.existsSync(targetPath)) {
|
||||
fs.mkdirSync(targetPath);
|
||||
}
|
||||
fs.writeFileSync(path.join(targetPath, 'new.json'), result2String);
|
||||
fs.writeFileSync(path.join(targetPath, 'old.json'), resultString);
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error(e);
|
||||
logger.info('skipping ', contractTxId);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -1,293 +0,0 @@
|
||||
/* eslint-disable */
|
||||
import Arweave from 'arweave';
|
||||
import * as fs from 'fs';
|
||||
import path from 'path';
|
||||
import Transaction from 'arweave/node/lib/transaction';
|
||||
import { GQLEdgeInterface, GQLResultInterface, LoggerFactory, SmartWeaveNodeFactory } from '@smartweave';
|
||||
import { readContract } from 'smartweave';
|
||||
|
||||
const diffStateToVerify = [
|
||||
'mzvUgNc8YFk0w5K5H7c8pyT-FC5Y_ba0r7_8766Kx74',
|
||||
'YLVpmhSq5JmLltfg6R-5fL04rIRPrlSU22f6RQ6VyYE',
|
||||
'w27141UQGgrCFhkiw9tL7A0-qWMQjbapU3mq2TfI4Cg'
|
||||
];
|
||||
|
||||
const query = `
|
||||
query Transactions($tags: [TagFilter!]!, $after: String) {
|
||||
transactions(tags: $tags, first: 100, sort: HEIGHT_ASC, after: $after) {
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
}
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
tags {
|
||||
name
|
||||
value
|
||||
}
|
||||
}
|
||||
cursor
|
||||
}
|
||||
}
|
||||
}`;
|
||||
|
||||
const logger = LoggerFactory.INST.create(__filename);
|
||||
|
||||
// LoggerFactory.INST.logLevel('debug');
|
||||
|
||||
async function main() {
|
||||
const arweave = Arweave.init({
|
||||
host: 'dh48zl0solow5.cloudfront.net', // Hostname or IP address for a Arweave host
|
||||
port: 443, // Port
|
||||
protocol: 'https', // Network protocol http or https
|
||||
timeout: 60000, // Network request timeouts in milliseconds
|
||||
logging: false // Enable network request logging
|
||||
});
|
||||
|
||||
const txs = loadTxFromFile();
|
||||
|
||||
const resumeFromContractTxId = 'YLVpmhSq5JmLltfg6R-5fL04rIRPrlSU22f6RQ6VyYE';
|
||||
let resumeFrom = false;
|
||||
|
||||
logger.info(`Checking ${txs.length} contracts`);
|
||||
|
||||
const differentStatesContractTxIds = [];
|
||||
|
||||
const errorContractTxIds = [];
|
||||
|
||||
const smartWeave = SmartWeaveNodeFactory.memCached(arweave);
|
||||
|
||||
const contractsBlacklist = [
|
||||
'jFInOjLc_FFt802OmUObIIOlY1xNKvomzUTkoUpyP9U', // readContract very long evaluation
|
||||
'El4EQmm3IztkMv3qXkuWVBMrwv_VJIxuT3btpmaZpxI', // confirmed with Fabian; https://discord.com/channels/817113909957361664/863061281488896020/871379515199344640
|
||||
'4j0j1Dfhz3d7HNcVFTFcrPYP8IvkPS9OfBLD6NxMGCo', // this also seems to be using Foreign Call Protocol and evaluates forever..
|
||||
'DVI-gBX6HtNUjoZHWLHnWmeujp01rQRnPOEDs4COwx0', // non-deterministic - new Date()
|
||||
'N9n48HdcRPNB34A4Zcxg2RiYvfFUa7HkbKFbZ1GmjZ8', // non-deterministic - new Date()
|
||||
'FgnK-IPuHLyQhGS_zQUCj22E0Tom-kFEun8zxaoRme4', // non-deterministic - new Date()
|
||||
'QYKnm-uZY9Ib6r-jwD4HXmkmyjtjWrjBiVTPgx6X1n0', // non-deterministic - new Date()
|
||||
'7UkUpwjSn8dWMUYU-XRfeHq68uzH8lbBYjEp5BYnOXY', // non-deterministic - new Date()
|
||||
'vgRwEGqrDsImkGXG9GNxBwCYR6-AVTKiet1kw-M_GdY', // non-deterministic - new Date()
|
||||
'Gx8E31NsUjkte9RMMdYXNynHXft_vo8c_G39OlIkyiQ', // non-deterministic - new Date()
|
||||
'jYn1iueQHZBo-1EJnK6wfiJzl6nSnIdvjQthxPdlnK4', // non-deterministic - new Date()
|
||||
'DeMsB5PRD2FXSMI2zYKgHufi032o5qhEhQMrYkXqUME', // non-deterministic - new Date()
|
||||
'wd2EL4p8aKjxs1mKBZmUFlg7PnMORIOmbKgM3qxT4As', // non-deterministic - new Date()
|
||||
'rJa4Nlifx992N4h-KrYAP4gK_9brSTilpU4OoIZMdco', // non-deterministic - new Date()
|
||||
'Do0Yg4vT9_OhjotAn-DI2J9ubkr8YmOpBg1Z8cBdLNA', // non-deterministic - new Date()
|
||||
'V5n-f9ULvIN8MrId6l34hB5akMBzZfQTnF0GJ9MgXgs', // non-deterministic - new Date()
|
||||
'iEyCOIzQC8hwh4_NkJyNcokp9jHy-qIaAOtIE10jdgY', // non-deterministic - new Date()
|
||||
'aMlIwSFvhUT5iEZSdzgEldOEd0oa8-7ZcbSSI5eA_3o', // non-deterministic - new Date()
|
||||
'8GU6bCVo_ageRXtLEAhNODkzLEMHAycy_d4CprxXlbw', // non-deterministic - new Date()
|
||||
'ENzSyU-5eMwhpdMJaNAPtbgLm-nIg6E0fS_kCQrnOIw', // non-deterministic - new Date()
|
||||
'PfNmSoFfLr5xoL14D6qXy6Gb3HVWX9vI8yLuqDEQTjY', // non-deterministic - new Date()
|
||||
'ZyU1cVKvaIvc1-eoUUp3W7e-I8hf-NkAfIukSq8wB7I', // non-deterministic - new Date()
|
||||
'NvC8d0BwJiCOTL0Jsy9U-jZvFpZb-29ls7VkDQwKZEw', // non-deterministic - new Date()
|
||||
'm_oIuIX0L-ex2pItk8UU1wVXo_ALhvMY-CaPPGrl2AI', // non-deterministic - new Date()
|
||||
'Ky8ypJK8sZTJg3sxFXq4xtwdpU4cDGzjyA9wh1ZHfOg', // non-deterministic - new Date()
|
||||
'2KQh2kOPCMqpOugbjXZGDWPWcWZpO9n6bC_CG6FQ40Q', // non-deterministic - new Date()
|
||||
'RWl3bimVg0Kdlr3R2vbjjxilKaJQwMcmCZ6Ho7dkv0g', // non-deterministic - new Date()
|
||||
'ljy4rdr6vKS6-jLgduBz_wlcad4GuKPEuhrRVaUd8tg', // cannot read state using original readContract - multiple unsafeClient.transactions.get calls
|
||||
'oS1dH-gklbNImarAZt8vpmiTSKGAdk9tvHAkn7MrrW0', // diff between consecutive calls of original readContract
|
||||
'rq4eay3i_LprbdFS8t3qAXHdzB2zDkTGChBof17oGY0', // diff between consecutive calls of original readContract
|
||||
'mNXgCKe0kChDjgs6IJS0sr0gncb2BZiVCfSxiz-wOvI', // diff between consecutive calls of original readContract
|
||||
'D5E8st-U-4W7lFnomhQKfJsAQZr6y4mvMpn1YhTfP_U', // diff between consecutive calls of original readContract
|
||||
'thL0Uy9N_ZiV1YGKl3ckHv-uMQvMHsuSq-gplbLfdFc', // diff between consecutive calls of original readContract
|
||||
'c2l8X1hIYyLvSpLHk2SaqfMhUk56vkLF7WxI1bdnfvE', // non-deterministic - new Date()
|
||||
'hX5IDyPNF8mMxlt_lXyhq_ZR_fB1aHlQLj1AtInEirI', // non-deterministic - new Date()
|
||||
'Mb73oSPIvOcZ07Q_qgVH6g10o2BlZS-Zbb9XddhIMFE', // non-deterministic - new Date()
|
||||
'OUu7a2eVaaOMgjs6bb0GNvLPvdBt4AShoJUtq59w0lY', // non-deterministic - new Date()
|
||||
'NY62EWpa7pTMH0PEUp3ODkqTQP11cdJEiYgV7-pobUw', // non-deterministic - new Date()
|
||||
'DqdgDjfMk6gLry2Sz12HTInOl3vvX7ObHBfzbUHMDGo', // non-deterministic - new Date()
|
||||
'HT5w1hwH6TPU9AIXVlXZ0oKAVyDPl8n4FEJvR8pKb_w', // non-deterministic - new Date()
|
||||
'QwdM8b5530AxTMZOKAg7l-Leh-ZpA8mTGA_8t-6V4R0', // non-deterministic - new Date()
|
||||
'6C6Fdm8qbyr9cWDBBuH_T4aXVi4UHw6WHojCgYg9mYI', // non-deterministic - new Date()
|
||||
'C8sUsnsm_SrUZpuDaHZihNYiR_EPhi3yBW9ae4M60YU', // non-deterministic - new Date()
|
||||
'_JrDtHCJ0AQij5SZjfoCFibMEi1ZvYuZ8kZmzlLjAoo', // non-deterministic - new Date()
|
||||
'LTBBqvVNR-fg_WOEUXYBSffkTGm8szIcJcER4YDmOeY', // non-deterministic - new Date()
|
||||
'I-UjB-xfVWxg9k7UrodhpaPKTqql868CrpFz-nW4szQ', // non-deterministic - new Date()
|
||||
'UDHVRRTPMbhoBHeSBbng6U8ZBryrBjtyqghdXt2Rpns', // non-deterministic - new Date()
|
||||
'ebVWmlGN1KkNZECCn-CzNUgtT50M2w2VOvzmbAvBMJ8', // non-deterministic - new Date()
|
||||
'3-KgLs_QZ39UuFqZMu1WXVd9eLULclj7knVLdv_2CBA', // non-deterministic - new Date()
|
||||
'm0-MJ4mQruT7cPRl8b2I0rF2nu7-MJd2kqw0wfYhG-A', // non-deterministic - new Date()
|
||||
'2JhxyWu9ai9OWJuc4xRFshrqoM5PS0rONJrIvj8RMtg', // non-deterministic - new Date()
|
||||
'p2UpExb4jrFPYg0gfaIJEEiJnmb1u1O_qtXwcIN7Vb4', // non-deterministic - new Date()
|
||||
'Gejd_7-M5q8dedSmjuApM9W2RyEZMMQPkchzGJNbTd0', // non-deterministic - new Date()
|
||||
'3O0Xcwquvl2r2_-qXD3DgT1wtE-FD9SK55HaJN7mWvs', // non-deterministic - new Date()
|
||||
'Q-S3m2Yj6tB0SQTkM1oZH7PvhUSy05OBhxDQ08xaxiU', // non-deterministic - new Date()
|
||||
'7UQr3tR35RtTiCr-_GG1GC-PzE_p0wScB_UqZPFK4T4', // non-deterministic - new Date()
|
||||
'RUsVtU-kywFWf63XivMPPM2o3hmP7xRQYdlwEk52paA', // non-deterministic - new Date()
|
||||
'fRyRiV40kTqz62IGDoK76MmELzB-gV9zcadN7V6fBGM', // non-deterministic - new Date()
|
||||
'uL69aODCIXuamOLyF5SuxrwrctvTw-8k01X_5fgUdqg', // non-deterministic - new Date()
|
||||
'm_eA9FQIwwWQwI2EucyS0V6KKupVJfb9SCycWI1KKJs', // non-deterministic - new Date()
|
||||
'P4Sn8AH0f5dFAda3CO2aI98YkiTIuVzZ2Obbb8ZiCFQ', // non-deterministic - new Date()
|
||||
'oy9X4ZR_qJ-jZCB56rwP1nrw-o0OOqtvm59lvzSfhAU', // non-deterministic - new Date()
|
||||
'kJiz2yvXjHDGUT45XudbRcC9uy6QJce2JgwDXlJlv0Y', // non-deterministic - new Date()
|
||||
'Y1Ik4EPSOpavP24nJzRLO4TeJRbSvarfRVvXxBOqEOI', // non-deterministic - new Date()
|
||||
'0Nx9CWDplg9guCp67_NlT2axv-GLyxQaZaI1TyDMSzg', // non-deterministic - new Date()
|
||||
'YuI0ZV7NziJbqVvTpjvzYah98B2eDtDK4G8h3hYEweA', // non-deterministic - new Date()
|
||||
'A3W2q5aO7Q4QoKb0uqJTcaqqxcLhTnfBvt2T9HJkFt4', // non-deterministic - new Date()
|
||||
'Ckbgnv1clR3au4P9-gDrtrQhf6O4YRD9p6xeZywJ2HQ', // non-deterministic - new Date()
|
||||
'm4_GVkSNSc7hFID68__ODi3xSZgGBfY3TDug7yIcwyE', // non-deterministic - new Date()
|
||||
'8V86hJS6grrBrpShGrUKRbUIuT4pez3PLsEh2bv8kzE', // non-deterministic - new Date()
|
||||
'u3dN2nvq71O3Or3qo_EM_V8_XSPGTh_3oUB0XzmI35A', // non-deterministic - new Date()
|
||||
'6J4K4fwBsu5D8Natm4k4u9HKfV9UdHUP9mCFkNll3ds', // non-deterministic - new Date()
|
||||
'dgxYRw4xxIaVsoOJs_giR6Nmxv0QDPBSglLV5UDnkpA', // non-deterministic - new Date()
|
||||
'_ZXfm1cXinE6-G6Uwjb_QVuo6jq325pienel971h_sw', // non-deterministic - new Date()
|
||||
'OQvFFrjnU-A2MLRzxNtqSym4Yd9d1ywtBKJOj3PxX-A', // non-deterministic - new Date()
|
||||
'P-jT_gXmglmBBmq6bEUKNUwyWX1L9fzzIi-AFftMCSA', // non-deterministic - new Date()
|
||||
'F1rX1aQH-qNKxkMFhTPQ_9pF_6Q8EdIw4iZoEv75dKc', // non-deterministic - new Date()
|
||||
'l1ndwQUSflTVCvlFxC2cScPI-LSHGqzcWwkNIMUOJ14', // non-deterministic - new Date()
|
||||
'tPuubx4kMUPS9Q21NZ2rZz4VlR_BrTawX3b84nl_eeQ', // non-deterministic - new Date()
|
||||
'SOzf9v7R9ddK4LV5zI5VrKJIRqHX3r3Y4p9oVgr36rg', // non-deterministic - new Date()
|
||||
'lAIRxKKWKXQTRT6XIsMvZh4JikXevO3zdu7uqo7VJy0', // non-deterministic - new Date()
|
||||
'Pr6ZKeFaJFHGLdn6vbCJ93JS1L1J3k3ptBRSspqLL2U', // non-deterministic - new Date()
|
||||
'P871U4YnHiClonG80BznhZW5Jy3aKwMV5nOZPONfrw4', // non-deterministic - new Date()
|
||||
'7-JcXmxIFTJoJtfC-E3uBnK1RkknW0WmhR1gmOcZaHc', // non-deterministic - new Date()
|
||||
'AqnCHJqo2ToqmCs6aKDhFW9pqDEe0CAkUr1T4C6rg3U', // non-deterministic - new Date()
|
||||
'WR9ZHiE8cyXjj5g5rpnkOXm4O4ul-iUjNy4j8--LLVs', // non-deterministic - new Date()
|
||||
'JQQHNA7scVEXRtbvFdFVtIw1AXk3LaCRea5t0axPk4k', // non-deterministic - new Date()
|
||||
'Yc6-QiukVnAyKDvS_S0Yz2BpsAPfahNpkbWSo4K5zk4', // non-deterministic - new Date()
|
||||
'1_v7yu1K6ttbwaNsQLmjZOvbAyCg7NNXpcLdZRIJOKg', // non-deterministic - new Date()
|
||||
'x0UlfULWsYGNttZf4QTIEuIvedjsYQtaHh_yOfyhOWg', // non-deterministic - new Date()
|
||||
'6nx5BlJbxPmXA1cFqR1KxHDf1f3zXz2glVEi4L72zMM', // non-deterministic - new Date()
|
||||
'M3JVDpeS8GkcbLYMUb5te1kYnSot0xkOeJktuQmPb9w', // non-deterministic - new Date()
|
||||
'V2CHShHCvXuidRJrPLlydgTbnINLjVpzagZyZjUiHws', // non-deterministic - new Date()
|
||||
'Pt9DTwf3aZcxooq7Eq7XlkVRiIQDt3JJS1LV9UwoxDE', // non-deterministic - new Date()
|
||||
'e9raEJJacDDCWqOshtfXaxjiXfeEfRvTj34eq4GqzVQ', // very long processing
|
||||
'DkmTmGPekZmYIvC3DzhcPq9xuKoE7prdebDrHlmRdDY', // very long processing
|
||||
'C_1uo08qRuQAeDi9Y1I8fkaWYUC9IWkOrKDNe9EphJo' // very long processing
|
||||
];
|
||||
|
||||
const sourcesBlacklist = [
|
||||
// https://discord.com/channels/817113909957361664/863061281488896020/871383143347781694
|
||||
'MjrjR6qCFcld0VO83tt3NcpZs2FIuLscvo7ya64afbY',
|
||||
'C_1uo08qRuQAeDi9Y1I8fkaWYUC9IWkOrKDNe9EphJo',
|
||||
'Z3Arb_sfuLpFxyLfolLClLfe89BFgrbbgJM2rKsebEY'
|
||||
];
|
||||
|
||||
let counter = 0;
|
||||
|
||||
const properContractTxIds = [];
|
||||
|
||||
for (const contractTxId of txs) {
|
||||
const tx: Transaction = await arweave.transactions.get(contractTxId);
|
||||
counter++;
|
||||
logger.info(`\n${contractTxId}: [${counter}/${txs.length}]`);
|
||||
|
||||
if (resumeFrom && contractTxId.localeCompare(resumeFromContractTxId) !== 0) {
|
||||
console.info('Skipping...');
|
||||
continue;
|
||||
} else {
|
||||
resumeFrom = false;
|
||||
}
|
||||
|
||||
if (contractsBlacklist.includes(contractTxId)) {
|
||||
logger.warn('Skipping blacklisted contract: ', contractTxId);
|
||||
continue;
|
||||
}
|
||||
|
||||
const tags = tx.tags;
|
||||
if (
|
||||
tags.some((tag) => {
|
||||
const key = tag.get('name', { decode: true, string: true });
|
||||
const value = tag.get('value', { decode: true, string: true });
|
||||
return key.localeCompare('Contract-Src') === 0 && sourcesBlacklist.includes(value);
|
||||
})
|
||||
) {
|
||||
logger.warn("Skipping blacklisted contract's source");
|
||||
continue;
|
||||
}
|
||||
|
||||
properContractTxIds.push(contractTxId);
|
||||
|
||||
/* let resultString = '';
|
||||
let result2String = '';
|
||||
try {
|
||||
logger.info('readContract');
|
||||
const result = await readContract(arweave, contractTxId);
|
||||
resultString = JSON.stringify(result);
|
||||
// console.log(resultString);
|
||||
|
||||
logger.info('readState');
|
||||
const result2 = await smartWeave.contract(contractTxId).readState();
|
||||
result2String = JSON.stringify(result2.state);
|
||||
// console.log(result2String);
|
||||
|
||||
} catch (e) {
|
||||
logger.error(e);
|
||||
logger.info('skipping ', contractTxId);
|
||||
errorContractTxIds.push(contractTxId);
|
||||
} finally {
|
||||
if (resultString.localeCompare(result2String) !== 0) {
|
||||
logger.error('States differ!');
|
||||
differentStatesContractTxIds.push(contractTxId);
|
||||
fs.writeFileSync(path.join(__dirname, 'diffs', `${contractTxId}_old.json`), resultString);
|
||||
fs.writeFileSync(path.join(__dirname, 'diffs', `${contractTxId}_new.json`), result2String);
|
||||
}
|
||||
logger.debug('Contracts with different states:', differentStatesContractTxIds);
|
||||
logger.info('\n\n ==== END');
|
||||
}*/
|
||||
}
|
||||
|
||||
fs.writeFileSync('proper-test-cases.json', JSON.stringify(properContractTxIds));
|
||||
}
|
||||
|
||||
main().catch();
|
||||
|
||||
function loadTxFromFile(): string[] {
|
||||
const transactions = JSON.parse(fs.readFileSync(path.join(__dirname, 'test-cases.json'), 'utf-8'));
|
||||
return Object.keys(transactions);
|
||||
}
|
||||
|
||||
async function loadContractTransactions(arweave: Arweave) {
|
||||
let variables = {
|
||||
tags: [
|
||||
{
|
||||
name: 'App-Name',
|
||||
values: ['SmartWeaveContract']
|
||||
},
|
||||
{
|
||||
name: 'Content-Type',
|
||||
values: ['application/json']
|
||||
}
|
||||
],
|
||||
after: undefined
|
||||
};
|
||||
|
||||
let transactions = await getNextPage(arweave, variables);
|
||||
|
||||
const txs: GQLEdgeInterface[] = transactions.edges.filter((tx) => !tx.node.parent || !tx.node.parent.id);
|
||||
|
||||
while (transactions.pageInfo.hasNextPage) {
|
||||
const cursor = transactions.edges[99].cursor;
|
||||
|
||||
variables = {
|
||||
...variables,
|
||||
after: cursor
|
||||
};
|
||||
|
||||
transactions = await getNextPage(arweave, variables);
|
||||
|
||||
txs.push(...transactions.edges.filter((tx) => !tx.node.parent || !tx.node.parent.id));
|
||||
}
|
||||
return txs;
|
||||
}
|
||||
|
||||
async function getNextPage(arweave, variables) {
|
||||
const response = await arweave.api.post('graphql', {
|
||||
query,
|
||||
variables
|
||||
});
|
||||
|
||||
logger.trace('Status:', response.status);
|
||||
if (response.status !== 200) {
|
||||
throw new Error('Wrong response from Ar GQL');
|
||||
}
|
||||
|
||||
if (response.data.errors) {
|
||||
logger.error(response.data.errors);
|
||||
throw new Error('Error while loading transactions');
|
||||
}
|
||||
|
||||
const data: GQLResultInterface = response.data;
|
||||
return data.data.transactions;
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
/* eslint-disable */
|
||||
import { GQLEdgeInterface, GQLResultInterface, GQLTransactionsResultInterface, LoggerFactory } from '@smartweave';
|
||||
import Arweave from 'arweave';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
// max number of results returned from single query.
|
||||
// If set more, arweave.net/graphql will still limit to 100 (not sure if that's a bug or feature).
|
||||
const MAX_RESULTS_PER_PAGE = 100;
|
||||
|
||||
const transactionsQuery = `
|
||||
query Transactions($tags: [TagFilter!]!, $after: String) {
|
||||
transactions(tags: $tags, first: 100, sort: HEIGHT_ASC, after: $after) {
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
}
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
tags {
|
||||
name
|
||||
value
|
||||
}
|
||||
}
|
||||
cursor
|
||||
}
|
||||
}
|
||||
}`;
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
const logger = LoggerFactory.INST.create(__filename);
|
||||
LoggerFactory.INST.logLevel('silly', 'swc-stats');
|
||||
|
||||
async function main() {
|
||||
const arweave = Arweave.init({
|
||||
host: 'arweave.net', // Hostname or IP address for a Arweave host
|
||||
port: 443, // Port
|
||||
protocol: 'https', // Network protocol http or https
|
||||
timeout: 60000, // Network request timeouts in milliseconds
|
||||
logging: false // Enable network request logging
|
||||
});
|
||||
|
||||
const contractTxs = await sendQuery(
|
||||
arweave,
|
||||
{
|
||||
tags: [
|
||||
{
|
||||
name: 'App-Name',
|
||||
values: ['SmartWeaveContract']
|
||||
},
|
||||
{
|
||||
name: 'Content-Type',
|
||||
values: ['application/json']
|
||||
}
|
||||
],
|
||||
after: undefined
|
||||
},
|
||||
transactionsQuery
|
||||
);
|
||||
|
||||
logger.info(`Checking ${contractTxs.length} contracts`);
|
||||
|
||||
const result = {};
|
||||
|
||||
// loading
|
||||
for (const contractTx of contractTxs) {
|
||||
const contractTxId = contractTx.node.id;
|
||||
|
||||
logger.trace(
|
||||
`\n[${contractTxs.indexOf(contractTx) + 1} / ${contractTxs.length}] loading interactions of the ${contractTxId}`
|
||||
);
|
||||
const interactions = await sendQuery(
|
||||
arweave,
|
||||
{
|
||||
tags: [
|
||||
{
|
||||
name: 'App-Name',
|
||||
values: ['SmartWeaveAction']
|
||||
},
|
||||
{
|
||||
name: 'Contract',
|
||||
values: [contractTxId]
|
||||
}
|
||||
]
|
||||
},
|
||||
transactionsQuery
|
||||
);
|
||||
|
||||
logger.trace(`${contractTxId}: ${interactions.length}`);
|
||||
|
||||
result[contractTxId] = interactions.length;
|
||||
|
||||
logger.silly('Waiting...');
|
||||
await sleep(2000);
|
||||
}
|
||||
|
||||
fs.writeFileSync(path.join(__dirname, `swc-stats.json`), JSON.stringify(result));
|
||||
|
||||
// sorting
|
||||
logger.silly('Sorting...');
|
||||
|
||||
const contracts = JSON.parse(fs.readFileSync(path.join(__dirname, `swc-stats.json`), 'utf-8'));
|
||||
|
||||
const sortable = [];
|
||||
// tslint:disable-next-line:forin
|
||||
for (const contract in contracts) {
|
||||
sortable.push([contract, contracts[contract]]);
|
||||
}
|
||||
sortable.sort((a, b) => b[1] - a[1]);
|
||||
const sortedContracts = {};
|
||||
sortable.forEach((item) => (sortedContracts[item[0]] = item[1]));
|
||||
|
||||
logger.trace(sortedContracts);
|
||||
|
||||
fs.writeFileSync(path.join(__dirname, `swc-sorted-stats.json`), JSON.stringify(sortedContracts));
|
||||
}
|
||||
|
||||
main().then(() => {
|
||||
logger.info('done');
|
||||
});
|
||||
|
||||
async function sendQuery(arweave: Arweave, variables: any, query: string) {
|
||||
let transactions: GQLTransactionsResultInterface | null = await getNextPage(arweave, variables, query);
|
||||
|
||||
const txs: GQLEdgeInterface[] = transactions.edges.filter((tx) => !tx.node.parent || !tx.node.parent.id);
|
||||
|
||||
while (transactions.pageInfo.hasNextPage) {
|
||||
const cursor = transactions.edges[MAX_RESULTS_PER_PAGE - 1].cursor;
|
||||
|
||||
variables = {
|
||||
...variables,
|
||||
after: cursor
|
||||
};
|
||||
|
||||
transactions = await getNextPage(arweave, variables, query);
|
||||
txs.push(...transactions.edges.filter((tx) => !tx.node.parent || !tx.node.parent.id));
|
||||
}
|
||||
|
||||
return txs;
|
||||
}
|
||||
|
||||
async function getNextPage(arweave, variables, query: string): Promise<GQLTransactionsResultInterface | null> {
|
||||
const response = await arweave.api.post('graphql', {
|
||||
query,
|
||||
variables
|
||||
});
|
||||
|
||||
if (response.status !== 200) {
|
||||
logger.error(response);
|
||||
throw new Error(`Wrong response status from Arweave: ${response.status}`);
|
||||
}
|
||||
|
||||
if (response.data.errors) {
|
||||
logger.error(response.data.errors);
|
||||
throw new Error('Error while loading transactions');
|
||||
}
|
||||
|
||||
const data: GQLResultInterface = response.data;
|
||||
|
||||
return data.data.transactions;
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
{
|
||||
"AVTqjPQGCCXim7Nl_gn3HMjE4k0Zi_eTFRJCNEVXZxw": 253,
|
||||
"6eTVr8IKPNYbMHVcpHFXr-XNaL5hT6zRJXimcP-owmo": 251,
|
||||
"l6S4oMyzw_rggjt4yt4LrnRmggHQ2CdM1hna2MK4o_c": 229,
|
||||
"mzvUgNc8YFk0w5K5H7c8pyT-FC5Y_ba0r7_8766Kx74": 218,
|
||||
"SJ3l7474UHh3Dw6dWVT1bzsJ-8JvOewtGoDdOecWIZo": 190,
|
||||
"U75PzAt0XWyH1HCd0gkHAFiWBIx-1dEyj33f2euHLYs": 164,
|
||||
"c25-RdheC6khcACLv23-XXg1W7YuA-VSZ_1_qnNFbhw": 158,
|
||||
"ZT-70ovBlkF6cRIqvyHy5lC2LcjudsmCz9z19M4_QC4": 154,
|
||||
"o-qJmQ4B0d6TnyA_awjhiBdiq0O4Vt_dNWU3pTnhTu8": 143,
|
||||
"BYRf00nIE4pGkJ8GyUY2PIJ1rBtxFPoWIu-0dd8iukg": 143,
|
||||
"5NgGX4OToJ4M5ohWP4yxaTz_2oPsnk7vmR0v3mqXi_A": 139,
|
||||
"4o-2xMPa45BXjGuII_LbOMQWfhE1F0qugdEUZvRlXRY": 100,
|
||||
"ydjfv0hRQdD2c-MASv4L5Qahjap_LXJyD9tNyKWvf50": 93,
|
||||
"eWB7FHyPyCYnkcbK1aINbAQ9YYTDhKGkS7lDiNPZ5Mg": 68,
|
||||
"oVUvLJ8dEMtOldu9JF3n-cA5tsO7Gel9MNGPPu2XFUA": 58,
|
||||
"dlKReXkvj7Af-mc_0DiY_2OQIVot_mUcc6YAzH9vo3s": 56,
|
||||
"9BX6HQV5qkGiXV6hTglAuPdccKoEP_XI2NNbjHv5MMM": 55,
|
||||
"7UkUpwjSn8dWMUYU-XRfeHq68uzH8lbBYjEp5BYnOXY": 54,
|
||||
"lkxZimx4GpKcmEYoy1sLjcmYOcYUNNDN4SfcoyJTcpo": 52,
|
||||
"lbHyzjQH4oZ4JxYuYzY20iLYEe4mX1p7ApU-S2Ew218": 52,
|
||||
"8GU6bCVo_ageRXtLEAhNODkzLEMHAycy_d4CprxXlbw": 49,
|
||||
"ZiBxuvFUNJlSx6tPlF2uvoAA9tA5NWW2-naLjXn7NAw": 43,
|
||||
"f31IwJvoun_1BgSW-0j_xBNMCKS6T2GJkmTD20Q7k-g": 43,
|
||||
"UvjBvJUy8pOMR_lf85tBDaJD0jF85G5Ayj1p2h7yols": 43,
|
||||
"rJa4Nlifx992N4h-KrYAP4gK_9brSTilpU4OoIZMdco": 43,
|
||||
"f1wibc4fPQbcOtHR9ZlcfiJZicJSHA2mgETC-3WHMME": 43,
|
||||
"FdY68iYqTvA40U34aXQBBYseGmIUmLV-u57bT7LZWm0": 42,
|
||||
"UjZ6sg7KvoF1XoW7ReB2X3P5uHAbCWYaUIzB7XrjTtM": 42,
|
||||
"tynArDso6PKe7h1uRfu8jS7XHhTYRJQhqVRExAi0bqU": 41,
|
||||
"nxZu3_PWyO_4w2Q7mX2NxpBmEFp5a_Q2bv8CWfDfOjo": 41,
|
||||
"p04Jz3AO0cuGLzrgRG0s2BJbGL20HP1N8F9hsu6iFrE": 39,
|
||||
"HJfFTVxB0kSkr2Q5soVYtoMN4nZd-WZHs1Kv0g2lHuY": 39,
|
||||
"q6SQ0dcSAJmKChrIMGiG3St9YF4VF_3ilbGt51YGQIk": 38,
|
||||
"sew_MAXZIgmyEPzzOTkdAca7SQCL9XTCMfxY3KOE5-M": 37,
|
||||
"S3a-4VByScX0vtjmh5oZPs8kHTNn-8UPFVOkm2RprDc": 35,
|
||||
"RWl3bimVg0Kdlr3R2vbjjxilKaJQwMcmCZ6Ho7dkv0g": 34,
|
||||
"Hyt8YBtfFR9KHbMIbQHy3DK7nKMRYArzLCcBbzZRpN8": 34,
|
||||
"BAfcKVhykkup_onxxgzj3T0fMhp33bY82OK23Rruy-Q": 33,
|
||||
"dpRwKqXGO234CgHp5i_zr0Vv-caoej-EWd9cpQVcYhA": 32,
|
||||
"4BM86e-zd_XBSY4nFFH3Kz_9GY2jkcEmnxe7CKqONIw": 32,
|
||||
"QIa535saTE2QBSKwAdV1ChxoH--t4liW49twzZAW7JM": 30,
|
||||
"BXCEBKTv-Fvan0m82aEi7njdnRsFDluFkfN8vrWG5FI": 30,
|
||||
"QYKnm-uZY9Ib6r-jwD4HXmkmyjtjWrjBiVTPgx6X1n0": 30,
|
||||
"GzekjMfuPHIv0T95pjupchKeYEFVcqc-rrAJ0QgENR0": 30,
|
||||
"OA2AH-uyk6IakJDTQhgUaAf5PWaSGJgWz178C1aYDL4": 30,
|
||||
"iOJmwmkP-vQxEGKe0F4fWnoU2vBP4tfoilNZzYEPLQY": 27,
|
||||
"a3WZd4Fa9gckxRqDyu-EAONy7v25J8kuqj75ZgtGoUg": 27,
|
||||
"DeMsB5PRD2FXSMI2zYKgHufi032o5qhEhQMrYkXqUME": 26,
|
||||
"CbGCxBJn6jLeezqDl1w3o8oCSeRCb-MmtZNKPodla-0": 26,
|
||||
"jFInOjLc_FFt802OmUObIIOlY1xNKvomzUTkoUpyP9U": 26,
|
||||
"lmOgf5O5wNiFi45rL5QMkB-bAEF5c-Yc0IZyoSCV-eU": 25,
|
||||
"KeOt45twVd0UwSmiY7SteZXuvwBiixb8XaAkXVs3ePE": 23,
|
||||
"PiM6NAml7owLgLkGafrfT662rkBh0n_PD7ltEEpI3aw": 23,
|
||||
"_iDpkuu4caqtRKa2LUIaWfESzD4pe2aJRWGTDG0xTUc": 23,
|
||||
"HWSbM2l-1gsBzCQMjzoP6G4aKafJvDeHyLs5YdTDxm0": 22,
|
||||
"K9Lb5WzRHxGyQqZVKL-ckBcnwtEouEBOlphKNmLhHtY": 22,
|
||||
"sdOMIHnYrrco6rnl_yJGZirqO54SMhxhdGV9RC8xyyY": 22,
|
||||
"YN7VDKn_JjziC4tTL92K9pO_iMcnMSjk6kgSBr1EPjI": 22,
|
||||
"FgnK-IPuHLyQhGS_zQUCj22E0Tom-kFEun8zxaoRme4": 21,
|
||||
"Wvp7APAOzwz_ZGxFmvAiVTGhKB47DRvI2yFmOqHW0e8": 21,
|
||||
"0Nx9CWDplg9guCp67_NlT2axv-GLyxQaZaI1TyDMSzg": 21,
|
||||
"mG-20tH4-wpDMsD1sl6QjkpoxpXxCT119boFtNfPztw": 20,
|
||||
"l4iqeiSb4oJrpByg6rgiXlW1iF3cgjXLbHdG2JvAC_c": 20,
|
||||
"7hVrRtwjs7XLPtpZsQMr6RPz19QjtTqQYpHy3rPEy-4": 20,
|
||||
"-aH2NkyNNODmaIyoNmPW1RqNmhirZgAQHYKXbpr1RtY": 20,
|
||||
"5pSyVjFI07z8mbLeQhYBMsQ4M_MPidXIGX6T77rnF2s": 20,
|
||||
"Wgp3SpOtWXGCi1SardwQAwrOsQeW6aQn36ooo6eo8nc": 20,
|
||||
"pnTOOL1MebQ-c4Dw4zgMKvCdPbvsCC7JTTDmEjAr0qI": 20,
|
||||
"bG4FzHB19RclVEU3pimgtw1oijono0y-XfDRZR_Nlhc": 19,
|
||||
"bkRi0K8DADQW9TNOpbYtV53EzvRwT9LLwZPGyCwJaAg": 19,
|
||||
"kJiz2yvXjHDGUT45XudbRcC9uy6QJce2JgwDXlJlv0Y": 19,
|
||||
"W_84yhLuUptuBi4qTUChiAE2wtHOOvTdqvj3IYfU6gg": 19,
|
||||
"DkmTmGPekZmYIvC3DzhcPq9xuKoE7prdebDrHlmRdDY": 19,
|
||||
"yowLo9OICoqnUJNwt55a0uZ_zrnV01laKReWUJWZyjA": 18,
|
||||
"MyTcxU4CpV7NKV0sTX6NNSQR2UhhIhzcjiRHLC4qluc": 18,
|
||||
"CpFzxta1dGIuMGkIlV50tA-NhJFcTsNDrvECQ6cg3_M": 18,
|
||||
"th76PmwfV5zgUsf3LLiI_qic7n8p4sHKarAIDqR-kG0": 17,
|
||||
"dg5m4ejxOCA84vAqRk9AhNumyeg3zCmGgg0sIeWoZkU": 17,
|
||||
"fN-nTV-Q6HX9wDPNo89CKpbUhC6nDLWlnic7QzRA1g0": 17,
|
||||
"l2uG_a4IoB3D910lpk2K30enL0rapLbH0GNt5O-PAdA": 17,
|
||||
"bBKWTDtnqYsk2jgWBQNhOnZzGWpXIvgg6l4yU4aqlXY": 16,
|
||||
"zBnoI4RYhs0g6WblVebJhEu0nolyiHBz3MegSyYcu0A": 16,
|
||||
"0hUxw3Ah1roZ2HR_E56IqxoV1qvaj1W_Wr-8PTocsd0": 16,
|
||||
"u7m6WwapDKXhcKmN1OrZW1VGtXWalm-C4QqHZNYIwug": 16,
|
||||
"uBAtZUaLK8rolhSILgfxG_UGU2GcvawhdQjid3K5oE4": 16,
|
||||
"vgRwEGqrDsImkGXG9GNxBwCYR6-AVTKiet1kw-M_GdY": 15,
|
||||
"bNmbXC1rJoepS9crl26imkFgiqg-uLFXBcfILuW0Aok": 15,
|
||||
"UGG1xAjpBU2gq66elzgiT_r1obYkwuoxO80YJ97n5dk": 15,
|
||||
"XmTFbgqgXi1SvgpbsbcxO7TWX6RtczIpzTF-IiNA1Lc": 15,
|
||||
"cpXtKvM0e6cqAgjv-BCfanWQmYGupECt1MxRk1N9Mjk": 15,
|
||||
"suEGI_H1NjKhPZVfOJxRTS8sSzaeSMAIZqLfCbSAVj8": 15,
|
||||
"cp1ka-VbZJJj_GOraw9cuJznspR2Vdvcqp71TJ3R03Q": 14,
|
||||
"RRvgew0V1aQzlgY3olVi9WPLojBGNR_jrwDkfyXHtyI": 14,
|
||||
"N9n48HdcRPNB34A4Zcxg2RiYvfFUa7HkbKFbZ1GmjZ8": 14,
|
||||
"mpuVOVsDjH-dazsC3CNlDHiqvVQdydCElVrgcJvkl_o": 14,
|
||||
"qGNZGZBNv5JffEPkkuYpHEOEtZYHLhrRrRygAjdanqw": 14,
|
||||
"7nLJGsvxVUKEFIHRVK-DHbgLuH_BIdZaDiRImktkb68": 14,
|
||||
"IZa8YcXoD9TasS9EoGj5_L0yg_csx7UIQq2I3QWELwI": 14,
|
||||
"rNDEPmLuGEO7n9hDNhNEsvOkPA_KabgVDG7LJw8UBYI": 13,
|
||||
"87HZ10dOeznvSDXD3UwtZuJtlZijnaa2Ptwr3HFGaeo": 13,
|
||||
"fXJNmztyJVQybKHambb5rzzg-z-mBbQSF_dAOZnhVzM": 13,
|
||||
"nD8hH9SymvfVOv2NKIzdzgGpi7I4L2f5WX2i7U_kIDU": 13,
|
||||
"P6IeiCcEBuGR4EDhzruUfvGV_5RNB6AWPo3u0noc0Rk": 13,
|
||||
"3H8ocWSWE7Yj2mzT13Pyt43koW8UsiB6xJA_QzXgiX8": 13,
|
||||
"vyDjA2UggLj12tcFR-lKAo1kKaZyNeAM2twEJ62xkco": 13,
|
||||
"HRut8B98Oe6pjs6OnZBfq93DhQVtRT9VfOER3e1-Ajg": 13,
|
||||
"iEPkBNzZTNXSsEJUKL-RH5N1IkEf83EGWG2-L3kSa3s": 13,
|
||||
"Ar1RAJDSAJdAGCI22nkAveDbtgtcMx1bNXopk2pfENs": 13,
|
||||
"XUc8q12a_Me80D4TJopM0ruW4McTPTk1EChVHzNk1lM": 13,
|
||||
"gvqSWUdeCAub91VKJ6_1yVIvqIAVOgVJXv68ozhFawc": 12,
|
||||
"do9ABIDHoZmulTjymVF8tydHfrH5pZRVZuu4qm4aDV4": 12,
|
||||
"dkVJmNCHFoChVBOrgYIv-XcCWTqg6q5HpkVk5zyyNdo": 12,
|
||||
"2caOW6ol9T8LHCMO8tVAx4GHRwv1q3fFc79KzKOtoww": 12,
|
||||
"HdZBZa0GfOEUYCubwvoSyxGUUgPmgy7RJb5l77T21bE": 12,
|
||||
"7Dp5r-UpZLDvHqsDbZbqWhCBwbYdJMKBuC3tFC-FF7U": 12,
|
||||
"YLVpmhSq5JmLltfg6R-5fL04rIRPrlSU22f6RQ6VyYE": 12,
|
||||
"EOtTxCGktZe_J2DTM0D5h04crjlpjgeygA1R6Pmo_qM": 12,
|
||||
"92Tq6BKm6pvVkKW8_6Fb13QWTdUzBRLnG9scMBNWYZ4": 12,
|
||||
"w27141UQGgrCFhkiw9tL7A0-qWMQjbapU3mq2TfI4Cg": 12,
|
||||
"YLRkokEfrNNIZ8Pq5UUG2DaEdxJOgrOb9U5Bnhz4beY": 11,
|
||||
"GATxiK4QNie39kefpC4xnyf8HWiEhFUQHEC_jy8oa3E": 11,
|
||||
"NftYHZU3-6B-_FV-Ec4ctpR49Ulr8zsMN2oXd96MTG0": 11,
|
||||
"qoUAMfYEBVOLQoQgqvbTyv302UVaFfl58jZow46sHhc": 11,
|
||||
"XQkGzXG6YknJyy-YbakEZvQKAWkW2_aPRhc3ShC8lyA": 11,
|
||||
"uOfZLIaT4qaLDXJau0twfkgqnPQhwm86Kjw02w1O3-g": 11,
|
||||
"iKArqYu4AXEJxMgzY-JMTknbWIQsovi7EcIBggjkz3M": 10,
|
||||
"2dE2vCKKGP7-LziJottAiq34vM1UOUazUqv_ukxJnu4": 10,
|
||||
"L5J7av6gQVEoH_dQjDV2Z_TnI3VE8m7Z_Oc7v0mBvWY": 10,
|
||||
"RaSbcDvwLwkauh_1O2BBzyBZ-Onu_LzGzcB7p-7GGXs": 10,
|
||||
"Z8HZq7c1VS6BxOvjCWvs46bnVaW_BepIoSy-v7KZn8E": 10,
|
||||
"n_X3YTN7Wqxz5shER97Q6coFXGLdjFV1OVqhF_lIW78": 10,
|
||||
"3FZjbTJoWH_qEuOmvDEIakVYNIJtHqQhM0pVjyMA_1M": 10,
|
||||
"8zGVX17V6u3Uzn2fWJFya3vEuPOvIZ6FRifUDhaprtE": 10,
|
||||
"Zwp7r7Z10O0TuF6lmFApB7m5lJIrE5RbLAVWg_WKNcU": 10,
|
||||
"1enYq8LDJQ7fxW20WMWxbq3jpMaBeN-k67WXnhEDIds": 10,
|
||||
"efrXSmKuDH32Svllu9g15PxTlxrL5T3UNT1jxgQqat0": 10,
|
||||
"RM1oi-MA5gvJiznjAINPCCfcbN18RBgdXMOJcNoqkUM": 10,
|
||||
"sTSWamZ22DNVQolWIc2L-Cfi88dC7YCE3dtXJwAa1kA": 10,
|
||||
"42MB4-R4ra6HRk7xOK_JODbKzGQ3gvYjssXHERSTROU": 10,
|
||||
"Qa9SzAuwJR6xZp3UiKzokKEoRnt_utJKjFjTaSR85Xw": 10,
|
||||
"38TR3D8BxlPTc89NOW67IkQQUPR8jDLaJNdYv-4wWfM": 10,
|
||||
"yWDo0H85PVimIpHM86qEP8BzXHIvyIfQE7NeVgTbhxs": 10
|
||||
}
|
||||
@@ -73,8 +73,12 @@ export class HandlerBasedContract<State> implements Contract<State> {
|
||||
this.maybeClearNetworkInfo();
|
||||
|
||||
const { stateEvaluator } = this.smartweave;
|
||||
const benchmark = Benchmark.measure();
|
||||
const executionContext = await this.createExecutionContext(this.contractTxId, blockHeight);
|
||||
logger.debug('context', benchmark.elapsed());
|
||||
benchmark.reset();
|
||||
const result = await stateEvaluator.eval(executionContext, currentTx || []);
|
||||
logger.debug('state', benchmark.elapsed());
|
||||
return result as EvalStateResult<State>;
|
||||
}
|
||||
|
||||
@@ -237,11 +241,11 @@ export class HandlerBasedContract<State> implements Contract<State> {
|
||||
contractTxId: string,
|
||||
blockHeight?: number
|
||||
): Promise<ExecutionContext<State, HandlerApi<State>>> {
|
||||
const benchmark = Benchmark.measure();
|
||||
const { arweave, definitionLoader, interactionsLoader, interactionsSorter, executorFactory } = this.smartweave;
|
||||
|
||||
let currentNetworkInfo;
|
||||
|
||||
const benchmark = Benchmark.measure();
|
||||
// if this is a "root" call (ie. original call from SmartWeave's client)
|
||||
if (this.callingContract == null) {
|
||||
logger.debug('Reading network info for root call');
|
||||
@@ -262,9 +266,11 @@ export class HandlerBasedContract<State> implements Contract<State> {
|
||||
if (blockHeight == null) {
|
||||
blockHeight = currentNetworkInfo.height;
|
||||
}
|
||||
logger.debug('network info', benchmark.elapsed());
|
||||
|
||||
const contractDefinition = await definitionLoader.load<State>(contractTxId);
|
||||
|
||||
benchmark.reset();
|
||||
const [contractDefinition, interactions] = await Promise.all([
|
||||
definitionLoader.load<State>(contractTxId),
|
||||
// note: "eagerly" loading all of the interactions up to the current
|
||||
// network height (instead of the requested "blockHeight").
|
||||
// as dumb as it may seem - this in fact significantly speeds up the processing
|
||||
@@ -274,11 +280,12 @@ export class HandlerBasedContract<State> implements Contract<State> {
|
||||
// This basically limits the amount of interactions with Arweave GraphQL endpoint -
|
||||
// each such interaction takes at least ~500ms.
|
||||
// TODO: this could be further optimized to always load interactions only up to the "root's" call requested height
|
||||
const interactions = await interactionsLoader.load(contractTxId, 0, this.networkInfo.height);
|
||||
interactionsLoader.load(contractTxId, 0, this.networkInfo.height)
|
||||
]);
|
||||
logger.debug('contract and interactions load', benchmark.elapsed());
|
||||
const sortedInteractions = await interactionsSorter.sort(interactions);
|
||||
const handler = (await executorFactory.create(contractDefinition)) as HandlerApi<State>;
|
||||
|
||||
logger.debug('Creating execution context:', benchmark.elapsed());
|
||||
const handler = (await executorFactory.create(contractDefinition)) as HandlerApi<State>;
|
||||
|
||||
return {
|
||||
contractDefinition,
|
||||
@@ -301,8 +308,10 @@ export class HandlerBasedContract<State> implements Contract<State> {
|
||||
const { definitionLoader, interactionsLoader, interactionsSorter, executorFactory } = this.smartweave;
|
||||
const blockHeight = transaction.block.height;
|
||||
const caller = transaction.owner.address;
|
||||
const contractDefinition = await definitionLoader.load<State>(contractTxId);
|
||||
const interactions = await interactionsLoader.load(contractTxId, 0, blockHeight);
|
||||
const [contractDefinition, interactions] = await Promise.all([
|
||||
definitionLoader.load<State>(contractTxId),
|
||||
await interactionsLoader.load(contractTxId, 0, blockHeight)
|
||||
]);
|
||||
const sortedInteractions = await interactionsSorter.sort(interactions);
|
||||
const handler = (await executorFactory.create(contractDefinition)) as HandlerApi<State>;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
Benchmark,
|
||||
GQLEdgeInterface,
|
||||
GQLResultInterface,
|
||||
GQLTransactionsResultInterface,
|
||||
@@ -109,10 +110,12 @@ export class ContractInteractionsLoader implements InteractionsLoader {
|
||||
}
|
||||
|
||||
private async getNextPage(variables: ReqVariables): Promise<GQLTransactionsResultInterface> {
|
||||
const benchmark = Benchmark.measure();
|
||||
let response = await this.arweave.api.post('graphql', {
|
||||
query: ContractInteractionsLoader.query,
|
||||
variables
|
||||
});
|
||||
logger.debug('GQL page load:', benchmark.elapsed());
|
||||
|
||||
while (response.status === 403) {
|
||||
logger.debug(`GQL rate limiting, waiting ${ContractInteractionsLoader._30seconds}ms before next try.`);
|
||||
|
||||
@@ -13,8 +13,9 @@ export class Benchmark {
|
||||
this.start = Date.now();
|
||||
}
|
||||
|
||||
public elapsed(): string {
|
||||
public elapsed(rawValue = false): string | number {
|
||||
const end = Date.now();
|
||||
return `${(end - this.start).toFixed(0)}ms`;
|
||||
const result = end - this.start;
|
||||
return rawValue ? result : `${(end - this.start).toFixed(0)}ms`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ export const defaultLoggerOptions: ISettingsParam = {
|
||||
displayFilePath: 'hidden',
|
||||
displayLoggerName: true,
|
||||
dateTimeTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||
minLevel: 'debug'
|
||||
minLevel: 'debug',
|
||||
overwriteConsole: false
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -5376,9 +5376,9 @@ slice-ansi@^4.0.0:
|
||||
is-fullwidth-code-point "^3.0.0"
|
||||
|
||||
smartweave@^0.4.43:
|
||||
version "0.4.43"
|
||||
resolved "https://registry.yarnpkg.com/smartweave/-/smartweave-0.4.43.tgz#0a52dc7dd743dc8300d93e802115b1218f3f9bf6"
|
||||
integrity sha512-jvWwkA3qpdrXngVAE9CeJRxNR0MbsNwvWq+m5U9GrtPY6IFOf9VUIC0mnWJ6SM+rcmXCDBCVFguNqWYfbL9DnA==
|
||||
version "0.4.44"
|
||||
resolved "https://registry.yarnpkg.com/smartweave/-/smartweave-0.4.44.tgz#a421e7ee36eda5d85803a90d11df5dd61c4bbe76"
|
||||
integrity sha512-eERk6fAKKSSHp/1vF+WFh8AtL+Vcq71tNsC+L2Ty/75twldNeYQO53CWTiemgheYrIOOFLB6SeRzTgxEe+zyGA==
|
||||
dependencies:
|
||||
"@types/clui" "^0.3.0"
|
||||
"@types/inquirer" "^7.3.1"
|
||||
|
||||
Reference in New Issue
Block a user