Skip to content

Commit

Permalink
Adding global comaparing BigT vs rpcs merged blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBger committed Jan 19, 2024
1 parent b2d114e commit b920f0b
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 11 deletions.
4 changes: 3 additions & 1 deletion block/fetcher/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,13 @@ func compileInstructionsToPbInnerInstructionArray(instructions []solana.Compiled
accounts = append(accounts, byte(account))
}

stackHeight := compiledInstruction.StackHeight

out = append(out, &pbsol.InnerInstruction{
ProgramIdIndex: uint32(compiledInstruction.ProgramIDIndex),
Accounts: accounts,
Data: compiledInstruction.Data,
StackHeight: &compiledInstruction.StackHeight, //not return by the rpc endpoint getBlockCall
StackHeight: &stackHeight,
})
}
return
Expand Down
19 changes: 19 additions & 0 deletions cmd/firesol/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import (
"fmt"
"os"

"github.com/streamingfast/firehose-core/cmd/tools"

Check failure on line 7 in cmd/firesol/main.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

github.com/streamingfast/[email protected]: replacement directory ../firehose-core does not exist

firecore "github.com/streamingfast/firehose-core"

Check failure on line 9 in cmd/firesol/main.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

github.com/streamingfast/[email protected]: replacement directory ../firehose-core does not exist
"github.com/streamingfast/firehose-core/cmd/tools/compare"

Check failure on line 10 in cmd/firesol/main.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

github.com/streamingfast/[email protected]: replacement directory ../firehose-core does not exist
pbsol "github.com/streamingfast/firehose-solana/pb/sf/solana/type/v1"

"github.com/spf13/cobra"
"github.com/streamingfast/firehose-solana/cmd/firesol/rpc"
"github.com/streamingfast/logging"
Expand All @@ -19,9 +25,22 @@ var rootCmd = &cobra.Command{
func init() {
logging.InstantiateLoggers(logging.WithDefaultLevel(zap.InfoLevel))
rootCmd.AddCommand(newFetchCmd(logger, tracer))
chain := &firecore.Chain[*pbsol.Block]{
//ShortName: "sol",
//LongName: "Solana",
//ExecutableName: "firesol",
//FullyQualifiedModule: "github.com/streamingfast/firehose-solana",
//Protocol: "SOL",
//ProtocolVersion: 1,
BlockFactory: func() firecore.Block { return new(pbsol.Block) },
}

rootCmd.AddCommand(tools.ToolsCmd)
tools.ToolsCmd.AddCommand(compare.NewToolsCompareBlocksCmd(chain))
}

func main() {

if err := rootCmd.Execute(); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Whoops. There was an error while executing your CLI '%s'", err)
os.Exit(1)
Expand Down
57 changes: 57 additions & 0 deletions devel/compare-bigTable-rpc-global.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
echo "STARTING GLOBAL COMPARING!"

# Initialize these variables as needed
runningTimes=10
current_block=200000000
eachNumberOfBlocks=1000000
stop_block=240000000
rpc_endpoint="https://frequent-sparkling-hill.solana-mainnet.quiknode.pro/ff194d392c35948e3ef04003d141cda78dbf9733/"
reference_storage="gs://dfuseio-global-blocks-uscentral/sol-mainnet/v1?project=dfuseio-global"
current_storage="file:///Users/arnaudberger/t/data/storage/merged-blocks"
function fetch_rpc_blocks_for_range() {
local rpc_endpoint=$1
local start_block=$2
rm -rf ~/t/data/

firecore start reader-node merger -c "" --data-dir=/Users/arnaudberger/t/data --reader-node-data-dir=/Users/arnaudberger/t/data --reader-node-path=firesol --reader-node-arguments="fetch rpc ${rpc_endpoint} ${start_block} --state-dir /Users/arnaudberger/t/data" --common-first-streamable-block=${start_block} > ~/t/firecore_output.txt 2>&1 &
local firecore_pid=$!

tail -f ~/t/firecore_output.txt | while read -r line; do
echo "$line"
if [[ "$line" == *"merged and uploaded"* ]]; then
kill $firecore_pid
break
fi
done

# Clean up
rm ~/t/firecore_output.txt
}

function compare_reference_rpc_for_range() {
local range=$1
local reference_storage=$2
local current_storage=$3
firesol tools compare-blocks ${reference_storage} ${current_storage} ${range} --ignore-error-when-JSON-matches --diff
}

for i in $(seq 1 $runningTimes); do
current_start_block=$((current_block + eachNumberOfBlocks * i))
current_stop_block=$((current_start_block + 100))

block_range="${current_start_block}:${current_stop_block}"

echo "Fetching blocks from rpc for range $block_range"
fetch_rpc_blocks_for_range "$rpc_endpoint" "$current_start_block"

echo "Comparing merged rpc blocks for range $block_range with reference blocks"
compare_reference_rpc_for_range "$block_range" "$reference_storage" "$current_storage"

# Break the loop if the end of the block range is reached
if [ $current_stop_block -eq $stop_block ]; then
break
fi

echo "COMPARING SUCCESSFULLY FINISHED FOR RANGE $block_range"
done
2 changes: 1 addition & 1 deletion devel/compare-merged-blocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function process_block_range() {
# local block_range="$start_block:$stop_block"
local block_range="$start_block"

firecore tools print merged-blocks "/Users/cbillett/t/data/storage/merged-blocks" "$block_range" -o jsonl > "/tmp/merged-blocks-compare/$output_file"
firecore tools print merged-blocks "/Users/arnaudberger/t/data/storage/merged-blocks" "$block_range" -o jsonl > "/tmp/merged-blocks-compare/$output_file"

echo "$output_file"
}
Expand Down
14 changes: 11 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/mr-tron/base58 v1.2.0
github.com/spf13/cobra v1.7.0
github.com/streamingfast/binary v0.0.0-20240116152459-ebe30de95370
github.com/streamingfast/bstream v0.0.2-0.20231211192436-01f6a005b0e4
github.com/streamingfast/bstream v0.0.2-0.20240118123300-2bc69dde3598
github.com/streamingfast/cli v0.0.4-0.20230825151644-8cc84512cd80
github.com/streamingfast/firehose-core v1.0.1-0.20240109054458-3f1edeff522c
github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091
Expand Down Expand Up @@ -66,8 +66,11 @@ require (
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gagliardetto/binary v0.7.7 // indirect
github.com/gagliardetto/treeout v0.1.4 // indirect
github.com/go-json-experiment/json v0.0.0-20231013223334-54c864be5b8d // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
Expand All @@ -86,6 +89,8 @@ require (
github.com/ipfs/go-ipfs-api v0.6.0 // indirect
github.com/jhump/protoreflect v1.14.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josephburnett/jd v1.7.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.3 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
Expand All @@ -94,6 +99,7 @@ require (
github.com/lithammer/dedent v1.1.0 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-ieproxy v0.0.1 // indirect
Expand All @@ -105,6 +111,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mostynb/go-grpc-compression v1.1.17 // indirect
github.com/mostynb/zstdpool-freelist v0.0.0-20201229113212-927304c0c3b1 // indirect
github.com/mschoch/smat v0.2.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
Expand Down Expand Up @@ -145,10 +152,11 @@ require (
github.com/streamingfast/dmetrics v0.0.0-20230919161904-206fa8ebd545 // indirect
github.com/streamingfast/dstore v0.1.1-0.20230620124109-3924b3b36c77 // indirect
github.com/streamingfast/dtracing v0.0.0-20220305214756-b5c0e8699839 // indirect
github.com/streamingfast/jsonpb v0.0.0-20210811021341-3670f0aa02d0 // indirect
github.com/streamingfast/opaque v0.0.0-20210811180740-0c01d37ea308 // indirect
github.com/streamingfast/pbgo v0.0.6-0.20231208140754-ed2bd10b96ee // indirect
github.com/streamingfast/shutter v1.5.0 // indirect
github.com/streamingfast/substreams v1.2.1-0.20231221200849-a355c5063d0c // indirect
github.com/streamingfast/substreams v1.3.2-0.20240119045851-7de579a236d2 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/teris-io/shortid v0.0.0-20201117134242-e59966efd125 // indirect
Expand Down Expand Up @@ -196,5 +204,5 @@ replace (
github.com/gagliardetto/solana-go => github.com/streamingfast/gagliardetto-solana-go v0.0.0-20240115191424-05c37cd0760d
github.com/graph-gophers/graphql-go => github.com/streamingfast/graphql-go v0.0.0-20210204202750-0e485a040a3c
github.com/jhump/protoreflect => github.com/streamingfast/protoreflect v0.0.0-20231205191344-4b629d20ce8d

github.com/streamingfast/firehose-core => ../firehose-core
)
Loading

0 comments on commit b920f0b

Please sign in to comment.