diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 2756a02e2f6d..c117726204e1 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -213,10 +213,10 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV1(update beacon.ForkchoiceStateV1, pa log.Error("TDs unavailable for TTD check", "number", block.NumberU64(), "hash", update.HeadBlockHash, "td", td, "parent", block.ParentHash(), "ptd", ptd) return beacon.STATUS_INVALID, errors.New("TDs unavailable for TDD check") } - if td.Cmp(ttd) < 0 { - log.Error("Refusing beacon update to pre-merge", "number", block.NumberU64(), "hash", update.HeadBlockHash, "diff", block.Difficulty(), "age", common.PrettyAge(time.Unix(int64(block.Time()), 0))) - return beacon.ForkChoiceResponse{PayloadStatus: beacon.INVALID_TERMINAL_BLOCK, PayloadID: nil}, nil - } + // if td.Cmp(ttd) < 0 { + // log.Error("Refusing beacon update to pre-merge", "number", block.NumberU64(), "hash", update.HeadBlockHash, "diff", block.Difficulty(), "age", common.PrettyAge(time.Unix(int64(block.Time()), 0))) + // return beacon.ForkChoiceResponse{PayloadStatus: beacon.INVALID_TERMINAL_BLOCK, PayloadID: nil}, nil + // } if block.NumberU64() > 0 && ptd.Cmp(ttd) >= 0 { log.Error("Parent block is already post-ttd", "number", block.NumberU64(), "hash", update.HeadBlockHash, "diff", block.Difficulty(), "age", common.PrettyAge(time.Unix(int64(block.Time()), 0))) return beacon.ForkChoiceResponse{PayloadStatus: beacon.INVALID_TERMINAL_BLOCK, PayloadID: nil}, nil diff --git a/miner/worker.go b/miner/worker.go index c60207997581..c65419cfa7bc 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1088,7 +1088,32 @@ func (w *worker) generateWork(params *generateParams) (*types.Block, error) { if !params.noTxs { w.fillTransactions(nil, work) } - return w.engine.FinalizeAndAssemble(w.chain, work.header, work.state, work.txs, work.unclelist(), work.receipts) + block, err := w.engine.FinalizeAndAssemble(w.chain, work.header, work.state, work.txs, work.unclelist(), work.receipts) + // Open the pre-tree to prove the pre-state against + preTrie, err := work.state.Database().OpenTrie(work.preRoot) + if err != nil { + return nil, err + } + if vtr, ok := preTrie.(*trie.VerkleTrie); ok { + keys := work.state.Witness().Keys() + kvs := work.state.Witness().KeyVals() + for _, key := range keys { + // XXX workaround - there is a problem in the witness creation + // so fix the witness creation as well. + v, err := vtr.TryGet(key) + if err != nil { + panic(err) + } + kvs[string(key)] = v + } + vtr.Hash() + p, k, err := vtr.ProveAndSerialize(work.state.Witness().Keys(), work.state.Witness().KeyVals()) + if err != nil { + return nil, err + } + block.SetVerkleProof(p, k) + } + return block, nil } // commitWork generates several new sealing tasks based on the parent block