CodeChain-io / CodeChain-io/foundry

block.state.commit is slow

Offen
#74 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
performance
Vorherrschende Sprache
Rust
Sterne
36
Forks
11
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

I found that `block.state.commit` function is slow.
In Corgi network, when a block has a transaction that splits one UTXO to 100 UTXOs, the `block.state.commit` function takes 7 seconds when called by a proposer, takes 5 seconds when is called by other validators.

I added logs to find the function. You can see the logs in this [link](https://github.com/CodeChain-io/codechain/pull/1718)

Here are the sample logs.

```
// in proposer
#105317671 2019-07-25 10:51:27 UTC Client Worker CodeChain-io/codechain#2 TRACE miner Adding transaction 0x7a2813b09fc75f31e94f10af6f8e80d4fdf9e7ab3a856852a5c76a75b5b62018 took 13.64375ms
#105317671 2019-07-25 10:51:27 UTC Client Worker CodeChain-io/codechain#2 DEBUG miner Pushed 1/1 transactions
#105317671 2019-07-25 10:51:27 UTC Client Worker CodeChain-io/codechain#2 DEBUG miner Get parent hash
#105317671 2019-07-25 10:51:27 UTC Client Worker CodeChain-io/codechain#2 DEBUG miner Get parent header
#105317671 2019-07-25 10:51:27 UTC Client Worker CodeChain-io/codechain#2 DEBUG miner Get parent view
#105317671 2019-07-25 10:51:27 UTC Client Worker CodeChain-io/codechain#2 DEBUG miner Get transactions root
#105317671 2019-07-25 10:51:27 UTC Client Worker CodeChain-io/codechain#2 DEBUG miner Clone block state
#105317671 2019-07-25 10:51:27 UTC Client Worker CodeChain-io/codechain#2 DEBUG miner Call on_close_block
#105317671 2019-07-25 10:51:27 UTC Client Worker CodeChain-io/codechain#2 TRACE state add_balance(0x6850…65e1, 50): 2639520825
#105317671 2019-07-25 10:51:27 UTC Client Worker CodeChain-io/codechain#2 TRACE state add_balance(0x6202…8750, 19): 1300650642
#105317671 2019-07-25 10:51:27 UTC Client Worker CodeChain-io/codechain#2 TRACE state add_balance(0x263b…fcb1, 30): 1762899421
#105317671 2019-07-25 10:51:27 UTC Client Worker CodeChain-io/codechain#2 TRACE state add_balance(0x0968…b3f6, 1): 919023814
#105317671 2019-07-25 10:51:27 UTC Client Worker CodeChain-io/codechain#2 DEBUG miner commit state

#105317671 2019-07-25 10:51:34 UTC Client Worker CodeChain-io/codechain#2 DEBUG miner Set transactions root
#105317671 2019-07-25 10:51:34 UTC Client Worker CodeChain-io/codechain#2 DEBUG miner set state root
#105317671 2019-07-25 10:51:34 UTC event.loop INFO rpc RPC call(slog([]))
#105317671 2019-07-25 10:51:34 UTC Client Worker CodeChain-io/codechain#2 DEBUG miner Close block
#105317671 2019-07-25 10:51:34 UTC Client Worker CodeChain-io/codechain#2 DEBUG miner Before get write access of mem_pool
#105317671 2019-07-25 10:51:34 UTC Client Worker CodeChain-io/codechain#2 DEBUG miner After get write access of mem_pool
#105317671 2019-07-25 10:51:34 UTC Client Worker CodeChain-io/codechain#2 TRACE mem_pool remove() called, time: 2126657, timestamp: 1564051884
#105317671 2019-07-25 10:51:34 UTC Client Worker CodeChain-io/codechain#2 TRACE miner update_sealing: engine indicates internal sealing
#105317671 2019-07-25 10:51:34 UTC Client Worker CodeChain-io/codechain#2 TRACE miner seal_block_internally: attempting internal seal.
#105317671 2019-07-25 10:51:34 UTC tendermint TRACE engine Proposer nonce: 26
```

```
// in another validator
#608329186 2019-07-25 11:17:25 UTC Blocks Verifier CodeChain-io/codechain#1 DEBUG miner Before lock block 2126978

#608329186 2019-07-25 11:17:30 UTC Blocks Verifier CodeChain-io/codechain#1 DEBUG miner After lock block 2126978
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit dem durch die Logs identifizierten Aufruf von block.state.commit und untersuche die im Issue beschriebenen Proposer- und Validator-Pfade. Profiliere den Fall mit 100-UTXO anhand der bereitgestellten Timing-Logs; erledigt bedeutet, dass der Commit-Engpass identifiziert und die gemeldeten Verzögerungen reduziert sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rust
Bereich
blockchain, performance
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.