Skip to content

Commit

Permalink
Updated to have Ack fix and missing msg fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Emyrk committed Apr 26, 2018
2 parents 8269bb6 + 39a9e8e commit b2e7bfb
Show file tree
Hide file tree
Showing 11 changed files with 501 additions and 292 deletions.
4 changes: 2 additions & 2 deletions common/interfaces/processList.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package interfaces

type IProcessList interface {
Clear()
//Clear()
GetKeysNewEntries() (keys [][32]byte)
GetNewEntry(key [32]byte) IEntry
LenNewEntries() int
Expand Down Expand Up @@ -35,7 +35,7 @@ type IProcessList interface {
ResetDiffSigTally()
IncrementDiffSigTally()
CheckDiffSigTally() bool
Ask(vmIndex int, height int, waitSeconds int64, tag int) int
// Ask(vmIndex int, height int) int
TrimVMList(height uint32, vmIndex int)
//Process(state IState) (progress bool)
//AddToProcessList(ack IMsg, m IMsg)
Expand Down
19 changes: 10 additions & 9 deletions common/messages/ack.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@ func (m *Ack) Validate(s interfaces.IState) int {
return -1
}

// Only new acks are valid. Of course, the VMIndex has to be valid too.
msg, _ := s.GetMsg(m.VMIndex, int(m.DBHeight), int(m.Height))
if msg != nil {
s.LogMessage("executeMsg", "Ack slot taken", m)
s.LogMessage("executeMsg", "found:", msg)
return -1
}

if s.GetHighestAck() < m.DBHeight {
s.SetHighestAck(m.DBHeight) // assume the ack isn't lying. this will make us start requesting DBState blocks...
}
Expand All @@ -111,9 +103,18 @@ func (m *Ack) Validate(s interfaces.IState) int {
return -1
}

if delta > 5 {
if delta > 15 {
return 0 // put this in the holding and validate it later
}

// Only new acks are valid. Of course, the VMIndex has to be valid too.
msg, _ := s.GetMsg(m.VMIndex, int(m.DBHeight), int(m.Height))
if msg != nil {
s.LogMessage("executeMsg", "Ack slot taken", m)
s.LogMessage("executeMsg", "found:", msg)
return -1
}

if !m.authvalid {
// Check signature
bytes, err := m.MarshalForSignature()
Expand Down
1 change: 0 additions & 1 deletion common/messages/dbstate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ func TestPropSignedDBStateValidate(t *testing.T) {
var signers []SmallIdentity

a := testHelper.CreateTestAdminBlock(prev.ABlock)
state.ProcessLists.Get(a.GetDatabaseHeight()).Clear()
state.ProcessLists.Get(a.GetDatabaseHeight()).FedServers = make([]interfaces.IServer, 0)
for ia := 0; ia < len(ids); ia++ {
switch random.RandIntBetween(0, 4) {
Expand Down
14 changes: 7 additions & 7 deletions common/messages/directoryBlockSignature.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,23 +395,23 @@ func (m *DirectoryBlockSignature) String() string {
} else {
m.dbsHash = primitives.NewHash(constants.ZERO)
}
return fmt.Sprintf("%6s-VM%3d: DBHt:%5d -- Signer[:3]=%x Directory Hash[:3]=%x hash[:3]=%x",
return fmt.Sprintf("%6s-VM%3d: DBHt:%5d -- Signer=%x PrevDBKeyMR[:3]=%x hash=%x",
"DBSig",
m.VMIndex,
m.DBHeight,
m.ServerIdentityChainID.Bytes()[2:6],
m.ServerIdentityChainID.Bytes()[3:6],
m.dbsHash.Bytes()[:5],
m.GetHash().Bytes()[:3])

}

func (m *DirectoryBlockSignature) LogFields() log.Fields {
return log.Fields{"category": "message", "messagetype": "dbsig",
"dbheight": m.DBHeight,
"vm": m.VMIndex,
"server": m.ServerIdentityChainID.String(),
"dbhash": m.DirectoryBlockHeader.GetPrevFullHash(),
"hash": m.GetHash().String()}
"dbheight": m.DBHeight,
"vm": m.VMIndex,
"server": m.ServerIdentityChainID.String(),
"prevkeymr": m.DirectoryBlockHeader.GetPrevKeyMR().String(),
"hash": m.GetHash().String()}
}

func (e *DirectoryBlockSignature) JSONByte() ([]byte, error) {
Expand Down
Loading

0 comments on commit b2e7bfb

Please sign in to comment.