Documentation
¶
Overview ¶
Package proto contains the IOSwarm gRPC types. In production, these would be generated from ioswarm.proto via protoc. For MVP, we define them manually to avoid the protoc dependency.
Index ¶
- Constants
- type AccountSnapshot
- type BatchResult
- type BlockCtx
- type DownloadSnapshotRequest
- type EvmTx
- type GetTasksRequest
- type HeartbeatRequest
- type HeartbeatResponse
- type JSONCodec
- type LogEntry
- type PayoutInfo
- type RegisterRequest
- type RegisterResponse
- type SnapshotChunk
- type StateChange
- type StateDiffEntry
- type StateDiffResponse
- type StreamStateDiffsRequest
- type SubmitResponse
- type TaskBatch
- type TaskLevel
- type TaskPackage
- type TaskResult
Constants ¶
const CodecName = "ioswarm-json"
CodecName is the content-subtype registered for the ioswarm JSON codec. Clients must use grpc.ForceCodec(JSONCodec{}) (or set content-subtype to this name) to interoperate with ioswarm services that exchange the plain Go structs in this package.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountSnapshot ¶
type AccountSnapshot struct {
Address string `json:"address"`
Balance string `json:"balance"` // big.Int as string
Nonce uint64 `json:"nonce"`
CodeHash []byte `json:"code_hash,omitempty"`
}
AccountSnapshot holds a point-in-time view of an account.
type BatchResult ¶
type BatchResult struct {
AgentID string `json:"agent_id"`
BatchID string `json:"batch_id"`
Results []*TaskResult `json:"results"`
Timestamp uint64 `json:"timestamp"`
}
BatchResult is a batch of results from an agent.
type BlockCtx ¶
type BlockCtx struct {
Timestamp uint64 `json:"timestamp"`
GasLimit uint64 `json:"gas_limit"`
BaseFee string `json:"base_fee"` // big.Int as string
Coinbase string `json:"coinbase"` // block producer address
Number uint64 `json:"number"`
}
BlockCtx carries block-level context needed for EVM execution.
type DownloadSnapshotRequest ¶
type DownloadSnapshotRequest struct {
AgentID string `json:"agent_id"`
}
DownloadSnapshotRequest is sent by L4 agents to download a full state snapshot.
type EvmTx ¶
type EvmTx struct {
To string `json:"to,omitempty"` // empty = contract creation
Value string `json:"value"` // big.Int as string
Data []byte `json:"data,omitempty"`
GasLimit uint64 `json:"gas_limit"`
GasPrice string `json:"gas_price"` // big.Int as string
}
EvmTx carries structured EVM transaction fields.
type GetTasksRequest ¶
type GetTasksRequest struct {
AgentID string `json:"agent_id"`
MaxLevel TaskLevel `json:"max_level"`
MaxBatchSize uint32 `json:"max_batch_size"`
}
GetTasksRequest is sent by agents to start receiving task streams.
type HeartbeatRequest ¶
type HeartbeatRequest struct {
AgentID string `json:"agent_id"`
TasksProcessed uint32 `json:"tasks_processed"`
TasksPending uint32 `json:"tasks_pending"`
CPUUsage float64 `json:"cpu_usage"`
MemUsage float64 `json:"mem_usage"`
}
HeartbeatRequest is the periodic health check from agents.
type HeartbeatResponse ¶
type HeartbeatResponse struct {
Alive bool `json:"alive"`
Directive string `json:"directive"` // "continue", "drain", "shutdown"
// Payout info (set when a new epoch payout was distributed since last heartbeat)
Payout *PayoutInfo `json:"payout,omitempty"`
}
HeartbeatResponse is the coordinator's heartbeat reply.
type JSONCodec ¶ added in v2.4.2
type JSONCodec struct{}
JSONCodec provides JSON marshaling for ioswarm internal use. Use a distinct name "ioswarm-json" to avoid overriding the default "proto" codec. In production, replace with proper protobuf types.
type LogEntry ¶
type LogEntry struct {
Address string `json:"address"`
Topics []string `json:"topics"`
Data []byte `json:"data"`
}
LogEntry records a single EVM log emitted during execution.
type PayoutInfo ¶
type PayoutInfo struct {
Epoch uint64 `json:"epoch"`
AmountIOTX float64 `json:"amount_iotx"`
Rank int `json:"rank"`
TotalAgents int `json:"total_agents"`
}
PayoutInfo carries per-agent payout data from coordinator to agent.
type RegisterRequest ¶
type RegisterRequest struct {
AgentID string `json:"agent_id"`
Capability TaskLevel `json:"capability"`
Region string `json:"region"`
Version string `json:"version"`
WalletAddress string `json:"wallet_address,omitempty"`
}
RegisterRequest is sent by agents to register with the coordinator.
type RegisterResponse ¶
type RegisterResponse struct {
Accepted bool `json:"accepted"`
Reason string `json:"reason,omitempty"`
HeartbeatIntervalSec uint32 `json:"heartbeat_interval_sec"`
}
RegisterResponse is sent by the coordinator in reply to registration.
type SnapshotChunk ¶
type SnapshotChunk struct {
ChunkIndex uint32 `json:"chunk_index"`
Data []byte `json:"data"`
TotalChunks uint32 `json:"total_chunks"` // 0 until last chunk
Height uint64 `json:"height"` // snapshot height
}
SnapshotChunk is a chunk of snapshot data streamed to agents.
type StateChange ¶
type StateChange struct {
Address string `json:"address"`
Slot string `json:"slot"` // hex
OldValue string `json:"old_value"` // hex
NewValue string `json:"new_value"` // hex
}
StateChange records a single storage mutation during EVM execution.
type StateDiffEntry ¶
type StateDiffEntry struct {
WriteType uint8 `json:"write_type"` // 0=Put, 1=Delete
Namespace string `json:"namespace"`
Key []byte `json:"key"`
Value []byte `json:"value,omitempty"`
}
StateDiffEntry is a single state mutation in a block.
type StateDiffResponse ¶
type StateDiffResponse struct {
Height uint64 `json:"height"`
Entries []*StateDiffEntry `json:"entries"`
DigestBytes []byte `json:"digest_bytes"` // for verification
}
StateDiffResponse is a single block's state diff streamed to agents.
type StreamStateDiffsRequest ¶
type StreamStateDiffsRequest struct {
AgentID string `json:"agent_id"`
FromHeight uint64 `json:"from_height"` // resume from this height (0 = latest only)
}
StreamStateDiffsRequest is sent by L4 agents to subscribe to state diffs.
type SubmitResponse ¶
type SubmitResponse struct {
Accepted bool `json:"accepted"`
Reason string `json:"reason,omitempty"`
}
SubmitResponse is the coordinator's response to submitted results.
type TaskBatch ¶
type TaskBatch struct {
BatchID string `json:"batch_id"`
Tasks []*TaskPackage `json:"tasks"`
Timestamp uint64 `json:"timestamp"`
}
TaskBatch is a batch of tasks sent to an agent.
type TaskPackage ¶
type TaskPackage struct {
TaskID uint32 `json:"task_id"`
TxRaw []byte `json:"tx_raw"`
Level TaskLevel `json:"level"`
Sender *AccountSnapshot `json:"sender"`
Receiver *AccountSnapshot `json:"receiver"`
BlockHeight uint64 `json:"block_height"`
// L3 EVM execution fields
BlockContext *BlockCtx `json:"block_context,omitempty"`
ContractCode map[string][]byte `json:"contract_code,omitempty"` // address → bytecode
StorageSlots map[string]map[string]string `json:"storage_slots,omitempty"` // address → slot → value (hex)
EvmTx *EvmTx `json:"evm_tx,omitempty"`
}
TaskPackage is a single transaction validation task.
type TaskResult ¶
type TaskResult struct {
TaskID uint32 `json:"task_id"`
Valid bool `json:"valid"`
RejectReason string `json:"reject_reason,omitempty"`
GasEstimate uint64 `json:"gas_estimate"`
LatencyUs uint64 `json:"latency_us"`
// L3 EVM execution results
GasUsed uint64 `json:"gas_used,omitempty"`
ReturnData []byte `json:"return_data,omitempty"`
StateChanges []*StateChange `json:"state_changes,omitempty"`
Logs []*LogEntry `json:"logs,omitempty"`
ExecError string `json:"exec_error,omitempty"`
}
TaskResult is the validation result for a single task.