nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: coinbase/rosetta-cli
Pull request #141 (2020-09-29 05:35:27)

Log Blocks Synced Per Second
![image](https://user-images.githubusercontent.com/13023275/94516440-a785e380-01da-11eb-9ab6-59fcd9f2f52a.png)

This PR prints the block syncing rate with other `check:data` metrics. This can be useful when tuning the `rosetta-cli` configuration.

### Changes
- [x] Log blocks synced per second when running `check:data`


Patch:
diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go
index 053f536..2d65bf8 100644
--- a/pkg/logger/logger.go
+++ b/pkg/logger/logger.go
@@ -34,6 +34,9 @@ import (
 var _ statefulsyncer.Logger = (*Logger)(nil)
 
 const (
+	// TimeElapsedCounter tracks the total time elapsed in seconds.
+	TimeElapsedCounter = "time_elapsed"
+
 	// blockStreamFile contains the stream of processed
 	// blocks and whether they were added or removed.
 	blockStreamFile = "blocks.txt"
@@ -107,6 +110,17 @@ func (l *Logger) LogDataStats(ctx context.Context) error {
 		return nil
 	}
 
+	elapsedTime, err := l.CounterStorage.Get(ctx, TimeElapsedCounter)
+	if err != nil {
+		return fmt.Errorf("%w cannot get elapsed time", err)
+	}
+
+	if elapsedTime.Sign() == 0 { // wait for at least some elapsed time
+		return nil
+	}
+
+	blocksPerSecond := new(big.Int).Div(blocks, elapsedTime)
+
 	orphans, err := l.CounterStorage.Get(ctx, storage.OrphanCounter)
 	if err != nil {
 		return fmt.Errorf("%w cannot get orphan counter", err)
@@ -133,9 +147,10 @@ func (l *Logger) LogDataStats(ctx context.Context) error {
 	}
 
 	statsMessage := fmt.Sprintf(
-		"[STATS] Blocks: %s (Orphaned: %s) Transactions: %s Operations: %s",
+		"[STATS] Blocks: %s (Orphaned: %s, Rate: %s/sec) Transactions: %s Operations: %s",
 		blocks.String(),
 		orphans.String(),
+		blocksPerSecond.String(),
 		txs.String(),
 		ops.String(),
 	)


Test patch:
diff --git a/pkg/tester/data.go b/pkg/tester/data.go
index 1003801..8387f72 100644
--- a/pkg/tester/data.go
+++ b/pkg/tester/data.go
@@ -19,6 +19,7 @@ import (
 	"errors"
 	"fmt"
 	"log"
+	"math/big"
 	"os"
 	"time"
 
@@ -49,16 +50,15 @@ const (
 	// until the client halts the search or the block is found).
 	InactiveFailureLookbackWindow = 250
 
+	// periodicLoggingSeconds is the frequency to print stats in seconds.
+	periodicLoggingSeconds = 10
+
 	// PeriodicLoggingFrequency is the frequency that stats are printed
 	// to the terminal.
-	//
-	// TODO: make configurable
-	PeriodicLoggingFrequency = 10 * time.Second
+	PeriodicLoggingFrequency = periodicLoggingSeconds * time.Second
 
 	// EndAtTipCheckInterval is the frequency that EndAtTip condition
 	// is evaludated
-	//
-	// TODO: make configurable
 	EndAtTipCheckInterval = 10 * time.Second
 )
 
@@ -357,6 +357,13 @@ func (t *DataTester) StartPeriodicLogger(
 
 			return ctx.Err()
 		case <-tc.C:
+			// Update the elapsed time in counter storage so that
+			// we can log metrics about the current check:data run.
+			_, _ = t.counterStorage.Update(
+				ctx,
+				logger.TimeElapsedCounter,
+				big.NewInt(periodicLoggingSeconds),
+			)
 			_ = t.logger.LogDataStats(ctx)
 		}
 	}
Repository: coinbase/rosetta-cli
Pull request #163 (2020-10-15 00:44:23)

[reconciler] Use buffered channels
Related: https://github.com/coinbase/rosetta-sdk-go/pull/187

This PR changes the `rosetta-cli` to use buffered channels for the reconciler.

### Changes
- [x] update rosetta-sdk-go
- [x] only exit reconciliation coverage end condition if last index is greater than min (protects against buffered channel backlog)


Patch:
diff --git a/go.mod b/go.mod
index dd9de39..041762d 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module github.com/coinbase/rosetta-cli
 go 1.13
 
 require (
-	github.com/coinbase/rosetta-sdk-go v0.5.2
+	github.com/coinbase/rosetta-sdk-go v0.5.3-0.20201015002757-978c228143a3
 	github.com/fatih/color v1.9.0
 	github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a
 	github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c
diff --git a/go.sum b/go.sum
index db9502e..6b1dbda 100644
--- a/go.sum
+++ b/go.sum
@@ -174,6 +174,8 @@ github.com/coinbase/rosetta-sdk-go v0.5.2-0.20201006190307-bf4606611446 h1:KbefW
 github.com/coinbase/rosetta-sdk-go v0.5.2-0.20201006190307-bf4606611446/go.mod h1:QVVeKHWFNb0NyzEY06LxXMAylJkYa7n+Hk03pORr0ws=
 github.com/coinbase/rosetta-sdk-go v0.5.2 h1:G91QWW0wrqmMhW2vJ4LP9P3gVukZs7df2Gf6FF1uff0=
 github.com/coinbase/rosetta-sdk-go v0.5.2/go.mod h1:QVVeKHWFNb0NyzEY06LxXMAylJkYa7n+Hk03pORr0ws=
+github.com/coinbase/rosetta-sdk-go v0.5.3-0.20201015002757-978c228143a3 h1:p8p0dVZDh/Zs35tzQq3nFftgFbphNvSzZ6dzLT31F7I=
+github.com/coinbase/rosetta-sdk-go v0.5.3-0.20201015002757-978c228143a3/go.mod h1:QVVeKHWFNb0NyzEY06LxXMAylJkYa7n+Hk03pORr0ws=
 github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
 github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
 github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=


Test patch:
diff --git a/pkg/tester/data.go b/pkg/tester/data.go
index a790b13..d8b8e9b 100644
--- a/pkg/tester/data.go
+++ b/pkg/tester/data.go
@@ -469,8 +469,27 @@ func (t *DataTester) EndReconciliationCoverage( // nolint:gocognit
 				}
 			}
 
+			// minIndex is the greater of firstTipIndex
+			// and reconciliationCoverage.Index
+			minIndex := firstTipIndex
+
 			// Check if at required minimum index
-			if reconciliationCoverage.Index != nil && *reconciliationCoverage.Index < blockIdentifier.Index {
+			if reconciliationCoverage.Index != nil {
+				if *reconciliationCoverage.Index < blockIdentifier.Index {
+					continue
+				}
+
+				// Override the firstTipIndex if reconciliationCoverage.Index
+				// is greater
+				if *reconciliationCoverage.Index > minIndex {
+					minIndex = *reconciliationCoverage.Index
+				}
+			}
+
+			// Check if all accounts reconciled at index (+1). If last index reconciled
+			// is less than the minimum allowed index but the QueueSize is 0, then
+			// we consider the reconciler to be caught up.
+			if t.reconciler.LastIndexReconciled() <= minIndex && t.reconciler.QueueSize() > 0 {
 				continue
 			}
Repository: coinbase/rosetta-cli
Pull request #362 (2022-09-19 19:54:47)

Decouple pruning configurations
Signed-off-by: Jingfu Wang <jingfu.wang@coinbase.com>

Decouple pruning configurations

### Motivation
<!--
Does this solve a bug? Enable a new use-case? Improve an existing behavior? Concrete examples are helpful here.
-->

### Solution
<!--
What is the solution here from a high level. What are the key technical decisions and why were they made?
-->

### Open questions
<!--
(optional) Any open questions or feedback on design desired?
-->



Patch:
diff --git a/configuration/types.go b/configuration/types.go
index 82afa7b..e1ad000 100644
--- a/configuration/types.go
+++ b/configuration/types.go
@@ -321,11 +321,15 @@ type DataConfiguration struct {
 	// the results of a check:data run.
 	ResultsOutputFile string `json:"results_output_file"`
 
-	// PruningDisabled is a bolean that indicates storage pruning should
+	// PruningBlockDisabled is a boolean that indicates storage pruning should
 	// not be attempted. This should really only ever be set to true if you
 	// wish to use `start_index` at a later point to restart from some
 	// previously synced block.
-	PruningDisabled bool `json:"pruning_disabled"`
+	PruningBlockDisabled bool `json:"pruning_block_disabled"`
+
+	// PruningBalanceDisabled is a boolean that indicates balance pruning
+	// should not be attempted.
+	PruningBalanceDisabled bool `json:"pruning_balance_disabled"`
 
 	// PruningFrequency is the frequency (in seconds) that we attempt
 	// to prune blocks. If not populated, we use the default value
diff --git a/examples/configuration/default.json b/examples/configuration/default.json
index c2ca45a..355e334 100644
--- a/examples/configuration/default.json
+++ b/examples/configuration/default.json
@@ -38,7 +38,8 @@
   "coin_tracking_disabled": false,
   "status_port": 9090,
   "results_output_file": "",
-  "pruning_disabled": false,
+  "pruning_block_disabled": false,
+  "pruning_balance_disabled": false,
   "initial_balance_fetch_disabled": false
  },
  "perf": null
diff --git a/pkg/processor/reconciler_helper.go b/pkg/processor/reconciler_helper.go
index dd50c76..a87fbc2 100644
--- a/pkg/processor/reconciler_helper.go
+++ b/pkg/processor/reconciler_helper.go
@@ -154,7 +154,7 @@ func (h *ReconcilerHelper) PruneBalances(
 	currency *types.Currency,
 	index int64,
 ) error {
-	if h.config.Data.PruningDisabled {
+	if h.config.Data.PruningBalanceDisabled {
 		return nil
 	}
 


Test patch:
diff --git a/pkg/tester/data.go b/pkg/tester/data.go
index e258469..dcaec8d 100644
--- a/pkg/tester/data.go
+++ b/pkg/tester/data.go
@@ -443,7 +443,7 @@ func (t *DataTester) StartSyncing(
 func (t *DataTester) StartPruning(
 	ctx context.Context,
 ) error {
-	if t.config.Data.PruningDisabled {
+	if t.config.Data.PruningBlockDisabled {
 		return nil
 	}
Repository: softwaremill/jox
Pull request #61 (2024-09-04 10:33:10)

Short-circuit select if there's any error


Patch:
diff --git a/channels/src/main/java/com/softwaremill/jox/Select.java b/channels/src/main/java/com/softwaremill/jox/Select.java
index ded6e1a..34587bf 100644
--- a/channels/src/main/java/com/softwaremill/jox/Select.java
+++ b/channels/src/main/java/com/softwaremill/jox/Select.java
@@ -100,6 +100,13 @@ public class Select {
 
     @SafeVarargs
     private static <U> Object doSelectOrClosed(SelectClause<? extends U>... clauses) throws InterruptedException {
+        // short-circuiting if any of the channels is in error; otherwise, we might have selected a clause, for which
+        // a value was available immediately - even though a channel for a clause appearing later was in error
+        var anyError = getAnyChannelInError(clauses);
+        if (anyError != null) {
+            return anyError;
+        }
+
         // check that the clause doesn't refer to a channel that is already used in a different clause
         var allRendezvous = verifyChannelsUnique_getAreAllRendezvous(clauses);
 
@@ -132,6 +139,20 @@ public class Select {
         return allRendezvous;
     }
 
+    private static ChannelError getAnyChannelInError(SelectClause<?>[] clauses) {
+        for (var clause : clauses) {
+            var ch = clause.getChannel();
+            if (ch != null) {
+                // if a channel is in error, closedForSend() will return that information
+                var closedForSend = clause.getChannel().closedForSend();
+                if (closedForSend instanceof ChannelError ce) {
+                    return ce;
+                }
+            }
+        }
+        return null;
+    }
+
     public static <T> SelectClause<T> defaultClause(T value) {
         return defaultClause(() -> value);
     }


Test patch:
diff --git a/channels/src/test/java/com/softwaremill/jox/SelectReceiveTest.java b/channels/src/test/java/com/softwaremill/jox/SelectReceiveTest.java
index af9541b..d41ec5b 100644
--- a/channels/src/test/java/com/softwaremill/jox/SelectReceiveTest.java
+++ b/channels/src/test/java/com/softwaremill/jox/SelectReceiveTest.java
@@ -222,4 +222,21 @@ public class SelectReceiveTest {
     void testSelectFromNone() throws InterruptedException {
         assertEquals(new ChannelDone(), selectOrClosed());
     }
+
+    @Test
+    public void testSelect_immediate_withError() throws InterruptedException {
+        // given
+        Channel<String> ch1 = new Channel<>(2);
+        ch1.send("x");
+
+        var e = new RuntimeException("boom!");
+        Channel<String> ch2 = new Channel<>(2);
+        ch2.error(e);
+
+        // when
+        var result = selectOrClosed(ch1.receiveClause(), ch2.receiveClause());
+
+        // then
+        assertEquals(new ChannelError(e), result);
+    }
 }