Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Oct 8, 2023
1 parent 3878c5c commit 44092f8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
19 changes: 19 additions & 0 deletions consensus/parlia/fusionfork.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,22 @@ func (p *Parlia) updateEligibleValidators(state *state.StateDB, header *types.He
// apply message
return p.applyTransaction(msg, state, header, chain, txs, receipts, receivedTxs, usedGas, mining)
}

func (p *Parlia) updateValidatorSetV2(state *state.StateDB, header *types.Header, chain core.ChainContext,
txs *[]*types.Transaction, receipts *[]*types.Receipt, receivedTxs *[]*types.Transaction, usedGas *uint64, mining bool,
) error {
// method
method := "updateValidatorSetV2"

// get packed data
data, err := p.validatorSetABI.Pack(method)
if err != nil {
log.Error("Unable to pack tx for updateValidatorSetV2", "error", err)
return err
}

// get system message
msg := p.getSystemMessage(header.Coinbase, common.HexToAddress(systemcontracts.ValidatorContract), data, big.NewInt(0))
// apply message
return p.applyTransaction(msg, state, header, chain, txs, receipts, receivedTxs, usedGas, mining)
}
6 changes: 6 additions & 0 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,9 @@ func (p *Parlia) Finalize(chain consensus.ChainHeaderReader, header *types.Heade
if err := p.updateEligibleValidators(state, header, cx, txs, receipts, systemTxs, usedGas, false); err != nil {
return err
}
if err := p.updateValidatorSetV2(state, header, cx, txs, receipts, systemTxs, usedGas, false); err != nil {
return err
}
}
}

Expand Down Expand Up @@ -1217,6 +1220,9 @@ func (p *Parlia) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *
if err := p.updateEligibleValidators(state, header, cx, &txs, &receipts, nil, &header.GasUsed, true); err != nil {
return nil, nil, err
}
if err := p.updateValidatorSetV2(state, header, cx, &txs, &receipts, nil, &header.GasUsed, true); err != nil {
return nil, nil, err
}
}
}

Expand Down

0 comments on commit 44092f8

Please sign in to comment.