mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 09:50:45 +00:00
parent
185e28ad14
commit
1a2c8ee180
4 changed files with 37 additions and 10 deletions
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/XinFinOrg/XDPoSChain/common"
|
"github.com/XinFinOrg/XDPoSChain/common"
|
||||||
|
|
@ -80,14 +79,16 @@ func (f *Forensics) SetCommittedQCs(headers []types.Header, incomingQC types.Quo
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *Forensics) ProcessForensics(chain consensus.ChainReader, engine *XDPoS_v2, incomingQC types.QuorumCert) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Entry point for processing forensics.
|
Entry point for processing forensics.
|
||||||
Triggered once processQC is successfully.
|
Triggered once processQC is successfully.
|
||||||
Forensics runs in a separate go routine as its no system critical
|
Forensics runs in a separate go routine as its no system critical
|
||||||
Link to the flow diagram: https://hashlabs.atlassian.net/wiki/spaces/HASHLABS/pages/97878029/Forensics+Diagram+flow
|
Link to the flow diagram: https://hashlabs.atlassian.net/wiki/spaces/HASHLABS/pages/97878029/Forensics+Diagram+flow
|
||||||
*/
|
|
||||||
func (f *Forensics) ProcessForensics(chain consensus.ChainReader, engine *XDPoS_v2, incomingQC types.QuorumCert) error {
|
func (f *Forensics) ProcessForensics(chain consensus.ChainReader, engine *XDPoS_v2, incomingQC types.QuorumCert) error {
|
||||||
return nil
|
|
||||||
log.Debug("Received a QC in forensics", "QC", incomingQC)
|
log.Debug("Received a QC in forensics", "QC", incomingQC)
|
||||||
// Clone the values to a temporary variable
|
// Clone the values to a temporary variable
|
||||||
highestCommittedQCs := f.HighestCommittedQCs
|
highestCommittedQCs := f.HighestCommittedQCs
|
||||||
|
|
@ -126,6 +127,7 @@ func (f *Forensics) ProcessForensics(chain consensus.ChainReader, engine *XDPoS_
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Last step of forensics which sends out detailed proof to report service.
|
// Last step of forensics which sends out detailed proof to report service.
|
||||||
func (f *Forensics) SendForensicProof(chain consensus.ChainReader, engine *XDPoS_v2, firstQc types.QuorumCert, secondQc types.QuorumCert) error {
|
func (f *Forensics) SendForensicProof(chain consensus.ChainReader, engine *XDPoS_v2, firstQc types.QuorumCert, secondQc types.QuorumCert) error {
|
||||||
|
|
@ -388,14 +390,16 @@ func generateVoteEquivocationId(signer common.Address, round1, round2 types.Roun
|
||||||
return fmt.Sprintf("%x:%d:%d", signer, round1, round2)
|
return fmt.Sprintf("%x:%d:%d", signer, round1, round2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *Forensics) ProcessVoteEquivocation(chain consensus.ChainReader, engine *XDPoS_v2, incomingVote *types.Vote) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Entry point for processing vote equivocation.
|
Entry point for processing vote equivocation.
|
||||||
Triggered once handle vote is successfully.
|
Triggered once handle vote is successfully.
|
||||||
Forensics runs in a separate go routine as its no system critical
|
Forensics runs in a separate go routine as its no system critical
|
||||||
Link to the flow diagram: https://hashlabs.atlassian.net/wiki/spaces/HASHLABS/pages/99516417/Vote+Equivocation+detection+specification
|
Link to the flow diagram: https://hashlabs.atlassian.net/wiki/spaces/HASHLABS/pages/99516417/Vote+Equivocation+detection+specification
|
||||||
*/
|
|
||||||
func (f *Forensics) ProcessVoteEquivocation(chain consensus.ChainReader, engine *XDPoS_v2, incomingVote *types.Vote) error {
|
func (f *Forensics) ProcessVoteEquivocation(chain consensus.ChainReader, engine *XDPoS_v2, incomingVote *types.Vote) error {
|
||||||
return nil
|
|
||||||
log.Debug("Received a vote in forensics", "vote", incomingVote)
|
log.Debug("Received a vote in forensics", "vote", incomingVote)
|
||||||
// Clone the values to a temporary variable
|
// Clone the values to a temporary variable
|
||||||
highestCommittedQCs := f.HighestCommittedQCs
|
highestCommittedQCs := f.HighestCommittedQCs
|
||||||
|
|
@ -449,6 +453,7 @@ func (f *Forensics) ProcessVoteEquivocation(chain consensus.ChainReader, engine
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func (f *Forensics) isExtendingFromAncestor(blockChainReader consensus.ChainReader, currentBlock *types.BlockInfo, ancestorBlock *types.BlockInfo) (bool, error) {
|
func (f *Forensics) isExtendingFromAncestor(blockChainReader consensus.ChainReader, currentBlock *types.BlockInfo, ancestorBlock *types.BlockInfo) (bool, error) {
|
||||||
blockNumDiff := int(big.NewInt(0).Sub(currentBlock.Number, ancestorBlock.Number).Int64())
|
blockNumDiff := int(big.NewInt(0).Sub(currentBlock.Number, ancestorBlock.Number).Int64())
|
||||||
|
|
@ -487,6 +492,10 @@ func (f *Forensics) isVoteBlamed(chain consensus.ChainReader, highestCommittedQC
|
||||||
|
|
||||||
func (f *Forensics) DetectEquivocationInVotePool(vote *types.Vote, votePool *utils.Pool) {
|
func (f *Forensics) DetectEquivocationInVotePool(vote *types.Vote, votePool *utils.Pool) {
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
func (f *Forensics) DetectEquivocationInVotePool(vote *types.Vote, votePool *utils.Pool) {
|
||||||
poolKey := vote.PoolKey()
|
poolKey := vote.PoolKey()
|
||||||
votePoolKeys := votePool.PoolObjKeysList()
|
votePoolKeys := votePool.PoolObjKeysList()
|
||||||
signer, err := GetVoteSignerAddresses(vote)
|
signer, err := GetVoteSignerAddresses(vote)
|
||||||
|
|
@ -523,6 +532,7 @@ func (f *Forensics) DetectEquivocationInVotePool(vote *types.Vote, votePool *uti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func (f *Forensics) SendVoteEquivocationProof(vote1, vote2 *types.Vote, signer common.Address) error {
|
func (f *Forensics) SendVoteEquivocationProof(vote1, vote2 *types.Vote, signer common.Address) error {
|
||||||
smallerRoundVote := vote1
|
smallerRoundVote := vote1
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,11 @@ type ECPoint struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ECPoint) toECPubKey() *ecdsa.PublicKey {
|
func (p *ECPoint) toECPubKey() *ecdsa.PublicKey {
|
||||||
return &ecdsa.PublicKey{curve, p.X, p.Y}
|
return &ecdsa.PublicKey{
|
||||||
|
Curve: curve,
|
||||||
|
X: p.X,
|
||||||
|
Y: p.Y,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func toECPoint(key *ecdsa.PublicKey) *ECPoint {
|
func toECPoint(key *ecdsa.PublicKey) *ECPoint {
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,11 @@ func DeserializeCompressed(curve elliptic.Curve, b []byte) *ecdsa.PublicKey {
|
||||||
if ybit != isOdd(y) {
|
if ybit != isOdd(y) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &ecdsa.PublicKey{curve, x, y}
|
return &ecdsa.PublicKey{
|
||||||
|
Curve: curve,
|
||||||
|
X: x,
|
||||||
|
Y: y,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// bytes returns the public key ring as a byte slice.
|
// bytes returns the public key ring as a byte slice.
|
||||||
|
|
@ -426,13 +430,21 @@ func Sign(m [32]byte, rings []Ring, privkeys []*ecdsa.PrivateKey, s int) (*RingS
|
||||||
// start at secret index s/PI
|
// start at secret index s/PI
|
||||||
// compute L_s = u*G
|
// compute L_s = u*G
|
||||||
l_x, l_y := curve.ScalarBaseMult(PadTo32Bytes(alpha[i].Bytes()))
|
l_x, l_y := curve.ScalarBaseMult(PadTo32Bytes(alpha[i].Bytes()))
|
||||||
L[i][s] = &ecdsa.PublicKey{curve, l_x, l_y}
|
L[i][s] = &ecdsa.PublicKey{
|
||||||
|
Curve: curve,
|
||||||
|
X: l_x,
|
||||||
|
Y: l_y,
|
||||||
|
}
|
||||||
lT := append(PadTo32Bytes(l_x.Bytes()), PadTo32Bytes(l_y.Bytes())...)
|
lT := append(PadTo32Bytes(l_x.Bytes()), PadTo32Bytes(l_y.Bytes())...)
|
||||||
l = append(l, lT...)
|
l = append(l, lT...)
|
||||||
// compute R_s = u*H_p(P[s])
|
// compute R_s = u*H_p(P[s])
|
||||||
h_x, h_y := HashPoint(pubkeys[i])
|
h_x, h_y := HashPoint(pubkeys[i])
|
||||||
r_x, r_y := curve.ScalarMult(h_x, h_y, PadTo32Bytes(alpha[i].Bytes()))
|
r_x, r_y := curve.ScalarMult(h_x, h_y, PadTo32Bytes(alpha[i].Bytes()))
|
||||||
R[i][s] = &ecdsa.PublicKey{curve, r_x, r_y}
|
R[i][s] = &ecdsa.PublicKey{
|
||||||
|
Curve: curve,
|
||||||
|
X: r_x,
|
||||||
|
Y: r_y,
|
||||||
|
}
|
||||||
rT := append(PadTo32Bytes(r_x.Bytes()), PadTo32Bytes(r_y.Bytes())...)
|
rT := append(PadTo32Bytes(r_x.Bytes()), PadTo32Bytes(r_y.Bytes())...)
|
||||||
l = append(l, rT...)
|
l = append(l, rT...)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -320,6 +320,7 @@ func (t *Trie) TryGetAllLeftKeyAndValue(limit []byte) ([][]byte, [][]byte, error
|
||||||
}
|
}
|
||||||
return keys, values, err
|
return keys, values, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Trie) tryGetAllLeftKeyAndValue(origNode node, prefix []byte, limit []byte) (keys [][]byte, values [][]byte, newnode node, didResolve bool, err error) {
|
func (t *Trie) tryGetAllLeftKeyAndValue(origNode node, prefix []byte, limit []byte) (keys [][]byte, values [][]byte, newnode node, didResolve bool, err error) {
|
||||||
switch n := (origNode).(type) {
|
switch n := (origNode).(type) {
|
||||||
case nil:
|
case nil:
|
||||||
|
|
@ -370,8 +371,8 @@ func (t *Trie) tryGetAllLeftKeyAndValue(origNode node, prefix []byte, limit []by
|
||||||
default:
|
default:
|
||||||
return nil, nil, nil, false, fmt.Errorf("%T: invalid Node: %v", origNode, origNode)
|
return nil, nil, nil, false, fmt.Errorf("%T: invalid Node: %v", origNode, origNode)
|
||||||
}
|
}
|
||||||
return nil, nil, nil, false, fmt.Errorf("%T: invalid Node: %v", origNode, origNode)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Trie) TryGetBestRightKeyAndValue() ([]byte, []byte, error) {
|
func (t *Trie) TryGetBestRightKeyAndValue() ([]byte, []byte, error) {
|
||||||
key, value, newroot, didResolve, err := t.tryGetBestRightKeyAndValue(t.root, []byte{})
|
key, value, newroot, didResolve, err := t.tryGetBestRightKeyAndValue(t.root, []byte{})
|
||||||
if err == nil && didResolve {
|
if err == nil && didResolve {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue