@@ -0,0 +1,114 @@
1+// usage: tweak constants at head of file, then run "node find-gas-usage.js"
2+// for very common events/calls, you may need to use a smaller TO-FROM
3+// range to keep web3 from yelling at you
5+const ORIGIN = 6784800; // launch ceremony begins
6+const PUBLIC = 7033765; // azimuth becomes public
7+const LATEST = 'latest';
8+const AZIMUTH_ADDRESS = '0x223c067f8cf28ae173ee5cafea60ca44c335fecb';
10+ 'https://mainnet.infura.io/v3/196a7f37c7d54211b4a07904ec73ad87';
15+const VENT = 'ChangedKeys';
16+const FUNC = '0x4447e48c'; // configureKeys
19+// const VENT = 'Spawned';
20+// const FUNC = '0xa0d3253f'; // spawn
23+// const VENT = 'OwnerChanged';
24+// const FUNC = '0x1e79a85b'; // transferPoint
27+// const VENT = 'ChangedSpawnProxy';
28+// const FUNC = '0xae326221'; // setSpawnProxy
31+// const VENT = 'ChangedManagementProxy';
32+// const FUNC = '0x8866bb2c'; // setManagementProxy
35+// const VENT = 'ChangedTransferProxy';
36+// const FUNC = '0x2c7ba564'; // setTransferProxy
39+// const VENT = 'ChangedVotingProxy';
40+// const FUNC = '0xa60e8bd6'; // setVotingProxy
43+// const VENT = 'EscapeRequested';
44+// const FUNC = '0xbf5772b9'; // escape
47+// const VENT = 'EscapeCanceled';
48+// const FUNC = '0xc6d761d4'; // cancelEscape
51+// const VENT = 'EscapeAccepted';
52+// const FUNC = '0xc1b9d98b'; // adopt
55+// const VENT = 'EscapeCanceled';
56+// const FUNC = '0xbbe21ca5'; // reject
59+// const VENT = 'LostSponsor';
60+// const FUNC = '0x073a7804'; // detach
63+const LENT = 64 * ARGS + FUNC.length;
65+const Web3 = require('web3');
66+const azimuth = require('azimuth-js');
69+ const web3 = new Web3(new Web3.providers.HttpProvider(ENDPOINT));
70+ const contracts = await azimuth.initContractsPartial(web3, AZIMUTH_ADDRESS);
72+ const keyEvents = await contracts.azimuth.getPastEvents(VENT, {
77+ const txsBatch = new web3.BatchRequest();
78+ keyEvents.map(vent => {
80+ web3.eth.getTransaction.request(vent.transactionHash, (err, res) => {})
83+ const txs = await txsBatch.execute();
84+ const keyTxs = txs.response.filter(tx => {
85+ const head = tx.input.slice(0, 10) === FUNC;
86+ const size = tx.input.length === LENT;
88+ console.log('weird inputs', tx.hash);
93+ const receiptsBatch = new web3.BatchRequest();
96+ web3.eth.getTransactionReceipt.request(tx.hash, (err, res) => {})
99+ const recs = await receiptsBatch.execute();
102+ recs.response.map(rec => {
103+ if (rec.status !== true) {
104+ console.log('rejecting', rec.gasUsed);
107+ if (rec.gasUsed in usage) {
108+ usage[rec.gasUsed]++;
110+ usage[rec.gasUsed] = 1;