mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-04 19:19:44 +00:00
consensus: fix commitCompact payload
Add state root signature to `commitCompact` in `recoveryMessage`.
This commit is contained in:
parent
d5ba2e49a2
commit
aebed3826b
2 changed files with 8 additions and 1 deletions
|
@ -228,6 +228,7 @@ func randomMessage(t *testing.T, mt messageType) io.Serializable {
|
|||
case commitType:
|
||||
var c commit
|
||||
random.Fill(c.signature[:])
|
||||
random.Fill(c.stateSig[:])
|
||||
return &c
|
||||
case recoveryRequestType:
|
||||
return &recoveryRequest{timestamp: rand.Uint32()}
|
||||
|
@ -275,12 +276,14 @@ func randomRecoveryMessage(t *testing.T) *recoveryMessage {
|
|||
ViewNumber: 0,
|
||||
ValidatorIndex: 1,
|
||||
Signature: [64]byte{1, 2, 3},
|
||||
StateSignature: [64]byte{4, 5, 6},
|
||||
InvocationScript: random.Bytes(20),
|
||||
},
|
||||
{
|
||||
ViewNumber: 0,
|
||||
ValidatorIndex: 2,
|
||||
Signature: [64]byte{11, 3, 4, 98},
|
||||
StateSignature: [64]byte{4, 8, 15, 16, 23, 42},
|
||||
InvocationScript: random.Bytes(10),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -29,6 +29,7 @@ type (
|
|||
ViewNumber byte
|
||||
ValidatorIndex uint16
|
||||
Signature [signatureSize]byte
|
||||
StateSignature [signatureSize]byte
|
||||
InvocationScript []byte
|
||||
}
|
||||
|
||||
|
@ -112,6 +113,7 @@ func (p *commitCompact) DecodeBinary(r *io.BinReader) {
|
|||
p.ViewNumber = r.ReadB()
|
||||
p.ValidatorIndex = r.ReadU16LE()
|
||||
r.ReadBytes(p.Signature[:])
|
||||
r.ReadBytes(p.StateSignature[:])
|
||||
p.InvocationScript = r.ReadVarBytes()
|
||||
}
|
||||
|
||||
|
@ -120,6 +122,7 @@ func (p *commitCompact) EncodeBinary(w *io.BinWriter) {
|
|||
w.WriteB(p.ViewNumber)
|
||||
w.WriteU16LE(p.ValidatorIndex)
|
||||
w.WriteBytes(p.Signature[:])
|
||||
w.WriteBytes(p.StateSignature[:])
|
||||
w.WriteVarBytes(p.InvocationScript)
|
||||
}
|
||||
|
||||
|
@ -172,6 +175,7 @@ func (m *recoveryMessage) AddPayload(p payload.ConsensusPayload) {
|
|||
ValidatorIndex: p.ValidatorIndex(),
|
||||
ViewNumber: p.ViewNumber(),
|
||||
Signature: p.GetCommit().(*commit).signature,
|
||||
StateSignature: p.GetCommit().(*commit).stateSig,
|
||||
InvocationScript: p.(*Payload).Witness.InvocationScript,
|
||||
})
|
||||
}
|
||||
|
@ -250,7 +254,7 @@ func (m *recoveryMessage) GetCommits(p payload.ConsensusPayload, validators []cr
|
|||
ps := make([]payload.ConsensusPayload, len(m.commitPayloads))
|
||||
|
||||
for i, c := range m.commitPayloads {
|
||||
cc := fromPayload(commitType, p.(*Payload), &commit{signature: c.Signature})
|
||||
cc := fromPayload(commitType, p.(*Payload), &commit{signature: c.Signature, stateSig: c.StateSignature})
|
||||
cc.SetValidatorIndex(c.ValidatorIndex)
|
||||
cc.Witness.InvocationScript = c.InvocationScript
|
||||
cc.Witness.VerificationScript = getVerificationScript(c.ValidatorIndex, validators)
|
||||
|
|
Loading…
Reference in a new issue