mirror of
https://github.com/luxfi/chains.git
synced 2026-09-24 00:26:00 +00:00
The two shims re-exported luxfi/oracle's and luxfi/relay's private vmID literals. constants.OracleVMID and constants.RelayVMID exist, agree with them, and nothing made them agree. This repo builds the plugin binary whose FILENAME is that id, so the shims now name the constant and their tests compare all three; a drift upstream fails here instead of producing a chain no node starts. cevm gets ErrNotLinked, so a caller can tell "this build has no C++ EVM" from "this input is bad". cevm/parallel's sender-recovery step returned a hard error for the first, which in a build without the library is every block, forever, and CEVM_STRICT=0 -- the documented rollback to the Go EVM -- did not reach that line. It now leaves by declineBlock like every other capability refusal. Its receipt gate asked whether a transaction carried calldata. A contract creation with empty init code carries none, so it was receipted as a value transfer: no ContractAddress, and 21000 intrinsic gas against creation's 53000, into the cumulative total the header commits to. ExecuteBlock splits into shape / dispatch / assemble so the parity-critical half needs no library to exercise. strictGPUEVM loses the sync.Once that fixed its answer at the first decline and left both branches unreachable from one process. The native build referenced gpu_execute_block and gpu_free_result, which ABI v6 removed, so nothing behind lux_cevm_native compiled at all. The three plugins print the version the VM reports rather than a second literal beside it, and the vmID the binary must be installed under: a plugin under the wrong filename is invisible and the chain simply never appears. cevm/plugin.go is gone. It located a binary at ~/work/luxcpp/evm/build/bin/cevm, a path that has never existed -- the tree is luxcpp/cevm -- claimed the lux CLI and universe Makefiles used it, which neither does, and returned "cevm" from a function called VMID. Its two tests skipped and asserted nothing. .gitignore's bare `plugin` matched every <vm>/cmd/plugin DIRECTORY, so a new file under one could not be added: git printed a hint and staged nothing. mpcvm's and bridgevm's plugin tests are written, pass, and are not in the repository. Coverage: evm 0.0 -> 85.0, evm/cevm 71.1 -> 100.0, evm/cevm/parallel 0.0 -> 86.1, oraclevm 0.0 -> 90.0, oraclevm/cmd/plugin 0.0 -> 72.2, relayvm/cmd/plugin 0.0 -> 72.2.
71 lines
2.3 KiB
Go
71 lines
2.3 KiB
Go
// Copyright (C) 2019-2026, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
// Command plugin serves the R-Chain VM to a Lux node.
|
|
//
|
|
// The binary's FILENAME must be the CB58 of relayvm.VMID
|
|
// (sP6dLqrrBR9w3soP18fbJ3YzZecZdD7DDdfH2cFhhLq7Hy9bz) — that is how the node's
|
|
// plugin registry resolves a vmID from a CreateChainTx to an implementation.
|
|
// A binary installed under any other name is invisible and the chain silently
|
|
// never starts, which is why `version` prints the id it must be installed as:
|
|
// the fact an operator needs is in the place an operator already looks.
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
|
|
"github.com/luxfi/chains/relayvm"
|
|
"github.com/luxfi/log"
|
|
"github.com/luxfi/sys/ulimit"
|
|
"github.com/luxfi/vm/chain"
|
|
"github.com/luxfi/vm/rpc"
|
|
)
|
|
|
|
func main() {
|
|
os.Exit(run(context.Background(), os.Args[1:], os.Stdout, os.Stderr))
|
|
}
|
|
|
|
// run is main with the exit lifted out, so what the plugin does is reachable
|
|
// from a test and only the exit itself is not.
|
|
func run(ctx context.Context, args []string, out, errOut io.Writer) int {
|
|
// Built through the same vms.Factory the node's registry uses. relayvm
|
|
// asserts *VM is a chain.ChainVM at compile time and its own test asserts
|
|
// the Factory produces one, so the conversion here cannot be wrong by the
|
|
// time this compiles.
|
|
raw, err := (&relayvm.Factory{}).New(log.Root())
|
|
if err != nil {
|
|
return fail(errOut, err)
|
|
}
|
|
vm := raw.(chain.ChainVM)
|
|
|
|
if len(args) > 0 && args[0] == "version" {
|
|
// The version comes from the VM, not from a second copy of the number
|
|
// here. Two declarations of one version disagree the first time either
|
|
// is bumped, and the one an operator reads is this one.
|
|
v, err := vm.Version(ctx)
|
|
if err != nil {
|
|
return fail(errOut, err)
|
|
}
|
|
fmt.Fprintf(out, "relayvm/%s %s\n", v, relayvm.VMID)
|
|
return 0
|
|
}
|
|
|
|
if err := ulimit.Set(ulimit.DefaultFDLimit, log.Root()); err != nil {
|
|
return fail(errOut, err)
|
|
}
|
|
if err := rpc.Serve(ctx, log.Root(), vm); err != nil {
|
|
return fail(errOut, err)
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// fail reports why the plugin is not serving and gives the node a non-zero
|
|
// exit. A plugin that dies quietly presents as a chain that never starts.
|
|
func fail(w io.Writer, err error) int {
|
|
fmt.Fprintf(w, "relayvm plugin: %s\n", err)
|
|
return 1
|
|
}
|