Skip to content

Commit

Permalink
Introduction of the Work Object type to facilitate MMTX
Browse files Browse the repository at this point in the history
  • Loading branch information
kiltsonfire authored and gameofpointers committed Apr 5, 2024
1 parent 389bf97 commit 6f2b7f0
Show file tree
Hide file tree
Showing 94 changed files with 3,653 additions and 3,735 deletions.
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."
4 changes: 2 additions & 2 deletions cmd/utils/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func defaultNodeConfig() node.Config {
}

// makeFullNode loads quai configuration and creates the Quai backend.
func makeFullNode(p2p quai.NetworkingAPI, nodeLocation common.Location, slicesRunning []common.Location, currentExpansionNumber uint8, genesisBlock *types.Block, logger *log.Logger) (*node.Node, quaiapi.Backend) {
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)
Expand All @@ -132,7 +132,7 @@ 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, currentExpansionNumber uint8, startingExpansionNumber uint64, genesisBlock *types.Block, logger *log.Logger) (quaiapi.Backend, error) {
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
2 changes: 1 addition & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ func MakeChainDatabase(stack *node.Node, readonly bool) ethdb.Database {
chainDb ethdb.Database
)
name := "chaindata"
chainDb, err = stack.OpenDatabaseWithFreezer(name, cache, handles, viper.GetString(AncientDirFlag.Name), "", readonly)
chainDb, err = stack.OpenDatabaseWithFreezer(name, cache, handles, viper.GetString(AncientDirFlag.Name), "", readonly, stack.Config().NodeLocation)
if err != nil {
Fatalf("Could not open database: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/utils/hierarchical_coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ func (hc *HierarchicalCoordinator) StartQuaiBackend() (*quai.QuaiBackend, error)
return quaiBackend, nil
}

func (hc *HierarchicalCoordinator) startNode(logPath string, quaiBackend quai.ConsensusAPI, location common.Location, genesisBlock *types.Block) {
func (hc *HierarchicalCoordinator) startNode(logPath string, quaiBackend quai.ConsensusAPI, location common.Location, genesisBlock *types.WorkObject) {
hc.wg.Add(1)
logger := log.NewLogger(logPath, hc.logLevel)
logger.Info("Starting Node at location", "location", location)
stack, apiBackend := makeFullNode(hc.p2p, location, hc.slicesRunning, hc.currentExpansionNumber, genesisBlock, logger)
quaiBackend.SetApiBackend(&apiBackend, location)

// Subscribe to the new topics after setting the api backend
hc.p2p.Subscribe(location, &types.Block{})
hc.p2p.Subscribe(location, &types.WorkObject{})
hc.p2p.Subscribe(location, common.Hash{})
hc.p2p.Subscribe(location, &types.Transaction{})

Expand Down Expand Up @@ -195,7 +195,7 @@ func (hc *HierarchicalCoordinator) expansionEventLoop() {
}
}

func (hc *HierarchicalCoordinator) TriggerTreeExpansion(block *types.Block) error {
func (hc *HierarchicalCoordinator) TriggerTreeExpansion(block *types.WorkObject) error {
// set the current expansion on all the backends
currentRegions, currentZones := common.GetHierarchySizeForExpansionNumber(hc.currentExpansionNumber)
newRegions, newZones := common.GetHierarchySizeForExpansionNumber(hc.currentExpansionNumber + 1)
Expand Down
4 changes: 2 additions & 2 deletions common/proto_common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 0 additions & 83 deletions consensus/blake3pow/api.go

This file was deleted.

37 changes: 0 additions & 37 deletions consensus/blake3pow/blake3pow.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import (
"time"

"github.com/dominant-strategies/go-quai/common"
"github.com/dominant-strategies/go-quai/consensus"
"github.com/dominant-strategies/go-quai/log"
"github.com/dominant-strategies/go-quai/rpc"
)

var (
Expand Down Expand Up @@ -55,7 +53,6 @@ type Blake3pow struct {
rand *rand.Rand // Properly seeded random source for nonces
threads int // Number of threads to mine on if mining
update chan struct{} // Notification channel to update mining parameters
remote *remoteSealer

// The fields below are hooks for testing
shared *Blake3pow // Shared PoW verifier to avoid cache regeneration
Expand All @@ -80,7 +77,6 @@ func New(config Config, notify []string, noverify bool, logger *log.Logger) *Bla
if config.PowMode == ModeShared {
blake3pow.shared = sharedBlake3pow
}
blake3pow.remote = startRemoteSealer(blake3pow, notify, noverify)
return blake3pow
}

Expand Down Expand Up @@ -141,19 +137,6 @@ func NewShared() *Blake3pow {
return &Blake3pow{shared: sharedBlake3pow}
}

// Close closes the exit channel to notify all backend threads exiting.
func (blake3pow *Blake3pow) Close() error {
blake3pow.closeOnce.Do(func() {
// Short circuit if the exit channel is not allocated.
if blake3pow.remote == nil {
return
}
close(blake3pow.remote.requestExit)
<-blake3pow.remote.exitCh
})
return nil
}

// Threads returns the number of mining threads currently enabled. This doesn't
// necessarily mean that mining is running!
func (blake3pow *Blake3pow) Threads() int {
Expand Down Expand Up @@ -184,23 +167,3 @@ func (blake3pow *Blake3pow) SetThreads(threads int) {
}
}
}

// APIs implements consensus.Engine, returning the user facing RPC APIs.
func (blake3pow *Blake3pow) APIs(chain consensus.ChainHeaderReader) []rpc.API {
// In order to ensure backward compatibility, we exposes blake3pow RPC APIs
// to both eth and blake3pow namespaces.
return []rpc.API{
{
Namespace: "eth",
Version: "1.0",
Service: &API{blake3pow},
Public: true,
},
{
Namespace: "blake3pow",
Version: "1.0",
Service: &API{blake3pow},
Public: true,
},
}
}
Loading

0 comments on commit 6f2b7f0

Please sign in to comment.