Skip to content

Commit

Permalink
setting logs index and validate blockindex sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
billettc committed Nov 9, 2023
1 parent d65d6de commit 709df9b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
13 changes: 10 additions & 3 deletions cmd/fireeth/tools_compare_blocks_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,16 +309,23 @@ func toFirehoseTraces(in *rpc.BlockTransactions, logs []*rpc.LogEntry) (traces [
}
ordinal++

for _, log := range logs {
var prevBlockIndex *uint32
for li, log := range logs {
currentBlockIndex := log.ToLog().BlockIndex
if log.TransactionHash.String() == txHash {
out[i].Receipt.Logs = append(out[i].Receipt.Logs, &pbeth.Log{
Address: log.Address.Bytes(), //[]byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
Topics: hashesToBytes(log.Topics), //[][]byte `protobuf:"bytes,2,rep,name=topics,proto3" json:"topics,omitempty"`
Data: log.Data.Bytes(), //[]byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
BlockIndex: log.ToLog().BlockIndex, //uint32 `protobuf:"varint,6,opt,name=blockIndex,proto3" json:"blockIndex,omitempty"`
BlockIndex: currentBlockIndex, //uint32 `protobuf:"varint,6,opt,name=blockIndex,proto3" json:"blockIndex,omitempty"`
Ordinal: ordinal,
//Index: uint32(li),
Index: uint32(li),
})
if prevBlockIndex != nil && currentBlockIndex-1 != *prevBlockIndex {
panic(fmt.Errorf("block index mismatch: %d != %d", currentBlockIndex, *prevBlockIndex))
}

prevBlockIndex = &currentBlockIndex
ordinal++
}
}
Expand Down
32 changes: 21 additions & 11 deletions devel/merged-blocks-compare/compare-merged-blocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,28 @@ rm -f /tmp/merged-blocks-compare/*
mkdir -p /tmp/merged-blocks-compare

start_block=22207900
stop_block=22208000

v1File=$(process_block_range v1 $start_block $stop_block)
vPollerFile=$(process_block_range vPoller $start_block $stop_block)
current_block=$start_block
for i in $(seq 1 1000); do
current_stop_block=$((current_block + 100))

echo "Diffing $v1File and $vPollerFile"
echo "Processing block range $current_block:$current_stop_block"

d=$(diff -C0 "/tmp/merged-blocks-compare/$v1File" "/tmp/merged-blocks-compare/$vPollerFile")
v1File=$(process_block_range v1 $current_block $current_stop_block)
vPollerFile=$(process_block_range vPoller $current_block $current_stop_block)

echo "Diffing $v1File and $vPollerFile"

d=$(diff -C0 "/tmp/merged-blocks-compare/$v1File" "/tmp/merged-blocks-compare/$vPollerFile")

if [ -z "$d" ]; then
echo "No diff found!"
rm "/tmp/merged-blocks-compare/$v1File" "/tmp/merged-blocks-compare/$vPollerFile"
else
echo "Diff found!"
echo "$d" > "/tmp/merged-blocks-compare/$current_block-$current_stop_block.diff"
fi

current_block=$current_stop_block
done

if [ -z "$d" ]; then
echo "No diff found!"
else
echo "Diff found!"
echo "$d" > "/tmp/merged-blocks-compare/$start_block-$stop_block.diff"
fi

0 comments on commit 709df9b

Please sign in to comment.