Repository: kaspanet/kaspad
Pull request #1877 (2021-12-10 14:44:01)

Remove unused args from CalcSubsidy

codecov[bot]: # [Codecov](https://codecov.io/gh/kaspanet/kaspad/pull/1877?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet) Report
> Merging [#1877](https://codecov.io/gh/kaspanet/kaspad/pull/1877?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet) (e7478b0) into [dev](https://codecov.io/gh/kaspanet/kaspad/commit/7292438e4ace2e547d6e4354df67f71a681be084?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet) (7292438) will **increase** coverage by `0.10%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/kaspanet/kaspad/pull/1877/graphs/tree.svg?width=650&height=150&src=pr&token=2FBIEEJTNU&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet)](https://codecov.io/gh/kaspanet/kaspad/pull/1877?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet)

```diff
@@            Coverage Diff             @@
##              dev    #1877      +/-   ##
==========================================
+ Coverage   61.74%   61.84%   +0.10%     
==========================================
  Files         624      624              
  Lines       29397    29391       -6     
==========================================
+ Hits        18150    18177      +27     
+ Misses       8673     8649      -24     
+ Partials     2574     2565       -9     
```


| [Impacted Files](https://codecov.io/gh/kaspanet/kaspad/pull/1877?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet) | Coverage Δ | |
|---|---|---|
| [.../consensus/processes/blockbuilder/block\_builder.go](https://codecov.io/gh/kaspanet/kaspad/pull/1877/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet#diff-ZG9tYWluL2NvbnNlbnN1cy9wcm9jZXNzZXMvYmxvY2tidWlsZGVyL2Jsb2NrX2J1aWxkZXIuZ28=) | `77.64% <100.00%> (ø)` | |
| [...ensus/processes/blockbuilder/test\_block\_builder.go](https://codecov.io/gh/kaspanet/kaspad/pull/1877/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet#diff-ZG9tYWluL2NvbnNlbnN1cy9wcm9jZXNzZXMvYmxvY2tidWlsZGVyL3Rlc3RfYmxvY2tfYnVpbGRlci5nbw==) | `69.37% <100.00%> (+0.66%)` | :arrow_up: |
| [.../processes/blockvalidator/block\_body\_in\_context.go](https://codecov.io/gh/kaspanet/kaspad/pull/1877/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet#diff-ZG9tYWluL2NvbnNlbnN1cy9wcm9jZXNzZXMvYmxvY2t2YWxpZGF0b3IvYmxvY2tfYm9keV9pbl9jb250ZXh0Lmdv) | `62.76% <100.00%> (ø)` | |
| [...ensus/processes/coinbasemanager/coinbasemanager.go](https://codecov.io/gh/kaspanet/kaspad/pull/1877/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet#diff-ZG9tYWluL2NvbnNlbnN1cy9wcm9jZXNzZXMvY29pbmJhc2VtYW5hZ2VyL2NvaW5iYXNlbWFuYWdlci5nbw==) | `52.60% <100.00%> (ø)` | |
| [...ses/consensusstatemanager/verify\_and\_build\_utxo.go](https://codecov.io/gh/kaspanet/kaspad/pull/1877/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet#diff-ZG9tYWluL2NvbnNlbnN1cy9wcm9jZXNzZXMvY29uc2Vuc3Vzc3RhdGVtYW5hZ2VyL3ZlcmlmeV9hbmRfYnVpbGRfdXR4by5nbw==) | `85.84% <100.00%> (+1.44%)` | :arrow_up: |
| [app/protocol/flows/blockrelay/handle\_relay\_invs.go](https://codecov.io/gh/kaspanet/kaspad/pull/1877/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet#diff-YXBwL3Byb3RvY29sL2Zsb3dzL2Jsb2NrcmVsYXkvaGFuZGxlX3JlbGF5X2ludnMuZ28=) | `51.50% <0.00%> (-1.00%)` | :arrow_down: |
| [...selectedchainstore/headers\_selected\_chain\_store.go](https://codecov.io/gh/kaspanet/kaspad/pull/1877/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet#diff-ZG9tYWluL2NvbnNlbnN1cy9kYXRhc3RydWN0dXJlcy9oZWFkZXJzc2VsZWN0ZWRjaGFpbnN0b3JlL2hlYWRlcnNfc2VsZWN0ZWRfY2hhaW5fc3RvcmUuZ28=) | `75.58% <0.00%> (+3.48%)` | :arrow_up: |
| [infrastructure/network/netadapter/router/route.go](https://codecov.io/gh/kaspanet/kaspad/pull/1877/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet#diff-aW5mcmFzdHJ1Y3R1cmUvbmV0d29yay9uZXRhZGFwdGVyL3JvdXRlci9yb3V0ZS5nbw==) | `88.57% <0.00%> (+5.71%)` | :arrow_up: |
| [...rver/grpcserver/protowire/rpc\_get\_mempool\_entry.go](https://codecov.io/gh/kaspanet/kaspad/pull/1877/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet#diff-aW5mcmFzdHJ1Y3R1cmUvbmV0d29yay9uZXRhZGFwdGVyL3NlcnZlci9ncnBjc2VydmVyL3Byb3Rvd2lyZS9ycGNfZ2V0X21lbXBvb2xfZW50cnkuZ28=) | `72.72% <0.00%> (+6.06%)` | :arrow_up: |
| [...ain/consensus/database/binaryserialization/hash.go](https://codecov.io/gh/kaspanet/kaspad/pull/1877/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet#diff-ZG9tYWluL2NvbnNlbnN1cy9kYXRhYmFzZS9iaW5hcnlzZXJpYWxpemF0aW9uL2hhc2guZ28=) | `78.26% <0.00%> (+8.69%)` | :arrow_up: |
| ... and [6 more](https://codecov.io/gh/kaspanet/kaspad/pull/1877/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/kaspanet/kaspad/pull/1877?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/kaspanet/kaspad/pull/1877?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet). Last update [7292438...e7478b0](https://codecov.io/gh/kaspanet/kaspad/pull/1877?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaspanet).


Patch:
diff --git a/domain/consensus/model/interface_processes_coinbasemanager.go b/domain/consensus/model/interface_processes_coinbasemanager.go
index 42ef4720..39db6180 100644
--- a/domain/consensus/model/interface_processes_coinbasemanager.go
+++ b/domain/consensus/model/interface_processes_coinbasemanager.go
@@ -6,7 +6,7 @@ import "github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
 // coinbase transactions
 type CoinbaseManager interface {
 	ExpectedCoinbaseTransaction(stagingArea *StagingArea, blockHash *externalapi.DomainHash,
-		coinbaseData *externalapi.DomainCoinbaseData, blockPruningPoint *externalapi.DomainHash) (*externalapi.DomainTransaction, error)
-	CalcBlockSubsidy(stagingArea *StagingArea, blockHash *externalapi.DomainHash, blockPruningPoint *externalapi.DomainHash) (uint64, error)
+		coinbaseData *externalapi.DomainCoinbaseData) (*externalapi.DomainTransaction, error)
+	CalcBlockSubsidy(blockHash *externalapi.DomainHash) (uint64, error)
 	ExtractCoinbaseDataBlueScoreAndSubsidy(coinbaseTx *externalapi.DomainTransaction) (blueScore uint64, coinbaseData *externalapi.DomainCoinbaseData, subsidy uint64, err error)
 }
diff --git a/domain/consensus/processes/blockbuilder/block_builder.go b/domain/consensus/processes/blockbuilder/block_builder.go
index 12f5768e..041454ab 100644
--- a/domain/consensus/processes/blockbuilder/block_builder.go
+++ b/domain/consensus/processes/blockbuilder/block_builder.go
@@ -107,7 +107,7 @@ func (bb *blockBuilder) buildBlock(stagingArea *model.StagingArea, coinbaseData
 	if err != nil {
 		return nil, err
 	}
-	coinbase, err := bb.newBlockCoinbaseTransaction(stagingArea, coinbaseData, newBlockPruningPoint)
+	coinbase, err := bb.newBlockCoinbaseTransaction(stagingArea, coinbaseData)
 	if err != nil {
 		return nil, err
 	}
@@ -175,9 +175,9 @@ func (bb *blockBuilder) validateTransaction(
 }
 
 func (bb *blockBuilder) newBlockCoinbaseTransaction(stagingArea *model.StagingArea,
-	coinbaseData *externalapi.DomainCoinbaseData, blockPruningPoint *externalapi.DomainHash) (*externalapi.DomainTransaction, error) {
+	coinbaseData *externalapi.DomainCoinbaseData) (*externalapi.DomainTransaction, error) {
 
-	return bb.coinbaseManager.ExpectedCoinbaseTransaction(stagingArea, model.VirtualBlockHash, coinbaseData, blockPruningPoint)
+	return bb.coinbaseManager.ExpectedCoinbaseTransaction(stagingArea, model.VirtualBlockHash, coinbaseData)
 }
 
 func (bb *blockBuilder) buildHeader(stagingArea *model.StagingArea, transactions []*externalapi.DomainTransaction,
diff --git a/domain/consensus/processes/blockvalidator/block_body_in_context.go b/domain/consensus/processes/blockvalidator/block_body_in_context.go
index 538051c7..015022e7 100644
--- a/domain/consensus/processes/blockvalidator/block_body_in_context.go
+++ b/domain/consensus/processes/blockvalidator/block_body_in_context.go
@@ -178,7 +178,7 @@ func (v *blockValidator) checkCoinbaseSubsidy(
 		return err
 	}
 
-	expectedSubsidy, err := v.coinbaseManager.CalcBlockSubsidy(stagingArea, blockHash, block.Header.PruningPoint())
+	expectedSubsidy, err := v.coinbaseManager.CalcBlockSubsidy(blockHash)
 	if err != nil {
 		return err
 	}
diff --git a/domain/consensus/processes/coinbasemanager/coinbasemanager.go b/domain/consensus/processes/coinbasemanager/coinbasemanager.go
index 0573ca34..b0c1fff8 100644
--- a/domain/consensus/processes/coinbasemanager/coinbasemanager.go
+++ b/domain/consensus/processes/coinbasemanager/coinbasemanager.go
@@ -36,7 +36,7 @@ type coinbaseManager struct {
 }
 
 func (c *coinbaseManager) ExpectedCoinbaseTransaction(stagingArea *model.StagingArea, blockHash *externalapi.DomainHash,
-	coinbaseData *externalapi.DomainCoinbaseData, blockPruningPoint *externalapi.DomainHash) (*externalapi.DomainTransaction, error) {
+	coinbaseData *externalapi.DomainCoinbaseData) (*externalapi.DomainTransaction, error) {
 
 	ghostdagData, err := c.ghostdagDataStore.Get(c.databaseContext, stagingArea, blockHash, true)
 	if !database.IsNotFoundError(err) && err != nil {
@@ -84,7 +84,7 @@ func (c *coinbaseManager) ExpectedCoinbaseTransaction(stagingArea *model.Staging
 		txOuts = append(txOuts, txOut)
 	}
 
-	subsidy, err := c.CalcBlockSubsidy(stagingArea, blockHash, blockPruningPoint)
+	subsidy, err := c.CalcBlockSubsidy(blockHash)
 	if err != nil {
 		return nil, err
 	}
@@ -184,9 +184,7 @@ func acceptanceDataFromArrayToMap(acceptanceData externalapi.AcceptanceData) map
 // has the expected value.
 //
 // Further details: https://hashdag.medium.com/kaspa-launch-plan-9a63f4d754a6
-func (c *coinbaseManager) CalcBlockSubsidy(stagingArea *model.StagingArea,
-	blockHash *externalapi.DomainHash, blockPruningPoint *externalapi.DomainHash) (uint64, error) {
-
+func (c *coinbaseManager) CalcBlockSubsidy(blockHash *externalapi.DomainHash) (uint64, error) {
 	if blockHash.Equal(c.genesisHash) {
 		return c.subsidyGenesisReward, nil
 	}
diff --git a/domain/consensus/processes/consensusstatemanager/verify_and_build_utxo.go b/domain/consensus/processes/consensusstatemanager/verify_and_build_utxo.go
index fe65126d..c235dd0e 100644
--- a/domain/consensus/processes/consensusstatemanager/verify_and_build_utxo.go
+++ b/domain/consensus/processes/consensusstatemanager/verify_and_build_utxo.go
@@ -166,12 +166,8 @@ func (csm *consensusStateManager) validateCoinbaseTransaction(stagingArea *model
 	}
 
 	log.Tracef("Calculating the expected coinbase transaction for the given coinbase data and block %s", blockHash)
-	header, err := csm.blockHeaderStore.BlockHeader(csm.databaseContext, stagingArea, blockHash)
-	if err != nil {
-		return err
-	}
 	expectedCoinbaseTransaction, err :=
-		csm.coinbaseManager.ExpectedCoinbaseTransaction(stagingArea, blockHash, coinbaseData, header.PruningPoint())
+		csm.coinbaseManager.ExpectedCoinbaseTransaction(stagingArea, blockHash, coinbaseData)
 	if err != nil {
 		return err
 	}


Test patch:
diff --git a/domain/consensus/processes/blockbuilder/test_block_builder.go b/domain/consensus/processes/blockbuilder/test_block_builder.go
index 8a87acc2..c644c51b 100644
--- a/domain/consensus/processes/blockbuilder/test_block_builder.go
+++ b/domain/consensus/processes/blockbuilder/test_block_builder.go
@@ -200,11 +200,7 @@ func (bb *testBlockBuilder) buildBlockWithParents(stagingArea *model.StagingArea
 
 	bb.acceptanceDataStore.Stage(stagingArea, tempBlockHash, acceptanceData)
 
-	pruningPoint, err := bb.newBlockPruningPoint(stagingArea, tempBlockHash)
-	if err != nil {
-		return nil, nil, err
-	}
-	coinbase, err := bb.coinbaseManager.ExpectedCoinbaseTransaction(stagingArea, tempBlockHash, coinbaseData, pruningPoint)
+	coinbase, err := bb.coinbaseManager.ExpectedCoinbaseTransaction(stagingArea, tempBlockHash, coinbaseData)
 	if err != nil {
 		return nil, nil, err
 	}
diff --git a/domain/consensus/timelock_CLTV_test.go b/domain/consensus/timelock_CLTV_test.go
index 323f9776..b1cef6fb 100644
--- a/domain/consensus/timelock_CLTV_test.go
+++ b/domain/consensus/timelock_CLTV_test.go
@@ -313,7 +313,7 @@ func TestCheckLockTimeVerifyConditionedByAbsoluteTime(t *testing.T) {
 		for i := int64(0); ; i++ {
 			tipBlock, err := testConsensus.BuildBlock(&emptyCoinbase, nil)
 			if err != nil {
-				t.Fatalf("Error creating tip using BuildBlock: %v", err)
+				t.Fatalf("Error creating tip using BuildBlock: %+v", err)
 			}
 			blockHeader := tipBlock.Header.ToMutable()
 			blockHeader.SetTimeInMilliseconds(timeStampBlockE + i*1000)