Documentation
¶
Index ¶
- func WaitReadyRPC(ctx context.Context, rpcURL string) error
- type Addresses
- type BlockOverrides
- type BlockStateCall
- type CallResult
- type ContractABIs
- type Contracts
- func (c *Contracts) AccountAddress() common.Address
- func (c *Contracts) AccountNonce() (uint64, error)
- func (c *Contracts) AddWeb3Endpoint(web3rpc string) error
- func (c *Contracts) BlobSidecarsOfBlock(ctx context.Context, parentBeaconRoot *common.Hash) ([]*types.BlobSidecar, error)
- func (c *Contracts) BlobsByTxHash(ctx context.Context, txHash common.Hash) ([]*types.BlobSidecar, error)
- func (c *Contracts) CensusValidatorABI() *abi.ABI
- func (c *Contracts) CheckTxStatus(txHash common.Hash) (bool, error)
- func (c *Contracts) Client() *rpc.Client
- func (c *Contracts) CreateProcess(process *types.Process) (types.ProcessID, *common.Hash, error)
- func (c *Contracts) CurrentBlock() uint64
- func (c *Contracts) DecodeError(err error) (string, bool)
- func (c *Contracts) FetchOnchainCensusRoot(address common.Address) (types.HexBytes, error)
- func (c *Contracts) LoadContracts(addresses *Addresses) error
- func (c *Contracts) MonitorProcessChanges(ctx context.Context, interval time.Duration, retries int, ...) (<-chan *types.ProcessWithChanges, error)
- func (c *Contracts) MonitorProcessCreation(ctx context.Context, interval time.Duration) (<-chan *types.Process, error)
- func (c *Contracts) NewEIP4844Transaction(ctx context.Context, to common.Address, data []byte, ...) (*gethtypes.Transaction, error)
- func (c *Contracts) NewEIP4844TransactionWithNonce(ctx context.Context, to common.Address, data []byte, nonce uint64, ...) (*gethtypes.Transaction, error)
- func (c *Contracts) NextProcessID(address common.Address) (types.ProcessID, error)
- func (c *Contracts) Process(processID types.ProcessID) (*types.Process, error)
- func (c *Contracts) ProcessCensusRootFilter(ctx context.Context, start, end uint64, ch chan<- *types.ProcessWithChanges) error
- func (c *Contracts) ProcessChangesFilters() []types.Web3FilterFn
- func (c *Contracts) ProcessMaxVotersFilter(ctx context.Context, start, end uint64, ch chan<- *types.ProcessWithChanges) error
- func (c *Contracts) ProcessRegistryABI() *abi.ABI
- func (c *Contracts) ProcessRegistryAddress() (string, error)
- func (c *Contracts) ProcessStateRootFilter(ctx context.Context, start, end uint64, ch chan<- *types.ProcessWithChanges) error
- func (c *Contracts) ProcessStatusFilter(ctx context.Context, start, end uint64, ch chan<- *types.ProcessWithChanges) error
- func (c *Contracts) RegisterKnownProcess(processID types.ProcessID)
- func (c *Contracts) ResultsVerifierABI() *abi.ABI
- func (c *Contracts) ResultsVerifierAddress() (string, error)
- func (c *Contracts) SetAccountPrivateKey(hexPrivKey string) error
- func (c *Contracts) SetProcessCensus(processID types.ProcessID, census types.Census) (*common.Hash, error)
- func (c *Contracts) SetProcessMaxVoters(processID types.ProcessID, maxVoters *types.BigInt) (*common.Hash, error)
- func (c *Contracts) SetProcessResults(processID types.ProcessID, proof, inputs []byte, timeout time.Duration, ...) error
- func (c *Contracts) SetProcessStatus(processID types.ProcessID, status types.ProcessStatus) (*common.Hash, error)
- func (c *Contracts) SetProcessTransition(processID types.ProcessID, proof, inputs []byte, ...) error
- func (c *Contracts) SetTxManager(tm *txmanager.TxManager)
- func (c *Contracts) SignMessage(msg []byte) ([]byte, error)
- func (c *Contracts) Signer() *ethSigner.Signer
- func (c *Contracts) SimulateContractCall(ctx context.Context, contractAddr common.Address, data []byte, ...) error
- func (c *Contracts) SimulateProcessResults(ctx context.Context, processID types.ProcessID, proof, inputs []byte) error
- func (c *Contracts) SimulateProcessTransition(ctx context.Context, processID types.ProcessID, proof, inputs []byte, ...) error
- func (c *Contracts) StateRoot(processID types.ProcessID) (*types.BigInt, error)
- func (c *Contracts) StateTransitionVerifierABI() *abi.ABI
- func (c *Contracts) StateTransitionVerifierAddress() (string, error)
- func (c *Contracts) SupportBlobTxs() bool
- func (c *Contracts) TransactionAndBlockHeader(ctx context.Context, txHash common.Hash) (*gethtypes.Transaction, *gethtypes.Header, error)
- func (c *Contracts) WaitTxByHash(txHash common.Hash, timeOut time.Duration, cb ...func(error)) error
- func (c *Contracts) WaitTxByID(id []byte, timeOut time.Duration, cb ...func(error)) error
- func (c *Contracts) Web3Pool() *rpc.Web3Pool
- type SimulatedBlock
- type SimulationRequest
- type StateOverride
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WaitReadyRPC ¶
WaitReadyRPC waits for the RPC endpoint to be ready by checking if it returns a valid block number. It will continuously try to get the block number until the context is canceled or a valid block number is received. The function returns an error if the context is canceled or if another error occurs.
Types ¶
type Addresses ¶
type Addresses struct {
ProcessRegistry common.Address
StateTransitionZKVerifier common.Address
ResultsZKVerifier common.Address
}
Addresses contains the addresses of the contracts deployed in the network.
type BlockOverrides ¶
type BlockOverrides struct {
BaseFeePerGas *hexutil.Big `json:"baseFeePerGas,omitempty"`
Timestamp *hexutil.Big `json:"timestamp,omitempty"`
}
BlockOverrides lets you override block fields
type BlockStateCall ¶
type BlockStateCall struct {
BlockOverrides *BlockOverrides `json:"blockOverrides,omitempty"`
StateOverrides map[string]StateOverride `json:"stateOverrides,omitempty"`
Calls []gethapitypes.SendTxArgs `json:"calls"`
}
BlockStateCall lets you override block fields, state, and queue up calls
type CallResult ¶
type CallResult struct {
Status string `json:"status"` // "0x1" or "0x0"
ReturnData hexutil.Bytes `json:"returnData"`
GasUsed hexutil.Uint64 `json:"gasUsed"`
Logs []gethtypes.Log `json:"logs"`
Error *rpc.RPCError `json:"error,omitempty"`
}
CallResult is the result of a single call in a simulated block
type ContractABIs ¶
type ContractABIs struct {
ProcessRegistry *abi.ABI
StateTransitionZKVerifier *abi.ABI
ResultsZKVerifier *abi.ABI
CensusValidator *abi.ABI
}
ContractABIs contains the ABIs of the deployed contracts.
type Contracts ¶
type Contracts struct {
ChainID uint64
ContractsAddresses *Addresses
ContractABIs *ContractABIs
Web3ConsensusAPIEndpoint string
GasMultiplier float64
// contains filtered or unexported fields
}
Contracts contains the bindings to the deployed contracts.
func New ¶
New creates a new Contracts instance with the given web3 endpoints. It initializes the web3 pool and the client, and sets up the known processes
func (*Contracts) AccountAddress ¶
AccountAddress returns the address of the account used to sign transactions.
func (*Contracts) AccountNonce ¶
AccountNonce returns the nonce of the account used to sign transactions.
func (*Contracts) AddWeb3Endpoint ¶
AddWeb3Endpoint adds a new web3 endpoint to the pool.
func (*Contracts) BlobSidecarsOfBlock ¶
func (c *Contracts) BlobSidecarsOfBlock(ctx context.Context, parentBeaconRoot *common.Hash) ([]*types.BlobSidecar, error)
BlobSidecarsOfBlock returns the blob sidecars stored in consensus layer, of a block identified by a parentBeaconRoot
func (*Contracts) BlobsByTxHash ¶
func (c *Contracts) BlobsByTxHash( ctx context.Context, txHash common.Hash, ) ([]*types.BlobSidecar, error)
BlobsByTxHash returns all the blobs sidecars of a tx, given a `txHash`.
func (*Contracts) CensusValidatorABI ¶
CensusValidatorABI returns the ABI of the CensusValidator contract.
func (*Contracts) CheckTxStatus ¶
CheckTxStatus checks the status of a transaction given its hash. Returns true if the transaction is confirmed and successful, false if it is still pending, or an error if the receipt query fails or the transaction was reverted on-chain.
func (*Contracts) CreateProcess ¶
CreateProcess creates a new process in the ProcessRegistry contract. It returns the process ID and the transaction hash.
func (*Contracts) CurrentBlock ¶
CurrentBlock returns the current block number for the chain.
func (*Contracts) DecodeError ¶
DecodeError tries to decode revert reasons or custom errors from err, and returns true if successful.
func (*Contracts) FetchOnchainCensusRoot ¶
FetchOnchainCensusRoot retrieves the census root from the specified census validator contract address.
func (*Contracts) LoadContracts ¶
LoadContracts loads the contracts
func (*Contracts) MonitorProcessChanges ¶
func (c *Contracts) MonitorProcessChanges( ctx context.Context, interval time.Duration, retries int, filters ...types.Web3FilterFn, ) (<-chan *types.ProcessWithChanges, error)
MonitorProcessChanges monitors changes to processes by polling the ProcessRegistry contract every interval. It applies the provided filter functions to detect specific types of changes. It returns a channel that emits ProcessWithChanges objects representing the detected changes.
func (*Contracts) MonitorProcessCreation ¶
func (c *Contracts) MonitorProcessCreation(ctx context.Context, interval time.Duration) (<-chan *types.Process, error)
MonitorProcessCreation monitors the creation of new processes by polling the ProcessRegistry contract every interval.
func (*Contracts) NewEIP4844Transaction ¶
func (c *Contracts) NewEIP4844Transaction( ctx context.Context, to common.Address, data []byte, blobsSidecar *types.BlobTxSidecar, ) (*gethtypes.Transaction, error)
NewEIP4844Transaction method creates and signs a new EIP-4844 (type-3) transaction by calculating the nonce from the RPC and returning the result of NewEIP4844TransactionWithNonce.
func (*Contracts) NewEIP4844TransactionWithNonce ¶
func (c *Contracts) NewEIP4844TransactionWithNonce( ctx context.Context, to common.Address, data []byte, nonce uint64, blobsSidecar *types.BlobTxSidecar, ) (*gethtypes.Transaction, error)
NewEIP4844TransactionWithNonce method creates and signs a new EIP-4844. It calculates gas limits and fee caps, and returns the signed transaction. The provided nonce is used (caller must ensure it's correct).
Requirements:
- `to` MUST be non-nil per EIP-4844.
- `method` MUST be a valid method in the ABI.
- `c.signer` MUST be non-nil (private key set).
func (*Contracts) NextProcessID ¶
NextProcessID returns the next process ID that will be created in the ProcessRegistry contract for the given address.
func (*Contracts) Process ¶
Process returns the process with the given ID from the ProcessRegistry contract.
func (*Contracts) ProcessCensusRootFilter ¶
func (c *Contracts) ProcessCensusRootFilter(ctx context.Context, start, end uint64, ch chan<- *types.ProcessWithChanges) error
ProcessCensusRootFilter monitors changes in process census root.
func (*Contracts) ProcessChangesFilters ¶
func (c *Contracts) ProcessChangesFilters() []types.Web3FilterFn
ProcessChangesFilters returns the list of filters to monitor process changes.
func (*Contracts) ProcessMaxVotersFilter ¶
func (c *Contracts) ProcessMaxVotersFilter(ctx context.Context, start, end uint64, ch chan<- *types.ProcessWithChanges) error
ProcessMaxVotersFilter monitors changes in process max voters.
func (*Contracts) ProcessRegistryABI ¶
ProcessRegistryABI returns the ABI of the ProcessRegistry contract.
func (*Contracts) ProcessRegistryAddress ¶
func (*Contracts) ProcessStateRootFilter ¶
func (c *Contracts) ProcessStateRootFilter(ctx context.Context, start, end uint64, ch chan<- *types.ProcessWithChanges) error
ProcessStateRootFilter monitors changes in process state root.
func (*Contracts) ProcessStatusFilter ¶
func (c *Contracts) ProcessStatusFilter(ctx context.Context, start, end uint64, ch chan<- *types.ProcessWithChanges) error
ProcessStatusFilter monitors changes in process status.
func (*Contracts) RegisterKnownProcess ¶
RegisterKnownProcess adds a process ID to the knownProcesses map. This is used during initialization to register processes that were created before the monitor started, ensuring their events are not filtered out.
func (*Contracts) ResultsVerifierABI ¶
ResultsVerifierABI returns the ABI of the ResultsVerifier contract.
func (*Contracts) ResultsVerifierAddress ¶
func (*Contracts) SetAccountPrivateKey ¶
SetAccountPrivateKey sets the private key to be used for signing transactions.
func (*Contracts) SetProcessCensus ¶
func (c *Contracts) SetProcessCensus(processID types.ProcessID, census types.Census) (*common.Hash, error)
SetProcessCensus sets the census of the process with the given ID in the ProcessRegistry contract. It returns the transaction hash of the census update, or an error if the update fails.
func (*Contracts) SetProcessMaxVoters ¶
func (c *Contracts) SetProcessMaxVoters(processID types.ProcessID, maxVoters *types.BigInt) (*common.Hash, error)
SetProcessMaxVoters sets the maximum number of voters for the process with the given ID in the ProcessRegistry contract. It returns the transaction hash of the update, or an error if the update fails.
func (*Contracts) SetProcessResults ¶
func (c *Contracts) SetProcessResults( processID types.ProcessID, proof, inputs []byte, timeout time.Duration, callback ...func(error), ) error
SetProcessResults sets the results of the process with the given ID in the ProcessRegistry contract and waits for the transaction to be mined. Once mined or the timeout is reached, it calls the optional callback with the result of the operation. It returns an error if the submission fails.
func (*Contracts) SetProcessStatus ¶
func (c *Contracts) SetProcessStatus(processID types.ProcessID, status types.ProcessStatus) (*common.Hash, error)
SetProcessStatus sets the status of the process with the given ID in the ProcessRegistry contract. It returns the transaction hash of the status update, or an error if the update fails.
func (*Contracts) SetProcessTransition ¶
func (c *Contracts) SetProcessTransition( processID types.ProcessID, proof, inputs []byte, blobsSidecar *types.BlobTxSidecar, timeout time.Duration, callback ...func(error), ) error
SetProcessTransition submits a state transition for the process with the given ID and waits for the transaction to be mined. Once mined or the timeout is reached, it calls the optional callback with the result of the operation. It returns an error if the submission fails.
func (*Contracts) SetTxManager ¶
SetTxManager sets the transaction manager to be used by the Contracts instance.
func (*Contracts) SignMessage ¶
SignMessage signs a message with the account private key.
func (*Contracts) SimulateContractCall ¶
func (c *Contracts) SimulateContractCall( ctx context.Context, contractAddr common.Address, data []byte, blobsSidecar *types.BlobTxSidecar, ) error
SimulateContractCall simulates a contract call using the eth_simulateV1 RPC method. If blobsSidecar is provided, it will simulate an EIP4844 transaction with blob data. If blobsSidecar is nil, it will simulate a regular contract call. NOTE: this is a temporary method to simulate contract calls it works on geth but not expected to work on other clients or external rpc providers.
func (*Contracts) SimulateProcessResults ¶
func (c *Contracts) SimulateProcessResults( ctx context.Context, processID types.ProcessID, proof, inputs []byte, ) error
SimulateProcessResults simulates a setProcessResults contract call using the eth_simulateV1 RPC method.
NOTE: this is a temporary method to simulate contract calls it works on geth but not expected to work on other clients or external rpc providers.
func (*Contracts) SimulateProcessTransition ¶
func (c *Contracts) SimulateProcessTransition( ctx context.Context, processID types.ProcessID, proof, inputs []byte, blobsSidecar *types.BlobTxSidecar, ) error
SimulateProcessTransition simulates a submitStateTransition contract call using the eth_simulateV1 RPC method. If blobsSidecar is provided, it will simulate an EIP4844 transaction with blob data. If blobsSidecar is nil, it will simulate a regular contract call.
NOTE: this is a temporary method to simulate contract calls it works on geth but not expected to work on other clients or external rpc providers.
func (*Contracts) StateRoot ¶
StateRoot returns the state root of the process with the given ID. It returns an error if the process does not exist or if there is an issue with the contract call.
func (*Contracts) StateTransitionVerifierABI ¶
StateTransitionVerifierABI returns the ABI of the ZKVerifier contract.
func (*Contracts) StateTransitionVerifierAddress ¶
func (*Contracts) SupportBlobTxs ¶
SupportBlobTxs returns whether the current contracts support blob transactions.
func (*Contracts) TransactionAndBlockHeader ¶
func (c *Contracts) TransactionAndBlockHeader(ctx context.Context, txHash common.Hash, ) (*gethtypes.Transaction, *gethtypes.Header, error)
TransactionAndBlockHeader returns the full tx identified by txHash and the header of the block it was mined in.
func (*Contracts) WaitTxByHash ¶
func (c *Contracts) WaitTxByHash(txHash common.Hash, timeOut time.Duration, cb ...func(error)) error
WaitTxByHash waits for a transaction to be mined given its hash. If the transaction is not mined within the timeout, it returns an error.
func (*Contracts) WaitTxByID ¶
WaitTxByID waits for a transaction to be mined given its hash. If the transaction is not mined within the timeout, it returns an error.
type SimulatedBlock ¶
type SimulatedBlock struct {
Hash common.Hash `json:"hash"`
Number string `json:"number"`
Calls []CallResult `json:"calls"`
}
SimulatedBlock is the result of a simulated block
type SimulationRequest ¶
type SimulationRequest struct {
BlockStateCalls []BlockStateCall `json:"blockStateCalls"`
Validation bool `json:"validation,omitempty"`
TraceTransfers bool `json:"traceTransfers,omitempty"`
ReturnFullTransactions bool `json:"returnFullTransactions,omitempty"`
}
SimulationRequest is the top‐level payload for eth_simulateV1