You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OS & Version: Linux
Commit hash : de1cecb (master)
Expected behaviour
When using AdjustTime directly after a Fork, the following Commit should still create a block in the side-chain, the same goes for all other AdjustTime and Commit calls afterwards.
Actual behaviour
AdjustTime uses the current head (b.blockchain.CurrentBlock()), which is the canonical head and thus not the block we just rolled back to when calling Fork. Thus the following call to Commit creates a block with parent h3 instead of with parent h1, resulting in the same bahavior as if Fork was never called.
Fix
Use b.blockchain.GetBlockByHash(b.pendingBlock.ParentHash()) instead of b.blockchain.CurrentBlock() in SimulatedBackend.AdjustTime.
Steps to reproduce the behaviour
// Create a new SimulatedBackend (should be possible without allocations)sb:=backends.NewSimulatedBackend(
core.GenesisAlloc{},
30_000_000,
)
sb.Commit() // h1h1:=sb.Blockchain().CurrentHeader().Hash()
sb.Commit() // h2sb.Fork(context.Background(), h1)
sb.AdjustTime(1*time.Second)
sb.Commit() // Should have h1 as parent but has h2
The text was updated successfully, but these errors were encountered:
System information
OS & Version: Linux
Commit hash : de1cecb (master)
Expected behaviour
When using
AdjustTime
directly after aFork
, the followingCommit
should still create a block in the side-chain, the same goes for all otherAdjustTime
andCommit
calls afterwards.Actual behaviour
AdjustTime
uses the current head (b.blockchain.CurrentBlock()
), which is the canonical head and thus not the block we just rolled back to when callingFork
. Thus the following call toCommit
creates a block with parenth3
instead of with parenth1
, resulting in the same bahavior as ifFork
was never called.Fix
Use
b.blockchain.GetBlockByHash(b.pendingBlock.ParentHash())
instead ofb.blockchain.CurrentBlock()
inSimulatedBackend.AdjustTime
.Steps to reproduce the behaviour
The text was updated successfully, but these errors were encountered: