Skip to content

Commit

Permalink
Merge branch 'communitynet-m3-candidate' into communitynet-m3-candida…
Browse files Browse the repository at this point in the history
…te_ackfix
  • Loading branch information
Emyrk committed Apr 27, 2018
2 parents 25662a1 + b2e7bfb commit cebff03
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 28 deletions.
16 changes: 9 additions & 7 deletions engine/NetStart.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ func NetStart(s *state.State, p *FactomParams, listenToStdin bool) {
seedURL = s.LocalSeedURL
networkPort = s.LocalNetworkPort
configPeers = s.LocalSpecialPeers

// Also update the local constants for custom networks
fmt.Println("Running on the local network, use local coinbase constants")
constants.COINBASE_DECLARATION = 10
constants.COINBASE_PAYOUT_FREQUENCY = 5
case "CUSTOM", "custom":
if bytes.Compare(p.CustomNet, []byte("\xe3\xb0\xc4\x42")) == 0 {
panic("Please specify a custom network with -customnet=<something unique here>")
Expand All @@ -338,13 +343,10 @@ func NetStart(s *state.State, p *FactomParams, listenToStdin bool) {
networkPort = s.CustomNetworkPort
configPeers = s.CustomSpecialPeers

// Also update the coinbase constants if running communitynet
if bytes.Compare(Params.CustomNet, []byte{0x88, 0x3e, 0x09, 0x3b}) == 0 {
fmt.Println("Running on the community testnet, using coinbase testnet coinbase constants.")
constants.COINBASE_ACTIVATION = 26625
constants.COINBASE_DECLARATION = 10
constants.COINBASE_PAYOUT_FREQUENCY = 5
}
// Also update the coinbase constants for custom networks
fmt.Println("Running on the custom network, use custom coinbase constants")
constants.COINBASE_DECLARATION = 10
constants.COINBASE_PAYOUT_FREQUENCY = 5
default:
panic("Invalid Network choice in Config File or command line. Choose MAIN, TEST, LOCAL, or CUSTOM")
}
Expand Down
11 changes: 8 additions & 3 deletions state/authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,14 @@ func (st *State) FastVerifyAuthoritySignature(msg []byte, sig interfaces.IFullSi
if auth == nil {
continue
}
valid, err := auth.VerifySignature(msg, sig.GetSignature())
if err == nil && valid {
return 1, nil
compareKey, err := auth.SigningKey.MarshalBinary()
if err == nil {
if pkEq(sig.GetKey(), compareKey) {
valid, err := auth.VerifySignature(msg, sig.GetSignature())
if err == nil && valid {
return 1, nil
}
}
}
}
}
Expand Down
38 changes: 20 additions & 18 deletions state/processList.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"fmt"
"os"
"sync"

"time"

"github.com/FactomProject/factomd/common/adminBlock"
Expand All @@ -21,6 +20,7 @@ import (
"github.com/FactomProject/factomd/common/messages"
"github.com/FactomProject/factomd/common/primitives"
"github.com/FactomProject/factomd/util/atomic"

//"github.com/FactomProject/factomd/database/databaseOverlay"

log "github.com/sirupsen/logrus"
Expand All @@ -43,7 +43,6 @@ type askRef struct {
When int64
}


type ProcessList struct {
DBHeight uint32 // The directory block height for these lists

Expand Down Expand Up @@ -643,7 +642,7 @@ func (p *ProcessList) makeMMRs(s interfaces.IState, asks <-chan askRef, adds <-c
pending[ask.plRef] = &when // add the requests to the map
s.LogPrintf(logname, "Ask %d/%d/%d %d", ask.DBH, ask.VM, ask.H, len(pending))
} // don't update the when if it already existed...
}
}

addAdd := func(add plRef) {
delete(pending, add) // Delete request that was just added to the process list in the map
Expand Down Expand Up @@ -710,11 +709,11 @@ func (p *ProcessList) makeMMRs(s interfaces.IState, asks <-chan askRef, adds <-c
mmrs[index] = messages.NewMissingMsg(s, ref.VM, ref.DBH, uint32(ref.H))
} else {
mmrs[index].ProcessListHeight = append(mmrs[index].ProcessListHeight, uint32(ref.H))
}
}
*when += 10000 // update when we asked...
//s.LogPrintf(logname, "mmr ask %d/%d/%d %d", ref.DBH, ref.VM, ref.H, len(pending))
// Maybe when asking for past the end of the list we should not ask again?
}
}
} //build a MMRs with all the expired asks.

for index, mmr := range mmrs {
Expand All @@ -741,9 +740,9 @@ func (p *ProcessList) makeMMRs(s interfaces.IState, asks <-chan askRef, adds <-c

func (p *ProcessList) Ask(vmIndex int, height uint32, delay int64) {

if vmIndex < 0 {
if vmIndex < 0 {
panic(errors.New("Old Faulting code"))
}
}

now := p.State.GetTimestamp().GetTimeMilli()
// Look up the VM
Expand All @@ -755,7 +754,7 @@ func (p *ProcessList) Ask(vmIndex int, height uint32, delay int64) {
if vm.List[i] == nil {
ask := askRef{plRef{p.DBHeight, vmIndex, height}, now + delay}
p.asks <- ask
}
}
}
// always ask for one past the end as well...Can't hurt ... Famous last words...
ask := askRef{plRef{p.DBHeight, vmIndex, uint32(lenVMList)}, now + delay}
Expand All @@ -769,10 +768,13 @@ func (p *ProcessList) TrimVMList(height uint32, vmIndex int) {
p.VMs[vmIndex].List = p.VMs[vmIndex].List[:height]
}
}
func (p *ProcessList) GetDBHeight() uint32 {
return p.DBHeight
}

type foo struct {
Syncing, DBSig, EOM, DBSigDone, EOMDone, EOMmax, EOMmin, DBSigMax, DBSigMin bool
}
}

var decodeMap map[foo]string = map[foo]string{
//grep "Unexpected state" FNode0*process.txt | awk ' {print substr($0,index($0,"0x"));}' | sort -u
Expand Down Expand Up @@ -801,12 +803,13 @@ var decodeMap map[foo]string = map[foo]string{
//foo{true, true, false, false, false, false, true, false, true}: "Start Syncing DBSig", //0x143
//foo{true, false, true, false, false, false, true, false, true}: "Syncing EOM Start (DBSIG !Done)", //0x145 ***
//foo{true, false, true, true, true, false, true, false, true}: "Syncing EOM ... ", //0x15d
}
}

func (p *ProcessList) decodeState(Syncing bool, DBSig bool, EOM bool, DBSigDone bool, EOMDone bool, FedServers int, EOMProcessed int, DBSigProcessed int) string {

if EOMProcessed > FedServers || EOMProcessed < 0 {
p.State.LogPrintf("process", "Unexpected EOMProcessed %v of %v", EOMProcessed, FedServers)
}
}
if DBSigProcessed > FedServers || DBSigProcessed < 0 {
p.State.LogPrintf("process", "Unexpected DBSigProcessed %v of %v", DBSigProcessed, FedServers)
}
Expand All @@ -819,19 +822,17 @@ func (p *ProcessList) decodeState(Syncing bool, DBSig bool, EOM bool, DBSigDone
for i, b := range z {
if b {
xx = xx | (1 << uint(i))
}
}
}
}

s, ok := decodeMap[x]
if !ok {

p.State.LogPrintf("process", "Unexpected state 0x%03x %v", xx, x)
s = "Unknown"
}
}
return fmt.Sprintf("SyncingStatus: 0x%03x %s", xx, s)
}

func (p *ProcessList) GetDBHeight() uint32 {
return p.DBHeight
}

// Process messages and update our state.
Expand Down Expand Up @@ -879,7 +880,6 @@ func (p *ProcessList) Process(state *State) (progress bool) {
last := vm.ListAck[vm.Height-1]
expectedSerialHash, err = primitives.CreateHash(last.MessageHash, thisAck.MessageHash)
if err != nil {
state.LogMessage("process", "Nil out message", vm.List[j])
vm.List[j] = nil
//p.State.AddStatus(fmt.Sprintf("ProcessList.go Process: Error computing serial hash at dbht: %d vm %d vm-height %d ", p.DBHeight, i, j))
p.Ask(i, uint32(j), 3000) // 3 second delay
Expand Down Expand Up @@ -928,10 +928,12 @@ func (p *ProcessList) Process(state *State) (progress bool) {
vm.ProcessTime = now

if msg.Process(p.DBHeight, state) { // Try and Process this entry

if msg.Type() == constants.REVEAL_ENTRY_MSG {
delete(p.State.Holding, msg.GetMsgHash().Fixed()) // We successfully executed the message, so take it out of holding if it is there.
p.State.Commits.Delete(msg.GetMsgHash().Fixed())
}

p.State.LogMessage("processList", "done", msg)
vm.heartBeat = 0
vm.Height = j + 1 // Don't process it again if the process worked.
Expand Down

0 comments on commit cebff03

Please sign in to comment.