mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
fix: add the mutation of coinbase address under clique mode (#126)
fix clique coinbase issue
This commit is contained in:
parent
3682e05f3f
commit
37dbb86aa6
4 changed files with 44772 additions and 16 deletions
|
|
@ -704,15 +704,26 @@ func (w *worker) makeCurrent(parent *types.Block, header *types.Header) error {
|
||||||
}
|
}
|
||||||
state.StartPrefetcher("miner")
|
state.StartPrefetcher("miner")
|
||||||
|
|
||||||
// fetch coinbase's proof
|
proofs := make(map[string][]hexutil.Bytes)
|
||||||
proof, err := state.GetProof(header.Coinbase)
|
// init proof with coinbase's proof
|
||||||
if err != nil {
|
for _, coinbase := range []common.Address{w.coinbase, header.Coinbase} {
|
||||||
log.Error("Proof for coinbase not available", "coinbase", header.Coinbase.String(), "error", err)
|
if coinbase == (common.Address{}) {
|
||||||
// but we still mark the proofs map with nil array
|
continue
|
||||||
}
|
}
|
||||||
wrappedProof := make([]hexutil.Bytes, len(proof))
|
|
||||||
for i, bt := range proof {
|
key := coinbase.String()
|
||||||
wrappedProof[i] = bt
|
if _, exist := proofs[key]; !exist {
|
||||||
|
proof, err := state.GetProof(coinbase)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Proof for coinbase not available", "coinbase", coinbase, "error", err)
|
||||||
|
// but we still mark the proofs map with nil array
|
||||||
|
}
|
||||||
|
wrappedProof := make([]hexutil.Bytes, len(proof))
|
||||||
|
for i, bt := range proof {
|
||||||
|
wrappedProof[i] = bt
|
||||||
|
}
|
||||||
|
proofs[key] = wrappedProof
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
env := &environment{
|
env := &environment{
|
||||||
|
|
@ -722,7 +733,7 @@ func (w *worker) makeCurrent(parent *types.Block, header *types.Header) error {
|
||||||
family: mapset.NewSet(),
|
family: mapset.NewSet(),
|
||||||
uncles: mapset.NewSet(),
|
uncles: mapset.NewSet(),
|
||||||
header: header,
|
header: header,
|
||||||
proofs: map[string][]hexutil.Bytes{header.Coinbase.String(): wrappedProof},
|
proofs: proofs,
|
||||||
storageProofs: make(map[string]map[string][]hexutil.Bytes),
|
storageProofs: make(map[string]map[string][]hexutil.Bytes),
|
||||||
}
|
}
|
||||||
// when 08 is processed ancestors contain 07 (quick block)
|
// when 08 is processed ancestors contain 07 (quick block)
|
||||||
|
|
@ -842,12 +853,12 @@ func (w *worker) commitTransaction(tx *types.Transaction, coinbase common.Addres
|
||||||
}
|
}
|
||||||
|
|
||||||
// collect affected account after tx being applied
|
// collect affected account after tx being applied
|
||||||
for _, acc := range []*common.Address{&from, to} {
|
for acc := range map[common.Address]bool{from: true, (*to): true, w.coinbase: true} {
|
||||||
after = append(after, &types.AccountWrapper{
|
after = append(after, &types.AccountWrapper{
|
||||||
Address: *acc,
|
Address: acc,
|
||||||
Nonce: w.current.state.GetNonce(*acc),
|
Nonce: w.current.state.GetNonce(acc),
|
||||||
Balance: (*hexutil.Big)(w.current.state.GetBalance(*acc)),
|
Balance: (*hexutil.Big)(w.current.state.GetBalance(acc)),
|
||||||
CodeHash: w.current.state.GetCodeHash(*acc),
|
CodeHash: w.current.state.GetCodeHash(acc),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
44734
trie/zkproof/delete_trace.json
Normal file
44734
trie/zkproof/delete_trace.json
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -357,7 +357,7 @@ func (w *zktrieProofWriter) traceAccountUpdate(addr common.Address, updateAccDat
|
||||||
|
|
||||||
var proof proofList
|
var proof proofList
|
||||||
if err := w.tracingZktrie.Prove(addr.Bytes32(), 0, &proof); err != nil {
|
if err := w.tracingZktrie.Prove(addr.Bytes32(), 0, &proof); err != nil {
|
||||||
return nil, fmt.Errorf("prove BEFORE state fail: %s", err)
|
return nil, fmt.Errorf("prove BEFORE state for <%x> fail: %s", addr.Bytes(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
decodeProofForMPTPath(proof, out.AccountPath[0])
|
decodeProofForMPTPath(proof, out.AccountPath[0])
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,17 @@ func TestFailedCallTx(t *testing.T) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//notice: now only work with OP_ORDER=2
|
||||||
|
func TestDeleteTx(t *testing.T) {
|
||||||
|
trace := loadStaff(t, "delete_trace.json")
|
||||||
|
traces, err := HandleBlockResult(trace)
|
||||||
|
outObj, _ := json.Marshal(traces)
|
||||||
|
t.Log(string(outObj))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestMutipleTx(t *testing.T) {
|
func TestMutipleTx(t *testing.T) {
|
||||||
trace := loadStaff(t, "multi_txs.json")
|
trace := loadStaff(t, "multi_txs.json")
|
||||||
traces, err := HandleBlockResult(trace)
|
traces, err := HandleBlockResult(trace)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue