-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix tracing for transactions using on-chain randomness in latest block (
#2186) * First pass implementing fix * Factor out ApplyBlockRandomnessTx * Fix lint * Nits: fix traceChain, add comment, remove TODOs * Separate out celoStateAtBlock into celo-specific file * Rename afterNextRandomCommit -> commitRandomness * Fix bug in traceChain * Fix typo
- Loading branch information
Eela Nagaraj
authored
Sep 19, 2023
1 parent
0ed594e
commit 87d69dc
Showing
7 changed files
with
94 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package eth | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/celo-org/celo-blockchain/core" | ||
"github.com/celo-org/celo-blockchain/core/state" | ||
"github.com/celo-org/celo-blockchain/core/types" | ||
) | ||
|
||
// Wraps `stateAtBlock` with the additional Celo-specific parameter `commitRandomness`. | ||
// This parameter executes the random commitment at the start of the next block, | ||
// since this is necessary for properly tracing transactions in the next block. | ||
func (eth *Ethereum) celoStateAtBlock(block *types.Block, reexec uint64, base *state.StateDB, checkLive bool, preferDisk bool, commitRandomness bool) (statedb *state.StateDB, err error) { | ||
statedb, err = eth.stateAtBlock(block, reexec, base, checkLive, preferDisk) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if !commitRandomness { | ||
return statedb, nil | ||
} | ||
// Fetch next block's random commitment | ||
nextBlockNum := block.NumberU64() + 1 | ||
nextBlock := eth.blockchain.GetBlockByNumber(nextBlockNum) | ||
if nextBlock == nil { | ||
return nil, fmt.Errorf("next block %d not found", nextBlockNum) | ||
} | ||
vmRunner := eth.blockchain.NewEVMRunner(nextBlock.Header(), statedb) | ||
err = core.ApplyBlockRandomnessTx(nextBlock, &vmRunner, statedb, eth.blockchain) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return statedb, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters