Skip to content

Commit

Permalink
Merge pull request #646 from FactomProject/develop
Browse files Browse the repository at this point in the history
Release v6.1.1
  • Loading branch information
carryforward authored Feb 2, 2019
2 parents ddc4817 + b5f102e commit 5f787fc
Show file tree
Hide file tree
Showing 228 changed files with 10,458 additions and 4,473 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
- run:
name: Run tests!
no_output_timeout: 2400
command: go test -v -vet=off $(glide nv | grep -v Utilities)
command: ./test.sh


- save_cache:
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
- run:
name: Go Test with Coverage
no_output_timeout: 2400
command: go test $(glide nv | grep -v Utilities) -vet=off -v -cover -coverprofile=coverage.out
command: go test $(glide nv | grep -v Utilities | grep -v LongTests) -vet=off -v -cover -coverprofile=coverage.out

- run:
name: Coveralls!
Expand Down
8 changes: 8 additions & 0 deletions CLA.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,12 @@ Name Github Account
=================================== ====================================== ===================================== ================================
Paul Snow PaulSnow Factom Inc. Founder and Architect of Factom
Brian Deery carryforward Factom Inc.
Paul Bernier PaulBernier Luciap Technology Inc.
Carl DiClementi Cahl-Dee Factom Inc. Product Management @ Factom
Matt York stackdump Factom Inc.
Sam Barnes sambarnes Factom Inc.
Michael Beam michaelbeam Factom Inc.
Joshua Brigati JoshuaBrigati Factom Inc.
Samuel Vanderwaal samuelvanderwaal Canonical Ledgers
Adam S Levy AdamSLevy Canonical Ledgers, LLC
Who Soup WhoSoup Factomize LLC
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.10
FROM golang:1.11

# Get git
RUN apt-get update \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.10-alpine as builder
FROM golang:1.11-alpine as builder

# Get git
RUN apk add --no-cache curl git
Expand Down
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ perks, Copyright (C) 2013 Blake Mizerany
logrustash, Copyright (c) 2016 Boaz Shuster
go-humanize, Copyright (c) 2005-2008 Dustin Sallings <[email protected]>
survey, Copyright (c) 2018 Alec Aivazis
testify, Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell


Use of any of this software is governed by the terms and conditions set forth below:
Expand Down
122 changes: 122 additions & 0 deletions LongTests/ChainTransaction_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package longtests

import (
"fmt"
"testing"
"time"

"github.com/FactomProject/factom"
. "github.com/FactomProject/factomd/engine"
. "github.com/FactomProject/factomd/testHelper"
)

// FIXME: test runs > 40 min try to tune down to 10 min
func TestChainedTransactions(t *testing.T) {
if RanSimTest {
return
}
RanSimTest = true

// a genesis block address w/ funding
bankSecret := "Fs3E9gV6DXsYzf7Fqx1fVBQPQXV695eP3k5XbmHEZVRLkMdD9qCK"
bankAddress := "FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q"

var depositSecrets []string
var depositAddresses []string

for i := 0; i < 120; i++ {
priv, addr := RandomFctAddressPair()
depositSecrets = append(depositSecrets, priv)
depositAddresses = append(depositAddresses, addr)
}

var maxBlocks = 500
state0 := SetupSim("LAF", map[string]string{"--debuglog": "."}, maxBlocks+1, 0, 0, t)
var ecPrice uint64 = state0.GetFactoshisPerEC() //10000
var oneFct uint64 = factom.FactoidToFactoshi("1")

waitForDeposit := func(i int, amt uint64) uint64 {
balance := GetBalance(state0, depositAddresses[i])
TimeNow(state0)
fmt.Printf("%v waitForDeposit %v %v - %v = diff: %v \n", i, depositAddresses[i], balance, amt, balance-int64(amt))
var waited bool
for balance != int64(amt) {
waited = true
balance = GetBalance(state0, depositAddresses[i])
time.Sleep(time.Millisecond * 100)
}
if waited {
fmt.Printf("%v waitForDeposit %v %v - %v = diff: %v \n", i, depositAddresses[i], balance, amt, balance-int64(amt))
TimeNow(state0)
}
return uint64(balance)
}
_ = waitForDeposit

initialBalance := 10 * oneFct
fee := 12 * ecPrice

prepareTransactions := func(bal uint64) ([]func(), uint64, int) {

var transactions []func()
var i int

for i = 0; i < len(depositAddresses)-1; i += 1 {
bal -= fee

in := i
out := i + 1
send := bal

txn := func() {
//fmt.Printf("TXN %v %v => %v \n", send, depositAddresses[in], depositAddresses[out])
SendTxn(state0, send, depositSecrets[in], depositAddresses[out], ecPrice)
}
transactions = append(transactions, txn)
}
return transactions, bal, i
}

// offset to send initial blocking transaction
offset := 1

mkTransactions := func() { // txnGenerator
// fund the start address
SendTxn(state0, initialBalance, bankSecret, depositAddresses[0], ecPrice)
WaitMinutes(state0, 1)
waitForDeposit(0, initialBalance)
transactions, finalBalance, finalAddress := prepareTransactions(initialBalance)

var sent []int
var unblocked bool = false

for i := 1; i < len(transactions); i++ {
sent = append(sent, i)
//fmt.Printf("offset: %v <=> i:%v", offset, i)
if i == offset {
fmt.Printf("\n==>TXN offset%v\n", offset)
transactions[0]() // unblock the transactions
unblocked = true
}
transactions[i]()
}
if !unblocked {
transactions[0]() // unblock the transactions
}
offset++ // next time start further in the future
fmt.Printf("send chained transations")
waitForDeposit(finalAddress, finalBalance)

// empty final address returning remaining funds to bank
SendTxn(state0, finalBalance-fee, depositSecrets[finalAddress], bankAddress, ecPrice)
waitForDeposit(finalAddress, 0)
}

for x := 1; x <= 120; x++ {
mkTransactions()
WaitBlocks(state0, 1)
}

WaitForAllNodes(state0)
ShutDownEverything(t)
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ Factom leverages the Bitcoin Blockchain, but in a way that minimizes the amount

## Getting Started

You need to set up Go environment with golang 1.10 or higher. You also need git. See the [Install from source](https://github.com/FactomProject/FactomDocs/blob/master/installFromSourceDirections.md) directions for more details and wallet installation instructions.
You need to set up Go environment with golang 1.11 or higher. You also need git. See the [Install from source](https://github.com/FactomProject/FactomDocs/blob/master/installFromSourceDirections.md) directions for more details and wallet installation instructions.

### Install the dependency management program

First check if golang 1.10 or higher is installed. some operating systems install older versions.
First check if golang 1.11 or higher is installed. some operating systems install older versions.

`go version` should return something like
`go version go1.10.1 linux/amd64`
`go version go1.11 linux/amd64`

Next install Glide, which gets the dependencies for factomd and places them in the `$GOPATH/src/github/FactomProject/factomd/vendor` directory.

Expand Down
83 changes: 57 additions & 26 deletions Utilities/BalanceFinder/FastbootExport/main.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package main

import (
"errors"
"flag"
"os"

"io/ioutil"

"fmt"

"os"

"github.com/FactomProject/factomd/common/primitives"
"github.com/FactomProject/factomd/state"
"github.com/FactomProject/factomd/testHelper"
Expand All @@ -21,46 +21,49 @@ func main() {
flag.Parse()

s := testHelper.CreateEmptyTestState()
//dbs := new(state.DBStateList)
file, err := os.OpenFile(*filename, os.O_RDONLY, 0777)
if err != nil {
panic(err)
}

data, err := ioutil.ReadAll(file)
statelist := s.DBStates
fmt.Println(statelist.State.FactomNodeName, "Loading from", filename)
b, err := state.LoadFromFile(s, *filename)
if err != nil {
fmt.Fprintln(os.Stderr, "LoadDBStateList error:", err)
panic(err)
}

if b == nil {
fmt.Fprintln(os.Stderr, "LoadDBStateList LoadFromFile returned nil")
panic(errors.New("failed to load from file"))
}
h := primitives.NewZeroHash()
data, err = h.UnmarshalBinaryData(data)
b, err = h.UnmarshalBinaryData(b)
if err != nil {
panic(err)
}
h2 := primitives.Sha(data)
h2 := primitives.Sha(b)
if h.IsSameAs(h2) == false {
fmt.Printf("LoadDBStateList - Integrity hashes do not match!")
panic(err)
fmt.Fprintf(os.Stderr, "LoadDBStateList - Integrity hashes do not match!")
panic(errors.New("fastboot file does not match its hash"))
//return fmt.Errorf("Integrity hashes do not match")
}

nd, err := s.DBStates.UnmarshalBinaryData(data)
if err != nil {
panic(err)
statelist.UnmarshalBinary(b)
var i int
for i = len(statelist.DBStates) - 1; i >= 0; i-- {
if statelist.DBStates[i].SaveStruct != nil {
break
}
}
statelist.DBStates[i].SaveStruct.RestoreFactomdState(statelist.State)

if len(nd) != 0 {
panic("Left over bytes after savestate unmarshal")
}
//fmt.Println(s.IdentityControl)

state.PrintState(s)
//state.PrintState(s)

h1 := state.GetMapHash(s.GetLLeaderHeight(), s.FactoidBalancesP)
h2 = state.GetMapHash(s.GetLLeaderHeight(), s.ECBalancesP)
h1 := state.GetMapHash(s.FactoidBalancesP)
h2 = state.GetMapHash(s.ECBalancesP)

var b []byte
b = append(b, h1.Bytes()...)
b = append(b, h2.Bytes()...)
var d []byte
d = append(d, h1.Bytes()...)
d = append(d, h2.Bytes()...)
r := primitives.Sha(b)

fmt.Printf("Balance Hash: DBHeight %d, FCTCount %d, ECCount %d, Hash %x\n", s.GetLLeaderHeight(), len(s.FactoidBalancesP), len(s.ECBalancesP), r.Bytes()[:])
Expand All @@ -73,4 +76,32 @@ func main() {
"EC Address Count: %d\n"+
"Balance Hash: %s\n",
s.LLeaderHeight, len(s.FactoidBalancesP), len(s.ECBalancesP), bh.String())

// Identity Related Info
//fmt.Println(s.IdentityControl)
fmt.Println("--- Will print any state inconsistencies, if they exits:")
errors := CheckForStateErrors(s)
for _, e := range errors {
fmt.Println(e)
}
}

// Find any inconsistency or errors with a savestate.
func CheckForStateErrors(s *state.State) (errors []error) {
errors = append(errors, checkIdentityErrors(s)...)
return
}

func checkIdentityErrors(s *state.State) (errors []error) {
// Check for sync blocks having issues
ic := s.IdentityControl
for _, id := range ic.Identities {
if !id.IdentityChainSync.Current.IsSameAs(&id.IdentityChainSync.Target) && len(id.IdentityChainSync.BlocksToBeParsed) == 0 {
errors = append(errors, fmt.Errorf("Identity %x has no 'BlocksToBeParsed' when it should for identity sync", id.IdentityChainID.Bytes()[3:8]))
}
if !id.ManagementChainSync.Current.IsSameAs(&id.ManagementChainSync.Target) && len(id.ManagementChainSync.BlocksToBeParsed) == 0 {
errors = append(errors, fmt.Errorf("Identity %x has no 'BlocksToBeParsed' when it should for management sync", id.IdentityChainID.Bytes()[3:8]))
}
}
return
}
3 changes: 2 additions & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
6.1.0
6.1.1

14 changes: 8 additions & 6 deletions activations/activationHeight.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import (
type ActivationType int

const (
_ ActivationType = iota // 0 Don't use ZERO
ELECTION_NO_SORT = iota // 1 -- this is a passing activation and this ID may be reused once that height is passes and the references are removed
TESTNET_COINBASE_PERIOD = iota // 2 -- this is a passing activation and this ID may be reused once that height is passes and the references are removed
_ ActivationType = iota // 0 Don't use ZERO
ELECTION_NO_SORT = iota // 1 -- this is a passing activation and this ID may be reused once that height is passes and the references are removed

TESTNET_COINBASE_PERIOD = iota // 2 -- this is a passing activation and this ID may be reused once that height is passes and the references are removed
//
ACTIVATION_TYPE_COUNT = iota - 1 // Always Last
)
Expand All @@ -40,16 +41,17 @@ func init() {
0, // active at the beginning of time unless overridden below
map[string]int{
"MAIN": 146060 + 8*24*10 + 1, // On 6/20/18 11:45 mainnet was 146060, we want activation at 6/28/18 at ~12pm
"TEST": 0, // Activate immediatly
"LOCAL": 10, // Must be > 6 for TestActivationHeightElection to pass
"CUSTOM:fct_community_test": 33037 + 2*24*10 + 1, // On 6/22/18 11:45 testnet was 33037, we want activation at 6/24/18 at 12:00pm
},
},
Activation{"TestNetCoinBasePeriod", TESTNET_COINBASE_PERIOD,
"Change testnet coin base payout delay to 144 blocks",
"Change testnet coin base payout delay to 140 blocks",
math.MaxInt32, // inactive unless overridden below
map[string]int{
"MAIN": math.MaxInt32,
"LOCAL": math.MaxInt32,
"LOCAL": 25,
"CUSTOM:fct_community_test": 45335, // Monday morning September 17
},
},
Expand All @@ -73,7 +75,7 @@ func (id ActivationType) String() string {

n, ok := ActivationNameMap[id]
if !ok {
n = fmt.Sprintf("ActivationId(%v)", string(id))
n = fmt.Sprintf("ActivationId(%v)", id)
}
return n
}
Expand Down
10 changes: 9 additions & 1 deletion common/adminBlock/EntryAddAuditServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package adminBlock
import (
"fmt"
"os"
"reflect"

"github.com/FactomProject/factomd/common/constants"
"github.com/FactomProject/factomd/common/interfaces"
Expand Down Expand Up @@ -137,7 +138,14 @@ func (e *AddAuditServer) Interpret() string {
return ""
}

func (e *AddAuditServer) Hash() interfaces.IHash {
func (e *AddAuditServer) Hash() (rval interfaces.IHash) {
defer func() {
if rval != nil && reflect.ValueOf(rval).IsNil() {
rval = nil // convert an interface that is nil to a nil interface
primitives.LogNilHashBug("AddAuditServer.Hash() saw an interface that was nil")
}
}()

bin, err := e.MarshalBinary()
if err != nil {
panic(err)
Expand Down
Loading

0 comments on commit 5f787fc

Please sign in to comment.