diff --git a/Makefile b/Makefile index f69dc41..e901430 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ endif ldflags= \ -X "github.com/mike76-dev/hostscore/internal/build.NodeBinaryName=hsd" \ --X "github.com/mike76-dev/hostscore/internal/build.NodeVersion=1.1.3" \ +-X "github.com/mike76-dev/hostscore/internal/build.NodeVersion=1.1.4" \ -X "github.com/mike76-dev/hostscore/internal/build.ClientBinaryName=hsc" \ -X "github.com/mike76-dev/hostscore/internal/build.ClientVersion=1.4.3" \ -X "github.com/mike76-dev/hostscore/internal/build.GitRevision=${GIT_DIRTY}${GIT_REVISION}" \ diff --git a/go.mod b/go.mod index ed0e715..c3765ed 100644 --- a/go.mod +++ b/go.mod @@ -1,31 +1,31 @@ module github.com/mike76-dev/hostscore -go 1.21.6 +go 1.21.8 -toolchain go1.21.7 +toolchain go1.21.11 require ( github.com/go-sql-driver/mysql v1.7.1 github.com/julienschmidt/httprouter v1.3.0 gitlab.com/NebulousLabs/merkletree v0.0.0-20200118113624-07fbf710afc4 - go.sia.tech/core v0.2.4-0.20240520154607-dce93a005b7c - go.sia.tech/coreutils v0.0.4-0.20240410064358-6dc8ac8cfe97 + go.sia.tech/core v0.3.0 + go.sia.tech/coreutils v0.1.0 go.sia.tech/mux v1.2.0 go.uber.org/zap v1.27.0 - golang.org/x/crypto v0.23.0 - golang.org/x/term v0.20.0 + golang.org/x/crypto v0.24.0 + golang.org/x/term v0.21.0 lukechampine.com/flagg v1.1.1 lukechampine.com/frand v1.4.2 ) require ( github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect - go.etcd.io/bbolt v1.3.9 // indirect + go.etcd.io/bbolt v1.3.10 // indirect go.uber.org/multierr v1.10.0 // indirect golang.org/x/tools v0.5.0 // indirect ) require ( go.sia.tech/jape v0.11.1 - golang.org/x/sys v0.20.0 // indirect + golang.org/x/sys v0.21.0 // indirect ) diff --git a/go.sum b/go.sum index 262cf48..a217ec7 100644 --- a/go.sum +++ b/go.sum @@ -16,12 +16,12 @@ gitlab.com/NebulousLabs/fastrand v0.0.0-20181126182046-603482d69e40 h1:dizWJqTWj gitlab.com/NebulousLabs/fastrand v0.0.0-20181126182046-603482d69e40/go.mod h1:rOnSnoRyxMI3fe/7KIbVcsHRGxe30OONv8dEgo+vCfA= gitlab.com/NebulousLabs/merkletree v0.0.0-20200118113624-07fbf710afc4 h1:iuNdBfBg0umjOvrEf9MxGzK+NwAyE2oCZjDqUx9zVFs= gitlab.com/NebulousLabs/merkletree v0.0.0-20200118113624-07fbf710afc4/go.mod h1:0cjDwhA+Pv9ZQXHED7HUSS3sCvo2zgsoaMgE7MeGBWo= -go.etcd.io/bbolt v1.3.9 h1:8x7aARPEXiXbHmtUwAIv7eV2fQFHrLLavdiJ3uzJXoI= -go.etcd.io/bbolt v1.3.9/go.mod h1:zaO32+Ti0PK1ivdPtgMESzuzL2VPoIG1PCQNvOdo/dE= -go.sia.tech/core v0.2.4-0.20240520154607-dce93a005b7c h1:EUWOatRZYsQNm12V5Y69hTmRQF4JKWVwj4R8X3Hp+ms= -go.sia.tech/core v0.2.4-0.20240520154607-dce93a005b7c/go.mod h1:tf07w3f/8XRtK1XoHl8C/MXzzUp/MEUuZE22L5uoCDQ= -go.sia.tech/coreutils v0.0.4-0.20240410064358-6dc8ac8cfe97 h1:9tNCniW3Ys1CKR7MhELDkKoxltBexNtY6vt5GEs92dI= -go.sia.tech/coreutils v0.0.4-0.20240410064358-6dc8ac8cfe97/go.mod h1:6e0bDPG1qQa6jrkQhgY925lGHmTNbtq8nQwAmfpWhmo= +go.etcd.io/bbolt v1.3.10 h1:+BqfJTcCzTItrop8mq/lbzL8wSGtj94UO/3U31shqG0= +go.etcd.io/bbolt v1.3.10/go.mod h1:bK3UQLPJZly7IlNmV7uVHJDxfe5aK9Ll93e/74Y9oEQ= +go.sia.tech/core v0.3.0 h1:PDfAQh9z8PYD+oeVS7rS9SEnTMOZzwwFfAH45yktmko= +go.sia.tech/core v0.3.0/go.mod h1:BMgT/reXtgv6XbDgUYTCPY7wSMbspDRDs7KMi1vL6Iw= +go.sia.tech/coreutils v0.1.0 h1:WQL7iT+jK1BiMx87bASXrZJZf4N2fbQkIOW8rS7wkh4= +go.sia.tech/coreutils v0.1.0/go.mod h1:ybaFgewKXrlxFW71LqsyQlxjG6yWL6BSePrbZYnrprU= go.sia.tech/jape v0.11.1 h1:M7IP+byXL7xOqzxcHUQuXW+q3sYMkYzmMlMw+q8ZZw0= go.sia.tech/jape v0.11.1/go.mod h1:4QqmBB+t3W7cNplXPj++ZqpoUb2PeiS66RLpXmEGap4= go.sia.tech/mux v1.2.0 h1:ofa1Us9mdymBbGMY2XH/lSpY8itFsKIo/Aq8zwe+GHU= @@ -34,8 +34,8 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200109152110-61a87790db17/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= -golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -44,10 +44,10 @@ golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 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-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= -golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= +golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.5.0 h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4= golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= diff --git a/internal/walletutil/store.go b/internal/walletutil/store.go index 449655d..49f3f69 100644 --- a/internal/walletutil/store.go +++ b/internal/walletutil/store.go @@ -219,28 +219,10 @@ func (s *DBStore) applyChainUpdate(cau chain.ApplyUpdate) error { return nil } - // Determine which Siacoin and Siafund elements are ephemeral. - created := make(map[types.Hash256]bool) - ephemeral := make(map[types.Hash256]bool) - for _, txn := range cau.Block.Transactions { - for i := range txn.SiacoinOutputs { - created[types.Hash256(txn.SiacoinOutputID(i))] = true - } - for _, input := range txn.SiacoinInputs { - ephemeral[types.Hash256(input.ParentID)] = created[types.Hash256(input.ParentID)] - } - for i := range txn.SiafundOutputs { - created[types.Hash256(txn.SiafundOutputID(i))] = true - } - for _, input := range txn.SiafundInputs { - ephemeral[types.Hash256(input.ParentID)] = created[types.Hash256(input.ParentID)] - } - } - // Add new Siacoin elements to the store. var newSiacoinElements, spentSiacoinElements []types.SiacoinElement - cau.ForEachSiacoinElement(func(se types.SiacoinElement, spent bool) { - if ephemeral[se.ID] { + cau.ForEachSiacoinElement(func(se types.SiacoinElement, created bool, spent bool) { + if created && spent { return } @@ -262,8 +244,8 @@ func (s *DBStore) applyChainUpdate(cau chain.ApplyUpdate) error { } var newSiafundElements, spentSiafundElements []types.SiafundElement - cau.ForEachSiafundElement(func(se types.SiafundElement, spent bool) { - if ephemeral[se.ID] { + cau.ForEachSiafundElement(func(se types.SiafundElement, created bool, spent bool) { + if created && spent { return } @@ -361,8 +343,8 @@ func (s *DBStore) revertChainUpdate(cru chain.RevertUpdate) error { } var removedSiacoinElements, addedSiacoinElements []types.SiacoinElement - cru.ForEachSiacoinElement(func(se types.SiacoinElement, spent bool) { - if ephemeral[se.ID] { + cru.ForEachSiacoinElement(func(se types.SiacoinElement, created, spent bool) { + if created && spent { return } @@ -387,8 +369,8 @@ func (s *DBStore) revertChainUpdate(cru chain.RevertUpdate) error { } var removedSiafundElements, addedSiafundElements []types.SiafundElement - cru.ForEachSiafundElement(func(se types.SiafundElement, spent bool) { - if ephemeral[se.ID] { + cru.ForEachSiafundElement(func(se types.SiafundElement, created, spent bool) { + if created && spent { return } diff --git a/wallet/wallet.go b/wallet/wallet.go index c5d3e08..f18e3ae 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -281,10 +281,10 @@ func (emfc EventMissedFileContract) String() string { } type ChainUpdate interface { - ForEachSiacoinElement(func(sce types.SiacoinElement, spent bool)) - ForEachSiafundElement(func(sfe types.SiafundElement, spent bool)) - ForEachFileContractElement(func(fce types.FileContractElement, rev *types.FileContractElement, resolved, valid bool)) - ForEachV2FileContractElement(func(fce types.V2FileContractElement, rev *types.V2FileContractElement, res types.V2FileContractResolutionType)) + ForEachSiacoinElement(func(sce types.SiacoinElement, created, spent bool)) + ForEachSiafundElement(func(sfe types.SiafundElement, created, spent bool)) + ForEachFileContractElement(func(fce types.FileContractElement, created bool, rev *types.FileContractElement, resolved, valid bool)) + ForEachV2FileContractElement(func(fce types.V2FileContractElement, created bool, rev *types.V2FileContractElement, res types.V2FileContractResolutionType)) } // AppliedEvents extracts a list of relevant events from a chain update. @@ -331,22 +331,22 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate, addr types return false } anythingRelevant := func() (ok bool) { - cu.ForEachSiacoinElement(func(sce types.SiacoinElement, spent bool) { + cu.ForEachSiacoinElement(func(sce types.SiacoinElement, created, spent bool) { if ok || sce.SiacoinOutput.Address == addr { ok = true } }) - cu.ForEachSiafundElement(func(sfe types.SiafundElement, spent bool) { + cu.ForEachSiafundElement(func(sfe types.SiafundElement, created, spent bool) { if ok || sfe.SiafundOutput.Address == addr { ok = true } }) - cu.ForEachFileContractElement(func(fce types.FileContractElement, rev *types.FileContractElement, resolved, valid bool) { + cu.ForEachFileContractElement(func(fce types.FileContractElement, _ bool, rev *types.FileContractElement, resolved, valid bool) { if ok || relevantContract(fce.FileContract) || (rev != nil && relevantContract(rev.FileContract)) { ok = true } }) - cu.ForEachV2FileContractElement(func(fce types.V2FileContractElement, rev *types.V2FileContractElement, res types.V2FileContractResolutionType) { + cu.ForEachV2FileContractElement(func(fce types.V2FileContractElement, _ bool, rev *types.V2FileContractElement, res types.V2FileContractResolutionType) { if ok || relevantV2Contract(fce.V2FileContract) || (rev != nil && relevantV2Contract(rev.V2FileContract)) || @@ -365,19 +365,19 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate, addr types sfes := make(map[types.SiafundOutputID]types.SiafundElement) fces := make(map[types.FileContractID]types.FileContractElement) v2fces := make(map[types.FileContractID]types.V2FileContractElement) - cu.ForEachSiacoinElement(func(sce types.SiacoinElement, spent bool) { + cu.ForEachSiacoinElement(func(sce types.SiacoinElement, created, spent bool) { sce.MerkleProof = nil sces[types.SiacoinOutputID(sce.ID)] = sce }) - cu.ForEachSiafundElement(func(sfe types.SiafundElement, spent bool) { + cu.ForEachSiafundElement(func(sfe types.SiafundElement, created, spent bool) { sfe.MerkleProof = nil sfes[types.SiafundOutputID(sfe.ID)] = sfe }) - cu.ForEachFileContractElement(func(fce types.FileContractElement, rev *types.FileContractElement, resolved, valid bool) { + cu.ForEachFileContractElement(func(fce types.FileContractElement, _ bool, rev *types.FileContractElement, resolved, valid bool) { fce.MerkleProof = nil fces[types.FileContractID(fce.ID)] = fce }) - cu.ForEachV2FileContractElement(func(fce types.V2FileContractElement, rev *types.V2FileContractElement, res types.V2FileContractResolutionType) { + cu.ForEachV2FileContractElement(func(fce types.V2FileContractElement, _ bool, rev *types.V2FileContractElement, res types.V2FileContractResolutionType) { fce.MerkleProof = nil v2fces[types.FileContractID(fce.ID)] = fce }) @@ -616,7 +616,7 @@ func AppliedEvents(cs consensus.State, b types.Block, cu ChainUpdate, addr types } // handle missed contracts - cu.ForEachFileContractElement(func(fce types.FileContractElement, rev *types.FileContractElement, resolved, valid bool) { + cu.ForEachFileContractElement(func(fce types.FileContractElement, _ bool, rev *types.FileContractElement, resolved, valid bool) { if resolved && !valid { if !relevantContract(fce.FileContract) { return