forked from TrueCloudLab/neoneo-go
Merge pull request #1086 from nspcc-dev/fix/recovery
consensus: fix commitCompact payload
This commit is contained in:
commit
9767817ee4
2 changed files with 8 additions and 1 deletions
|
@ -228,6 +228,7 @@ func randomMessage(t *testing.T, mt messageType) io.Serializable {
|
||||||
case commitType:
|
case commitType:
|
||||||
var c commit
|
var c commit
|
||||||
random.Fill(c.signature[:])
|
random.Fill(c.signature[:])
|
||||||
|
random.Fill(c.stateSig[:])
|
||||||
return &c
|
return &c
|
||||||
case recoveryRequestType:
|
case recoveryRequestType:
|
||||||
return &recoveryRequest{timestamp: rand.Uint32()}
|
return &recoveryRequest{timestamp: rand.Uint32()}
|
||||||
|
@ -275,12 +276,14 @@ func randomRecoveryMessage(t *testing.T) *recoveryMessage {
|
||||||
ViewNumber: 0,
|
ViewNumber: 0,
|
||||||
ValidatorIndex: 1,
|
ValidatorIndex: 1,
|
||||||
Signature: [64]byte{1, 2, 3},
|
Signature: [64]byte{1, 2, 3},
|
||||||
|
StateSignature: [64]byte{4, 5, 6},
|
||||||
InvocationScript: random.Bytes(20),
|
InvocationScript: random.Bytes(20),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ViewNumber: 0,
|
ViewNumber: 0,
|
||||||
ValidatorIndex: 2,
|
ValidatorIndex: 2,
|
||||||
Signature: [64]byte{11, 3, 4, 98},
|
Signature: [64]byte{11, 3, 4, 98},
|
||||||
|
StateSignature: [64]byte{4, 8, 15, 16, 23, 42},
|
||||||
InvocationScript: random.Bytes(10),
|
InvocationScript: random.Bytes(10),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -29,6 +29,7 @@ type (
|
||||||
ViewNumber byte
|
ViewNumber byte
|
||||||
ValidatorIndex uint16
|
ValidatorIndex uint16
|
||||||
Signature [signatureSize]byte
|
Signature [signatureSize]byte
|
||||||
|
StateSignature [signatureSize]byte
|
||||||
InvocationScript []byte
|
InvocationScript []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +113,7 @@ func (p *commitCompact) DecodeBinary(r *io.BinReader) {
|
||||||
p.ViewNumber = r.ReadB()
|
p.ViewNumber = r.ReadB()
|
||||||
p.ValidatorIndex = r.ReadU16LE()
|
p.ValidatorIndex = r.ReadU16LE()
|
||||||
r.ReadBytes(p.Signature[:])
|
r.ReadBytes(p.Signature[:])
|
||||||
|
r.ReadBytes(p.StateSignature[:])
|
||||||
p.InvocationScript = r.ReadVarBytes()
|
p.InvocationScript = r.ReadVarBytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +122,7 @@ func (p *commitCompact) EncodeBinary(w *io.BinWriter) {
|
||||||
w.WriteB(p.ViewNumber)
|
w.WriteB(p.ViewNumber)
|
||||||
w.WriteU16LE(p.ValidatorIndex)
|
w.WriteU16LE(p.ValidatorIndex)
|
||||||
w.WriteBytes(p.Signature[:])
|
w.WriteBytes(p.Signature[:])
|
||||||
|
w.WriteBytes(p.StateSignature[:])
|
||||||
w.WriteVarBytes(p.InvocationScript)
|
w.WriteVarBytes(p.InvocationScript)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,6 +175,7 @@ func (m *recoveryMessage) AddPayload(p payload.ConsensusPayload) {
|
||||||
ValidatorIndex: p.ValidatorIndex(),
|
ValidatorIndex: p.ValidatorIndex(),
|
||||||
ViewNumber: p.ViewNumber(),
|
ViewNumber: p.ViewNumber(),
|
||||||
Signature: p.GetCommit().(*commit).signature,
|
Signature: p.GetCommit().(*commit).signature,
|
||||||
|
StateSignature: p.GetCommit().(*commit).stateSig,
|
||||||
InvocationScript: p.(*Payload).Witness.InvocationScript,
|
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))
|
ps := make([]payload.ConsensusPayload, len(m.commitPayloads))
|
||||||
|
|
||||||
for i, c := range 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.SetValidatorIndex(c.ValidatorIndex)
|
||||||
cc.Witness.InvocationScript = c.InvocationScript
|
cc.Witness.InvocationScript = c.InvocationScript
|
||||||
cc.Witness.VerificationScript = getVerificationScript(c.ValidatorIndex, validators)
|
cc.Witness.VerificationScript = getVerificationScript(c.ValidatorIndex, validators)
|
||||||
|
|
Loading…
Reference in a new issue