Commit Graph

58 Commits

Author SHA1 Message Date
jangko 77be2f66d2
handle PoA block difficulty during block creation
- in vmState
- in txpool
- in sealing engine

fix #1105
2022-06-15 07:55:00 +07:00
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 cec628e620
cleanup: remove unused accessLogs code from vm_state
they are not used anywhere at present, nor in the future
2021-10-28 11:30:18 +07:00
jangko db8988fe64
EIP-1559: Fee market change for ETH 1.0 chain
Transaction and BlockHeader already updated in nim-eth repo
to support EIP-1559

EIP-1559 header validation and gasLimit validation
already implemented in previous commit

This commit deals with block validation:
- Effective gasPrice per EIP-1559
- new miner reward based on priorityFee
2021-06-30 20:30:39 +07:00
Jordan Hrycaj 69a1ee5fc8 re-named some v2state_transactions.nim to its original name without the v2
also:
  re-integrated stack_defs.nim back into stack.nim

why:
  the v2 prefix of the file name was used as a visual aid when
  comparing vm2 against vm sources
2021-04-28 15:24:14 +03:00
Jordan Hrycaj ff6921eb1a re-named some v2*.nim sources to its original name *.nim (without the v2)
why:
  the v2 prefix of the file name was used as a visual aid when
  comparing vm2 against vm sources

details:
  all renamed v2*.nim sources compile locally with the -d:kludge:1 flag
  set or without (some work with either)

  only sources not renamed yet: v2state_transactions.nim
2021-04-28 15:24:14 +03:00
Jordan Hrycaj 18587f5496 move setupTxContext() from v2state.nim to v2state_transactions.nim
why:
  removes circular dependency in v2state.nim which is more used than
  v2state_transactions.nim
2021-04-28 15:24:14 +03:00
Jordan Hrycaj f159e67bba renamed states*.nim => v2states*.nim
why:
  these files provide part of the externally accessible interface
  provided by vm_state*.nim. so the new filename indicates that the
  source code belongs to vm2 (rather than vm).
2021-04-23 14:04:06 +03:00
Jordan Hrycaj b4f8450968 provide identical copy of vm folder => vm2, activated by make flag ENABLE_VM2=1
why:
  vm2 enabled by ENABLE_VM2=1 behaves as vm without ENABLE_EVMC=1 until
  it doesn't in some future fatch set. this leaves some wiggle room
  to work on a vm copy without degrading the original implementation.

details:
  + additional make flag ENABLE_VM2=1 (or ENABLE_VM2=0 to explicitely disable)
  + when both flags ENABLE_EVMC=1 and ENABLE_VM2=1 are present, the former
    flag ENABLE_EVMC=1 takes precedence, this is implemented at the NIM
    compiler level for -d:evmc_enabled and -d:vm2_enabled
2021-04-23 14:04:06 +03:00
Jordan Hrycaj 9e365734e6
renamed nvm_ prefixed modules to its original names
why:
  the nvm_ prefix was used inside the vm folder to hide them temporarily
  from the outside world while writing export wrappers. now all
  functionality is accessed via vm_*, rather than vm/* imports.

todo:
  at a later stage the import headers of the vm modules need to get fixed
  to meet style guide standards (as jacek kindly pointed out.)
2021-03-31 17:19:54 +01:00
Jordan Hrycaj eda1290c25
isolate vm_state as import/export wrapper
details:
  moved original vm_state.nim => vm/nvm_state.nim
2021-03-31 09:58:26 +01:00
jangko 165f9fea2e
reduce warnings 2020-07-21 13:15:06 +07:00
jangko 845671bf0a
fix compilation error following breaking changes in nim-eth 2020-07-20 13:50:05 +07:00
jangko f401622782
cache miner address instead of recalculation 2020-06-22 07:48:23 +07:00
jangko 2385df7bae
miner address calculation for PoA consensus engine 2020-06-19 20:24:09 +07:00
jangko bd7e1fe2e5
reuse VMState and AccountsCache for better performance 2020-06-18 13:16:38 +07:00
jangko 49460b6b1e
move buildWitness from test_blockchain_json to vm_state 2020-06-18 13:16:38 +07:00
jangko eabacb0a33
allow nimbus to read geth database 2020-06-18 13:16:25 +07:00
jangko 7c026e1b48
modify VMState to enable witness data collection 2020-06-06 10:05:11 +07:00
jangko 71514a0a66
replace state_db with accounts_cache 2020-05-30 10:14:59 +07:00
andri lim 87bae2bb78
switch to new toFork 2020-04-12 18:02:59 +07:00
andri lim 1cd9353faa simplify computation 2020-02-12 17:53:26 +02:00
andri lim d656f7f701 rename 'txContext' to 'setupTxContext' 2020-01-23 18:07:44 +02:00
andri lim c1ef8632b2 move fork and gasCosts from Computation to vmState 2020-01-20 18:36:58 +02:00
andri lim bab359cabf move origin and gasPrice from Message to vmState 2020-01-20 18:36:58 +02:00
andri lim d30f434f03 get rid of computation child after execution 2020-01-19 19:17:37 +02:00
andri lim 2472662057 [skip ci] simplify rootHash usage 2020-01-19 19:17:37 +02:00
andri lim c4dcf5da30
reduce compiler warnings 2019-11-13 21:49:39 +07:00
andri lim e63a43ee9f fixes getAncestorHash 2019-09-26 12:33:43 +03:00
andri lim 7c134b481e
split state clearing in execComputation to processTransaction, GST +5 2019-04-18 08:27:55 +07:00
andri lim 527891cdb8
integrate snapshot with computation 2019-03-28 19:06:31 +07:00
Ștefan Talpalaru a67edd693a
assert() -> doAssert() 2019-03-13 22:36:54 +01:00
andri lim 4cc318d948 fix block 668910 problem 2019-02-28 10:04:49 +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 c722f34ef3 safer snapshot commit revert and dispose 2019-02-18 18:15:32 +02:00
andri lim 8461211f9a bugfix: implement computation snapshot, revert, commit 2019-02-18 13:16:04 +02:00
andri lim 282824cd53 zah's request: add missing comments 2019-02-18 13:16:04 +02:00
andri lim 04f28d9048 fixes vm state get block hash 2019-02-15 17:20:51 +02:00
andri lim fdc34a4cf6 fixes vmState construction 2019-02-15 17:20:51 +02:00
andri lim d8db3d74d0 fix NUMBER opcode regression 2019-02-07 11:01:43 +01:00
andri lim 67c38b0275 fixes NUMBER opcode 2019-02-06 18:42:03 +01:00
Yuriy Glukhov 481c6cf4ed Use nim-eth (#224) 2019-02-05 20:15:50 +01:00
Ștefan Talpalaru a431ceed11 add "--threads:on" to tests and main binary
- some "funcs" were no longer considered side-effect free, so I made
  them procs
- added {.base.} to some base methods to avoid a deprecation warning
2019-01-15 18:59:24 +02:00
andri lim b93d809805 fix internal transactions account tracing 2019-01-06 13:17:25 +02:00
andri lim e78fb72ef6 fixes #188 2019-01-06 13:16:45 +02:00
andri lim 8a6d351c22 add internal transactions dump 2019-01-06 11:43:38 +02:00
andri lim 9d6dbceefc add enable/disableTracing to vm_state 2019-01-06 11:43:38 +02:00
andri lim ad1202f98a initial make_receipt 2018-12-16 15:38:51 +02:00
andri lim 5509c66cce implement transaction tracer 2018-12-05 22:01:28 +07:00