Implement CIP-43: BlockContext(now rename to SysContractCallCtx)#1696
Implement CIP-43: BlockContext(now rename to SysContractCallCtx)#169637ng merged 63 commits intotrianglesphere/workfrom
Conversation
56edaf0 to
da41ae9
Compare
trianglesphere
left a comment
There was a problem hiding this comment.
Looking good so far. I've got one comment on keeping track of the statedb
trianglesphere
left a comment
There was a problem hiding this comment.
Looking good. I left a couple small comments. Try a merge from trianglesphere/work - more tests should be passing.
|
Coverage from tests in |
|
Coverage from tests in |
|
Coverage from tests in |
|
Coverage from tests in |
|
Coverage from tests in |
- Use stateDB.Copy() for sysContractCallCtx in Process() & BlockState - Use header rather than parentHeader
This reverts commit a82eeb5.
|
Coverage from tests in |
|
Coverage from tests in |
|
Coverage from tests in |
trianglesphere
left a comment
There was a problem hiding this comment.
Overall looks good. The only change I'd like before merging is removing the Faker check inside state_transition.go.
|
Coverage from tests in |
|
Coverage from tests in |
|
Coverage from tests in |
|
Coverage from tests in |
|
Coverage from tests in |
|
Coverage from tests in |
Description
Background
CIP Link
Use cases
Current
1. In
core.tx_pool_contextReset in
txPool.reset()every new block, for sorting and checking TX validity.New
1. In
miner.blockStateThis is where validators mine blocks. We can initialize it within
BlockStatescope since we will reuse the contract call results from the state of beginning of a block, and apply all transactions within that block, and reset it for every new block.2. In
core.stateProcessor.Process()This
stateProcessor.Process()is used forengine.Verify()during consensus, andchain.insertChain().Process()takes a block as argument, it makes sense to initialize an SCCC in this scope.Implementation plan
core.BlockContexttoSysContractCallCtx(SCCC) to avoid confusion, because we already havevm.BlockContext.For use case 1: miner.BlockState
worker.prepareBlock, such that when the miner is constructing blocks, the SCCC can be passed over tocore.ApplyTransaction().For use case 2: core.stateProcessor.Process()
stateProcessor.Process(), pass it over tocore.ApplyTransaction().Other changes
None
Tested
TODO
Related issues
Backwards compatibility
A hard fork change.