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

v2024.3.0 release #4768

Merged
merged 24 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
016d979
add connection manager high water mark flag to boot node (#4747)
GheisMohammadi Aug 30, 2024
4718a1c
Lock free consensus methods (#4739)
Frozen Sep 3, 2024
583e38a
chore(CI) - point tests to the master
mur-me Aug 28, 2024
e1b0ebc
feat(CI) - cover corner case for the PR from forked repo
mur-me Aug 28, 2024
f90304a
chore(CI) - tell Docker to silence it output to minimal or it will br…
mur-me Aug 30, 2024
3a2349c
fix(CI) - move harmony folder to the GOPATH instead of default folder
mur-me Sep 5, 2024
647d20b
run stable localnet with external node
sophoah Sep 10, 2024
952814a
improve comment detection in deploy.sh
sophoah Sep 10, 2024
6d9b09d
Add RPC for Boot Nodes (#4735)
GheisMohammadi Sep 11, 2024
3e23739
feat(Makefile) - cover verbose mode for the local debug (#4755)
mur-me Sep 11, 2024
e08df0c
Improve Crosslinks Retrieving and Processing (#4754)
GheisMohammadi Sep 20, 2024
84672e8
Fix for localnet syncing ports. (#4753)
Frozen Sep 20, 2024
797511c
feat(localnet) - add localnet log aggregation tool (#4758)
mur-me Sep 24, 2024
991d1a0
feat(Makefile) - add switch for the legacy sync, make stream sync (#4…
mur-me Sep 25, 2024
1d8dfe6
Broadcast vote power. (#4748)
Frozen Sep 25, 2024
0aaa180
Broadcast epoch block (#4756)
Frozen Sep 27, 2024
feb5180
[localnet] fix external config (#4763)
sophoah Sep 27, 2024
aba5af0
switch localnet to yamux muxer (#4764)
GheisMohammadi Oct 3, 2024
2d8fb0e
feat(RPC) - GetLastSigningPower on public harmony API (#4766)
mur-me Oct 4, 2024
c823abd
Improve Crosslink Retrieve from RawDB (#4765)
GheisMohammadi Oct 4, 2024
544f2ac
Not Checking Pending Crosslinks for First ten Epoch (#4757)
GheisMohammadi Oct 4, 2024
1588c05
Empty signing power workaround (#4663)
Frozen Oct 4, 2024
672cd76
HIP32 epoch activation and new sharding config (#4769)
Frozen Oct 8, 2024
2e824e1
HIP32 set to epoch 2152 (#4770)
sophoah Oct 8, 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,6 @@ profiles/*.pb.gz
# cache db
cache/
cache_*_db

# log aggregation logs folder variable file, no sense to track it
test/logs_aggregator/.env
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ install:
# /home/travis/gopath/src/github.com/harmony-one/harmony
# https://docs.travis-ci.com/user/languages/go/#go-import-path
- echo $TRAVIS_PULL_REQUEST_BRANCH
#TODO: return back to master
- TEST_REPO_BRANCH="feature/go1.22"
- TEST_REPO_BRANCH="master"
- git clone https://github.com/harmony-one/mcl.git $GOPATH/src/github.com/harmony-one/mcl
- git clone https://github.com/harmony-one/bls.git $GOPATH/src/github.com/harmony-one/bls
#TODO: return back harmony instead of personal fork
- git clone --branch $TEST_REPO_BRANCH https://github.com/harmony-one/harmony-test.git $GOPATH/src/github.com/harmony-one/harmony-test
- (cd $GOPATH/src/github.com/harmony-one/mcl; make -j4)
- (cd $GOPATH/src/github.com/harmony-one/bls; make BLS_SWAP_G=1 -j4)
# - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.41.1
- make go-get
- go install golang.org/x/tools/cmd/goimports@latest
- go install github.com/harmony-ek/gencodec@latest
- echo "[WARN] - workaround for the GOPATH:"
- mv /home/travis/build/harmony-one/harmony $GOPATH/src/github.com/harmony-one/
script:
- ${TEST}
after_success:
Expand Down
23 changes: 22 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ help:
@echo "travis_rosetta_checker - run the Travis Rosetta checker script, defaulting the test branch to 'master' unless overridden by TEST_REPO_BRANCH"
@echo "debug_external - cleans up environment, rebuilds the binary, and deploys with external nodes"
@echo "build_localnet_validator - imports validator keys, funds validator accounts, waits for the epoch, and creates external validators on a local network"
@echo "debug-start-log - start a docker compose Promtail->Loki->Grafana stack against localnet logs, needs docker compose and started localnet"
@echo "debug-stop-log - stops a docker compose Promtail->Loki->Grafana stack"
@echo "debug-restart-log - restart a docker compose Promtail->Loki->Grafana stack"

libs:
make -C $(TOP)/mcl -j8
Expand All @@ -73,13 +76,23 @@ debug:
# uncomment the following lines to enable debug logging for libp2p, it produces a lot of logs, so disabled by default
#export GOLOG_LOG_LEVEL=debug
#export GOLOG_OUTPUT=stdout
# add VERBOSE=true before bash or run `export VERBOSE=true` on the shell level for have max logging
# add LEGACY_SYNC=true before bash or run `export LEGACY_SYNC=true` on the shell level to switch to the legacy sync
bash ./test/debug.sh

debug-kill:
bash ./test/kill_node.sh

debug-ext:
bash ./test/debug-external.sh
# update localnet block per epoch to ensure a stable localnet
sed -i 's/localnetBlocksPerEpoch\s*=\s*[0-9]*/localnetBlocksPerEpoch = 64/' internal/configs/sharding/localnet.go
sed -i 's/localnetBlocksPerEpochV2\s*=\s*[0-9]*/localnetBlocksPerEpochV2 = 64/' internal/configs/sharding/localnet.go
# add VERBOSE=true before bash or run `export VERBOSE=true` on the shell level for have max logging
# add LEGACY_SYNC=true before bash or run `export LEGACY_SYNC=true` on the shell level to switch to the legacy sync
bash ./test/debug-external.sh &
echo sleep 10s before creating the external validator
sleep 10
bash ./test/build-localnet-validator.sh

clean:
rm -rf ./tmp_log*
Expand Down Expand Up @@ -206,3 +219,11 @@ build_localnet_validator:

protofiles:
bash ./scripts/gogenerate.sh

debug-start-log:
bash ./test/logs_aggregator/start_log_aggregator.sh

debug-stop-log:
bash ./test/logs_aggregator/stop_log_aggregator.sh

debug-restart-log: debug-stop-log debug-start-log
410 changes: 269 additions & 141 deletions api/proto/message/harmonymessage.pb.go

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions api/proto/message/harmonymessage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum MessageType {
DRAND_INIT = 10 [deprecated=true];
DRAND_COMMIT = 11 [deprecated=true];
LOTTERY_REQUEST = 12 [deprecated=true]; // it should be either ENTER or GETPLAYERS but it will be removed later.
LAST_SIGN_POWER = 13;
}

// This is universal message for all communication protocols.
Expand All @@ -47,6 +48,7 @@ message Message {
ViewChangeRequest viewchange = 7;
// Refactor this later after demo.
LotteryRequest lottery_request = 8 [deprecated=true];
LastSignPowerBroadcast last_sign_power = 9;
}
}

Expand Down Expand Up @@ -116,3 +118,11 @@ message ViewChangeRequest {
bytes m3_bitmap= 12;
bytes prepared_block = 13;
}

message LastSignPowerBroadcast {
int64 prepare = 1;
int64 commit = 2;
int64 change = 3;
bytes sender_pubkey = 4;
uint32 shard_id = 5;
}
10 changes: 10 additions & 0 deletions api/proto/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const (
Receipt // cross-shard transaction receipts
SlashCandidate // A report of a double-signing event
CrosslinkHeartbeat // Heart beat signal for crosslinks. Needed for epoch chain.
Epoch
)

var (
Expand All @@ -61,6 +62,7 @@ var (
crossLinkB = byte(CrossLink)
crossLinkHeardBeatB = byte(CrosslinkHeartbeat)
receiptB = byte(Receipt)
epochB = byte(Epoch)
// H suffix means header
slashH = []byte{nodeB, blockB, slashB}
transactionListH = []byte{nodeB, txnB, sendB}
Expand All @@ -69,6 +71,7 @@ var (
crossLinkH = []byte{nodeB, blockB, crossLinkB}
cxReceiptH = []byte{nodeB, blockB, receiptB}
crossLinkHeartBeatH = []byte{nodeB, blockB, crossLinkHeardBeatB}
epochBlockH = []byte{nodeB, blockB, epochB}
)

// ConstructTransactionListMessageAccount constructs serialized transactions in account model
Expand Down Expand Up @@ -139,6 +142,13 @@ func ConstructCrossLinkMessage(bc engine.ChainReader, headers []*block.Header) [
return byteBuffer.Bytes()
}

// ConstructEpochBlockMessage creates epoch block message
func ConstructEpochBlockMessage(blockBytes []byte) []byte {
byteBuffer := bytes.NewBuffer(epochBlockH)
byteBuffer.Write(blockBytes)
return byteBuffer.Bytes()
}

// ConstructCXReceiptsProof constructs cross shard receipts and related proof including
// merkle proof, blockHeader and commitSignatures
func ConstructCXReceiptsProof(cxReceiptsProof *types.CXReceiptsProof) []byte {
Expand Down
2 changes: 1 addition & 1 deletion api/service/legacysync/epoch_syncing.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func ProcessStateSync(syncConfig *SyncConfig, heights []uint64, bc core.BlockCha
func processWithPayload(payload [][]byte, bc core.BlockChain) error {
decoded := make([]*types.Block, 0, len(payload))
for idx, blockBytes := range payload {
block, err := RlpDecodeBlockOrBlockWithSig(blockBytes)
block, err := core.RlpDecodeBlockOrBlockWithSig(blockBytes)
if err != nil {
return errors.Wrap(err, "failed decode")
}
Expand Down
28 changes: 1 addition & 27 deletions api/service/legacysync/syncing.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

"github.com/Workiva/go-datastructures/queue"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rlp"
"github.com/harmony-one/harmony/api/service/legacysync/downloader"
pb "github.com/harmony-one/harmony/api/service/legacysync/downloader/proto"
"github.com/harmony-one/harmony/consensus"
Expand Down Expand Up @@ -356,13 +355,6 @@ func CompareSyncPeerConfigByblockHashes(a *SyncPeerConfig, b *SyncPeerConfig) in
return 0
}

// BlockWithSig the serialization structure for request DownloaderRequest_BLOCKWITHSIG
// The block is encoded as block + commit signature
type BlockWithSig struct {
Block *types.Block
CommitSigAndBitmap []byte
}

// GetBlocks gets blocks by calling grpc request to the corresponding peer.
func (peerConfig *SyncPeerConfig) GetBlocks(hashes [][]byte) ([][]byte, error) {
response := peerConfig.client.GetBlocksAndSigs(hashes)
Expand Down Expand Up @@ -663,7 +655,7 @@ func (ss *StateSync) handleBlockSyncResult(payload [][]byte, tasks syncBlockTask

for i, blockBytes := range payload {
// For forward compatibility at server side, it can be types.block or BlockWithSig
blockObj, err := RlpDecodeBlockOrBlockWithSig(blockBytes)
blockObj, err := core.RlpDecodeBlockOrBlockWithSig(blockBytes)
if err != nil {
utils.Logger().Warn().
Err(err).
Expand All @@ -689,24 +681,6 @@ func (ss *StateSync) handleBlockSyncResult(payload [][]byte, tasks syncBlockTask
return failedTasks
}

// RlpDecodeBlockOrBlockWithSig decode payload to types.Block or BlockWithSig.
// Return the block with commitSig if set.
func RlpDecodeBlockOrBlockWithSig(payload []byte) (*types.Block, error) {
var block *types.Block
if err := rlp.DecodeBytes(payload, &block); err == nil {
// received payload as *types.Block
return block, nil
}

var bws BlockWithSig
if err := rlp.DecodeBytes(payload, &bws); err == nil {
block := bws.Block
block.SetCurrentCommitSig(bws.CommitSigAndBitmap)
return block, nil
}
return nil, errors.New("failed to decode to either types.Block or BlockWithSig")
}

// downloadTaskQueue is wrapper around Queue with item to be SyncBlockTask
type downloadTaskQueue struct {
q *queue.Queue
Expand Down
77 changes: 61 additions & 16 deletions cmd/bootnode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import (
"time"

"github.com/ethereum/go-ethereum/log"
//cmdharmony "github.com/harmony-one/harmony/cmd/harmony"
harmonyConfigs "github.com/harmony-one/harmony/cmd/config"
nodeConfigs "github.com/harmony-one/harmony/internal/configs/node"
"github.com/harmony-one/harmony/internal/utils"
bootnode "github.com/harmony-one/harmony/node/boot"
"github.com/harmony-one/harmony/p2p"
net "github.com/libp2p/go-libp2p/core/network"
ma "github.com/multiformats/go-multiaddr"
Expand Down Expand Up @@ -87,8 +91,7 @@ var (
)

func printVersion(me string) {
fmt.Fprintf(os.Stderr, "Harmony (C) 2019. %v, version %v-%v (%v %v)\n", path.Base(me), version, commit, builtBy, builtAt)
os.Exit(0)
fmt.Fprintf(os.Stderr, "Harmony (C) 2024. %v, version %v-%v (%v %v)\n", path.Base(me), version, commit, builtBy, builtAt)
}

func main() {
Expand All @@ -97,6 +100,8 @@ func main() {

ip := flag.String("ip", "127.0.0.1", "IP of the node")
port := flag.String("port", "9876", "port of the node.")
httpPort := flag.Int("rpc_http_port", 9500, "port of the rpc http")
wsPort := flag.Int("rpc_ws_port", 9800, "port of the rpc ws")
console := flag.Bool("console_only", false, "Output to console only")
logFolder := flag.String("log_folder", "latest", "the folder collecting the logs of this execution")
logMaxSize := flag.Int("log_max_size", 100, "the max size in megabytes of the log file before it gets rotated")
Expand All @@ -108,11 +113,12 @@ func main() {
logConn := flag.Bool("log_conn", false, "log incoming/outgoing connections")
maxConnPerIP := flag.Int("max_conn_per_ip", 10, "max connections number for same ip")
forceReachabilityPublic := flag.Bool("force_public", false, "forcing the local node to believe it is reachable externally")
connMgrHighWaterMark := flag.Int("cmg_high_watermark", 900, "connection manager trims excess connections when they pass the high watermark")
noTransportSecurity := flag.Bool("no_transport_security", false, "disable TLS encrypted transport")
muxer := flag.String("muxer", "mplex, yamux", "protocol muxer to mux per-protocol streams (mplex, yamux)")
userAgent := flag.String("user_agent", defUserAgent, "explicitly set the user-agent, so we can differentiate from other Go libp2p users")
noRelay := flag.Bool("no_relay", true, "no relay services, direct connections between peers only")

networkType := flag.String("network", "mainnet", "network type (mainnet, testnet, pangaea, partner, stressnet, devnet, localnet)")
pprof := flag.Bool("pprof", false, "enabled pprof")
pprofAddr := flag.String("pprof.addr", "127.0.0.1:6060", "http pprof address")
//keyFile := flag.String("pprof.profile.names", "", "the private key file of the bootnode")
Expand All @@ -123,12 +129,13 @@ func main() {

if *versionFlag {
printVersion(os.Args[0])
os.Exit(0)
}

// Logging setup
utils.SetLogContext(*port, *ip)
utils.SetLogVerbosity(log.Lvl(*verbosity))
if *console != true {
if !*console {
utils.AddLogFile(fmt.Sprintf("%v/bootnode-%v-%v.log", *logFolder, *ip, *port), *logMaxSize, *logRotateCount, *logRotateMaxAge)
}

Expand All @@ -142,18 +149,19 @@ func main() {
selfPeer := p2p.Peer{IP: *ip, Port: *port}

host, err := p2p.NewHost(p2p.HostConfig{
Self: &selfPeer,
BLSKey: privKey,
BootNodes: nil, // Boot nodes have no boot nodes :) Will be connected when other nodes joined
DataStoreFile: &dataStorePath,
MaxConnPerIP: *maxConnPerIP,
ForceReachabilityPublic: *forceReachabilityPublic,
NoTransportSecurity: *noTransportSecurity,
NAT: true,
UserAgent: *userAgent,
DialTimeout: time.Minute,
Muxer: *muxer,
NoRelay: *noRelay,
Self: &selfPeer,
BLSKey: privKey,
BootNodes: nil, // Boot nodes have no boot nodes :) Will be connected when other nodes joined
DataStoreFile: &dataStorePath,
MaxConnPerIP: *maxConnPerIP,
ForceReachabilityPublic: *forceReachabilityPublic,
ConnManagerHighWatermark: *connMgrHighWaterMark,
NoTransportSecurity: *noTransportSecurity,
NAT: true,
UserAgent: *userAgent,
DialTimeout: time.Minute,
Muxer: *muxer,
NoRelay: *noRelay,
})
if err != nil {
utils.FatalErrMsg(err, "cannot initialize network")
Expand All @@ -163,8 +171,19 @@ func main() {
fmt.Sprintf("/ip4/%s/tcp/%s/p2p/%s\n", *ip, *port, host.GetID().String()),
)

nt := nodeConfigs.NetworkType(*networkType)
nodeConfigs.SetNetworkType(nt)
harmonyConfigs.VersionMetaData = append(harmonyConfigs.VersionMetaData, path.Base(os.Args[0]), version, commit, builtBy, builtAt)
nodeConfigs.SetVersion(harmonyConfigs.GetHarmonyVersion())
nodeConfigs.SetPeerID(host.GetID())
hc := harmonyConfigs.GetDefaultConfigCopy()

host.Start()

utils.Logger().Info().
Interface("network", nt).
Msg("boot node host started")

if *logConn {
host.GetP2PHost().Network().Notify(NewConnLogger(utils.GetLogInstance()))
}
Expand All @@ -174,5 +193,31 @@ func main() {
http.ListenAndServe(*pprofAddr, nil)
}

currentBootNode := bootnode.New(host, &hc)
rpcConfigs := currentBootNode.GetRPCServerConfig()
rpcConfigs.HTTPPort = *httpPort
rpcConfigs.WSPort = *wsPort

// TODO: enable boot services
/*
if err := currentBootNode.StartServices(); err != nil {
fmt.Fprint(os.Stderr, err.Error())
os.Exit(-1)
}
*/

if err := currentBootNode.StartRPC(); err != nil {
utils.Logger().Error().
Err(err).
Msg("StartRPC failed")
}

utils.Logger().Info().
Interface("network", nt).
Interface("ip", currentBootNode.SelfPeer.IP).
Interface("port", currentBootNode.SelfPeer.Port).
Interface("PeerID", currentBootNode.SelfPeer.PeerID).
Msg("boot node RPC started")

select {}
}
Loading
Loading