Skip to content

Commit

Permalink
Handle rewards sorting and add bytes encoding flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBger committed Jan 26, 2024
1 parent a964565 commit 0738bea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 14 additions & 2 deletions cmd/firesol/block/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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())
Expand All @@ -82,13 +83,24 @@ 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 {
return nil, fmt.Errorf("unmarshaling solana block %d: %w", block.Number, err)
}

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
}
4 changes: 2 additions & 2 deletions devel/compare-bigTable-rpc-global.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0738bea

Please sign in to comment.