Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/pos-networking-and-syncing #899

Merged
merged 78 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
fefb100
Add BLS Keystore
tholonious Dec 15, 2023
a7edc6c
PoS Validator Constants and Network Changes (#876)
AeonSw4n Dec 28, 2023
b2b113c
PoS Validator Connect/Disconnect Flow (#768)
AeonSw4n Dec 29, 2023
43d8e36
PoS RemoteNode and RemoteNodeId (#857)
AeonSw4n Jan 6, 2024
2eb2632
PoS Remote Node Indexer and Manager (#879)
AeonSw4n Jan 10, 2024
a86d1c8
PoS HandshakeController (#860)
AeonSw4n Jan 11, 2024
48c0677
Add HandshakeController (#861)
AeonSw4n Jan 24, 2024
21ba1dd
Add validator deduplication test (#942)
AeonSw4n Jan 29, 2024
59af74d
Revert "Code split" (#943)
AeonSw4n Jan 29, 2024
3901564
Revert "Code split" (#944)
AeonSw4n Jan 29, 2024
4a53182
Merge branch 'feature/proof-of-stake' into feature/pos-networking-and…
tholonious Jan 29, 2024
c057262
Merge branch 'feature/proof-of-stake' into feature/pos-networking-and…
tholonious Jan 29, 2024
3543f2c
Nits
AeonSw4n Jan 29, 2024
927df23
PoS NetworkManager RemoteNode Cleanup (#945)
AeonSw4n Jan 30, 2024
f60ec17
PoS NetworkManager Address (#957)
AeonSw4n Jan 30, 2024
baa91ae
PoS NetworkManager Rename and Nits (#959)
AeonSw4n Jan 30, 2024
c7317f5
PoS NetworkManager Fix Integration Tests (#960)
AeonSw4n Jan 30, 2024
edaf174
Fix fmt (#973)
AeonSw4n Jan 30, 2024
76bf439
PoS Networking and Syncing Documentation (#974)
AeonSw4n Jan 31, 2024
a6b26b7
Rewording (#981)
AeonSw4n Jan 31, 2024
20f2eb4
Rename (#986)
AeonSw4n Jan 31, 2024
5ffc022
PoS NetworkManager Fix Deadlock and Test AddIps (#996)
AeonSw4n Feb 1, 2024
1b0bc01
PoS NetworkManager Comment Nit (#997)
AeonSw4n Feb 1, 2024
b4454e0
Merge branch 'feature/proof-of-stake' into feature/pos-networking-and…
AeonSw4n Feb 7, 2024
c9571c8
Merge branch 'feature/proof-of-stake' into feature/pos-networking-and…
tholonious Feb 14, 2024
f4059c6
Merge branch 'feature/proof-of-stake' into feature/pos-networking-and…
tholonious Feb 14, 2024
362d634
Merge branch 'feature/proof-of-stake' into feature/pos-networking-and…
tholonious Feb 14, 2024
aa0fb85
Add ProtocolVersion To Regtest Params (#1035)
tholonious Feb 15, 2024
2a1e9c7
Merge branch 'feature/proof-of-stake' into feature/pos-networking-and…
tholonious Feb 15, 2024
f0c7b5d
Fix Constructor Name for NetworkManager
tholonious Feb 15, 2024
94c8130
Merge branch 'feature/proof-of-stake' into feature/pos-networking-and…
tholonious Feb 15, 2024
bc95c03
Broadcast Votes, Timeouts, and Block Proposals To Validators (#1036)
tholonious Feb 16, 2024
99d0a46
Use RemoteNode To Fetch Missing PoS Blocks (#1045)
tholonious Feb 16, 2024
2b3f154
Merge branch 'feature/proof-of-stake' into feature/pos-networking-and…
tholonious Feb 20, 2024
d2f2cdd
Update Active Validator Connections In PoS Consensus (#1054)
tholonious Feb 20, 2024
50db24d
Remove Rollbacks To bestHeaderChain When bestChain is Mutated (#1055)
tholonious Feb 21, 2024
e87c72b
PoW Miner Event Loop Cleanup (#1056)
tholonious Feb 21, 2024
4239b8e
Log Peer Validator Vote Messages (#1057)
tholonious Feb 22, 2024
3d3b816
Log Peer Validator Timeout Messages (#1058)
tholonious Feb 22, 2024
6b52173
Merge branch 'feature/proof-of-stake' into feature/pos-networking-and…
tholonious Feb 22, 2024
f10d6dc
Request Missing HighQC Block For Timeout Message (#1061)
tholonious Feb 22, 2024
5d1bb33
Remove Peer Disconnects in Server._handleBlock (#1062)
tholonious Feb 22, 2024
ac60b95
Change log level for consensus events
tholonious Feb 22, 2024
c1a4cbb
Update regtest block producer domain
tholonious Feb 22, 2024
19e8511
Prevent Commited Tip Reorgs in ProcessHeaderPoS (#1063)
tholonious Feb 22, 2024
cf47baa
Add Estimate fee rate to mempool interface (#1066)
lazynina Feb 26, 2024
7ab45bb
Add BLS Public Key PKID Pair Entry Snapshot to core state (#1068)
lazynina Feb 26, 2024
5a20c5c
Fix txindex for failing txns (#1069)
lazynina Feb 28, 2024
ae9e118
Introduce failing txn type so state syncer understand failing txns (#…
lazynina Feb 28, 2024
0eff225
Support uncommitted blocks in state syncer mempool flush (#1065)
lazynina Feb 28, 2024
bf84888
Fix Connect failing txn test (#1071)
lazynina Feb 28, 2024
1f644e8
Add support for seed hex in block producer seed (#1072)
lazynina Feb 28, 2024
0c40ac8
Make GetCommittedTip public (#1073)
lazynina Feb 29, 2024
9445f77
Assorted small enhancements for node restart w/ pos (#1079)
lazynina Feb 29, 2024
e1312f9
Fix txindex dependent transaction within uncommitted blocks (#1082)
lazynina Mar 1, 2024
ea2db8f
Add flag to control number of mempool txns to sync in state syncer ro…
lazynina Mar 1, 2024
b492efe
PoS NetworkManager Consolidation (#1078)
AeonSw4n Mar 4, 2024
b264238
Connect Uncommitted Blocks To Best Header Chain on Startup (#1087)
tholonious Mar 6, 2024
b15eb62
Smarter Transition From Syncing To Steady State PoS Consensus (#1088)
tholonious Mar 6, 2024
038f4f6
Fix FastHotStuffConsensus Transition Timer (#1091)
tholonious Mar 7, 2024
f22f402
Gossip New Block Hashes Via Inv Message to Non-Validators (#1092)
tholonious Mar 7, 2024
662fb82
Fix Edge Cases With Header Syncing, Block Syncing, and PoS Steady Sta…
tholonious Mar 7, 2024
6248251
Safer Heuristic to Detemine When to Transition to FastHotStuffConsens…
tholonious Mar 7, 2024
4a4b84a
Fix Mempool and Fee Estimator Past Blocks Refresh on Block Connect (#…
tholonious Mar 8, 2024
93fc6aa
Fix Race Conditions With Mempool Txn Relay (#1096)
tholonious Mar 8, 2024
c6a5a61
Add Peer nil Check in Block Gossiping (#1097)
tholonious Mar 8, 2024
be34e3d
Beef up logging for FastHotStuffConsensus (#1107)
tholonious Mar 12, 2024
4cb18c7
Fix Validation For Zero Validator HighQC View Value In Timeout QCs (#…
tholonious Mar 13, 2024
6609ba0
Print Current Leader Check Debugging Info (#1112)
tholonious Mar 13, 2024
9678323
Fix Block Hash Comparison In ProcessValidatorVote (#1117)
tholonious Mar 14, 2024
3589349
Pass uncommitted utxo view through validation funcs to prevent rebuil…
lazynina Mar 19, 2024
1f90ae3
Cache block views (#1110)
lazynina Mar 19, 2024
c06bbc6
VerifySignature syncing enhancements (#1115)
lazynina Mar 19, 2024
2ed8912
Update flow crypto dependency (#1123)
lazynina Mar 19, 2024
fba2e95
Reject Forking PoW Blocks Once Chain Reaches Final Height of PoW Prot…
tholonious Mar 19, 2024
2127ef5
PoS NetworkManager Review (#1119)
AeonSw4n Mar 20, 2024
476787f
PoS NetworkManager ConnectIps Fixes (#1120)
AeonSw4n Mar 20, 2024
1b488fe
PoS NetworManager ConnectIps Tests (#1121)
AeonSw4n Mar 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ COPY scripts scripts
COPY test_data test_data
COPY main.go .

RUN ./scripts/install-relic.sh

# build backend
RUN GOOS=linux go build -mod=mod -a -installsuffix cgo -o bin/core -tags=relic main.go
RUN GOOS=linux go build -mod=mod -a -installsuffix cgo -o bin/core main.go

# create tiny image
FROM alpine:edge
Expand Down
22 changes: 18 additions & 4 deletions bls/signature.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build relic

package bls

import (
Expand All @@ -11,8 +9,8 @@ import (
"fmt"
"strings"

flowCrypto "github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/crypto/hash"
flowCrypto "github.com/onflow/crypto"
"github.com/onflow/crypto/hash"
)

// The signingAlgorithm for BLS keys is BLSBLS12381 which is BLS on the BLS 12-381 curve.
Expand Down Expand Up @@ -227,6 +225,14 @@ func (publicKey *PublicKey) FromString(publicKeyString string) (*PublicKey, erro
return publicKey, err
}

func (publicKey *PublicKey) ToAbbreviatedString() string {
str := publicKey.ToString()
if len(str) <= 8 {
return str
}
return str[:8] + "..." + str[len(str)-8:]
}

func (publicKey *PublicKey) MarshalJSON() ([]byte, error) {
// This is called automatically by the JSON library when converting a
// bls.PublicKey to JSON. This is useful when passing a bls.PublicKey
Expand Down Expand Up @@ -324,6 +330,14 @@ func (signature *Signature) FromString(signatureString string) (*Signature, erro
return signature, nil
}

func (signature *Signature) ToAbbreviatedString() string {
str := signature.ToString()
if len(str) <= 8 {
return str
}
return str[:8] + "..." + str[len(str)-8:]
}

func (signature *Signature) MarshalJSON() ([]byte, error) {
// This is called automatically by the JSON library when converting a
// bls.Signature to JSON. This is useful when passing a bls.Signature
Expand Down
157 changes: 0 additions & 157 deletions bls/signature_no_relic.go

This file was deleted.

15 changes: 0 additions & 15 deletions bls/signature_no_relic_test.go

This file was deleted.

2 changes: 0 additions & 2 deletions bls/signature_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build relic

package bls

import (
Expand Down
4 changes: 3 additions & 1 deletion cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ type Config struct {
TimeEvents bool

// State Syncer
StateChangeDir string
StateChangeDir string
StateSyncerMempoolTxnSyncLimit uint64
}

func LoadConfig() *Config {
Expand Down Expand Up @@ -176,6 +177,7 @@ func LoadConfig() *Config {

// State Syncer
config.StateChangeDir = viper.GetString("state-change-dir")
config.StateSyncerMempoolTxnSyncLimit = viper.GetUint64("state-syncer-mempool-txn-sync-limit")

return &config
}
Expand Down
19 changes: 10 additions & 9 deletions cmd/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ import (
)

type Node struct {
Server *lib.Server
ChainDB *badger.DB
TXIndex *lib.TXIndex
Params *lib.DeSoParams
Config *Config
Postgres *lib.Postgres
Server *lib.Server
ChainDB *badger.DB
TXIndex *lib.TXIndex
Params *lib.DeSoParams
Config *Config
Postgres *lib.Postgres
Listeners []net.Listener

// IsRunning is false when a NewNode is created, set to true on Start(), set to false
// after Stop() is called. Mainly used in testing.
Expand Down Expand Up @@ -117,8 +118,7 @@ func (node *Node) Start(exitChannels ...*chan struct{}) {

// This just gets localhost listening addresses on the protocol port.
// Such as [{127.0.0.1 18000 } {::1 18000 }], and associated listener structs.
listeningAddrs, listeners := GetAddrsToListenOn(node.Config.ProtocolPort)
_ = listeningAddrs
_, node.Listeners = GetAddrsToListenOn(node.Config.ProtocolPort)

// If --connect-ips is not passed, we will connect the addresses from
// --add-ips, DNSSeeds, and DNSSeedGenerators.
Expand Down Expand Up @@ -238,7 +238,7 @@ func (node *Node) Start(exitChannels ...*chan struct{}) {
shouldRestart := false
node.Server, err, shouldRestart = lib.NewServer(
node.Params,
listeners,
node.Listeners,
desoAddrMgr,
node.Config.ConnectIPs,
node.ChainDB,
Expand Down Expand Up @@ -282,6 +282,7 @@ func (node *Node) Start(exitChannels ...*chan struct{}) {
node.Config.AugmentedBlockViewRefreshIntervalMillis,
node.Config.PosBlockProductionIntervalMilliseconds,
node.Config.PosTimeoutBaseDurationMilliseconds,
node.Config.StateSyncerMempoolTxnSyncLimit,
)
if err != nil {
// shouldRestart can be true if, on the previous run, we did not finish flushing all ancestral
Expand Down
2 changes: 2 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ func SetupRunFlags(cmd *cobra.Command) {
cmd.PersistentFlags().Bool("time-events", false, "Enable simple event timer, helpful in hands-on performance testing")
cmd.PersistentFlags().String("state-change-dir", "", "The directory for state change logs. WARNING: Changing this "+
"from an empty string to a non-empty string (or from a non-empty string to the empty string) requires a resync.")
cmd.PersistentFlags().Uint("state-syncer-mempool-txn-sync-limit", 10000, "The maximum number of transactions to "+
"process in the mempool tx state syncer at a time.")
cmd.PersistentFlags().VisitAll(func(flag *pflag.Flag) {
viper.BindPFlag(flag.Name, flag)
})
Expand Down
80 changes: 80 additions & 0 deletions collections/concurrent_map.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package collections

import "sync"

type ConcurrentMap[Key comparable, Value any] struct {
mtx sync.RWMutex
m map[Key]Value
}

func NewConcurrentMap[Key comparable, Value any]() *ConcurrentMap[Key, Value] {
return &ConcurrentMap[Key, Value]{
m: make(map[Key]Value),
}
}

func (cm *ConcurrentMap[Key, Value]) Set(key Key, val Value) {
cm.mtx.Lock()
defer cm.mtx.Unlock()

cm.m[key] = val
}

func (cm *ConcurrentMap[Key, Value]) Remove(key Key) {
cm.mtx.Lock()
defer cm.mtx.Unlock()

_, ok := cm.m[key]
if !ok {
return
}
delete(cm.m, key)
}

func (cm *ConcurrentMap[Key, Value]) Get(key Key) (Value, bool) {
cm.mtx.RLock()
defer cm.mtx.RUnlock()

val, ok := cm.m[key]
return val, ok
}

func (cm *ConcurrentMap[Key, Value]) Clone() *ConcurrentMap[Key, Value] {
cm.mtx.RLock()
defer cm.mtx.RUnlock()

clone := NewConcurrentMap[Key, Value]()
for key, val := range cm.m {
clone.Set(key, val)
}
return clone
}

func (cm *ConcurrentMap[Key, Value]) ToMap() map[Key]Value {
cm.mtx.RLock()
defer cm.mtx.RUnlock()

index := make(map[Key]Value)
for key, node := range cm.m {
index[key] = node
}
return index
}

func (cm *ConcurrentMap[Key, Value]) GetAll() []Value {
cm.mtx.RLock()
defer cm.mtx.RUnlock()

var vals []Value
for _, val := range cm.m {
vals = append(vals, val)
}
return vals
}

func (cm *ConcurrentMap[Key, Value]) Count() int {
cm.mtx.RLock()
defer cm.mtx.RUnlock()

return len(cm.m)
}
Loading
Loading