From 0738bea6b262324f56e9c5b9c42c9fc4de900a36 Mon Sep 17 00:00:00 2001 From: arnaudberger Date: Fri, 26 Jan 2024 16:50:58 -0500 Subject: [PATCH] Handle rewards sorting and add bytes encoding flag --- cmd/firesol/block/upgrader.go | 16 ++++++++++++++-- devel/compare-bigTable-rpc-global.sh | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cmd/firesol/block/upgrader.go b/cmd/firesol/block/upgrader.go index 06f5e828..0158656d 100644 --- a/cmd/firesol/block/upgrader.go +++ b/cmd/firesol/block/upgrader.go @@ -15,6 +15,7 @@ import ( pbsol "github.com/streamingfast/firehose-solana/pb/sf/solana/type/v1" "github.com/streamingfast/logging" "go.uber.org/zap" + "golang.org/x/exp/slices" ) func NewBlockCmd(logger *zap.Logger, tracer logging.Tracer) *cobra.Command { @@ -68,7 +69,7 @@ func getMergedBlockUpgrader(rootLog *zap.Logger) func(cmd *cobra.Command, args [ Store: destStore, LowBlockNum: firecore.LowBoundary(start), StopBlockNum: stop, - TweakBlock: setParentBlockNumber, + TweakBlock: tweakBlock, Logger: rootLog, } blockStream := stream.New(nil, sourceStore, nil, int64(start), writer, stream.WithFinalBlocksOnly()) @@ -82,7 +83,7 @@ func getMergedBlockUpgrader(rootLog *zap.Logger) func(cmd *cobra.Command, args [ } } -func setParentBlockNumber(block *pbbstream.Block) (*pbbstream.Block, error) { +func tweakBlock(block *pbbstream.Block) (*pbbstream.Block, error) { b := &pbsol.Block{} err := block.Payload.UnmarshalTo(b) if err != nil { @@ -90,5 +91,16 @@ func setParentBlockNumber(block *pbbstream.Block) (*pbbstream.Block, error) { } block.ParentNum = b.ParentSlot + + slices.SortFunc(b.Rewards, func(a, b *pbsol.Reward) bool { + return a.Lamports > b.Lamports + }) + + err = block.Payload.MarshalFrom(b) + + if err != nil { + return nil, fmt.Errorf("marshaling solana block %d: %w", block.Number, err) + } + return block, nil } diff --git a/devel/compare-bigTable-rpc-global.sh b/devel/compare-bigTable-rpc-global.sh index 59bf48a4..c12e40ab 100755 --- a/devel/compare-bigTable-rpc-global.sh +++ b/devel/compare-bigTable-rpc-global.sh @@ -3,7 +3,7 @@ echo "STARTING GLOBAL COMPARING!" # Initialize these variables as needed runningTimes=10 -current_block=11690600 +current_block=131690600 eachNumberOfBlocks=10000000 stop_block=240000000 @@ -56,7 +56,7 @@ 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} --diff + firesol tools compare-blocks ${reference_storage} ${current_storage} ${range} --diff --bytes-encoding base58 } for i in $(seq 0 $runningTimes); do