From 6ea33bd82928c538812ded21afd25883635ec67d Mon Sep 17 00:00:00 2001 From: lukechampine Date: Thu, 4 Jan 2024 16:45:56 -0500 Subject: [PATCH] mod: Update core dependency --- go.mod | 2 +- go.sum | 4 ++-- syncer/syncer.go | 15 +++++++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 75a4cb6..0eb2c68 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( go.etcd.io/bbolt v1.3.7 - go.sia.tech/core v0.1.12-0.20240103234000-bae2b8fd3029 + go.sia.tech/core v0.1.12-0.20240104213000-41097337c139 go.sia.tech/jape v0.9.0 go.sia.tech/web/walletd v0.10.0 golang.org/x/term v0.6.0 diff --git a/go.sum b/go.sum index 0b167f9..ae6c2a8 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= -go.sia.tech/core v0.1.12-0.20240103234000-bae2b8fd3029 h1:oYriMRrX0rSaDj9rvupmw2elGAnmjDxAE8zWVVFGuJg= -go.sia.tech/core v0.1.12-0.20240103234000-bae2b8fd3029/go.mod h1:3EoY+rR78w1/uGoXXVqcYdwSjSJKuEMI5bL7WROA27Q= +go.sia.tech/core v0.1.12-0.20240104213000-41097337c139 h1:7/cRTofOXmp150CvEiJQWsYZ+psmzn8bKmA2Jp7V5+0= +go.sia.tech/core v0.1.12-0.20240104213000-41097337c139/go.mod h1:3EoY+rR78w1/uGoXXVqcYdwSjSJKuEMI5bL7WROA27Q= go.sia.tech/jape v0.9.0 h1:kWgMFqALYhLMJYOwWBgJda5ko/fi4iZzRxHRP7pp8NY= go.sia.tech/jape v0.9.0/go.mod h1:4QqmBB+t3W7cNplXPj++ZqpoUb2PeiS66RLpXmEGap4= go.sia.tech/mux v1.2.0 h1:ofa1Us9mdymBbGMY2XH/lSpY8itFsKIo/Aq8zwe+GHU= diff --git a/syncer/syncer.go b/syncer/syncer.go index ac842b2..5d7ec3f 100644 --- a/syncer/syncer.go +++ b/syncer/syncer.go @@ -29,7 +29,7 @@ type ChainManager interface { PoolTransaction(txid types.TransactionID) (types.Transaction, bool) AddPoolTransactions(txns []types.Transaction) error V2PoolTransaction(txid types.TransactionID) (types.V2Transaction, bool) - AddV2PoolTransactions(index types.ChainIndex, txns []types.V2Transaction) error + AddV2PoolTransactions(basis types.ChainIndex, txns []types.V2Transaction) error TransactionsForPartialBlock(missing []types.Hash256) ([]types.Transaction, []types.V2Transaction) } @@ -397,7 +397,7 @@ func (h *rpcHandler) RelayV2BlockOutline(bo gateway.V2BlockOutline, origin *gate h.s.relayV2BlockOutline(bo, origin) // non-blocking } -func (h *rpcHandler) RelayV2TransactionSet(index types.ChainIndex, txns []types.V2Transaction, origin *gateway.Peer) { +func (h *rpcHandler) RelayV2TransactionSet(basis types.ChainIndex, txns []types.V2Transaction, origin *gateway.Peer) { // if we've already seen these transactions, don't relay them again allSeen := true for _, txn := range txns { @@ -408,11 +408,18 @@ func (h *rpcHandler) RelayV2TransactionSet(index types.ChainIndex, txns []types. if allSeen { return } - if err := h.s.cm.AddV2PoolTransactions(index, txns); err != nil { + if _, ok := h.s.cm.Block(basis.ID); !ok { + h.s.log.Printf("peer %v relayed a v2 transaction set with unknown basis (%v); triggering a resync", origin, basis) + h.s.mu.Lock() + h.s.synced[origin.Addr] = false + h.s.mu.Unlock() + return + } + if err := h.s.cm.AddV2PoolTransactions(basis, txns); err != nil { h.s.log.Printf("received an invalid transaction set from %v: %v", origin, err) return } - h.s.relayV2TransactionSet(index, txns, origin) // non-blocking + h.s.relayV2TransactionSet(basis, txns, origin) // non-blocking } func (s *Syncer) ban(p *gateway.Peer, err error) {