dealpusher

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0, MIT Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const PDPDealEpochSentinel = int32(math.MaxInt32)

Variables

View Source
var Logger = log.Logger("dealpusher")

Functions

This section is empty.

Types

type DDOBalanceStatus added in v1.0.0

type DDOBalanceStatus struct {
	WalletAddr     common.Address
	NativeFIL      *big.Int // native FIL balance (for gas)
	TokenBalance   *big.Int // payment token balance held in wallet
	DepositedFunds *big.Int // funds already deposited in payments contract
	LockupCurrent  *big.Int // current lockup in payments contract
	Available      *big.Int // deposited - lockup (spendable for new deals)
}

DDOBalanceStatus summarizes a wallet's balance state for DDO deal-making.

type DDODealManager added in v1.0.0

type DDODealManager interface {
	// ValidateSP checks that the provider is registered and active in the
	// DDO contract, and returns its on-chain config.
	ValidateSP(ctx context.Context, providerActorID uint64) (*DDOSPConfig, error)

	// CheckBalance queries the wallet's native FIL and payment token balances,
	// as well as the payments contract account status. Returns a summary that
	// the scheduler uses for pre-flight logging and low-balance warnings.
	CheckBalance(ctx context.Context, walletAddr common.Address) (*DDOBalanceStatus, error)

	// EnsurePayments checks account balance and operator approval, deposits
	// and approves if needed. Takes the actual pieces (not aggregated totals)
	// because the SDK computes per-piece lockup: allocationLockupAmount * len(pieces).
	EnsurePayments(ctx context.Context, evmSigner signer.EVMSigner,
		pieces []DDOPieceSubmission, cfg DDOSchedulingConfig) error

	// CreateAllocations submits a batch of pieces as DDO allocations.
	CreateAllocations(ctx context.Context, evmSigner signer.EVMSigner,
		pieces []DDOPieceSubmission, cfg DDOSchedulingConfig) (*DDOQueuedTx, error)

	// WaitForConfirmations polls for tx confirmation to the specified depth.
	WaitForConfirmations(ctx context.Context, txHash string,
		depth uint64, pollInterval time.Duration) (*DDOTransactionReceipt, error)

	// ParseAllocationIDs extracts allocation IDs from a confirmed tx receipt.
	ParseAllocationIDs(ctx context.Context, txHash string) ([]uint64, error)
}

DDODealManager defines DDO allocation lifecycle operations needed by scheduling. Path B implements this using the ddo-client SDK.

type DDOPieceSubmission added in v1.0.0

type DDOPieceSubmission struct {
	PieceCID    cid.Cid
	PieceSize   uint64
	ProviderID  uint64
	DownloadURL string
}

type DDOQueuedTx added in v1.0.0

type DDOQueuedTx struct {
	Hash string
}

type DDOSPConfig added in v1.0.0

type DDOSPConfig struct {
	IsActive     bool
	MinPieceSize uint64
	MaxPieceSize uint64
	MinTermLen   int64
	MaxTermLen   int64
}

type DDOSchedulingConfig added in v1.0.0

type DDOSchedulingConfig struct {
	BatchSize         int           // pieces per createAllocationRequests tx
	ConfirmationDepth uint64        // block confirmations before considering tx final
	PollingInterval   time.Duration // confirmation polling interval
	TermMin           int64         // min term in epochs, default 518400 (~6 months)
	TermMax           int64         // max term in epochs, default 5256000 (~5 years)
	ExpirationOffset  int64         // expiration offset in epochs, default 172800
}

DDOSchedulingConfig holds DDO-specific scheduling knobs for on-chain operations.

func (DDOSchedulingConfig) Validate added in v1.0.0

func (c DDOSchedulingConfig) Validate() error

Validate validates DDO scheduling configuration.

type DDOTransactionReceipt added in v1.0.0

type DDOTransactionReceipt struct {
	Hash        string
	BlockNumber uint64
	GasUsed     uint64
	Status      uint64
}

type DealPusher

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

DealPusher represents a struct that encapsulates the data and functionality related to pushing deals in a replication process.

func NewDealPusher

func NewDealPusher(db *gorm.DB, lotusURL string,
	lotusToken string, numAttempts uint, maxReplicas uint, opts ...Option,
) (*DealPusher, error)

func (*DealPusher) Name

func (*DealPusher) Name() string

func (*DealPusher) Start

func (d *DealPusher) Start(ctx context.Context, exitErr chan<- error) error

Start initializes and starts the DealPusher service.

It first attempts to register the worker with the health check system. If another worker is already running, it waits and retries until it can register or the context is cancelled. Once registered, it launches three main activities in separate goroutines:

  1. Reporting its health status.
  2. Running the deal processing loop.
  3. Handling cleanup when the service is stopped.

Parameters:

  • ctx : The context for managing the lifecycle of the Start function. If Done, the function exits cleanly.
  • exitErr : A channel for an error or nil when the service exits

Returns:

  • An error if there was a problem starting the service.

This function is intended to be called once at the start of the service lifecycle.

type OnChainDDO added in v1.0.0

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

OnChainDDO implements the DDO scheduling interfaces using ddo-client. It keeps a read-only DDO client for queries and confirmation polling, and derives write-capable DDO/payments clients from the caller's EVMSigner.

caveat: ddo-client (pinned at 2fff1a5b168a) overwrites auth.Context with context.Background() in its write methods, so ctx cancellation does not propagate to in-flight EnsurePayments/CreateAllocations calls.

func NewOnChainDDO added in v1.0.0

func NewOnChainDDO(
	ctx context.Context,
	rpcURL string,
	ddoAddr, paymentsAddr, payToken string,
) (*OnChainDDO, error)

func (*OnChainDDO) CheckBalance added in v1.0.0

func (o *OnChainDDO) CheckBalance(ctx context.Context, walletAddr common.Address) (*DDOBalanceStatus, error)

func (*OnChainDDO) Close added in v1.0.0

func (o *OnChainDDO) Close()

func (*OnChainDDO) CreateAllocations added in v1.0.0

func (o *OnChainDDO) CreateAllocations(
	ctx context.Context,
	evmSigner signer.EVMSigner,
	pieces []DDOPieceSubmission,
	cfg DDOSchedulingConfig,
) (*DDOQueuedTx, error)

func (*OnChainDDO) EnsurePayments added in v1.0.0

func (o *OnChainDDO) EnsurePayments(
	ctx context.Context,
	evmSigner signer.EVMSigner,
	pieces []DDOPieceSubmission,
	cfg DDOSchedulingConfig,
) error

func (*OnChainDDO) ParseAllocationIDs added in v1.0.0

func (o *OnChainDDO) ParseAllocationIDs(ctx context.Context, txHash string) ([]uint64, error)

func (*OnChainDDO) ValidateSP added in v1.0.0

func (o *OnChainDDO) ValidateSP(ctx context.Context, providerActorID uint64) (*DDOSPConfig, error)

func (*OnChainDDO) WaitForConfirmations added in v1.0.0

func (o *OnChainDDO) WaitForConfirmations(
	ctx context.Context,
	txHash string,
	depth uint64,
	pollInterval time.Duration,
) (*DDOTransactionReceipt, error)

type OnChainPDP added in v1.0.0

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

OnChainPDP drives the FWSS-mediated pull flow. We never submit any PDPVerifier tx ourselves: the SP downloads pieces from our content provider via /pdp/piece/pull, then commits on-chain from its own wallet via /pdp/data-sets/create-and-add (new sets) or /pdp/data-sets/{id}/pieces (existing). The only EVM RPC use is the ServiceProviderRegistry view call that resolves an SP's PDP service URL.

func NewOnChainPDP added in v1.0.0

func NewOnChainPDP(ctx context.Context, cfg OnChainPDPConfig) (*OnChainPDP, error)

func (*OnChainPDP) Close added in v1.0.0

func (o *OnChainPDP) Close() error

func (*OnChainPDP) PullPiecesToFWSS added in v1.0.0

func (o *OnChainPDP) PullPiecesToFWSS(
	ctx context.Context,
	evmSigner signer.EVMSigner,
	provider string,
	pieces []PDPPieceInput,
	cfg PDPSchedulingConfig,
) (PDPPullResult, error)

PullPiecesToFWSS implements PDPProofSetManager.

type OnChainPDPConfig added in v1.0.0

type OnChainPDPConfig struct {
	// DB is required.
	DB *gorm.DB
	// RPCURL is the FEVM JSON-RPC endpoint (read-only; we never submit txs).
	RPCURL string
	// SourceURLBase is the HTTPS base singularity serves pieces from. The
	// per-piece URL is constructed as <base>/piece/<pieceCidV2>. Required.
	SourceURLBase string
	// RecordKeeper is the FWSS contract address (hex). Empty defaults to
	// the network FWSS from go-synapse constants.
	RecordKeeper string
}

OnChainPDPConfig configures the FWSS-pull adapter.

type Option added in v1.0.0

type Option func(*DealPusher)

Option customizes DealPusher initialization.

func WithDDODealManager added in v1.0.0

func WithDDODealManager(manager DDODealManager) Option

func WithDDOSchedulingConfig added in v1.0.0

func WithDDOSchedulingConfig(cfg DDOSchedulingConfig) Option

func WithPDPProofSetManager added in v1.0.0

func WithPDPProofSetManager(manager PDPProofSetManager) Option

func WithPDPSchedulingConfig added in v1.0.0

func WithPDPSchedulingConfig(cfg PDPSchedulingConfig) Option

type PDPPieceInput added in v1.0.0

type PDPPieceInput struct {
	PieceCID    cid.Cid
	PieceSize   int64 // padded
	PayloadSize int64 // real CAR bytes; encoded into the CommPv2 CID, fetched over HTTP
}

PDPPieceInput names a piece the scheduler wants pushed to the SP. The implementation constructs the SP-side source URL.

type PDPProofSetManager added in v1.0.0

type PDPProofSetManager interface {
	// PullPiecesToFWSS pushes a batch of pieces to the SP via the FWSS-pull
	// flow. If no assembling proof set has room, a new FWSS-listened set is
	// created atomically with the first batch; otherwise pieces are added
	// to the existing assembling set. Blocks until Curio reports the SP
	// transfer is complete and the on-chain tx confirms (giving us the
	// dataSetId), or the configured timeout elapses. The returned
	// DataSetID is the set the pieces landed in.
	//
	// evmSigner is the client's secp256k1 wallet; its EVMAddress is the
	// on-chain payer, and its raw key (via signer.EVMSigner.ECDSAKey)
	// is used for the EIP-712 extraData signing.
	PullPiecesToFWSS(
		ctx context.Context,
		evmSigner signer.EVMSigner,
		provider string,
		pieces []PDPPieceInput,
		cfg PDPSchedulingConfig,
	) (PDPPullResult, error)
}

PDPProofSetManager pushes pieces to an SP's Curio via /pdp/piece/pull, then triggers the SP's on-chain commit via /pdp/data-sets/create-and-add (new sets) or /pdp/data-sets/{id}/pieces (existing). It encapsulates SP service-URL discovery, clientDataSetId persistence, EIP-712 signing, and post-completion bookkeeping.

type PDPPullResult added in v1.0.0

type PDPPullResult struct {
	// DataSetID is the FWSS-listened data set the pieces ended up in.
	// For new sets, this is the SetID Curio returns after the
	// createDataSet+addPieces tx confirms.
	DataSetID uint64
}

PDPPullResult reports the outcome of a /pdp/piece/pull batch.

type PDPSchedulingConfig added in v1.0.0

type PDPSchedulingConfig struct {
	// BatchSize bounds pieces per /pdp/piece/pull request.
	BatchSize int
	// MaxPiecesPerProofSet bounds pieces per data set; the scheduler starts
	// a new set when the current one fills.
	MaxPiecesPerProofSet int
	// PullTimeout bounds the time we wait for Curio to finish pulling a
	// batch (per request, not aggregate).
	PullTimeout time.Duration
}

PDPSchedulingConfig holds PDP-specific scheduling knobs for the FWSS-pull flow.

func (PDPSchedulingConfig) Validate added in v1.0.0

func (c PDPSchedulingConfig) Validate() error

Validate validates PDP scheduling configuration.

Jump to

Keyboard shortcuts

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