difforacle

package
v0.0.0-...-29d77a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package difforacle implements the differential serialization fuzzer.

The oracle subprocess (C++ binary) serializes FDB messages using the real C++ ObjectWriter. We compare its output byte-for-byte against Go's MarshalFDB to catch wire-format divergences.

This package is built as a Go library + fuzz test only — the runnable binary is the C++ diff-oracle (the //cmd/fdb-diff-oracle:diff_oracle_bin genrule), so there is intentionally no func main here. It lives under cmd/ for proximity to its cpp/ sibling, not because it is a Go binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConflictRange

type ConflictRange struct {
	Begin []byte
	End   []byte
}

ConflictRange represents a key range for conflict detection.

type Mutation

type Mutation struct {
	Type   uint8
	Param1 []byte
	Param2 []byte
}

Mutation represents a single mutation for CommitTransactionRequest.

type Oracle

type Oracle struct {
	// contains filtered or unexported fields
}

Oracle wraps the C++ diff-oracle subprocess. It is NOT safe for concurrent use — the binary protocol over stdin/stdout is inherently sequential.

func NewOracle

func NewOracle(binaryPath string) (*Oracle, error)

NewOracle starts the C++ oracle subprocess. The binaryPath should point to the compiled diff-oracle binary (built via build.sh).

func (*Oracle) Close

func (o *Oracle) Close() error

Close shuts down the oracle subprocess.

func (*Oracle) SerializeClientDBInfo

func (o *Oracle) SerializeClientDBInfo(
	grvProxies, commitProxies []byte,
	id [16]byte,
	hasForward bool, forward []byte,
	history []byte,
	hasEncryptKeyProxy bool, encryptKeyProxy []byte,
	clusterId [16]byte, clusterType int32,
	hasMetaclusterName bool, metaclusterName []byte,
) ([]byte, error)

SerializeClientDBInfo sends a ClientDBInfo to the oracle.

func (*Oracle) SerializeCommitID

func (o *Oracle) SerializeCommitID(
	version int64, txnBatchId uint16,
	hasMetadataVersion bool, metadataVersion []byte,
	hasConflictingKRIndices bool, conflictingKRIndices []byte,
) ([]byte, error)

SerializeCommitID sends a CommitID to the oracle.

func (*Oracle) SerializeCommitTransactionRequest

func (o *Oracle) SerializeCommitTransactionRequest(
	readSnapshot int64,
	mutations []Mutation,
	readConflictRanges, writeConflictRanges []ConflictRange,
	flags uint32,
	hasDebugID bool, debugID []byte,
	hasCommitCostEstimation bool, commitCostEstimation []byte,
	hasTagSet bool, tagSet []byte,
	tenantId int64,
	idempotencyId []byte,
) ([]byte, error)

SerializeCommitTransactionRequest sends a CommitTransactionRequest to the oracle.

func (*Oracle) SerializeEndpoint

func (o *Oracle) SerializeEndpoint(
	ipAddr uint32, port, flags uint16, fromHostname bool,
	token [16]byte,
) ([]byte, error)

SerializeEndpoint sends an Endpoint to the oracle.

func (*Oracle) SerializeError

func (o *Oracle) SerializeError(errorCode uint16) ([]byte, error)

SerializeError sends an Error to the oracle.

func (*Oracle) SerializeGetKeyReply

func (o *Oracle) SerializeGetKeyReply(
	penalty float64,
	hasError bool, errorData []byte,
	cached bool,
) ([]byte, error)

SerializeGetKeyReply sends a GetKeyReply to the oracle.

func (*Oracle) SerializeGetKeyRequest

func (o *Oracle) SerializeGetKeyRequest(
	selKey []byte, selOrEqual bool, selOffset int32,
	version int64,
	hasTags bool, tags []byte,
	tenantId int64,
	hasOptions bool,
	ssLatestCommitVersions []byte,
	field10 []byte,
) ([]byte, error)

SerializeGetKeyRequest sends a GetKeyRequest to the oracle.

func (*Oracle) SerializeGetKeyServerLocationsReply

func (o *Oracle) SerializeGetKeyServerLocationsReply(
	results, resultsTssMapping, resultsTagMapping []byte,
) ([]byte, error)

SerializeGetKeyServerLocationsReply sends a GetKeyServerLocationsReply to the oracle.

func (*Oracle) SerializeGetKeyServerLocationsRequest

func (o *Oracle) SerializeGetKeyServerLocationsRequest(
	begin []byte, hasEnd bool, end []byte,
	limit int32, reverse bool,
	tenantId, minTenantVersion int64,
) ([]byte, error)

SerializeGetKeyServerLocationsRequest sends a GetKeyServerLocationsRequest to the oracle.

func (*Oracle) SerializeGetKeyValuesReply

func (o *Oracle) SerializeGetKeyValuesReply(
	penalty float64,
	hasError bool, errorData []byte,
	data []byte, version int64,
	more, cached bool,
) ([]byte, error)

SerializeGetKeyValuesReply sends a GetKeyValuesReply to the oracle.

func (*Oracle) SerializeGetKeyValuesRequest

func (o *Oracle) SerializeGetKeyValuesRequest(
	beginKey []byte, beginOrEqual bool, beginOffset int32,
	endKey []byte, endOrEqual bool, endOffset int32,
	version int64, limit, limitBytes int32,
	hasTags bool, tags []byte,
	tenantId int64,
	hasOptions bool,
	ssLatestCommitVersions []byte,
) ([]byte, error)

SerializeGetKeyValuesRequest sends a GetKeyValuesRequest to the oracle.

func (*Oracle) SerializeGetReadVersionReply

func (o *Oracle) SerializeGetReadVersionReply(
	processBusyTime int32, version int64, locked bool,
	hasMetadataVersion bool, metadataVersion []byte,
	tagThrottleInfo []byte, midShardSize int64,
	rkDefaultThrottled, rkBatchThrottled bool,
	ssVersionVectorDelta []byte,
	proxyId [16]byte, proxyTagThrottledDuration float64,
) ([]byte, error)

SerializeGetReadVersionReply sends a GetReadVersionReply to the oracle.

func (*Oracle) SerializeGetReadVersionRequest

func (o *Oracle) SerializeGetReadVersionRequest(
	transactionCount, flags uint32,
	hasTags bool, tags []byte,
	hasDebugID bool, debugID []byte,
	maxVersion int64,
) ([]byte, error)

SerializeGetReadVersionRequest sends a GetReadVersionRequest to the oracle.

func (*Oracle) SerializeGetValueReply

func (o *Oracle) SerializeGetValueReply(
	penalty float64,
	hasError bool, errorData []byte,
	hasValue bool, value []byte,
	cached bool,
) ([]byte, error)

SerializeGetValueReply sends a GetValueReply to the oracle.

func (*Oracle) SerializeGetValueRequest

func (o *Oracle) SerializeGetValueRequest(
	key []byte, version int64,
	hasTags bool, tags []byte,
	tenantId int64,
	hasOptions bool,
	ssLatestCommitVersions []byte,
) ([]byte, error)

SerializeGetValueRequest sends a GetValueRequest to the oracle.

func (*Oracle) SerializeNetworkAddress

func (o *Oracle) SerializeNetworkAddress(
	ipAddr uint32, port, flags uint16, fromHostname bool,
) ([]byte, error)

SerializeNetworkAddress sends a NetworkAddress to the oracle.

func (*Oracle) SerializeNetworkAddressV6

func (o *Oracle) SerializeNetworkAddressV6(
	ip16 [16]byte, port, flags uint16, fromHostname bool,
) ([]byte, error)

SerializeNetworkAddressV6 sends an IPv6 NetworkAddress to the oracle (16-byte address), exercising the IPAddress variant tag=2 (count-prefixed vector) marshal path.

func (*Oracle) SerializeOpenDatabaseCoordRequest

func (o *Oracle) SerializeOpenDatabaseCoordRequest(
	issues, supportedVersions, traceLogGroup []byte,
	knownClientInfoID [16]byte,
	clusterKey, coordinators, hostnames []byte,
	internal bool,
) ([]byte, error)

SerializeOpenDatabaseCoordRequest sends an OpenDatabaseCoordRequest to the oracle.

func (*Oracle) SerializeReadOptions

func (o *Oracle) SerializeReadOptions(
	roType int32, cacheResult bool,
	hasDebugID bool, debugID [16]byte,
	hasCCSV bool, ccsv int64,
	lockAware bool,
) ([]byte, error)

SerializeReadOptions sends a ReadOptions (carried inside a GetValueRequest with key="ro") to the oracle. Exercises RFC-117's Optional<Version> consistencyCheckStartVersion + the sibling Optional<UID> debugID + lockAware. The field order matches the C++ handleReadOptions.

func (*Oracle) SerializeReplyPromise

func (o *Oracle) SerializeReplyPromise(token [16]byte) ([]byte, error)

SerializeReplyPromise sends a ReplyPromise to the oracle.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL