Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
fc9a0d3
start by refactoring block index into a read-through cache
lazynina Sep 23, 2024
f3e8e4c
best chain and header chain with read through cache
lazynina Sep 24, 2024
a2e5b4b
check bestHeaderChain.ChainMap ONLY when processing pos headers
lazynina Sep 24, 2024
ff6ee24
updates for locating headers and faster cache usage
lazynina Sep 24, 2024
71b1eaa
more fixes
lazynina Sep 25, 2024
17a56bd
more fixes
lazynina Sep 26, 2024
d153927
more fix, specifically around .Ancestor
lazynina Sep 26, 2024
47e1958
bump test timeout
lazynina Sep 26, 2024
5e5c0c1
load all blocks after committed tip in block index
lazynina Sep 26, 2024
9a32c26
fix GetBlockNodeByHashAndHeight - no need for checking height > maxHe…
lazynina Sep 26, 2024
5359be8
bump timeout to 60m
lazynina Sep 27, 2024
89a845e
try hashicorp lru cache
lazynina Sep 27, 2024
4f7ff12
Fix up some more tests and remove logging
lazynina Sep 27, 2024
722dcc0
fix string slice workaround, fix calc next difficulty
lazynina Sep 27, 2024
1941487
use best header chain instead of best chain for calc next difficulty …
lazynina Sep 27, 2024
627e882
fix tests
lazynina Sep 28, 2024
a469c3a
refactor to just use a block hash for best block chain and best heade…
lazynina Oct 3, 2024
c6ad24a
move block index migration to NewBlockchain instead of NewServer, add…
lazynina Oct 3, 2024
216fd31
merge main into branch
lazynina Oct 3, 2024
1f80f19
Merge branch 'ln/read-through-cache-for-block-index-and-best-chain' i…
lazynina Oct 3, 2024
8b73b1c
handle case where we haven't hit PoS cutover yet in block index migra…
lazynina Oct 3, 2024
7ac67bd
cleanup
lazynina Oct 4, 2024
7675765
do some sampling for is fully stored and check archival mode
lazynina Oct 7, 2024
148bad3
fix get blocks to store
lazynina Oct 7, 2024
8aa6a5b
cleanup
lazynina Oct 7, 2024
53b2d29
make a bunch of methods on block index private and expose block index…
lazynina Oct 7, 2024
91e22ff
don't bother healing orphan pointers if we're syncing
lazynina Oct 8, 2024
9abe238
refactor to reduce number of times we have to call hash and don't bot…
lazynina Oct 8, 2024
23991c4
upgrade cloudflare/circl
lazynina Oct 8, 2024
8adc624
Ln/replace best chain plus replace old lru cache (#1414)
lazynina Oct 8, 2024
2608ec5
Merge branch 'ln/replace-best-chain-with-block-index' of github.com:d…
lazynina Oct 8, 2024
dbad649
go mod tidy
lazynina Oct 8, 2024
ebb1175
expose SetBestChain
lazynina Oct 8, 2024
ae34cff
fix exit condition for GetBlocksToStore
lazynina Oct 8, 2024
b48c52d
use bytes.Equal instead of reflect.DeepEqual for comparing block hashes
lazynina Oct 8, 2024
925e44e
use get block from best chain by height to speed up syncing
lazynina Oct 8, 2024
dddd64c
fix condition for returning from get block by hash
lazynina Oct 8, 2024
62503c1
revert using get block from best chain by height
lazynina Oct 8, 2024
131f389
add height check to reduce calls to compare hashes
lazynina Oct 9, 2024
f57a699
fix exit condition for height in get block from best chain by hash
lazynina Oct 9, 2024
2bae1a2
allow early return from GetBlockFromBestChainByHash if we're using he…
lazynina Oct 9, 2024
ea243f3
minor enhancement to isTipCurrent
lazynina Oct 9, 2024
3f73bb6
fix txindex issue w/ genesis block
lazynina Oct 9, 2024
e200407
fix process block pow logic for genesis block
lazynina Oct 9, 2024
3ad68be
fix - get next block after tip hash in update process of txindex
lazynina Oct 9, 2024
78034d4
reduce direct access to BlockNode.Parent and get rid of heal orphan p…
lazynina Oct 9, 2024
02e9e15
fix postgres get best chain logic
lazynina Oct 9, 2024
dec4675
merge in main
lazynina Oct 21, 2024
2a82dea
Ln/downgrade badger (#1430)
lazynina Nov 5, 2024
d7b6f93
resolve conflicts with main
lazynina Dec 5, 2024
453cf51
resolve merge conflicts
lazynina Dec 5, 2024
35f7a6a
remove LocateBestBlockChainHeaders and replace with DH suggestion. fl…
lazynina Dec 5, 2024
69e1825
make GetUtxoViewAndUtxoOpsAtBlockHash public
lazynina Dec 5, 2024
a859c72
cleanup
lazynina Dec 5, 2024
01cd500
change GetBlockFromBestChainByHash to GetBlockFromBestChainByHashAndO…
lazynina Dec 5, 2024
09091df
use GetBlockFromBestChainByHashAndOptionalHeight in GetBlockNodesToFetch
lazynina Dec 5, 2024
77a1f57
nuke locator and inventory logic, just return a slice of the tip hash
lazynina Dec 5, 2024
0585ebc
move check in should verify signatures up in function to reduce amoun…
lazynina Dec 5, 2024
139fb2c
reduce size of block index cache
lazynina Dec 5, 2024
4259c39
use header chain for get blocks to store
lazynina Dec 5, 2024
aea51a8
fix return value from processHeaderPoW
lazynina Dec 5, 2024
fc63a94
disable deadlock detection around putting block nodes into db after h…
lazynina Dec 5, 2024
90b5372
add more logging as we're processing headers after finishing download…
lazynina Dec 5, 2024
f9a4f3e
iterate backwards to update status of block nodes after finishing hyp…
lazynina Dec 5, 2024
f425317
fix set tip call since we reverse backwards through the block nodes a…
lazynina Dec 6, 2024
231a6dc
small clean up, add some todos
lazynina Dec 9, 2024
8eb3e94
call hash less often to speed up block processing
lazynina Dec 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ type Config struct {
func GetStringSliceWorkaround(flagName string) []string {
value := viper.GetString(flagName)
if value == "" || value == " " {
return []string{}
values := viper.GetStringSlice(flagName)
return values
}
return strings.Split(value, ",")
}
Expand Down Expand Up @@ -147,7 +148,6 @@ func LoadConfig() *Config {

// Peers
config.ConnectIPs = GetStringSliceWorkaround("connect-ips")
glog.V(2).Infof("Connect IPs read in: %v", config.ConnectIPs)
config.AddIPs = GetStringSliceWorkaround("add-ips")
config.AddSeeds = GetStringSliceWorkaround("add-seeds")
config.TargetOutboundPeers = viper.GetUint32("target-outbound-peers")
Expand Down
17 changes: 8 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ require (
github.com/bxcodec/faker v2.0.1+incompatible
github.com/cloudflare/circl v1.5.0
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/decred/dcrd/container/lru v1.0.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/deso-protocol/go-deadlock v1.0.1
github.com/deso-protocol/go-merkle-tree v1.0.0
Expand All @@ -38,11 +37,11 @@ require (
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
github.com/tyler-smith/go-bip39 v1.1.0
github.com/unrolled/secure v1.16.0
golang.org/x/crypto v0.28.0
golang.org/x/sync v0.8.0
golang.org/x/crypto v0.29.0
golang.org/x/sync v0.9.0
gopkg.in/DataDog/dd-trace-go.v1 v1.69.0
)

Expand Down Expand Up @@ -101,7 +100,7 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.17.1 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/kyokomi/emoji/v2 v2.2.13 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
Expand Down Expand Up @@ -145,10 +144,10 @@ require (
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.26.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/time v0.7.0 // indirect
golang.org/x/tools v0.26.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
Expand Down
34 changes: 16 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decred/dcrd/container/lru v1.0.0 h1:7foQymtbu18aQWYiY9RnNIeE+kvpiN+fiBQ3+viyJjI=
github.com/decred/dcrd/container/lru v1.0.0/go.mod h1:vlPwj0l+IzAHhQSsbgQnJgO5Cte78+yI065V+Mc5PRQ=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/crypto/blake256 v1.1.0 h1:zPMNGQCm0g4QTY27fOCorQW7EryeQ/U0x++OzVrdms8=
github.com/decred/dcrd/crypto/blake256 v1.1.0/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
Expand Down Expand Up @@ -250,8 +248,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
github.com/klauspost/compress v1.17.1 h1:NE3C767s2ak2bweCZo3+rdP4U/HoyVXLv/X9f2gPS5g=
github.com/klauspost/compress v1.17.1/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
Expand Down Expand Up @@ -384,8 +382,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
Expand Down Expand Up @@ -440,8 +438,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8=
Expand Down Expand Up @@ -476,8 +474,8 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
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=
Expand All @@ -488,8 +486,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
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-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -520,24 +518,24 @@ golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.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.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ=
golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
4 changes: 2 additions & 2 deletions lib/block_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ func (desoBlockProducer *DeSoBlockProducer) _getBlockTemplate(publicKey []byte)
blockRet.Header.TransactionMerkleRoot = merkleRoot

// Compute the next difficulty target given the current tip.
diffTarget, err := CalcNextDifficultyTarget(
lastNode, CurrentHeaderVersion, desoBlockProducer.params)
diffTarget, err := desoBlockProducer.chain.CalcNextDifficultyTarget(
lastNode, CurrentHeaderVersion)
if err != nil {
return nil, nil, nil, errors.Wrapf(err, "DeSoBlockProducer._getBlockTemplate: Problem computing next difficulty: ")
}
Expand Down
1 change: 1 addition & 0 deletions lib/block_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -5114,6 +5114,7 @@ func (bav *UtxoView) GetSpendableDeSoBalanceNanosForPublicKey(pkBytes []byte,
// but we do have the header. As a result, this condition always evaluates to false and thus
// we only process the block reward for the previous block instead of all immature block rewards
// as defined by the params.
// NOTE: we are not using .GetParent here as it changes the meaning of this code.
if blockNode.Parent != nil {
nextBlockHash = blockNode.Parent.Hash
} else {
Expand Down
8 changes: 4 additions & 4 deletions lib/block_view_lockups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2353,7 +2353,7 @@ func TestLockupBlockConnectsAndDisconnects(t *testing.T) {
// Process the first block
err = testMeta.miner.BlockProducer.SignBlock(blk1)
require.NoError(t, err)
_, _, _, err = testMeta.chain.ProcessBlock(blk1, false)
_, _, _, err = testMeta.chain.ProcessBlock(blk1, nil, false)
require.NoError(t, err)

// Validate state update
Expand Down Expand Up @@ -2417,7 +2417,7 @@ func TestLockupBlockConnectsAndDisconnects(t *testing.T) {
// Process the second block
err = testMeta.miner.BlockProducer.SignBlock(blk2)
require.NoError(t, err)
_, _, _, err = testMeta.chain.ProcessBlock(blk2, false)
_, _, _, err = testMeta.chain.ProcessBlock(blk2, nil, false)
require.NoError(t, err)

// Validate state update
Expand Down Expand Up @@ -2462,7 +2462,7 @@ func TestLockupBlockConnectsAndDisconnects(t *testing.T) {
require.NoError(t, utxoView.FlushToDb(blk2.Header.Height))

// Update the tip
testMeta.chain.bestChain = testMeta.chain.bestChain[:len(testMeta.chain.bestChain)-1]
testMeta.chain.blockIndex.tip = testMeta.chain.blockIndex.tip.Parent

// Validate the state update
utxoView = NewUtxoView(
Expand Down Expand Up @@ -2517,7 +2517,7 @@ func TestLockupBlockConnectsAndDisconnects(t *testing.T) {
require.NoError(t, utxoView.FlushToDb(blk1.Header.Height))

// Update the tip
testMeta.chain.bestChain = testMeta.chain.bestChain[:len(testMeta.chain.bestChain)-1]
testMeta.chain.blockIndex.setTip(testMeta.chain.blockIndex.tip.Parent)

// Verify we return back to the initial state
utxoView = NewUtxoView(
Expand Down
15 changes: 7 additions & 8 deletions lib/block_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/hex"
"fmt"
lru "github.com/hashicorp/golang-lru/v2"
"math"
_ "net/http/pprof"
"reflect"
Expand All @@ -13,7 +14,6 @@ import (
"github.com/deso-protocol/core/bls"

"github.com/btcsuite/btcd/btcec/v2"
"github.com/decred/dcrd/container/lru"
"github.com/dgraph-io/badger/v3"
embeddedpostgres "github.com/fergusstrange/embedded-postgres"
"github.com/golang/glog"
Expand Down Expand Up @@ -702,8 +702,8 @@ func (tes *transactionTestSuite) testDisconnectBlock(tm *transactionTestMeta, te
require.NoError(err)
// sanity-check that the last block hash is the same as the last header hash.
require.Equal(true, bytes.Equal(
tm.chain.bestChain[len(tm.chain.bestChain)-1].Hash.ToBytes(),
tm.chain.bestHeaderChain[len(tm.chain.bestHeaderChain)-1].Hash.ToBytes()))
tm.chain.blockIndex.GetTip().Hash.ToBytes(),
tm.chain.blockIndex.GetHeaderTip().Hash.ToBytes()))
// Last block shouldn't be nil, and the number of expectedTxns should be the same as in the testVectorBlock + 1,
// because of the additional block reward.
require.NotNil(lastBlock)
Expand Down Expand Up @@ -791,15 +791,14 @@ func (tes *transactionTestSuite) testDisconnectBlock(tm *transactionTestMeta, te
// TODO: if ever needed we can call tm.chain.eventManager.blockDisconnected() here.

// Update the block and header metadata chains.
tm.chain.bestChain = tm.chain.bestChain[:len(tm.chain.bestChain)-1]
tm.chain.bestHeaderChain = tm.chain.bestHeaderChain[:len(tm.chain.bestHeaderChain)-1]
delete(tm.chain.bestChainMap, *lastBlockHash)
delete(tm.chain.bestHeaderChainMap, *lastBlockHash)
tm.chain.blockIndex.setTip(tm.chain.BlockTip().GetParent(tm.chain.blockIndex))
tm.chain.blockIndex.setHeaderTip(tm.chain.HeaderTip().GetParent(tm.chain.blockIndex))

// We don't pass the chain's snapshot above to prevent certain concurrency issues. As a
// result, we need to reset the snapshot's db cache to get rid of stale data.
if tm.chain.snapshot != nil {
tm.chain.snapshot.DatabaseCache = *lru.NewMap[string, []byte](DatabaseCacheSize)
tm.chain.snapshot.DatabaseCache, err = lru.New[string, []byte](int(DatabaseCacheSize))
require.NoError(err)
}

// Note that unlike connecting test vectors, when disconnecting, we don't need to verify db entries.
Expand Down
Loading
Loading