diff --git a/.github/workflows/SetPageFileSize.ps1 b/.github/workflows/SetPageFileSize.ps1 index 8eaf70f9ab..5bfb3a329f 100644 --- a/.github/workflows/SetPageFileSize.ps1 +++ b/.github/workflows/SetPageFileSize.ps1 @@ -11,8 +11,8 @@ #> param( - [System.UInt64] $MinimumSize = 16gb , - [System.UInt64] $MaximumSize = 16gb , + [System.UInt64] $MinimumSize = 32gb , + [System.UInt64] $MaximumSize = 32gb , [System.String] $DiskRoot = "D:" ) @@ -193,4 +193,4 @@ namespace Util Add-Type -TypeDefinition $source # Set SetPageFileSize -[Util.PageFile]::SetPageFileSize($minimumSize, $maximumSize, $diskRoot) \ No newline at end of file +[Util.PageFile]::SetPageFileSize($minimumSize, $maximumSize, $diskRoot) diff --git a/.github/workflows/race.yaml b/.github/workflows/race.yaml deleted file mode 100644 index f07a380109..0000000000 --- a/.github/workflows/race.yaml +++ /dev/null @@ -1,48 +0,0 @@ -name: Race - -on: - schedule: - - cron: "0 0 * * *" - workflow_dispatch: - -jobs: - race_test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - branch: [ stable, latest ] - name: Race detection on ${{ matrix.branch }} - steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: 1.21 - - - name: Set scheduled branch name - shell: bash - if: github.event_name == 'schedule' - run: | - if [ "${{ matrix.branch }}" == "stable" ]; then - echo "run_on=master" >> $GITHUB_ENV - fi - if [ "${{ matrix.branch }}" == "latest" ]; then - echo "run_on=dev" >> $GITHUB_ENV - fi - - - name: Set manual branch name - shell: bash - if: github.event_name == 'workflow_dispatch' - run: echo "run_on=${{ github.ref }}" >> $GITHUB_ENV - - - name: Test with race detector - shell: bash - run: | - git checkout "${{ env.run_on }}" - git status - go test -timeout 20m -race ./... diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 54cd4c7aaa..bc3a63a763 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -28,28 +28,36 @@ jobs: if: runner.os == 'Windows' run: powershell -command .github\workflows\SetPageFileSize.ps1 + # Increase the swap size on Linux to aviod running out of memory + - name: Increase swap size on Linux + if: runner.os == 'Linux' + uses: thejerrybao/setup-swap-space@v1 + with: + swap-size-gb: 12 + - name: Setup Go uses: actions/setup-go@v4 with: go-version: 1.21 - # Source: https://github.com/actions/cache/blob/main/examples.md#go---modules - - name: Go Cache - uses: actions/cache@v4 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - name: Test shell: bash + env: + NO_PARALLEL: 1 run: ./build_and_test.sh stability-test-fast: runs-on: ubuntu-latest name: Fast stability tests steps: + + # Increase the swap size on Linux to aviod running out of memory + - name: Increase swap size on Linux + if: runner.os == 'Linux' + uses: thejerrybao/setup-swap-space@v1 + with: + swap-size-gb: 12 + - name: Setup Go uses: actions/setup-go@v4 with: @@ -71,6 +79,14 @@ jobs: runs-on: ubuntu-latest name: Produce code coverage steps: + + # Increase the swap size on Linux to aviod running out of memory + - name: Increase swap size on Linux + if: runner.os == 'Linux' + uses: thejerrybao/setup-swap-space@v1 + with: + swap-size-gb: 12 + - name: Check out code into the Go module directory uses: actions/checkout@v4 @@ -83,7 +99,7 @@ jobs: run: rm -r stability-tests - name: Create coverage file - run: go test -v -covermode=atomic -coverpkg=./... -coverprofile coverage.txt ./... + run: go test -timeout 120m -parallel=1 -v -covermode=atomic -coverpkg=./... -coverprofile coverage.txt ./... - name: Upload coverage file run: bash <(curl -s https://codecov.io/bash) diff --git a/README.md b/README.md index 3ff13e4416..58bb9a8a9d 100644 --- a/README.md +++ b/README.md @@ -38,18 +38,15 @@ miners. We will ensure long-term GPU-friendly mining. ### Hashing Function We initially started with `kHeavyHash` and `blake3` modifications -on-top. This algorithm is called `KarlsenHashv1`. However `kHeavyHash` -and `blake3` are not future proof in ASIC resistence. Therefore we've -launched already our `testnet-1` with [FishHash](https://github.com/iron-fish/fish-hash/blob/main/FishHash.pdf). -It is the worlds first implementation of FishHash with Golang in a -1bps blockchain. +on-top. This algorithm is called `KarlsenHashv1`. `KarlsenHashv1` is currently used in [mainnet](https://github.com/karlsen-network/karlsend/releases/tag/v1.1.0) and can be mined using the following miners maintained by the Karlsen developers: * Built-in CPU miner from `karlsend` -* Karlsen [GPU miner](https://github.com/karlsen-network/karlsen-miner) as reference implementation of `kHeavyHash` with `blake3`. +* Karlsen [GPU miner](https://github.com/karlsen-network/karlsen-miner) + as reference implementation of `kHeavyHash` with `blake3`. The following third-party miners are available and have added `KarlsenHashv1`: @@ -61,14 +58,42 @@ The following third-party miners are available and have added * [Rigel](https://github.com/rigelminer/rigel) * [GMiner](https://github.com/develsoftware/GMinerRelease) -`KarlsenHashv2` is currently being investigated and tested in [testnet-1](https://github.com/karlsen-network/karlsend/releases/tag/v2.0.0-testnet-1-fishhash) +`KarlsenHashv2` will become active via hardfork at DAA score `26.962.009`. +It is based on [FishHash](https://github.com/iron-fish/fish-hash/blob/main/FishHash.pdf) +written from scratch in our Golang node implementation. It is FPGA/ASIC +resistent. It is the worlds first implementation of FishHash with Golang +in `mainnet` in a 1bps blockchain. + +`KarlsenHashv2` is currently used in [mainnet](https://github.com/karlsen-network/karlsend/releases/tag/v2.1.0) and can be mined using the following miners maintained by the Karlsen developers: * Built-in CPU miner from `karlsend` -* Karlsen [GPU miner](https://github.com/wam-rd/karlsen-miner/releases/tag/v2.0.0-alpha) as bleeding edge and unoptimized reference implementation of FishHash. +* Karlsen [GPU miner](https://github.com/karlsen-network/karlsen-miner/releases/tag/v2.0.0) + as bleeding edge and unoptimized reference implementation of + `KarlsenHashv2`. Please follow the steps in the [README.md](https://github.com/karlsen-network/karlsen-miner/blob/main/README.md) + to generate a DAG file. + +The following third-party miners are available and have added +`KarlsenHashv2`: + +* [SRBMiner](https://github.com/doktor83/SRBMiner-Multi) + +### DAG Generation + +To start mining using the built-in CPU miner it needs a pre-generated +DAG file. `KarlsenHashv2` miner uses a 4GB DAG for efficient mining. +It generates this DAG with 8 CPU threads and saves it as `hashes.dat` +for faster subsequent runs. + +* First Run: Generates a 4GB DAG using 8 CPU threads. This may take + time depending on your computer. Saves the DAG as `hashes.dat` for + future use. +* Next Runs: Loads `hashes.dat` to skip DAG generation, speeding up + startup. -There are no third-party miners available as of now. +If you need to regenerate the DAG, delete `hashes.dat` and run the +`karlsenminer` again. ## Smart Contracts diff --git a/app/app.go b/app/app.go index cc68141389..3f3aaa4281 100644 --- a/app/app.go +++ b/app/app.go @@ -7,6 +7,7 @@ import ( "runtime" "time" + "github.com/karlsen-network/karlsend/domain/consensus/utils/pow" "github.com/karlsen-network/karlsend/infrastructure/config" "github.com/karlsen-network/karlsend/infrastructure/db/database" "github.com/karlsen-network/karlsend/infrastructure/db/database/ldb" @@ -82,6 +83,7 @@ func (app *karlsendApp) main(startedChan chan<- struct{}) error { // Show version at startup. log.Infof("Version %s", version.Version()) + log.Infof("Using KarlsenHashV2 impl: %s", pow.GetHashingAlgoVersion()) // Enable http profiling server if requested. if app.cfg.Profile != "" { diff --git a/app/protocol/manager.go b/app/protocol/manager.go index b63313bf11..895627285b 100644 --- a/app/protocol/manager.go +++ b/app/protocol/manager.go @@ -70,6 +70,9 @@ func (m *Manager) AddTransaction(tx *externalapi.DomainTransaction, allowOrphan // AddBlock adds the given block to the DAG and propagates it. func (m *Manager) AddBlock(block *externalapi.DomainBlock) error { + //TODO switch this to debug level + log.Infof("NEW BLOCK ADDED ***************************************") + log.Infof("BlueWork[%s] BlueScore[%d] DAAScore[%d] Bits[%d] Version[%d]", block.Header.BlueWork(), block.Header.BlueScore(), block.Header.DAAScore(), block.Header.Bits(), block.Header.Version()) return m.context.AddBlock(block) } diff --git a/build_and_test.sh b/build_and_test.sh index 7d59a4c91a..6a3dd6b793 100755 --- a/build_and_test.sh +++ b/build_and_test.sh @@ -24,7 +24,7 @@ go build -v -o karlsend . # check if parallel tests are enabled. [ -n "${NO_PARALLEL}" ] && { - go test -timeout 20m -parallel=1 -v ./... + go test -timeout 30m -parallel=1 -v ./... } || { - go test -timeout 20m -v ./... + go test -timeout 30m -v ./... } diff --git a/cmd/karlsenminer/main.go b/cmd/karlsenminer/main.go index 1399ba7899..00e16b8e45 100644 --- a/cmd/karlsenminer/main.go +++ b/cmd/karlsenminer/main.go @@ -12,6 +12,7 @@ import ( _ "net/http/pprof" + "github.com/karlsen-network/karlsend/domain/consensus/utils/pow" "github.com/karlsen-network/karlsend/infrastructure/os/signal" "github.com/karlsen-network/karlsend/util/panics" "github.com/karlsen-network/karlsend/util/profiling" @@ -29,6 +30,7 @@ func main() { // Show version at startup. log.Infof("Version %s", version.Version()) + log.Infof("Using KarlsenHashV2 impl: %s", pow.GetHashingAlgoVersion()) // Enable http profiling server if requested. if cfg.Profile != "" { diff --git a/cmd/karlsenminer/mineloop.go b/cmd/karlsenminer/mineloop.go index 925646fb9c..1bb7a699c3 100644 --- a/cmd/karlsenminer/mineloop.go +++ b/cmd/karlsenminer/mineloop.go @@ -19,6 +19,7 @@ import ( ) var hashesTried uint64 +var dagReady = false const logHashRateInterval = 10 * time.Second @@ -97,6 +98,12 @@ func logHashRate() { spawn("logHashRate", func() { lastCheck := time.Now() for range time.Tick(logHashRateInterval) { + + if !dagReady { + log.Infof("Generating DAG, please wait ...") + continue + } + currentHashesTried := atomic.LoadUint64(&hashesTried) currentTime := time.Now() kiloHashesTried := float64(currentHashesTried) / 1000.0 @@ -138,7 +145,11 @@ func handleFoundBlock(client *minerClient, block *externalapi.DomainBlock) error func mineNextBlock(mineWhenNotSynced bool) *externalapi.DomainBlock { nonce := rand.Uint64() // Use the global concurrent-safe random source. for { + if !dagReady { + continue + } nonce++ + //fmt.Printf("mineNextBlock -- log1\n") // For each nonce we try to build a block from the most up to date // block template. // In the rare case where the nonce space is exhausted for a specific @@ -165,7 +176,6 @@ func getBlockForMining(mineWhenNotSynced bool) (*externalapi.DomainBlock, *pow.S for { tryCount++ - shouldLog := (tryCount-1)%10 == 0 template, state, isSynced := templatemanager.Get() if template == nil { @@ -207,7 +217,10 @@ func templatesLoop(client *minerClient, miningAddr util.Address, errChan chan er errChan <- errors.Wrapf(err, "Error getting block template from %s", client.Address()) return } - err = templatemanager.Set(template) + err = templatemanager.Set(template, backendLog) + // after first template DAG is supposed to be ready + // TODO: refresh dag status in real time + dagReady = true if err != nil { errChan <- errors.Wrapf(err, "Error setting block template from %s", client.Address()) return diff --git a/cmd/karlsenminer/templatemanager/templatemanager.go b/cmd/karlsenminer/templatemanager/templatemanager.go index 9902272f6e..4b82702cb5 100644 --- a/cmd/karlsenminer/templatemanager/templatemanager.go +++ b/cmd/karlsenminer/templatemanager/templatemanager.go @@ -6,6 +6,7 @@ import ( "github.com/karlsen-network/karlsend/app/appmessage" "github.com/karlsen-network/karlsend/domain/consensus/model/externalapi" "github.com/karlsen-network/karlsend/domain/consensus/utils/pow" + "github.com/karlsen-network/karlsend/infrastructure/logger" ) var currentTemplate *externalapi.DomainBlock @@ -27,7 +28,7 @@ func Get() (*externalapi.DomainBlock, *pow.State, bool) { } // Set sets the current template to work on -func Set(template *appmessage.GetBlockTemplateResponseMessage) error { +func Set(template *appmessage.GetBlockTemplateResponseMessage, backendLog *logger.Backend) error { block, err := appmessage.RPCBlockToDomainBlock(template.Block) if err != nil { return err @@ -35,7 +36,8 @@ func Set(template *appmessage.GetBlockTemplateResponseMessage) error { lock.Lock() defer lock.Unlock() currentTemplate = block - currentState = pow.NewState(block.Header.ToMutable()) + pow.SetLogger(backendLog, logger.LevelTrace) + currentState = pow.NewState(block.Header.ToMutable(), true) isSynced = template.IsSynced return nil } diff --git a/domain/consensus/factory.go b/domain/consensus/factory.go index 25013a1c10..4c70792751 100644 --- a/domain/consensus/factory.go +++ b/domain/consensus/factory.go @@ -349,6 +349,7 @@ func (f *factory) NewConsensus(config *Config, db infrastructuredatabase.Databas config.MaxBlockParents, config.TimestampDeviationTolerance, config.TargetTimePerBlock, + config.HFDAAScore, config.MaxBlockLevel, dbManager, @@ -397,6 +398,7 @@ func (f *factory) NewConsensus(config *Config, db infrastructuredatabase.Databas blockBuilder := blockbuilder.New( dbManager, genesisHash, + config.HFDAAScore, difficultyManager, pastMedianTimeManager, diff --git a/domain/consensus/model/interface_processes_difficultymanager.go b/domain/consensus/model/interface_processes_difficultymanager.go index 0e9296b234..f710c03128 100644 --- a/domain/consensus/model/interface_processes_difficultymanager.go +++ b/domain/consensus/model/interface_processes_difficultymanager.go @@ -10,4 +10,5 @@ type DifficultyManager interface { StageDAADataAndReturnRequiredDifficulty(stagingArea *StagingArea, blockHash *externalapi.DomainHash, isBlockWithTrustedData bool) (uint32, error) RequiredDifficulty(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (uint32, error) EstimateNetworkHashesPerSecond(startHash *externalapi.DomainHash, windowSize int) (uint64, error) + GenesisDifficulty() uint32 } diff --git a/domain/consensus/processes/blockbuilder/block_builder.go b/domain/consensus/processes/blockbuilder/block_builder.go index 14ac3583c2..c3c8da688b 100644 --- a/domain/consensus/processes/blockbuilder/block_builder.go +++ b/domain/consensus/processes/blockbuilder/block_builder.go @@ -20,6 +20,7 @@ import ( type blockBuilder struct { databaseContext model.DBManager genesisHash *externalapi.DomainHash + hfDAAScore uint64 difficultyManager model.DifficultyManager pastMedianTimeManager model.PastMedianTimeManager @@ -42,6 +43,7 @@ type blockBuilder struct { func New( databaseContext model.DBManager, genesisHash *externalapi.DomainHash, + hfDAAScore uint64, difficultyManager model.DifficultyManager, pastMedianTimeManager model.PastMedianTimeManager, @@ -63,6 +65,7 @@ func New( return &blockBuilder{ databaseContext: databaseContext, genesisHash: genesisHash, + hfDAAScore: hfDAAScore, difficultyManager: difficultyManager, pastMedianTimeManager: pastMedianTimeManager, @@ -207,6 +210,12 @@ func (bb *blockBuilder) buildHeader(stagingArea *model.StagingArea, transactions if err != nil { return nil, err } + + // adjust the difficulty + /*if daaScore <= (bb.hfDAAScore+10) && daaScore >= bb.hfDAAScore { + bits = bb.difficultyManager.GenesisDifficulty() + }*/ + hashMerkleRoot := bb.newBlockHashMerkleRoot(transactions) acceptedIDMerkleRoot, err := bb.newBlockAcceptedIDMerkleRoot(stagingArea) if err != nil { @@ -225,8 +234,13 @@ func (bb *blockBuilder) buildHeader(stagingArea *model.StagingArea, transactions return nil, err } + version := constants.BlockVersionKHashV1 + if daaScore >= bb.hfDAAScore { + version = constants.BlockVersionKHashV2 + } + return blockheader.NewImmutableBlockHeader( - constants.BlockVersion, + version, parents, hashMerkleRoot, acceptedIDMerkleRoot, diff --git a/domain/consensus/processes/blockbuilder/test_block_builder.go b/domain/consensus/processes/blockbuilder/test_block_builder.go index 7f30e8327a..51cb5167ad 100644 --- a/domain/consensus/processes/blockbuilder/test_block_builder.go +++ b/domain/consensus/processes/blockbuilder/test_block_builder.go @@ -95,9 +95,14 @@ func (bb *testBlockBuilder) buildUTXOInvalidHeader(stagingArea *model.StagingAre }) } + version := constants.BlockVersionKHashV1 + if daaScore >= bb.hfDAAScore { + version = constants.BlockVersionKHashV2 + } + bb.nonceCounter++ return blockheader.NewImmutableBlockHeader( - constants.BlockVersion, + version, parents, hashMerkleRoot, &externalapi.DomainHash{}, diff --git a/domain/consensus/processes/blockvalidator/block_body_in_isolation_test.go b/domain/consensus/processes/blockvalidator/block_body_in_isolation_test.go index befb46e8f6..040440e800 100644 --- a/domain/consensus/processes/blockvalidator/block_body_in_isolation_test.go +++ b/domain/consensus/processes/blockvalidator/block_body_in_isolation_test.go @@ -1280,7 +1280,7 @@ func initBlockWithFirstTransactionDifferentThanCoinbase(consensusConfig *consens return &externalapi.DomainBlock{ Header: blockheader.NewImmutableBlockHeader( - constants.BlockVersion, + constants.BlockVersionKHashV1, []externalapi.BlockLevelParents{[]*externalapi.DomainHash{consensusConfig.GenesisHash}}, merkle.CalculateHashMerkleRoot([]*externalapi.DomainTransaction{tx}), &externalapi.DomainHash{}, diff --git a/domain/consensus/processes/blockvalidator/block_header_in_context_test.go b/domain/consensus/processes/blockvalidator/block_header_in_context_test.go index ff1b22e361..b55120d6d1 100644 --- a/domain/consensus/processes/blockvalidator/block_header_in_context_test.go +++ b/domain/consensus/processes/blockvalidator/block_header_in_context_test.go @@ -109,7 +109,10 @@ func TestCheckParentsIncest(t *testing.T) { t.Fatalf("AddBlock: %+v", err) } - version := constants.BlockVersion + version := constants.BlockVersionKHashV1 + if consensusConfig.HFDAAScore == 0 { + version = constants.BlockVersionKHashV2 + } directParentsRelationBlock := &externalapi.DomainBlock{ Header: blockheader.NewImmutableBlockHeader( version, diff --git a/domain/consensus/processes/blockvalidator/block_header_in_isolation.go b/domain/consensus/processes/blockvalidator/block_header_in_isolation.go index f155a3ed4f..26e1399f4d 100644 --- a/domain/consensus/processes/blockvalidator/block_header_in_isolation.go +++ b/domain/consensus/processes/blockvalidator/block_header_in_isolation.go @@ -59,9 +59,18 @@ func (v *blockValidator) checkParentsLimit(header externalapi.BlockHeader) error } func (v *blockValidator) checkBlockVersion(header externalapi.BlockHeader) error { - if header.Version() != constants.BlockVersion { - return errors.Wrapf( - ruleerrors.ErrWrongBlockVersion, "The block version should be %d", constants.BlockVersion) + /* + if header.Version() != constants.BlockVersion { + return errors.Wrapf( + ruleerrors.ErrWrongBlockVersion, "The block version should be %d", constants.BlockVersion) + } + */ + if header.DAAScore() >= v.hfDAAScore && header.Version() != constants.BlockVersionKHashV2 { + log.Warnf("After HF1 the block version should be %d - block[%d][v%d]", constants.BlockVersionKHashV2, header.DAAScore(), header.Version()) + return errors.Wrapf(ruleerrors.ErrWrongBlockVersion, "The block version should be %d", constants.BlockVersionKHashV2) + } else if header.DAAScore() < v.hfDAAScore && header.Version() != constants.BlockVersionKHashV1 { + log.Warnf("Before HF1 the block version should be %d - block[%d][v%d]", constants.BlockVersionKHashV1, header.DAAScore(), header.Version()) + return errors.Wrapf(ruleerrors.ErrWrongBlockVersion, "The block version should be %d", constants.BlockVersionKHashV1) } return nil } diff --git a/domain/consensus/processes/blockvalidator/block_header_in_isolation_test.go b/domain/consensus/processes/blockvalidator/block_header_in_isolation_test.go index e85b921a6a..1a4fa81fba 100644 --- a/domain/consensus/processes/blockvalidator/block_header_in_isolation_test.go +++ b/domain/consensus/processes/blockvalidator/block_header_in_isolation_test.go @@ -63,7 +63,11 @@ func CheckBlockVersion(t *testing.T, tc testapi.TestConsensus, consensusConfig * t.Fatalf("BuildBlockWithParents: %+v", err) } - expectedVersion := constants.BlockVersion + expectedVersion := constants.BlockVersionKHashV1 + if consensusConfig.HFDAAScore == 0 { + expectedVersion = constants.BlockVersionKHashV2 + } + block.Header = blockheader.NewImmutableBlockHeader( expectedVersion+1, block.Header.Parents(), diff --git a/domain/consensus/processes/blockvalidator/blockvalidator.go b/domain/consensus/processes/blockvalidator/blockvalidator.go index 53411a1c44..1ca4568810 100644 --- a/domain/consensus/processes/blockvalidator/blockvalidator.go +++ b/domain/consensus/processes/blockvalidator/blockvalidator.go @@ -24,6 +24,7 @@ type blockValidator struct { maxBlockParents externalapi.KType timestampDeviationTolerance int targetTimePerBlock time.Duration + hfDAAScore uint64 maxBlockLevel int databaseContext model.DBReader @@ -63,6 +64,7 @@ func New(powMax *big.Int, maxBlockParents externalapi.KType, timestampDeviationTolerance int, targetTimePerBlock time.Duration, + hfDAAScore uint64, maxBlockLevel int, databaseContext model.DBReader, @@ -102,6 +104,7 @@ func New(powMax *big.Int, maxBlockMass: maxBlockMass, mergeSetSizeLimit: mergeSetSizeLimit, maxBlockParents: maxBlockParents, + hfDAAScore: hfDAAScore, maxBlockLevel: maxBlockLevel, timestampDeviationTolerance: timestampDeviationTolerance, diff --git a/domain/consensus/processes/blockvalidator/pruning_violation_proof_of_work_and_difficulty.go b/domain/consensus/processes/blockvalidator/pruning_violation_proof_of_work_and_difficulty.go index a15f67ff09..f7f591fba9 100644 --- a/domain/consensus/processes/blockvalidator/pruning_violation_proof_of_work_and_difficulty.go +++ b/domain/consensus/processes/blockvalidator/pruning_violation_proof_of_work_and_difficulty.go @@ -134,6 +134,11 @@ func (v *blockValidator) validateDifficulty(stagingArea *model.StagingArea, return err } + // bypass the difficulty check during HF + if header.DAAScore() <= (v.hfDAAScore+10) && header.DAAScore() >= v.hfDAAScore { + expectedBits = v.difficultyManager.GenesisDifficulty() + } + if header.Bits() != expectedBits { return errors.Wrapf(ruleerrors.ErrUnexpectedDifficulty, "block difficulty of %d is not the expected value of %d", header.Bits(), expectedBits) } @@ -150,7 +155,7 @@ func (v *blockValidator) validateDifficulty(stagingArea *model.StagingArea, // difficulty is not performed. func (v *blockValidator) checkProofOfWork(header externalapi.BlockHeader) error { // The target difficulty must be larger than zero. - state := pow.NewState(header.ToMutable()) + state := pow.NewState(header.ToMutable(), false) target := &state.Target if target.Sign() <= 0 { return errors.Wrapf(ruleerrors.ErrNegativeTarget, "block target difficulty of %064x is too low", diff --git a/domain/consensus/processes/blockvalidator/pruning_violation_proof_of_work_and_difficulty_test.go b/domain/consensus/processes/blockvalidator/pruning_violation_proof_of_work_and_difficulty_test.go index 71e214718b..4bd7593dee 100644 --- a/domain/consensus/processes/blockvalidator/pruning_violation_proof_of_work_and_difficulty_test.go +++ b/domain/consensus/processes/blockvalidator/pruning_violation_proof_of_work_and_difficulty_test.go @@ -115,7 +115,7 @@ func TestPOW(t *testing.T) { // solveBlockWithWrongPOW increments the given block's nonce until it gets wrong POW (for test!). func solveBlockWithWrongPOW(block *externalapi.DomainBlock) *externalapi.DomainBlock { header := block.Header.ToMutable() - state := pow.NewState(header) + state := pow.NewState(header, false) for i := uint64(0); i < math.MaxUint64; i++ { state.Nonce = i if !state.CheckProofOfWork() { @@ -299,7 +299,9 @@ func TestCheckPruningPointViolation(t *testing.T) { func TestValidateDifficulty(t *testing.T) { testutils.ForAllNets(t, true, func(t *testing.T, consensusConfig *consensus.Config) { factory := consensus.NewFactory() - mocDifficulty := &mocDifficultyManager{genesisDaaScore: consensusConfig.GenesisBlock.Header.DAAScore()} + mocDifficulty := &mocDifficultyManager{ + genesisDaaScore: consensusConfig.GenesisBlock.Header.DAAScore(), + genesisBits: consensusConfig.GenesisBlock.Header.Bits()} factory.SetTestDifficultyManager(func(_ model.DBReader, _ model.GHOSTDAGManager, _ model.GHOSTDAGDataStore, _ model.BlockHeaderStore, daaBlocksStore model.DAABlocksStore, _ model.DAGTopologyManager, _ model.DAGTraversalManager, _ *big.Int, _ int, _ bool, _ time.Duration, @@ -346,6 +348,12 @@ type mocDifficultyManager struct { testGenesisBits uint32 daaBlocksStore model.DAABlocksStore genesisDaaScore uint64 + genesisBits uint32 +} + +// GenesisDifficulty implements model.DifficultyManager. +func (dm *mocDifficultyManager) GenesisDifficulty() uint32 { + return dm.genesisBits } // RequiredDifficulty returns the difficulty required for the test diff --git a/domain/consensus/processes/difficultymanager/difficultymanager.go b/domain/consensus/processes/difficultymanager/difficultymanager.go index d541f1a793..2f73bd1098 100644 --- a/domain/consensus/processes/difficultymanager/difficultymanager.go +++ b/domain/consensus/processes/difficultymanager/difficultymanager.go @@ -100,6 +100,11 @@ func (dm *difficultyManager) RequiredDifficulty(stagingArea *model.StagingArea, return dm.requiredDifficultyFromTargetsWindow(targetsWindow) } +// GenesisDifficulty returns the difficulty current network genesis block +func (dm *difficultyManager) GenesisDifficulty() uint32 { + return dm.genesisBits +} + func (dm *difficultyManager) requiredDifficultyFromTargetsWindow(targetsWindow blockWindow) (uint32, error) { if dm.disableDifficultyAdjustment { return dm.genesisBits, nil diff --git a/domain/consensus/processes/ghostdagmanager/ghostdag_test.go b/domain/consensus/processes/ghostdagmanager/ghostdag_test.go index b78a622c10..b78a825381 100644 --- a/domain/consensus/processes/ghostdagmanager/ghostdag_test.go +++ b/domain/consensus/processes/ghostdagmanager/ghostdag_test.go @@ -111,7 +111,7 @@ func TestGHOSTDAG(t *testing.T) { blockID := StringToDomainHash(testBlockData.ID) dagTopology.parentsMap[*blockID] = StringToDomainHashSlice(testBlockData.Parents) blockHeadersStore.dagMap[*blockID] = blockheader.NewImmutableBlockHeader( - constants.BlockVersion, + constants.BlockVersionKHashV1, []externalapi.BlockLevelParents{StringToDomainHashSlice(testBlockData.Parents)}, nil, nil, diff --git a/domain/consensus/processes/pruningmanager/pruning_test.go b/domain/consensus/processes/pruningmanager/pruning_test.go index b89b336500..6e5e77e798 100644 --- a/domain/consensus/processes/pruningmanager/pruning_test.go +++ b/domain/consensus/processes/pruningmanager/pruning_test.go @@ -40,7 +40,7 @@ func TestPruning(t *testing.T) { dagconfig.MainnetParams.Name: "503", dagconfig.TestnetParams.Name: "502", dagconfig.DevnetParams.Name: "503", - dagconfig.SimnetParams.Name: "502", + dagconfig.SimnetParams.Name: "503", }, } diff --git a/domain/consensus/utils/constants/constants.go b/domain/consensus/utils/constants/constants.go index 351f4cfc0f..60ea5c6e6e 100644 --- a/domain/consensus/utils/constants/constants.go +++ b/domain/consensus/utils/constants/constants.go @@ -3,8 +3,11 @@ package constants import "math" const ( - // BlockVersion represents the current block version - BlockVersion uint16 = 1 + // BlockVersionKHashV1 represents the block version before the HF + BlockVersionKHashV1 uint16 = 1 + + // BlockVersionKHashV2 represents the block version after the HF + BlockVersionKHashV2 uint16 = 2 // MaxTransactionVersion is the current latest supported transaction version. MaxTransactionVersion uint16 = 0 diff --git a/domain/consensus/utils/mining/solve.go b/domain/consensus/utils/mining/solve.go index b93e68fd9e..1ae47bae97 100644 --- a/domain/consensus/utils/mining/solve.go +++ b/domain/consensus/utils/mining/solve.go @@ -12,7 +12,7 @@ import ( // SolveBlock increments the given block's nonce until it matches the difficulty requirements in its bits field func SolveBlock(block *externalapi.DomainBlock, rd *rand.Rand) { header := block.Header.ToMutable() - state := pow.NewState(header) + state := pow.NewState(header, false) for state.Nonce = rd.Uint64(); state.Nonce < math.MaxUint64; state.Nonce++ { if state.CheckProofOfWork() { header.SetNonce(state.Nonce) diff --git a/domain/consensus/utils/pow/fishhash.go b/domain/consensus/utils/pow/fishhash.go new file mode 100644 index 0000000000..2fdb72a23c --- /dev/null +++ b/domain/consensus/utils/pow/fishhash.go @@ -0,0 +1,258 @@ +package pow + +import ( + "github.com/edsrzf/mmap-go" + "golang.org/x/crypto/sha3" + + //"crypto/sha3" + "encoding/binary" + "os" + "sync" +) + +// ============================================================================ + +const ( + fnvPrime = 0x01000193 + fullDatasetItemParents = 512 + numDatasetAccesses = 32 + lightCacheRounds = 3 + lightCacheNumItems = 1179641 + fullDatasetNumItems = 37748717 +) + +var ( + // we use the same seed as fish hash whitepaper for testnet debug reasons + seed = [32]byte{ + 0xeb, 0x01, 0x63, 0xae, 0xf2, 0xab, 0x1c, 0x5a, + 0x66, 0x31, 0x0c, 0x1c, 0x14, 0xd6, 0x0f, 0x42, + 0x55, 0xa9, 0xb3, 0x9b, 0x0e, 0xdf, 0x26, 0x53, + 0x98, 0x44, 0xf1, 0x17, 0xad, 0x67, 0x21, 0x19, + } + + //sharedContext *fishhashContext + sharedContextLock sync.Mutex +) + +type hash256 [32]byte +type hash512 [64]byte +type hash1024 [128]byte + +type fishhashContext struct { + ready bool + LightCacheNumItems int + LightCache []*hash512 + FullDatasetNumItems uint32 + FullDataset []hash1024 +} + +type itemState struct { + cache []*hash512 + numCacheItems int64 + seed uint32 + mix hash512 +} + +func (state *itemState) update(round uint32) { + numWords := len(state.mix) / 4 + t := fnv1(state.seed^round, binary.LittleEndian.Uint32(state.mix[4*(round%uint32(numWords)):])) + parentIndex := t % uint32(state.numCacheItems) + state.mix = fnv1Hash512(state.mix, *state.cache[parentIndex]) +} + +func (state *itemState) final() hash512 { + hash := sha3.NewLegacyKeccak512() + hash.Write(state.mix[:]) + copy(state.mix[:], hash.Sum(nil)) + return state.mix +} + +func bitwiseXOR(x, y hash512) hash512 { + + var result hash512 + for i := 0; i < 8; i++ { + binary.LittleEndian.PutUint64(result[8*i:], binary.LittleEndian.Uint64(x[8*i:])^binary.LittleEndian.Uint64(y[8*i:])) + } + return result +} + +func buildLightCache(cache []*hash512, numItems int, seed hash256) { + + item := hash512{} + hash := sha3.NewLegacyKeccak512() + hash.Write(seed[:]) + copy(item[:], hash.Sum(nil)) + cache[0] = &item + + for i := 1; i < numItems; i++ { + hash.Reset() + hash.Write(cache[i-1][:]) + newitem := hash512{} + copy(newitem[:], hash.Sum(nil)) + cache[i] = &newitem + } + + for q := 0; q < lightCacheRounds; q++ { + for i := 0; i < numItems; i++ { + indexLimit := uint32(numItems) + t := binary.LittleEndian.Uint32(cache[i][0:]) + v := t % indexLimit + w := uint32(numItems+(i-1)) % indexLimit + x := bitwiseXOR(*cache[v], *cache[w]) + + if i == 0 && q == 0 { + var result hash512 + for k := 0; k < 8; k++ { + binary.LittleEndian.PutUint64(result[8*k:], binary.LittleEndian.Uint64(cache[v][8*k:])^binary.LittleEndian.Uint64(cache[w][8*k:])) + } + + } + + hash.Reset() + hash.Write(x[:]) + copy(cache[i][:], hash.Sum(nil)) + } + } +} + +func buildDatasetSegment(ctx *fishhashContext, start, end uint32) { + for i := start; i < end; i++ { + ctx.FullDataset[i] = calculateDatasetItem1024(ctx, i) + } +} + +func prebuildDataset(ctx *fishhashContext, numThreads uint32) { + log.Infof("Building prebuilt Dataset - we must be on miner") + + if ctx.FullDataset == nil { + return + } + + if ctx.ready { + log.Infof("Dataset already generated") + return + } + + // TODO: dag file name (hardcoded for debug) + // must parameterized this + filename := "hashes.dat" + + log.Infof("Verifying if DAG local storage file already exists ...") + hashes, err := loadmappedHashesFromFile(filename) + if err == nil { + log.Infof("DAG loaded succesfully from local storage ") + ctx.FullDataset = hashes + + log.Debugf("debug DAG hash[10] : %x", ctx.FullDataset[10]) + log.Debugf("debug DAG hash[42] : %x", ctx.FullDataset[42]) + log.Debugf("debug DAG hash[12345] : %x", ctx.FullDataset[12345]) + ctx.ready = true + return + } + + log.Infof("DAG local storage file not found") + log.Infof("GENERATING DATASET, This operation may take a while, please wait ...") + + if numThreads > 1 { + log.Infof("Using multithread generation nb threads : %d", numThreads) + batchSize := ctx.FullDatasetNumItems / numThreads + var wg sync.WaitGroup + + for i := uint32(0); i < numThreads; i++ { + start := i * batchSize + end := start + batchSize + if i == numThreads-1 { + end = ctx.FullDatasetNumItems + } + + wg.Add(1) + go func(ctx *fishhashContext, start, end uint32) { + defer wg.Done() + buildDatasetSegment(ctx, start, end) + }(ctx, start, end) + } + + wg.Wait() + } else { + buildDatasetSegment(ctx, 0, ctx.FullDatasetNumItems) + } + + log.Debugf("debug DAG hash[10] : %x", ctx.FullDataset[10]) + log.Debugf("debug DAG hash[42] : %x", ctx.FullDataset[42]) + log.Debugf("debug DAG hash[12345] : %x", ctx.FullDataset[12345]) + + log.Infof("Saving DAG to local storage file ...") + err = mapHashesToFile(ctx.FullDataset, filename) + + if err != nil { + panic(err) + } + + log.Infof("DATASET geneated succesfully") + ctx.ready = true +} + +func mapHashesToFile(hashes []hash1024, filename string) error { + // Create or open fila + file, err := os.Create(filename) + if err != nil { + return err + } + defer file.Close() + + // hash1024 table size (128 per object) + size := len(hashes) * 128 + + // file size setup + err = file.Truncate(int64(size)) + if err != nil { + return err + } + + // Mapping the file in memory + mmap, err := mmap.Map(file, mmap.RDWR, 0) + if err != nil { + return err + } + defer mmap.Unmap() + + // Copy data from memory to file + for i, hash := range hashes { + copy(mmap[i*128:(i+1)*128], hash[:]) + } + + // Sync data + err = mmap.Flush() + if err != nil { + return err + } + + return nil +} + +func loadmappedHashesFromFile(filename string) ([]hash1024, error) { + // Open the file + file, err := os.Open(filename) + if err != nil { + return nil, err + } + defer file.Close() + + // Mapping file in memory + mmap, err := mmap.Map(file, mmap.RDONLY, 0) + if err != nil { + return nil, err + } + defer mmap.Unmap() + + // Get the nb of hash1028 (128bytes) + numHashes := len(mmap) / 128 + hashes := make([]hash1024, numHashes) + + // Read data and convert in hash1024 + for i := 0; i < numHashes; i++ { + copy(hashes[i][:], mmap[i*128:(i+1)*128]) + } + + return hashes, nil +} diff --git a/domain/consensus/utils/pow/fishhash_kernel.go b/domain/consensus/utils/pow/fishhash_kernel.go new file mode 100644 index 0000000000..602ef29279 --- /dev/null +++ b/domain/consensus/utils/pow/fishhash_kernel.go @@ -0,0 +1,129 @@ +package pow + +import ( + "golang.org/x/crypto/sha3" + + //"crypto/sha3" + "encoding/binary" +) + +func mergeHashes(hash1, hash2 hash512) (result hash1024) { + copy(result[:len(hash1)], hash1[:]) + copy(result[len(hash1):], hash2[:]) + return +} + +func fnv1(u, v uint32) uint32 { + return (u * fnvPrime) ^ v +} + +func fnv1Hash512(u, v hash512) hash512 { + var result hash512 + for j := 0; j < 16; j++ { + binary.LittleEndian.PutUint32(result[4*j:], fnv1(binary.LittleEndian.Uint32(u[4*j:]), binary.LittleEndian.Uint32(v[4*j:]))) + } + return result +} + +func newItemState(ctx *fishhashContext, index int64) *itemState { + state := &itemState{ + cache: ctx.LightCache, + numCacheItems: int64(ctx.LightCacheNumItems), + seed: uint32(index), + } + + state.mix = *state.cache[index%state.numCacheItems] + binary.LittleEndian.PutUint32(state.mix[0:], binary.LittleEndian.Uint32(state.mix[0:])^state.seed) + + hash := sha3.NewLegacyKeccak512() + hash.Write(state.mix[:]) + copy(state.mix[:], hash.Sum(nil)) + + return state +} + +func calculateDatasetItem1024(ctx *fishhashContext, index uint32) hash1024 { + item0 := newItemState(ctx, int64(index)*2) + item1 := newItemState(ctx, int64(index)*2+1) + + for j := uint32(0); j < fullDatasetItemParents; j++ { + item0.update(j) + item1.update(j) + } + + it0 := item0.final() + it1 := item1.final() + + return mergeHashes(it0, it1) +} + +func lookup(ctx *fishhashContext, index uint32) hash1024 { + if ctx.FullDataset != nil { + item := &ctx.FullDataset[index] + if item[0] == 0 { + *item = calculateDatasetItem1024(ctx, index) + } + return *item + } + return calculateDatasetItem1024(ctx, index) +} + +/* +func fishhashKernel(ctx *fishhashContext, seed hash512) hash256 { + indexLimit := uint32(ctx.FullDatasetNumItems) + mix := mergeHashes(seed, seed) + + //log.Debugf("lookup matrix : ") + for i := uint32(0); i < numDatasetAccesses; i++ { + + p0 := binary.LittleEndian.Uint32(mix[0:]) % indexLimit + p1 := binary.LittleEndian.Uint32(mix[4*4:]) % indexLimit + p2 := binary.LittleEndian.Uint32(mix[8*4:]) % indexLimit + + fetch0 := lookup(ctx, p0) + fetch1 := lookup(ctx, p1) + fetch2 := lookup(ctx, p2) + + for j := 0; j < 32; j++ { + binary.LittleEndian.PutUint32( + fetch1[4*j:], + fnv1(binary.LittleEndian.Uint32(mix[4*j:4*j+4]), binary.LittleEndian.Uint32(fetch1[4*j:4*j+4]))) + binary.LittleEndian.PutUint32( + fetch2[4*j:], + binary.LittleEndian.Uint32(mix[4*j:4*j+4])^binary.LittleEndian.Uint32(fetch2[4*j:4*j+4])) + } + + //fmt.Printf("The NEW fetch1 is : %x \n", fetch1) + //fmt.Printf("The NEW fetch2 is : %x \n", fetch2) + + for j := 0; j < 16; j++ { + binary.LittleEndian.PutUint64( + mix[8*j:], + binary.LittleEndian.Uint64(fetch0[8*j:8*j+8])*binary.LittleEndian.Uint64(fetch1[8*j:8*j+8])+binary.LittleEndian.Uint64(fetch2[8*j:8*j+8])) + } + //log.Debugf("\n") + } + + mixHash := hash256{} + for i := 0; i < (len(mix) / 4); i += 4 { + j := 4 * i + h1 := fnv1(binary.LittleEndian.Uint32(mix[j:]), binary.LittleEndian.Uint32(mix[j+4:])) + h2 := fnv1(h1, binary.LittleEndian.Uint32(mix[j+8:])) + h3 := fnv1(h2, binary.LittleEndian.Uint32(mix[j+12:])) + binary.LittleEndian.PutUint32(mixHash[i:], h3) + } + + return mixHash +} + +func fishHash(ctx *fishhashContext, hashin *externalapi.DomainHash) *externalapi.DomainHash { + + seed := hash512{} + copy(seed[:], hashin.ByteSlice()) + + output := fishhashKernel(ctx, seed) + outputArray := [32]byte{} + copy(outputArray[:], output[:]) + return externalapi.NewDomainHashFromByteArray(&outputArray) +} +*/ diff --git a/domain/consensus/utils/pow/fishhashplus_kernel.go b/domain/consensus/utils/pow/fishhashplus_kernel.go new file mode 100644 index 0000000000..e26311929d --- /dev/null +++ b/domain/consensus/utils/pow/fishhashplus_kernel.go @@ -0,0 +1,71 @@ +package pow + +import ( + "github.com/karlsen-network/karlsend/domain/consensus/model/externalapi" + + //"crypto/sha3" + "encoding/binary" +) + +func fishhashPlusKernel(ctx *fishhashContext, seed hash512) hash256 { + indexLimit := uint32(ctx.FullDatasetNumItems) + mix := mergeHashes(seed, seed) + + //log.Debugf("lookup matrix : ") + for i := uint32(0); i < numDatasetAccesses; i++ { + + mixGroup := [8]uint32{} + for c := uint32(0); c < 8; c++ { + mixGroup[c] = binary.LittleEndian.Uint32(mix[(4*4*c+0):]) ^ binary.LittleEndian.Uint32(mix[(4*4*c+4):]) ^ binary.LittleEndian.Uint32(mix[(4*4*c+8):]) ^ binary.LittleEndian.Uint32(mix[(4*4*c+12):]) + } + + p0 := (mixGroup[0] ^ mixGroup[3] ^ mixGroup[6]) % indexLimit + p1 := (mixGroup[1] ^ mixGroup[4] ^ mixGroup[7]) % indexLimit + p2 := (mixGroup[2] ^ mixGroup[5] ^ i) % indexLimit + + fetch0 := lookup(ctx, p0) + fetch1 := lookup(ctx, p1) + fetch2 := lookup(ctx, p2) + + for j := 0; j < 32; j++ { + binary.LittleEndian.PutUint32( + fetch1[4*j:], + fnv1(binary.LittleEndian.Uint32(mix[4*j:4*j+4]), binary.LittleEndian.Uint32(fetch1[4*j:4*j+4]))) + binary.LittleEndian.PutUint32( + fetch2[4*j:], + binary.LittleEndian.Uint32(mix[4*j:4*j+4])^binary.LittleEndian.Uint32(fetch2[4*j:4*j+4])) + } + + //fmt.Printf("The NEW fetch1 is : %x \n", fetch1) + //fmt.Printf("The NEW fetch2 is : %x \n", fetch2) + + for j := 0; j < 16; j++ { + binary.LittleEndian.PutUint64( + mix[8*j:], + binary.LittleEndian.Uint64(fetch0[8*j:8*j+8])*binary.LittleEndian.Uint64(fetch1[8*j:8*j+8])+binary.LittleEndian.Uint64(fetch2[8*j:8*j+8])) + } + //log.Debugf("\n") + } + + mixHash := hash256{} + for i := 0; i < (len(mix) / 4); i += 4 { + j := 4 * i + h1 := fnv1(binary.LittleEndian.Uint32(mix[j:]), binary.LittleEndian.Uint32(mix[j+4:])) + h2 := fnv1(h1, binary.LittleEndian.Uint32(mix[j+8:])) + h3 := fnv1(h2, binary.LittleEndian.Uint32(mix[j+12:])) + binary.LittleEndian.PutUint32(mixHash[i:], h3) + } + + return mixHash +} + +func fishHashPlus(ctx *fishhashContext, hashin *externalapi.DomainHash) *externalapi.DomainHash { + + seed := hash512{} + copy(seed[:], hashin.ByteSlice()) + + output := fishhashPlusKernel(ctx, seed) + outputArray := [32]byte{} + copy(outputArray[:], output[:]) + return externalapi.NewDomainHashFromByteArray(&outputArray) +} diff --git a/domain/consensus/utils/pow/heavyhash.go b/domain/consensus/utils/pow/heavyhash.go index fb74f18ea8..bd673826d4 100644 --- a/domain/consensus/utils/pow/heavyhash.go +++ b/domain/consensus/utils/pow/heavyhash.go @@ -89,4 +89,5 @@ func (mat *matrix) HeavyHash(hash *externalapi.DomainHash) *externalapi.DomainHa writer := hashes.NewHeavyHashWriter() writer.InfallibleWrite(res[:]) return writer.Finalize() + //return externalapi.NewDomainHashFromByteArray(&res) } diff --git a/domain/consensus/utils/pow/heavyhash_test.go b/domain/consensus/utils/pow/heavyhash_test.go index 69a7dcf655..f256fa9e0c 100644 --- a/domain/consensus/utils/pow/heavyhash_test.go +++ b/domain/consensus/utils/pow/heavyhash_test.go @@ -151,7 +151,11 @@ func TestGenerateMatrix(t *testing.T) { } func TestMatrix_HeavyHash(t *testing.T) { + //original expect + //expected, err := hex.DecodeString("87689f379943eaf9b7475ca95325687772bfcc68fc7899caeb4409ec4590c325") + //karlsenhashv1 expect expected, err := hex.DecodeString("f32d27ec12b058b602252dc79dbd5c32958ef5c153731dfc8220d25b58ffa691") + if err != nil { t.Fatal(err) } diff --git a/domain/consensus/utils/pow/log.go b/domain/consensus/utils/pow/log.go new file mode 100644 index 0000000000..ba17b89d01 --- /dev/null +++ b/domain/consensus/utils/pow/log.go @@ -0,0 +1,9 @@ +package pow + +import ( + "github.com/karlsen-network/karlsend/infrastructure/logger" + "github.com/karlsen-network/karlsend/util/panics" +) + +var log = logger.RegisterSubSystem("POWK") +var spawn = panics.GoroutineWrapperFunc(log) diff --git a/domain/consensus/utils/pow/pow.go b/domain/consensus/utils/pow/pow.go index 1e8e039f2d..ce0ff272c4 100644 --- a/domain/consensus/utils/pow/pow.go +++ b/domain/consensus/utils/pow/pow.go @@ -3,15 +3,19 @@ package pow import ( "github.com/karlsen-network/karlsend/domain/consensus/model/externalapi" "github.com/karlsen-network/karlsend/domain/consensus/utils/consensushashing" + "github.com/karlsen-network/karlsend/domain/consensus/utils/constants" "github.com/karlsen-network/karlsend/domain/consensus/utils/hashes" "github.com/karlsen-network/karlsend/domain/consensus/utils/serialization" + "github.com/karlsen-network/karlsend/infrastructure/logger" "github.com/karlsen-network/karlsend/util/difficulty" + "github.com/karlsen-network/karlsend/util/panics" + "github.com/pkg/errors" "math/big" - - "github.com/pkg/errors" ) +const hashingAlgoVersion = "fishhash-kls-0.0.2" + // State is an intermediate data structure with pre-computed values to speed up mining. type State struct { mat matrix @@ -19,11 +23,67 @@ type State struct { Nonce uint64 Target big.Int prePowHash externalapi.DomainHash + //cache cache + context fishhashContext + blockVersion uint16 +} + +// var context *fishhashContext +var sharedContext *fishhashContext + +func getContext(full bool, log *logger.Logger) *fishhashContext { + sharedContextLock.Lock() + defer sharedContextLock.Unlock() + + if sharedContext != nil { + if !full || sharedContext.FullDataset != nil { + log.Debugf("log0 getContext ====") + return sharedContext + } + log.Debugf("log1 getContext ==== going to build dataset") + } + + // DISABLE LIGHT CACHE FOR THE MOMENT + + lightCache := make([]*hash512, lightCacheNumItems) + log.Infof("Building light cache") + buildLightCache(lightCache, lightCacheNumItems, seed) + + log.Debugf("getContext object 0 : %x", lightCache[0]) + log.Debugf("getContext object 42 : %x", lightCache[42]) + log.Debugf("getContext object 100 : %x", lightCache[100]) + + fullDataset := make([]hash1024, fullDatasetNumItems) + + sharedContext = &fishhashContext{ + ready: false, + LightCacheNumItems: lightCacheNumItems, + LightCache: lightCache, + FullDatasetNumItems: fullDatasetNumItems, + FullDataset: fullDataset, + } + + if full { + //TODO : we forced the threads to 8 - must be calculated and parameterized + prebuildDataset(sharedContext, 8) + } else { + log.Infof("Dataset building SKIPPED - we must be on node") + } + + return sharedContext +} + +// SetLogger uses a specified Logger to output package logging info +func SetLogger(backend *logger.Backend, level logger.Level) { + const logSubsystem = "POWK" + log = backend.Logger(logSubsystem) + log.SetLevel(level) + spawn = panics.GoroutineWrapperFunc(log) } // NewState creates a new state with pre-computed values to speed up mining // It takes the target from the Bits field -func NewState(header externalapi.MutableBlockHeader) *State { +func NewState(header externalapi.MutableBlockHeader, generatedag bool) *State { target := difficulty.CompactToBig(header.Bits()) // Zero out the time and nonce. timestamp, nonce := header.TimeInMilliseconds(), header.Nonce() @@ -33,13 +93,31 @@ func NewState(header externalapi.MutableBlockHeader) *State { header.SetTimeInMilliseconds(timestamp) header.SetNonce(nonce) + log.Debugf("BlueWork[%s] BlueScore[%d] DAAScore[%d] Version[%d]", header.BlueWork(), header.BlueScore(), header.DAAScore(), header.Version()) + return &State{ Target: *target, prePowHash: *prePowHash, - mat: *generateMatrix(prePowHash), - Timestamp: timestamp, - Nonce: nonce, + //will remove matrix opow + mat: *generateMatrix(prePowHash), + Timestamp: timestamp, + Nonce: nonce, + context: *getContext(generatedag, log), + blockVersion: header.Version(), + } +} + +// GetHashingAlgoVersion return the hashing algo version +func GetHashingAlgoVersion() string { + return hashingAlgoVersion +} + +// IsContextReady checks the readiness of the context +func (state *State) IsContextReady() bool { + if state != nil { + return state.context.ready } + return false } // CalculateProofOfWorkValue hashes the internal header and returns its big.Int value @@ -51,15 +129,36 @@ func (state *State) CalculateProofOfWorkValue() *big.Int { if err != nil { panic(errors.Wrap(err, "this should never happen. Hash digest should never return an error")) } + zeroes := [32]byte{} writer.InfallibleWrite(zeroes[:]) err = serialization.WriteElement(writer, state.Nonce) if err != nil { panic(errors.Wrap(err, "this should never happen. Hash digest should never return an error")) } + //log.Debugf("Hash prePowHash %x\n", state.prePowHash.ByteSlice()) + //fmt.Printf("Hash prePowHash %x\n", state.prePowHash.ByteSlice()) + powHash := writer.Finalize() - heavyHash := state.mat.HeavyHash(powHash) - return toBig(heavyHash) + + //middleHash := state.mat.HeavyHash(powHash) + //log.Infof("Hash b3-1: %x", powHash.ByteSlice()) + finalHash := powHash + if state.blockVersion == constants.BlockVersionKHashV1 { + log.Debugf("Using khashv1 %d %d", state.blockVersion, constants.BlockVersionKHashV1) + finalHash = state.mat.HeavyHash(powHash) + } else { + log.Debugf("Using khashv2 %d %d", state.blockVersion, constants.BlockVersionKHashV2) + middleHash := fishHashPlus(&state.context, powHash) + writer2 := hashes.NewPoWHashWriter() + writer2.InfallibleWrite(middleHash.ByteSlice()) + finalHash = writer2.Finalize() + } + + //log.Infof("Hash fish: %x", middleHash.ByteSlice()) + //log.Infof("Hash b3-2: %x", finalHash.ByteSlice()) + + return toBig(finalHash) } // IncrementNonce the nonce in State by 1 @@ -80,7 +179,7 @@ func (state *State) CheckProofOfWork() bool { // CheckProofOfWorkByBits check's if the block has a valid PoW according to its Bits field // it does not check if the difficulty itself is valid or less than the maximum for the appropriate network func CheckProofOfWorkByBits(header externalapi.MutableBlockHeader) bool { - return NewState(header).CheckProofOfWork() + return NewState(header, false).CheckProofOfWork() } // ToBig converts a externalapi.DomainHash into a big.Int treated as a little endian string. @@ -103,7 +202,7 @@ func BlockLevel(header externalapi.BlockHeader, maxBlockLevel int) int { return maxBlockLevel } - proofOfWorkValue := NewState(header.ToMutable()).CalculateProofOfWorkValue() + proofOfWorkValue := NewState(header.ToMutable(), false).CalculateProofOfWorkValue() level := maxBlockLevel - proofOfWorkValue.BitLen() // If the block has a level lower than genesis make it zero. if level < 0 { diff --git a/domain/dagconfig/genesis.go b/domain/dagconfig/genesis.go index 1ef1c34f75..5308898d26 100644 --- a/domain/dagconfig/genesis.go +++ b/domain/dagconfig/genesis.go @@ -121,7 +121,7 @@ var devnetGenesisBlock = externalapi.DomainBlock{ &externalapi.DomainHash{}, externalapi.NewDomainHashFromByteArray(muhash.EmptyMuHashHash.AsArray()), 0x11e9db49828, - 525264379, + 0x1f4ee5fb, 0x48e5e, 0, 0, diff --git a/domain/dagconfig/params.go b/domain/dagconfig/params.go index 6cae3fec98..41c58ac64b 100644 --- a/domain/dagconfig/params.go +++ b/domain/dagconfig/params.go @@ -188,6 +188,7 @@ type Params struct { MaxBlockLevel int MergeDepth uint64 + HFDAAScore uint64 } // NormalizeRPCServerAddress returns addr with the current network default @@ -277,6 +278,7 @@ var MainnetParams = Params{ // This means that any block that has a level lower or equal to genesis will be level 0. MaxBlockLevel: 225, MergeDepth: defaultMergeDepth, + HFDAAScore: 26962009, // HF DAAscore to switch to khashv2 (Fri Sep 13 01:37:00 PM UTC 2024) } // TestnetParams defines the network parameters for the test Karlsen network. @@ -287,7 +289,7 @@ var TestnetParams = Params{ RPCPort: "42210", DefaultPort: "42211", DNSSeeds: []string{ - "testnet-1.karlsencoin.com", + "testnet-1-dnsseed.karlsencoin.com", }, // DAG parameters @@ -341,6 +343,7 @@ var TestnetParams = Params{ MaxBlockLevel: 250, MergeDepth: defaultMergeDepth, + HFDAAScore: 6000000, // TODO: define the fork date DAAscore } // SimnetParams defines the network parameters for the simulation test Karlsen @@ -407,6 +410,7 @@ var SimnetParams = Params{ MaxBlockLevel: 250, MergeDepth: defaultMergeDepth, + HFDAAScore: 50, } // DevnetParams defines the network parameters for the development Karlsen network. @@ -469,6 +473,7 @@ var DevnetParams = Params{ MaxBlockLevel: 250, MergeDepth: defaultMergeDepth, + HFDAAScore: 50, } // ErrDuplicateNet describes an error where the parameters for a Karlsen diff --git a/go.mod b/go.mod index e03e36b276..225b53143a 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd github.com/btcsuite/winsvc v1.0.0 github.com/davecgh/go-spew v1.1.1 + github.com/edsrzf/mmap-go v1.1.0 github.com/gofrs/flock v0.8.1 github.com/golang/protobuf v1.5.3 github.com/jessevdk/go-flags v1.5.0 @@ -16,21 +17,20 @@ require ( github.com/pkg/errors v0.9.1 github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d github.com/tyler-smith/go-bip39 v1.1.0 - golang.org/x/crypto v0.19.0 + golang.org/x/crypto v0.26.0 golang.org/x/exp v0.0.0-20240213143201-ec583247a57a - golang.org/x/term v0.17.0 + golang.org/x/term v0.23.0 google.golang.org/grpc v1.61.1 - google.golang.org/protobuf v1.32.0 + google.golang.org/protobuf v1.34.2 lukechampine.com/blake3 v1.2.1 ) require ( github.com/golang/snappy v0.0.4 // indirect github.com/klauspost/cpuid/v2 v2.2.6 // indirect - golang.org/x/net v0.21.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/sys v0.23.0 // indirect + golang.org/x/text v0.17.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect gopkg.in/yaml.v2 v2.3.0 // indirect ) diff --git a/go.sum b/go.sum index 15f915992d..cef9634e82 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= @@ -13,55 +11,27 @@ github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0 h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/edsrzf/mmap-go v1.1.0 h1:6EUwBLQ/Mcr1EYLE4Tn1VdW1A4ckqCQWZBw8Hr0kjpQ= +github.com/edsrzf/mmap-go v1.1.0/go.mod h1:19H/e8pUPLicwkyNgOykDXkJ9F0MHE+Z52B8EIth78Q= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jrick/logrotate v1.0.0 h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI= @@ -71,8 +41,6 @@ github.com/kaspanet/go-muhash v0.0.4/go.mod h1:10bPW5mO1vNHPSejaAh9ZTtLZE16jzEvg github.com/kaspanet/go-secp256k1 v0.0.7 h1:WHnrwopKB6ZeHSbdAwwxNhTqflm56XT1mM6LF4/OvOs= github.com/kaspanet/go-secp256k1 v0.0.7/go.mod h1:cFbxhxKkxqHX5eIwUGKARkph19PehipDPJejWB+H0jM= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= -github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -82,125 +50,50 @@ github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d h1:gZZadD8H+fF+n9CmNhYL1Y0dJB+kLOmKd7FbPJLeGHs= github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210317152858-513c2a44f670/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20220414153411-bcd21879b8fd h1:zVFyTKZN/Q7mNRWSs1GOYnHM9NiFSJ54YVRsD0rNWT4= -golang.org/x/exp v0.0.0-20220414153411-bcd21879b8fd/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE= golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= +golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08 h1:pc16UedxnxXXtGxHCSUhafAoVHQZ0yXl8ZelMH4EETc= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 h1:9+tzLLstTlPTRyJTh+ah5wIMsBW5c4tQwGTN3thOW9Y= -google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:mqHbVIp48Muh7Ywss/AD6I5kNVKZMmAa/QEW58Gxp2s= google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c h1:NUsgEN92SQQqzfA+YtqYNqYmB3DMMYLlIwUZAQFVFbo= google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.61.1 h1:kLAiWrZs7YeDM6MumDe7m3y4aM6wacLzM1Y/wiLP9XY= google.golang.org/grpc v1.61.1/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= @@ -208,10 +101,7 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= diff --git a/stability-tests/daa/daa_test.go b/stability-tests/daa/daa_test.go index 65ec6ad342..088dafbb80 100644 --- a/stability-tests/daa/daa_test.go +++ b/stability-tests/daa/daa_test.go @@ -161,7 +161,7 @@ func measureMachineHashNanoseconds(t *testing.T) int64 { defer t.Logf("Finished measuring machine hash rate") genesisBlock := dagconfig.DevnetParams.GenesisBlock - state := pow.NewState(genesisBlock.Header.ToMutable()) + state := pow.NewState(genesisBlock.Header.ToMutable(), false) machineHashesPerSecondMeasurementDuration := 10 * time.Second hashes := int64(0) @@ -200,7 +200,7 @@ func runDAATest(t *testing.T, testName string, runDuration time.Duration, loopForDuration(runDuration, func(isFinished *bool) { templateBlock := fetchBlockForMining(t, rpcClient) headerForMining := templateBlock.Header.ToMutable() - minerState := pow.NewState(headerForMining) + minerState := pow.NewState(headerForMining, false) // Try hashes until we find a valid block miningStartTime := time.Now() diff --git a/stability-tests/many-tips/main.go b/stability-tests/many-tips/main.go index bf89c7551d..f8175887e9 100644 --- a/stability-tests/many-tips/main.go +++ b/stability-tests/many-tips/main.go @@ -115,7 +115,7 @@ func startNode() (teardown func(), err error) { "--appdir", dataDir, "--logdir", dataDir, "--rpclisten", rpcAddress, - "--loglevel", "debug", + "--loglevel", "info", "--allow-submit-block-when-not-synced", ) if err != nil { diff --git a/stability-tests/orphans/main.go b/stability-tests/orphans/main.go index ffe87e73b3..76bc7db1ee 100644 --- a/stability-tests/orphans/main.go +++ b/stability-tests/orphans/main.go @@ -49,8 +49,8 @@ func main() { os.Exit(1) } - // Wait a second to let karlsend process orphans - <-time.After(1 * time.Second) + // Wait 5 seconds to let karlsend process orphans + <-time.After(5 * time.Second) err = checkTopBlockIsTip(rpcClient, topBlock) if err != nil { diff --git a/stability-tests/run/run-fast.sh b/stability-tests/run/run-fast.sh index 73d6da88f2..1ba644cb4a 100755 --- a/stability-tests/run/run-fast.sh +++ b/stability-tests/run/run-fast.sh @@ -30,6 +30,9 @@ echo "Running simple-sync" cd "${PROJECT_ROOT}/simple-sync/run" && ./run.sh || failedTests+=("simple-sync") echo "Done running simple-sync" +echo "Moving khashv2 pre-computed dag file" +mv "${PROJECT_ROOT}/simple-sync/run/hashes.dat" "${PROJECT_ROOT}/many-tips/run" + echo "Running orphans" cd "${PROJECT_ROOT}/orphans/run" && ./run.sh || failedTests+=("orphans") echo "Done running orphans" @@ -42,6 +45,9 @@ echo "Running many-tips" cd "${PROJECT_ROOT}/many-tips/run" && ./run.sh || failedTests+=("many-tips") echo "Done running many-tips" +echo "Removing khashv2 pre-computed dag file" +rm "${PROJECT_ROOT}/many-tips/run/hashes.dat" + echo "Running netsync - fast" cd "${PROJECT_ROOT}/netsync/run" && ./run-fast.sh || failedTests+=("netsync") echo "Done running netsync - fast" @@ -54,4 +60,4 @@ for t in "${failedTests[@]}"; do done echo "Exiting with: ${EXIT_CODE}" -exit $EXIT_CODE \ No newline at end of file +exit $EXIT_CODE diff --git a/stability-tests/simple-sync/run/run.sh b/stability-tests/simple-sync/run/run.sh index f8a44799ea..a82b8c05ab 100755 --- a/stability-tests/simple-sync/run/run.sh +++ b/stability-tests/simple-sync/run/run.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e -simple-sync --simnet -n=1000 --profile=7000 +simple-sync --simnet -n=100 --profile=7000 TEST_EXIT_CODE=$? echo "Exit code: $TEST_EXIT_CODE" diff --git a/version/version.go b/version/version.go index 619e8f3f57..a15ad996a5 100644 --- a/version/version.go +++ b/version/version.go @@ -9,8 +9,8 @@ import ( const validCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-" const ( - appMajor uint = 1 - appMinor uint = 2 + appMajor uint = 2 + appMinor uint = 1 appPatch uint = 0 )