Files
zeekay 8cf453d4b0 chains: a signature of the wrong width is refused, not reshaped
warpmsg is the one place bridgevm, mpcvm and zkvm turn a payload into a signed
cross-chain envelope. It copied whatever the signer returned into a fixed
96-byte array without checking the length. Signer is an interface, so that
width is a runtime fact: a short signature was silently zero-padded and a long
one silently truncated, and either way the envelope came out well-formed and
unverifiable -- a message the sender believes it sent and no receiver can ever
accept, with no error anywhere.

oraclevm's accel host documented an error for a nil VM and never checked,
deferring the failure to whichever method the operator called first.
2026-08-28 10:56:44 -07:00

57 lines
1.7 KiB
Go

// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package oraclevm
import (
"errors"
"github.com/luxfi/accel"
)
// ErrNilVM is returned by NewAccelHost when there is no VM to wrap. A host
// built around nothing defers its failure to whichever method the operator
// calls first, arbitrarily far from the mistake.
var ErrNilVM = errors.New("oraclevm: nil VM")
// AccelHost wraps an O-Chain VM with a per-VM GPU acceleration session.
// O-Chain is currently CPU-only; the session is allocated for future
// batch verification of oracle aggregation signatures, threshold
// commitments, and feed proofs.
//
// chains/oraclevm re-exports luxfi/oracle/vm.VM as a type alias, so we
// cannot add a field to VM directly. AccelHost gives the operator an
// explicit composition point: build the VM, wrap it with NewAccelHost,
// and route GPU ops via host.Session().
type AccelHost struct {
*VM
session *accel.VMSession
}
// NewAccelHost creates a per-VM GPU session and binds it to vm.
// Returns ErrNilVM when vm is nil. The session is created with PriorityNormal
// and no memory cap; tune via opts.
func NewAccelHost(vm *VM, opts ...accel.VMSessionOption) (*AccelHost, error) {
if vm == nil {
return nil, ErrNilVM
}
s, err := accel.NewVMSession("oraclevm", opts...)
if err != nil {
return nil, err
}
return &AccelHost{VM: vm, session: s}, nil
}
// Session returns the per-VM GPU session.
func (h *AccelHost) Session() *accel.VMSession {
return h.session
}
// Close releases the GPU session. The wrapped VM is left untouched.
func (h *AccelHost) Close() error {
if h.session == nil {
return nil
}
return h.session.Close()
}