This commit is contained in:
Jared Wasinger 2023-12-03 22:23:33 +08:00
parent 33317bb3a3
commit ea4632a0a2
2 changed files with 7 additions and 5 deletions

View file

@ -1489,9 +1489,6 @@ func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types
return NonStatTy, err return NonStatTy, err
} }
st.Witness.Block = block
state.DumpWitnessToFile(st.Witness)
currentBlock := bc.CurrentBlock() currentBlock := bc.CurrentBlock()
reorg, err := bc.forker.ReorgNeeded(currentBlock, block.Header()) reorg, err := bc.forker.ReorgNeeded(currentBlock, block.Header())
if err != nil { if err != nil {
@ -1855,6 +1852,10 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
} else { } else {
status, err = bc.writeBlockAndSetHead(block, receipts, logs, statedb, false) status, err = bc.writeBlockAndSetHead(block, receipts, logs, statedb, false)
} }
fmt.Println("dump block")
statedb.Witness.Block = block
state.DumpWitnessToFile(statedb.Witness)
followupInterrupt.Store(true) followupInterrupt.Store(true)
if err != nil { if err != nil {
return it.index, err return it.index, err

View file

@ -49,12 +49,13 @@ func (w *Witness) EncodeRLP() []byte {
func (obj *EncodeWitness) encode(_w io.Writer) error { func (obj *EncodeWitness) encode(_w io.Writer) error {
w := rlp.NewEncoderBuffer(_w) w := rlp.NewEncoderBuffer(_w)
_tmp0 := w.List() _tmp0 := w.List()
obj.block.EncodeRLP(w)
w.ListEnd(_tmp0) w.ListEnd(_tmp0)
return w.Flush() return w.Flush()
} }
func newWitness(originalRoot common.Hash) *Witness { func newWitness(originalRoot common.Hash) *Witness {
return &Witness{Root: originalRoot} return &Witness{Root: originalRoot, Lists: make(map[common.Hash]map[string][]byte)}
} }
func (w *Witness) addAccessList(owner common.Hash, list map[string][]byte) { func (w *Witness) addAccessList(owner common.Hash, list map[string][]byte) {
@ -82,7 +83,7 @@ func DumpWitnessToFile(w *Witness) {
if err != nil { if err != nil {
panic("shite") panic("shite")
} }
outputFName := fmt.Sprintf("%d-%x.rlp\n", w.Block.NumberU64(), w.Block.Hash()) outputFName := fmt.Sprintf("%d-%x.rlp", w.Block.NumberU64(), w.Block.Hash())
err = os.WriteFile(path+"/"+outputFName, enc, 0644) err = os.WriteFile(path+"/"+outputFName, enc, 0644)
if err != nil { if err != nil {
panic("shite 2") panic("shite 2")