From 3e6d7c169b23b3aa95fe0e2f1cbfb3501015af57 Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Fri, 27 Oct 2017 09:40:52 +0100 Subject: [PATCH 1/4] cmd/rlpdump: allow hex input to have leading '0x' --- cmd/rlpdump/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/rlpdump/main.go b/cmd/rlpdump/main.go index 7d328e59b3..d0f993c5b8 100644 --- a/cmd/rlpdump/main.go +++ b/cmd/rlpdump/main.go @@ -51,7 +51,7 @@ func main() { var r io.Reader switch { case *hexMode != "": - data, err := hex.DecodeString(*hexMode) + data, err := hex.DecodeString(strings.TrimPrefix(*hexMode, "0x")) if err != nil { die(err) } From 8d434f6a6f18c5172db9a8216d61cd50b746c964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felf=C3=B6ldi=20Zsolt?= Date: Fri, 27 Oct 2017 16:18:53 +0200 Subject: [PATCH 2/4] les, core/bloombits: post-LES/2 fixes (#15391) * les: fix topic ID * core/bloombits: fix interface conversion --- core/bloombits/matcher.go | 5 ++++- les/backend.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/bloombits/matcher.go b/core/bloombits/matcher.go index a75f8c0859..d38d4ba83e 100644 --- a/core/bloombits/matcher.go +++ b/core/bloombits/matcher.go @@ -534,7 +534,10 @@ func (s *MatcherSession) Close() { // Error returns any failure encountered during the matching session. func (s *MatcherSession) Error() error { - return s.err.Load().(error) + if err := s.err.Load(); err != nil { + return err.(error) + } + return nil } // AllocateRetrieval assigns a bloom bit index to a client process that can either diff --git a/les/backend.go b/les/backend.go index 3a68d13ebe..333df920e0 100644 --- a/les/backend.go +++ b/les/backend.go @@ -145,7 +145,7 @@ func lesTopic(genesisHash common.Hash, protocolVersion uint) discv5.Topic { default: panic(nil) } - return discv5.Topic(name + common.Bytes2Hex(genesisHash.Bytes()[0:8])) + return discv5.Topic(name + "@" + common.Bytes2Hex(genesisHash.Bytes()[0:8])) } type LightDummyAPI struct{} From 07e8c177e7f1cceadc70709946aa24777b4bf2af Mon Sep 17 00:00:00 2001 From: ferhat elmas Date: Mon, 30 Oct 2017 01:23:23 +0100 Subject: [PATCH 3/4] core, swarm: typo fixes --- core/tx_journal.go | 2 +- swarm/api/http/error.go | 2 +- swarm/api/http/error_test.go | 2 +- swarm/storage/pyramid.go | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/tx_journal.go b/core/tx_journal.go index 3fd8ece49e..e872d7b530 100644 --- a/core/tx_journal.go +++ b/core/tx_journal.go @@ -68,7 +68,7 @@ func (journal *txJournal) load(add func(*types.Transaction) error) error { } defer input.Close() - // Temporarilly discard any journal additions (don't double add on load) + // Temporarily discard any journal additions (don't double add on load) journal.writer = new(devNull) defer func() { journal.writer = nil }() diff --git a/swarm/api/http/error.go b/swarm/api/http/error.go index b4d46b3c48..dbd97182fd 100644 --- a/swarm/api/http/error.go +++ b/swarm/api/http/error.go @@ -72,7 +72,7 @@ func initErrHandling() { //ShowMultipeChoices is used when a user requests a resource in a manifest which results //in ambiguous results. It returns a HTML page with clickable links of each of the entry //in the manifest which fits the request URI ambiguity. -//For example, if the user requests bzz://read and that manifest containes entries +//For example, if the user requests bzz://read and that manifest contains entries //"readme.md" and "readinglist.txt", a HTML page is returned with this two links. //This only applies if the manifest has no default entry func ShowMultipleChoices(w http.ResponseWriter, r *http.Request, list api.ManifestList) { diff --git a/swarm/api/http/error_test.go b/swarm/api/http/error_test.go index 465fbf4cad..ed52bafbd2 100644 --- a/swarm/api/http/error_test.go +++ b/swarm/api/http/error_test.go @@ -132,7 +132,7 @@ func TestJsonResponse(t *testing.T) { } if !isJSON(string(respbody)) { - t.Fatalf("Expected repsonse to be JSON, received invalid JSON: %s", string(respbody)) + t.Fatalf("Expected response to be JSON, received invalid JSON: %s", string(respbody)) } } diff --git a/swarm/storage/pyramid.go b/swarm/storage/pyramid.go index e3be2a987f..631ab52b86 100644 --- a/swarm/storage/pyramid.go +++ b/swarm/storage/pyramid.go @@ -27,7 +27,7 @@ import ( /* The main idea of a pyramid chunker is to process the input data without knowing the entire size apriori. For this to be achieved, the chunker tree is built from the ground up until the data is exhausted. - This opens up new aveneus such as easy append and other sort of modifications to the tree therby avoiding + This opens up new aveneus such as easy append and other sort of modifications to the tree thereby avoiding duplication of data chunks. @@ -451,7 +451,7 @@ func (self *PyramidChunker) prepareChunks(isAppend bool, chunkLevel [][]*TreeEnt } } - // Data ended in chunk boundry.. just signal to start bulding tree + // Data ended in chunk boundary.. just signal to start bulding tree if n == 0 { self.buildTree(isAppend, chunkLevel, parent, chunkWG, jobC, quitC, true, rootKey) break From 0131bd6ff9b1850fdd307715c62174af4f05d2c7 Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Mon, 30 Oct 2017 11:05:00 +0000 Subject: [PATCH 4/4] core: respect price bump threshold (#15401) * core: allow price bump at threshold * core: test changes to allow price bump at threshold * core: reinstate tx replacement test underneath threshold * core: minor test failure message cleanups --- core/tx_list.go | 5 ++++- core/tx_pool_test.go | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/core/tx_list.go b/core/tx_list.go index 2935929d72..838433b897 100644 --- a/core/tx_list.go +++ b/core/tx_list.go @@ -254,7 +254,10 @@ func (l *txList) Add(tx *types.Transaction, priceBump uint64) (bool, *types.Tran old := l.txs.Get(tx.Nonce()) if old != nil { threshold := new(big.Int).Div(new(big.Int).Mul(old.GasPrice(), big.NewInt(100+int64(priceBump))), big.NewInt(100)) - if threshold.Cmp(tx.GasPrice()) >= 0 { + // Have to ensure that the new gas price is higher than the old gas + // price as well as checking the percentage threshold to ensure that + // this is accurate for low (Wei-level) gas price replacements + if old.GasPrice().Cmp(tx.GasPrice()) >= 0 || threshold.Cmp(tx.GasPrice()) > 0 { return false, nil } } diff --git a/core/tx_pool_test.go b/core/tx_pool_test.go index eec128cbaf..737ea4cd39 100644 --- a/core/tx_pool_test.go +++ b/core/tx_pool_test.go @@ -1411,10 +1411,10 @@ func TestTransactionReplacement(t *testing.T) { if err := pool.AddRemote(pricedTransaction(0, big.NewInt(100000), big.NewInt(price), key)); err != nil { t.Fatalf("failed to add original proper pending transaction: %v", err) } - if err := pool.AddRemote(pricedTransaction(0, big.NewInt(100000), big.NewInt(threshold), key)); err != ErrReplaceUnderpriced { + if err := pool.AddRemote(pricedTransaction(0, big.NewInt(100001), big.NewInt(threshold-1), key)); err != ErrReplaceUnderpriced { t.Fatalf("original proper pending transaction replacement error mismatch: have %v, want %v", err, ErrReplaceUnderpriced) } - if err := pool.AddRemote(pricedTransaction(0, big.NewInt(100000), big.NewInt(threshold+1), key)); err != nil { + if err := pool.AddRemote(pricedTransaction(0, big.NewInt(100000), big.NewInt(threshold), key)); err != nil { t.Fatalf("failed to replace original proper pending transaction: %v", err) } if err := validateEvents(events, 2); err != nil { @@ -1422,23 +1422,23 @@ func TestTransactionReplacement(t *testing.T) { } // Add queued transactions, ensuring the minimum price bump is enforced for replacement (for ultra low prices too) if err := pool.AddRemote(pricedTransaction(2, big.NewInt(100000), big.NewInt(1), key)); err != nil { - t.Fatalf("failed to add original queued transaction: %v", err) + t.Fatalf("failed to add original cheap queued transaction: %v", err) } if err := pool.AddRemote(pricedTransaction(2, big.NewInt(100001), big.NewInt(1), key)); err != ErrReplaceUnderpriced { - t.Fatalf("original queued transaction replacement error mismatch: have %v, want %v", err, ErrReplaceUnderpriced) + t.Fatalf("original cheap queued transaction replacement error mismatch: have %v, want %v", err, ErrReplaceUnderpriced) } if err := pool.AddRemote(pricedTransaction(2, big.NewInt(100000), big.NewInt(2), key)); err != nil { - t.Fatalf("failed to replace original queued transaction: %v", err) + t.Fatalf("failed to replace original cheap queued transaction: %v", err) } if err := pool.AddRemote(pricedTransaction(2, big.NewInt(100000), big.NewInt(price), key)); err != nil { - t.Fatalf("failed to add original queued transaction: %v", err) + t.Fatalf("failed to add original proper queued transaction: %v", err) } - if err := pool.AddRemote(pricedTransaction(2, big.NewInt(100001), big.NewInt(threshold), key)); err != ErrReplaceUnderpriced { - t.Fatalf("original queued transaction replacement error mismatch: have %v, want %v", err, ErrReplaceUnderpriced) + if err := pool.AddRemote(pricedTransaction(2, big.NewInt(100001), big.NewInt(threshold-1), key)); err != ErrReplaceUnderpriced { + t.Fatalf("original proper queued transaction replacement error mismatch: have %v, want %v", err, ErrReplaceUnderpriced) } - if err := pool.AddRemote(pricedTransaction(2, big.NewInt(100000), big.NewInt(threshold+1), key)); err != nil { - t.Fatalf("failed to replace original queued transaction: %v", err) + if err := pool.AddRemote(pricedTransaction(2, big.NewInt(100000), big.NewInt(threshold), key)); err != nil { + t.Fatalf("failed to replace original proper queued transaction: %v", err) } if err := validateEvents(events, 0); err != nil {