Skip to content

Instantly share code, notes, and snippets.

View feuGeneA's full-sized avatar

F. Eugene Aumson feuGeneA

View GitHub Profile
$ time cargo bench -- --verbose 2>&1 |ts -i
00:00:00 Compiling rethnet_evm v0.1.0-dev (/home/gene/dev/nomiclabs/rethnet/crates/rethnet_evm)
00:00:04 Finished bench [optimized] target(s) in 4.59s
00:00:00 Running benches/state_ref_basic.rs (/home/gene/dev/nomiclabs/rethnet/target/release/deps/state_ref_basic-a361ed5b0ff66871)
00:00:01 Benchmarking layered_create_with_{}_addresses/100
00:00:00 Benchmarking layered_create_with_{}_addresses/100: Warming up for 3.0000 s
00:00:04 Benchmarking layered_create_with_{}_addresses/100: Collecting 10 samples in estimated 5.1261 s (330 iterations)
00:00:05 Benchmarking layered_create_with_{}_addresses/100: Analyzing
00:00:00 layered_create_with_{}_addresses/100
00:00:00 time: [15.447 ms 15.563 ms 15.713 ms]

Is monerod wasting time in handle_incoming_txs during initial node synchronization?

I wondered if there might be some way to speed up the initial node synchronization, so I profiled it with perf. I discovered that the cryptonote_protocol_handler function is reportedly spending 58% of its time in cryptonote::core::handle_incoming_txs, and only 40% of its time in cryptonote::core::handle_incoming_block. I'm still new to Monero, but shouldn't a still-synchronizing node be ignoring incoming transactions until it is fully synchronized?

(An explanation of those 58% and 40% numbers: See in the perf report below the line 43.77% cryptonote::t_cryptonote_protocol_handler, indicating that monerod spent 43.77% of its time in that function. Then see the subsequent two lines, 25.47% cryptonote::core::handle_incoming_txs and 17.65% cryptonote::core::handle_incoming_block. 24.47 is 58% of 43.77, and 17.65 is 40% of 43.77.)

Code in use

$ git status
DROP VIEW IF EXISTS price_data CASCADE;
DROP VIEW IF EXISTS volatility CASCADE;
DROP VIEW IF EXISTS concepts.hourly_log_returns CASCADE;
CREATE MATERIALIZED VIEW concepts.hourly_log_returns AS
SELECT
candle_hour,
symbol,
LN(
--- addresses.json_3.0.0 2020-06-27 08:04:53.975997296 -0400
+++ addresses.json_3.1.0 2020-06-27 08:04:44.715898823 -0400
@@ -1,127 +1,222 @@
{
"1": {
"exchangeV2": "0x080bf510fcbf18b91105470639e9561022937712",
"exchange": "0x61935cbdd02287b511119ddb11aeb42f1593b7ef",
"erc20Proxy": "0x95e6f48254609a6ee006f7d493c8e5fb97094cef",
"erc721Proxy": "0xefc70a1b18c432bdc64b596838b4d138f6bc6cad",
- "forwarder": "0xa3ac9844514b96bb502627ca9dceb57c4be289e3",
$ node lib/src/PgListenNotify.js
Received {"timestamp":1593013915520}. Latency was 1 ms
Received {"timestamp":1593013916523}. Latency was 1 ms
Received {"timestamp":1593013917525}. Latency was 0 ms
Received {"timestamp":1593013918526}. Latency was 1 ms
Received {"timestamp":1593013919528}. Latency was 0 ms
Received {"timestamp":1593013920529}. Latency was 1 ms
Received {"timestamp":1593013921531}. Latency was 1 ms
Received {"timestamp":1593013922533}. Latency was 0 ms
Received {"timestamp":1593013923534}. Latency was 1 ms
import createSubscriber from 'pg-listen';
// Function to sleep in between latency samples.
async function sleep(): Promise<void> {
const delay: number = 1000;
await new Promise(resolve => setTimeout(resolve, delay));
}
const subscriber = createSubscriber({ connectionString: 'http://postgres:password@localhost:5432' });
$ yarn test:rest && yarn test:rfqt
$ ETHEREUM_RPC_URL=http://localhost:8545 CHAIN_ID=1337 RFQT_API_KEY_WHITELIST='koolApiKey1,koolApikey2' RFQT_MAKER_ASSET_OFFERINGS='{"https://mock-rfqt1.club": [["0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c","0x0b1ba0af832d7c05fd64161e0db78e85978e8082"]]}' META_TXN_RELAY_ADDRESS=0x9eFCa436873b55a0d6AEa260f92DE50150360dca META_TXN_RELAY_PRIVATE_KEY=82b9c3b8d45f608badd8fda250a0d95088381540e850734519b659e1e1ac3e71 mocha --exclude lib/test/rfqt_test.js --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --timeout 200000 --exit
meta transactions tests
[meta transactions tests-start] $ node -r dotenv/config lib/src/index.js
[meta transactions tests-start] {"level":"error","time":1592002985264,"pid":26692,"hostname":"precision5510","msg":"TypeError: contract_wrappers_1.ITransformERC20Contract is not a constructor\n at new ExchangeProxySwapQuoteConsumer (/home/gene/dev/0x-api/node_modules/@0x/asset-swapper/src/quote_consumers/exchange_proxy
12Jun18:53:24 [2 jobs] ~/dev/0x-api[master *$%=]$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: package.json
modified: test/meta_transaction_test.ts
modified: test/utils/deployment.ts
$ bt
yarn run v1.21.1
$ tsc -p tsconfig.json
Done in 12.42s.
yarn run v1.21.1
$ yarn test:rest && yarn test:rfqt
$ ETHEREUM_RPC_URL=http://localhost:8545 CHAIN_ID=1337 RFQT_API_KEY_WHITELIST='koolApiKey1,koolApikey2' RFQT_MAKER_ASSET_OFFERINGS='{"https://mock-rfqt1.club": [["0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c","0x0b1ba0af832d7c05fd64161e0db78e85978e8082"]]}' META_TXN_RELAY_ADDRESS=0x9eFCa436873b55a0d6AEa260f92DE50150360dca META_TXN_RELAY_PRIVATE_KEY=82b9c3b8d45f608badd8fda250a0d95088381540e850734519b659e1e1ac3e71 mocha --exclude lib/test/rfqt_test.js --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --timeout 200000 --exit
meta transactions tests
22May12:37:56 [2 jobs] ~/dev/0x-api[fix/asset-swapper-rfqt-response-codes %=]$ t
yarn run v1.19.1
$ yarn test:rest && yarn test:rfqt
$ ETHEREUM_RPC_URL=http://localhost:8545 CHAIN_ID=1337 RFQT_API_KEY_WHITELIST='koolApiKey1,koolApikey2' RFQT_MAKER_ASSET_OFFERINGS='{"https://mock-rfqt1.club": [["0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c","0x0b1ba0af832d7c05fd64161e0db78e85978e8082"]]}' META_TXN_RELAY_ADDRESS=0x9eFCa436873b55a0d6AEa260f92DE50150360dca META_TXN_RELAY_PRIVATE_KEY=82b9c3b8d45f608badd8fda250a0d95088381540e850734519b659e1e1ac3e71 mocha --exclude lib/test/rfqt_test.js --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --timeout 200000 --exit
transaction watcher signer tests
.getSortedSignersByAvailability
✓ sorts signers in order of highest balance andd lowest tx count
tx lifecycle