Commit Graph

141 Commits

Author SHA1 Message Date
Jordan Hrycaj 261c0b51a7
Redesign of BaseVMState descriptor (#923)
* Redesign of BaseVMState descriptor

why:
  BaseVMState provides an environment for executing transactions. The
  current descriptor also provides data that cannot generally be known
  within the execution environment, e.g. the total gasUsed which is
  available not before after all transactions have finished.

  Also, the BaseVMState constructor has been replaced by a constructor
  that does not need pre-initialised input of the account database.

also:
  Previous constructor and some fields are provided with a deprecated
  annotation (producing a lot of noise.)

* Replace legacy directives in production sources

* Replace legacy directives in unit test sources

* fix CI (missing premix update)

* Remove legacy directives

* chase CI problem

* rebased

* Re-introduce 'AccountsCache' constructor optimisation for 'BaseVmState' re-initialisation

why:
  Constructing a new 'AccountsCache' descriptor can be avoided sometimes
  when the current state root is properly positioned already. Such a
  feature existed already as the update function 'initStateDB()' for the
  'BaseChanDB' where the accounts cache was linked into this desctiptor.

  The function 'initStateDB()' was removed and re-implemented into the
  'BaseVmState' constructor without optimisation. The old version was of
  restricted use as a wrong accounts cache state would unconditionally
  throw an exception rather than conceptually ask for a remedy.

  The optimised 'BaseVmState' re-initialisation has been implemented for
  the 'persistBlocks()' function.

also:
  moved some test helpers to 'test/replay' folder

* Remove unused & undocumented fields from Chain descriptor

why:
  Reduces attack surface in general & improves reading the code.
2022-01-18 16:19:32 +00:00
jangko f051c2530e
fixes related to nim-json-rpc bump 2021-11-30 14:13:20 +07:00
jangko baf508f6ae
move stateDB from VMState to chainDB
previously, every time the VMState was created, it will also create
new stateDB, and this action will nullify the advantages of cached accounts.

the new changes will conserve the accounts cache if the executed blocks
are contiguous. if not the stateDB need to be reinited.

this changes also allow rpcCallEvm and rpcEstimateGas executed properly
using current stateDB instead of creating new one each time they are called.
2021-10-28 18:57:08 +07:00
jangko 8552dda7bb
premix: fixes premix parser dan graphql_downloader
premix parser:
- fix incorrect tx type comparison
- fix chainId parser to support both graphql and json returned data

graphql_downloadse:
- allow downloader to skip parsing transactions
2021-09-26 10:38:41 +07:00
jangko e23300e2cc
fix premix tools due to recent changes
- persist: fix related to new config
- parser: add EIP 2930 and EIP 1559 features in parseBlockHeader
  and parseTransaction
- add graphql_downloader as a supplement json-rpc downloader
2021-09-21 13:35:52 +07:00
jangko 69f2a0f95a
config: replace stdlib parseOpt with nim-confutils
fixes #581
2021-09-18 17:34:46 +07:00
jangko 48d497580a
config: remove last instance of getConfiguration usage from nimbus code
this is a preparation for migration to confutils based config
although there is still some getConfiguration usage in tests code
it will be removed after new config arrived
2021-09-08 21:25:14 +07:00
jangko c9cfebfa97
config: rearrange getConfiguration usage
avoid using getConfiguration inside object construction and
replace it with passing suitable param
2021-09-08 08:07:10 +07:00
Jordan Hrycaj ca07c40a48
Fearture/poa clique tuning (#765)
* Provide API

details:
  API is bundled via clique.nim.

* Set extraValidation as default for PoA chains

why:
  This triggers consensus verification and an update of the list
  of authorised signers. These signers are integral part of the
  PoA block chain.

todo:
  Option argument to control validation for the nimbus binary.

* Fix snapshot state block number

why:
  Using sub-sequence here, so the len() function was wrong.

* Optional start where block verification begins

why:
  Can speed up time building loading initial parts of block chain. For
  PoA, this allows to prove & test that authorised signers can be
  (correctly) calculated starting at any point on the block chain.

todo:
  On Goerli around blocks #193537..#197568, processing time increases
  disproportionally -- needs to be understand

* For Clique test, get old grouping back (7 transactions per log entry)

why:
  Forgot to change back after troubleshooting

* Fix field/function/module-name misunderstanding

why:
  Make compilation work

* Use eth_types.blockHash() rather than utils.hash() in Clique modules

why:
  Prefer lib module

* Dissolve snapshot_misc.nim

details:
  .. into clique_verify.nim (the other source file clique_unused.nim
  is inactive)

* Hide unused AsyncLock in Clique descriptor

details:
  Unused here but was part of the Go reference implementation

* Remove fakeDiff flag from Clique descriptor

details:
  This flag was a kludge in the Go reference implementation used for the
  canonical tests. The tests have been adapted so there is no need for
  the fakeDiff flag and its implementation.

* Not observing minimum distance from epoch sync point

why:
  For compiling PoA state, the go implementation will walk back to the
  epoch header with at least 90000 blocks apart from the current header
  in the absence of other synchronisation points.

  Here just the nearest epoch header is used. The assumption is that all
  the checkpoints before have been vetted already regardless of the
  current branch.

details:
  The behaviour of using the nearest vs the minimum distance epoch is
  controlled by a flag and can be changed at run time.

* Analysing processing time (patch adds some debugging/visualisation support)

why:
  At the first half million blocks of the Goerli replay, blocks on the
  interval #194854..#196224 take exceptionally long to process, but not
  due to PoA processing.

details:
  It turns out that much time is spent in p2p/excecutor.processBlock()
  where the elapsed transaction execution time is significantly greater
  for many of these blocks.

  Between the 1371 blocks #194854..#196224 there are 223 blocks with more
  than 1/2 seconds execution time whereas there are only 4 such blocks
  before and 13 such after this range up to #504192.

* fix debugging symbol in clique_desc (causes CI failing)

* Fixing canonical reference tests

why:
  Two errors were introduced earlier but ovelooked:
   1. "Remove fakeDiff flag .." patch was incomplete
   2. "Not observing minimum distance .." introduced problem w/tests 23/24

details:
  Fixing 2. needed to revert the behaviour by setting the
  applySnapsMinBacklog flag for the Clique descriptor. Also a new
  test was added to lock the new behaviour.

* Remove cruft

why:
  Clique/PoA processing was intended to take place somewhere in
  executor/process_block.processBlock() but was decided later to run
  from chain/persist_block.persistBlock() instead.

* Update API comment

* ditto
2021-07-30 15:06:51 +01:00
Jordan Hrycaj fbff3aea68
Feature/goerli replay clique poa (#743)
* extract unused clique/mining support into separate file

why:
  mining is currently unsupported by nimbus

* Replay first 51840 transactions from Goerli block chain

why:
  Currently Goerli is loaded but the block headers are not verified.
  Replaying allows real data PoA development.

details:
  Simple stupid gzipped dump/undump layer for debugging based on
  the zlib module (no nim-faststream support.)

  This is a replay running against p2p/chain.persistBlocks() where
  the data were captured from.

* prepare stubs for PoA engine

* split executor source into sup-modules

why:
  make room for updates, clique integration should go into
  executor/update_poastate.nim

* Simplify p2p/executor.processBlock() function prototype

why:
  vmState argument always wraps basicChainDB

* split processBlock() into sub-functions

why:
  isolate the part where it will support clique/poa

* provided additional processTransaction() function prototype without _fork_ argument

why:
  with the exception of some tests, the _fork_ argument is always derived
  from the other prototype argument _vmState_

details:
  similar situation with makeReceipt()

* provide new processBlock() version explicitly supporting PoA

details:
  The new processBlock() version supporting PoA is the general one also
  supporting non-PoA networks, it needs an additional _Clique_ descriptor
  function argument for PoA state (if any.)
  The old processBlock() function without the _Clique_ descriptor argument
  retorns an error on PoA networgs (e.g. Goerli.)

* re-implemented Clique descriptor as _ref object_

why:
  gives more flexibility when moving around the descriptor object

details:
  also cleaned up a bit the clique sources

* comments for clarifying handling of Clique/PoA state descriptor
2021-07-06 14:14:45 +01:00
jangko d47be9047f
London: fix test_blockchain_json and test_generalstate_json
new London HF requires update to test code
2021-06-30 20:41:29 +07:00
jangko 4a188788bd
preparation for EIP-1559 implementation
- unify signTx in test_helper and signTransaction in rpc_utils
  and put it into transaction.nim
- clean up mess by previous EIP-2930
2021-06-29 07:33:48 +07:00
jangko a0d10f5728
drop PublicNetwork enum usage and replace it with NetworkId
we cannot limit the `--networkid` switch to values available in
`PublicNetwork` enum. it should able to accept very wide range of
custom NetworkId.
2021-05-20 14:04:16 +07:00
jangko 79044f1e92
eip2718: test_blockchain_json pass test 2021-05-15 18:09:35 +07:00
jangko 39ce2390ae
fixes `getRecipient`: using `sender` param instead of calculating sender itself
usually, there is always a sender around `getRecipient` call.
no need to recalculate sender. and more important, in some of
JSON-RPC/GraphQL call, the sender is come from `rpcCallData`,
not from `tx.getSender`. or in ohter situation when the tx is
an unsigned tx, without `r,s,v` fields to calculate sender.
2021-05-04 15:31:47 +07:00
Jamie Lokier 33481064fd
Premix: Remove `MordenNet` to match main program
Morden network has not had a working configuration in Nimbus for a few years,
so it's been removed form the main program.  Remove it from premix as well.

Signed-off-by: Jamie Lokier <jamie@shareable.org>
2021-04-27 11:11:24 +01:00
jangko 14cf2c8cac fixes premix/downloader.nim to compile with new json_rpc 2021-03-19 12:30:00 +07:00
jangko f6774b636a
fix premix/parser 2020-07-30 15:24:22 +07:00
jangko 9c38266ba7
implement eth_estimateGas 2020-07-29 12:42:32 +07:00
jangko f82dff64fa
implement more eth rpc and keystore management 2020-07-23 14:54:32 +07:00
jangko 165f9fea2e
reduce warnings 2020-07-21 13:15:06 +07:00
jangko 2e583e9aa0
fix persist tool to support testnet 2020-06-19 17:52:19 +07:00
andri lim 02db881eea
upgrade jquery to 3.5.0, uikit to 3.4.0 and silence github security alert 2020-05-01 11:24:49 +07:00
Jacek Sieka 4ade5797ee
rlp: don't use ranges / experimental features (#495) 2020-04-20 20:12:44 +02:00
andri lim f66f49168a
fix bc/gst tester for istanbul [skip ci] 2019-11-14 21:20:34 +07:00
andri lim c5d07fc07f implement bc test fixtures parser 2019-09-04 19:05:21 +02:00
Jacek Sieka 2763bd0dd5
std_shims -> stew 2019-07-07 12:12:01 +02:00
Yuriy Glukhov 19e7d70099 Fixed rpc client api usage 2019-06-24 19:32:34 +03:00
andri lim 0b87151195
remove head from processBlock 2019-03-21 09:44:53 +07:00
Ștefan Talpalaru a67edd693a
assert() -> doAssert() 2019-03-13 22:36:54 +01:00
andri lim 72cebff516 add 'DownloadAndValidate' flag to premix downloader 2019-03-13 15:45:33 +02:00
andri lim 0c01735c4b
add some info to persist tool 2019-03-11 20:21:09 +07:00
andri lim 299d88d3f9
fix premix report page pagination 2019-03-11 16:38:16 +07:00
andri lim 8b9f4fd702
add pagination to premix report page 2019-03-11 10:49:36 +07:00
andri lim e2311d798b
fix recurring symbol collision problem 2019-03-07 22:53:09 +07:00
andri lim 14d1c28982 new member of premix tool set 2019-02-27 13:44:01 +02:00
andri lim 2c032ad1ab refactor utils 2019-02-27 13:30:18 +02:00
andri lim d21d0814c6 add getAncestorHash to hunter tool 2019-02-22 13:11:28 +02:00
andri lim 0e6f96b0e1 use transaction.rollback in debug, hunter, and dumper 2019-02-22 13:11:28 +02:00
andri lim 47a8089ff8 fixes #236 2019-02-21 13:09:36 +02:00
andri lim 6f0f7624b9 premix report page: fix receipts logs renderer 2019-02-20 15:16:07 +02:00
andri lim e1c622f83f update readme.md 2019-02-18 13:16:04 +02:00
andri lim 00989e9c9a premix report page: chunked table cell using monospace font 2019-02-18 13:16:04 +02:00
andri lim fdc34a4cf6 fixes vmState construction 2019-02-15 17:20:51 +02:00
andri lim a6ecdb22b4 premix report page: fix empty traces renderer 2019-02-07 11:25:54 +01:00
Zahary Karadjov 48cdc6da0b
make some 'beginTransaction' usages safer 2019-02-07 11:10:04 +01:00
andri lim fdc9a15785 premix: fix dumper tool, dispose db changes 2019-02-07 11:01:43 +01:00
andri lim 601350d8d0 premix: fixes debug tool, dispose db changes 2019-02-06 18:42:03 +01:00
andri lim 2f208c32e0 premix report page: fixes stack renderer 2019-02-06 18:42:03 +01:00
andri lim 817bce3555 premix report page: modify header section to display block summary 2019-02-06 18:42:03 +01:00
andri lim f75faf54c3 premix report page: add accounts section 2019-02-06 18:42:03 +01:00
andri lim e3b6ffe5ba add precompiled contract names to premix report page to identify accounts 2019-02-06 18:42:03 +01:00
Yuriy Glukhov 481c6cf4ed Use nim-eth (#224) 2019-02-05 20:15:50 +01:00
andri lim 33716888df
sign with GPG 2019-01-28 20:58:06 +07:00
andri lim c0484adfa0 remove tabs from js_tracer.nim 2019-01-28 20:17:20 +07:00
Ștefan Talpalaru 95829b1f3f reword the HTML help
and add a note about geth not switching to a full sync if it was run
with a fast sync at any time in the past in that same db
2019-01-28 12:38:23 +02:00
Ștefan Talpalaru f37352e127 readme subtitles for individual tools 2019-01-28 12:38:23 +02:00
Ștefan Talpalaru ede45648e7 Premix-related changes
- build all tools using the Makefile and place them in ./build
- add copyright header to Makefile
- premix/readme.md edited to fix some errors, improve descriptions and
  document Makefile usage
- link the Premix documentation in the main README.md
- also build `hunter` in the nimble tests
- refactored the file and directory search so all debugging tools can be run
  from the top-level dir like this: `./build/<tool> ...`
- write all JSON debugging data in the current directory
- add JSON files generated in the top-level dir to .gitignore
- Nimbus now exits with an exception after dumping debug data and
  running `premix` on it
2019-01-28 12:38:23 +02:00
andri lim c3190f0c7a add db beginTransaction and dispose to hunter 2019-01-21 22:22:41 +02:00
andri lim 1c80c1c160 remove unnecessary debug code 2019-01-15 19:34:28 +02:00
andri lim 691dc5566f fix render missing field in premix report page 2019-01-15 19:34:28 +02:00
andri lim 9b33aeff6b update readme.md, hunter usage 2019-01-15 15:30:25 +02:00
andri lim e90c7498ba update readme.md 2019-01-15 15:30:25 +02:00
andri lim 16cebc469b add txKind to report page 2019-01-15 15:30:25 +02:00
andri lim 6ebe8ef2d4 add hunter tool 2019-01-15 15:30:25 +02:00
andri lim c1881fb061 simplifly premix code 2019-01-15 15:30:25 +02:00
andri lim 66ae0145f0 augment debug tool: fix, compile, update report page, iterate 2019-01-15 15:30:25 +02:00
andri lim 78367bf10a fix debug tool 2019-01-15 15:30:25 +02:00
andri lim e104153379 add premix and browser launcher code 2019-01-15 15:30:25 +02:00
andri lim 2b66716d9c fix some renderer logic 2019-01-15 15:30:25 +02:00
andri lim 07ab94cdf0 fix some typo 2019-01-15 15:30:25 +02:00
andri lim 087f2db5bf update readme.md 2019-01-15 15:30:25 +02:00
andri lim 019a208f94 add render receipts logs and accounts storage 2019-01-15 15:30:25 +02:00
andri lim f1bb0d1b31 poststate processing 2019-01-15 15:30:25 +02:00
andri lim 451eaed620 update readme.md 2019-01-15 15:30:25 +02:00
andri lim 7c4cb7a58e add report page 2019-01-15 15:30:25 +02:00
andri lim 0a6b3505f2 add dumper tool 2019-01-15 15:30:25 +02:00
andri lim 000af79b03 premix trace uncles account 2019-01-15 15:30:25 +02:00
andri lim da75707912 catch premix and persit tool exception 2019-01-15 15:30:25 +02:00
andri lim b0f4a236fa add .gitignore 2019-01-15 15:30:25 +02:00
andri lim 013d935642 add premix tool 2019-01-15 15:30:25 +02:00
andri lim 101c17d126 add prestate.nim 2019-01-15 15:30:25 +02:00
andri lim 8978d1fcaa update readme.md 2019-01-15 15:30:25 +02:00
andri lim 729686ff57 add debug tool 2019-01-15 15:30:25 +02:00
andri lim 49bb7bb6e4 add configuration 2019-01-15 15:30:25 +02:00
andri lim 9f590a22e8 fix persist tool 2019-01-15 15:30:25 +02:00
andri lim 0c887b3711 move initializeEmptyDb to genesis.nim 2019-01-15 15:30:25 +02:00
andri lim 7190b218de add premix support tools 2019-01-15 15:30:25 +02:00
andri lim fb92552f28 add report page assets 2019-01-15 15:30:25 +02:00
andri lim 4da247f9a9 update readme.md 2019-01-15 15:30:25 +02:00
andri lim e9f9c13c02 add readme.md 2019-01-15 15:30:25 +02:00