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

Mmtx #37

Draft
wants to merge 29 commits into
base: mmtx-save
Choose a base branch
from
Draft

Mmtx #37

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
402dda4
bugfix: Not including mixhash in the SealHash generation
gameofpointers Mar 25, 2024
a611a9e
fix: carried pointer on delete utxo array
0xalank Mar 23, 2024
0c953cc
Expose functions for WS and HTTP ports
Djadih Mar 27, 2024
5b0d0b3
Removed Encode/Decode RLP for header
gameofpointers Mar 1, 2024
b9ada0c
Added new fields to the header for dynamic expansion
gameofpointers Mar 19, 2024
785b8a2
Computing the UncledS and ParentSubDeltaS
gameofpointers Mar 19, 2024
8cab583
Computing the Efficiency score, Threshold Count and Expansion Number
gameofpointers Mar 19, 2024
d80a494
GasLimit update for new chains
gameofpointers Mar 18, 2024
b3bcd1a
Hierarchical expansion using Hierarchical coordinator
gameofpointers Mar 19, 2024
5ec95b7
Computing the prime terminus in the header
gameofpointers Mar 20, 2024
47ba3fa
Computing the EtxEligible slices, disallow etx to non eligible slices
gameofpointers Mar 20, 2024
2124916
Added a flag to start from a custom starting expansion number
gameofpointers Mar 21, 2024
4fa6eb5
bugfix: Have to store the body with evm and utxo root for uniqueness
gameofpointers Mar 22, 2024
6ba42b1
Updated the genesis hash after all the header changes
gameofpointers Mar 28, 2024
99b00d4
Remove the encode and decode rlp for block
gameofpointers Mar 23, 2024
4701419
Added interlink hashs to body and header
gameofpointers Mar 23, 2024
5263257
Prefix topic with prime genesis hash
wizeguyy Mar 20, 2024
8cb2d1d
cherrypick cicd from main
robertlincecum Mar 12, 2024
7a7b9a6
bugfix: Only set consensus backend once
wizeguyy Apr 3, 2024
98980ce
Renamed InternalTx to QuaiTx
jdowning100 Mar 13, 2024
fa9da0d
Removed InternalToExternalTx and replaced functionality with QuaiTx
jdowning100 Mar 14, 2024
ec361ae
QIP10: Txhash has location encoded in bytes 0 and 1
jdowning100 Mar 14, 2024
21a326e
Removed ValidateETXGasPriceAndTip as ETX no longer has GasPrice or Tip
jdowning100 Apr 2, 2024
be58c7d
Fix BlocksPerDay calc for development
Djadih Apr 2, 2024
389bf97
Genesis hash print mistamtch
Djadih Apr 2, 2024
3b365a1
Bugfix: addUtxoTx should only RLock mempool if necessary
jdowning100 Apr 4, 2024
96215da
Removing the Sync Target logic as the downloader process is completel…
gameofpointers Apr 5, 2024
3fc20f7
Introduction of the Work Object type to facilitate MMTX
kiltsonfire Mar 6, 2024
686a197
bugfix: Only send chain head feed in zone preventing the lock
gameofpointers Mar 26, 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
21 changes: 21 additions & 0 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Patch Release Branch Workflow
on:
pull_request:
types: [closed]
branches:
- 'v?[0-9]+.[0-9]+'
jobs:
call-common-workflow:
uses: dominant-strategies/quai-cicd/.github/workflows/deploy-sandbox-common.yml@main
with:
needs_build: true
build_command: "make go-quai"
needs_docker: false
include_chart: false
cloud_deploy: false
skip_deploy: true
update_version: false
secrets:
GH_PAT: ${{ secrets.GH_PAT }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY2 }}
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
1 change: 1 addition & 0 deletions .github/workflows/cut-minor-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
include_chart: false
cloud_deploy: false
skip_deploy: true
update_version: true
secrets:
GH_PAT: ${{ secrets.GH_PAT }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY2 }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
cloud_deploy: false
skip_deploy: true
update_version: false

secrets:
GH_PAT: ${{ secrets.GH_PAT }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY2 }}
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/patch.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: Patch Release Branch Workflow
on:
pull_request:
types: [closed]
branches:
- 'v?[0-9]+.[0-9]+'
on: workflow_dispatch
jobs:
call-common-workflow:
uses: dominant-strategies/quai-cicd/.github/workflows/deploy-sandbox-common.yml@main
Expand All @@ -14,6 +10,7 @@ jobs:
include_chart: false
cloud_deploy: false
skip_deploy: true
update_version: true
secrets:
GH_PAT: ${{ secrets.GH_PAT }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY2 }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ debug:
go-quai:
$(GORUN) build/ci.go build ./cmd/go-quai
@echo "Done building."
@echo "Run \"$(GOBIN)/go-quai\" to launch go-quai."
@echo "Run \"$(GOBIN)/go-quai\" to launch go-quai."
18 changes: 12 additions & 6 deletions cmd/go-quai/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,20 @@ func runStart(cmd *cobra.Command, args []string) error {
}

logLevel := cmd.Flag(utils.LogLevelFlag.Name).Value.String()
// create instance of consensus backend
var nodeWG sync.WaitGroup
consensus, err := utils.StartQuaiBackend(ctx, node, logLevel, &nodeWG)

var startingExpansionNumber uint64
if viper.IsSet(utils.StartingExpansionNumberFlag.Name) {
startingExpansionNumber = viper.GetUint64(utils.StartingExpansionNumberFlag.Name)
}
// Start the hierarchical co-ordinator
var nodeWg sync.WaitGroup
hc := utils.NewHierarchicalCoordinator(node, logLevel, &nodeWg, startingExpansionNumber)
err = hc.StartHierarchicalCoordinator()
if err != nil {
log.Global.WithField("error", err).Fatal("error creating consensus backend")
log.Global.WithField("error", err).Fatal("error starting hierarchical coordinator")
}

// start the p2p node
node.SetConsensusBackend(consensus)
if err := node.Start(); err != nil {
log.Global.WithField("error", err).Fatal("error starting node")
}
Expand All @@ -110,7 +115,8 @@ func runStart(cmd *cobra.Command, args []string) error {
<-ch
log.Global.Warn("Received 'stop' signal, shutting down gracefully...")
cancel()
nodeWG.Wait()
// stop the hierarchical co-ordinator
hc.Stop()
if err := node.Stop(); err != nil {
panic(err)
}
Expand Down
88 changes: 28 additions & 60 deletions cmd/utils/cmd.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package utils

import (
"context"
"fmt"
"io"
"os"
"runtime"
"slices"
"strings"
"sync"

"github.com/spf13/viper"

"github.com/dominant-strategies/go-quai/common"
"github.com/dominant-strategies/go-quai/core/types"
"github.com/dominant-strategies/go-quai/internal/quaiapi"
"github.com/dominant-strategies/go-quai/log"
"github.com/dominant-strategies/go-quai/metrics_config"
Expand All @@ -21,58 +20,25 @@ import (
"github.com/dominant-strategies/go-quai/quai"
"github.com/dominant-strategies/go-quai/quai/quaiconfig"
"github.com/dominant-strategies/go-quai/quaistats"
"github.com/syndtr/goleveldb/leveldb"
)

// Create a new instance of the QuaiBackend consensus service
func StartQuaiBackend(ctx context.Context, p2p quai.NetworkingAPI, logLevel string, nodeWG *sync.WaitGroup) (*quai.QuaiBackend, error) {
quaiBackend, _ := quai.NewQuaiBackend()
startNode := func(logPath string, location common.Location, slicesRunning []common.Location) {
nodeWG.Add(1)
go func() {
defer nodeWG.Done()
logger := log.NewLogger(logPath, logLevel)
logger.Info("Starting Node at location", "location", location)
stack, apiBackend := makeFullNode(p2p, location, slicesRunning, logger)
quaiBackend.SetApiBackend(apiBackend, location)
StartNode(stack)
// Create a channel to signal when stack.Wait() is done
done := make(chan struct{})
go func() {
stack.Wait()
close(done)
}()

select {
case <-done:
logger.Info("Node stopped normally")
stack.Close()
return
case <-ctx.Done():
logger.Info("Context cancelled, shutting down node")
stack.Close()
return
}
}()
func OpenBackendDB() (*leveldb.DB, error) {
dataDir := viper.GetString(DataDirFlag.Name)
if _, err := os.Stat(dataDir); os.IsNotExist(err) {
err := os.MkdirAll(dataDir, 0755)
if err != nil {
log.Global.Errorf("error creating data directory: %s", err)
return nil, err
}
}
dbPath := dataDir + "quaibackend"

// Set the p2p backend inside the quaiBackend
quaiBackend.SetP2PApiBackend(p2p)

runningSlices := GetRunningZones()
runningRegions := GetRunningRegions(runningSlices)

// Start nodes in separate goroutines
startNode("nodelogs/prime.log", nil, runningSlices)
for _, region := range runningRegions {
nodelogsFileName := "nodelogs/region-" + fmt.Sprintf("%d", region) + ".log"
startNode(nodelogsFileName, common.Location{region}, runningSlices)
}
for _, slice := range runningSlices {
nodelogsFileName := "nodelogs/zone-" + fmt.Sprintf("%d", slice[0]) + "-" + fmt.Sprintf("%d", slice[1]) + ".log"
startNode(nodelogsFileName, slice, runningSlices)
db, err := leveldb.OpenFile(dbPath, nil)
if err != nil {
return nil, err
}

return quaiBackend, nil
return db, err
}

// GetRunningZones returns the slices that are processing state (which are only zones)
Expand All @@ -83,12 +49,13 @@ func GetRunningZones() []common.Location {
if slices[0] == "" {
Fatalf("no slices are specified")
}
if len(slices) > common.NumRegionsInPrime*common.NumZonesInRegion {
Fatalf("number of slices exceed the current ontology")
}
runningSlices := []common.Location{}
for _, slice := range slices {
runningSlices = append(runningSlices, common.Location{slice[1] - 48, slice[3] - 48})
location := common.Location{slice[1] - 48, slice[3] - 48}
if location.Region() > common.MaxRegions || location.Zone() > common.MaxZones {
Fatalf("invalid slice: %s", location)
}
runningSlices = append(runningSlices, location)
}
return runningSlices
}
Expand All @@ -112,7 +79,7 @@ func StartNode(stack *node.Node) {
}

// makeConfigNode loads quai configuration and creates a blank node instance.
func makeConfigNode(slicesRunning []common.Location, nodeLocation common.Location, logger *log.Logger) (*node.Node, quaiconfig.QuaiConfig) {
func makeConfigNode(slicesRunning []common.Location, nodeLocation common.Location, currentExpansionNumber uint8, logger *log.Logger) (*node.Node, quaiconfig.QuaiConfig) {
// Load defaults.
cfg := quaiconfig.QuaiConfig{
Quai: quaiconfig.Defaults,
Expand All @@ -130,7 +97,7 @@ func makeConfigNode(slicesRunning []common.Location, nodeLocation common.Locatio
if err != nil {
Fatalf("Failed to create the protocol stack: %v", err)
}
SetQuaiConfig(stack, &cfg.Quai, slicesRunning, nodeLocation, logger)
SetQuaiConfig(stack, &cfg.Quai, slicesRunning, nodeLocation, currentExpansionNumber, logger)

// TODO: Apply stats
if viper.IsSet(QuaiStatsURLFlag.Name) {
Expand All @@ -150,9 +117,10 @@ func defaultNodeConfig() node.Config {
}

// makeFullNode loads quai configuration and creates the Quai backend.
func makeFullNode(p2p quai.NetworkingAPI, nodeLocation common.Location, slicesRunning []common.Location, logger *log.Logger) (*node.Node, quaiapi.Backend) {
stack, cfg := makeConfigNode(slicesRunning, nodeLocation, logger)
backend, _ := RegisterQuaiService(stack, p2p, cfg.Quai, cfg.Node.NodeLocation.Context(), logger)
func makeFullNode(p2p quai.NetworkingAPI, nodeLocation common.Location, slicesRunning []common.Location, currentExpansionNumber uint8, genesisBlock *types.WorkObject, logger *log.Logger) (*node.Node, quaiapi.Backend) {
stack, cfg := makeConfigNode(slicesRunning, nodeLocation, currentExpansionNumber, logger)
startingExpansionNumber := viper.GetUint64(StartingExpansionNumberFlag.Name)
backend, _ := RegisterQuaiService(stack, p2p, cfg.Quai, cfg.Node.NodeLocation.Context(), currentExpansionNumber, startingExpansionNumber, genesisBlock, logger)
sendfullstats := viper.GetBool(SendFullStatsFlag.Name)
// Add the Quai Stats daemon if requested.
if cfg.Quaistats.URL != "" {
Expand All @@ -164,8 +132,8 @@ func makeFullNode(p2p quai.NetworkingAPI, nodeLocation common.Location, slicesRu
// RegisterQuaiService adds a Quai client to the stack.
// The second return value is the full node instance, which may be nil if the
// node is running as a light client.
func RegisterQuaiService(stack *node.Node, p2p quai.NetworkingAPI, cfg quaiconfig.Config, nodeCtx int, logger *log.Logger) (quaiapi.Backend, error) {
backend, err := quai.New(stack, p2p, &cfg, nodeCtx, logger)
func RegisterQuaiService(stack *node.Node, p2p quai.NetworkingAPI, cfg quaiconfig.Config, nodeCtx int, currentExpansionNumber uint8, startingExpansionNumber uint64, genesisBlock *types.WorkObject, logger *log.Logger) (quaiapi.Backend, error) {
backend, err := quai.New(stack, p2p, &cfg, nodeCtx, currentExpansionNumber, startingExpansionNumber, genesisBlock, logger)
if err != nil {
Fatalf("Failed to register the Quai service: %v", err)
}
Expand Down
Loading