mirror of
https://github.com/luxfi/proto.git
synced 2026-10-30 15:21:09 +00:00
The platform and exchange VMs are the last chain code living in luxfi/node and the reason the node cannot be retired. This brings over the part of them proto did not already have: the adopt registry, the ZAP wire generators for signer, warp and validator fees, the hybrid and runtime proof-of-possession signers, the native admission check, the zwarp client and server, the X-chain network layer, the xvmroot state root, the batch verifier and owner root, and the credential policy the P and X mempools share, which lands beside the mempool it gates as proto/txs/auth. The X-chain genesis builder moves into proto/x/genesis, where the codec it calls already lives, so it no longer reaches for the xvm package to build primary-asset bytes. Imports point at the packages that already have homes: cache, upgrade, version and util as their own modules, and gas, verify and index in luxfi/vm. The three generated files bring github.com/zap-proto/go with them, which requires go 1.26.5. Most of the remaining difference between the node's trees and proto is not a backlog. proto restructured this code in August and the node's copies predate it, so files that look absent are largely present here under other names. What genuinely cannot come yet is anything reaching for node/server/http, node/vms or node/wallet, and the tests written against tx constructors proto's tx layer no longer exports. Co-authored-by: Hanzo Dev <[email protected]>
54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
// Code generated by zip; DO NOT EDIT.
|
|
|
|
package warp
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
zap "github.com/zap-proto/go"
|
|
)
|
|
|
|
// ---- UnsignedMessage ---------------------------------------------------
|
|
|
|
const (
|
|
unsignedMessageNetworkIDAt = 0
|
|
unsignedMessageSourceChainIDAt = 4
|
|
unsignedMessagePayloadAt = 40
|
|
unsignedMessageSize = 48
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*UnsignedMessage)(nil)
|
|
|
|
// MarshalZAP writes UnsignedMessage from constant offsets.
|
|
func (x *UnsignedMessage) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(unsignedMessageSize + 256)
|
|
ob := b.StartObject(unsignedMessageSize)
|
|
ob.SetUint32(unsignedMessageNetworkIDAt, uint32(x.NetworkID))
|
|
ob.SetBytesFixed(unsignedMessageSourceChainIDAt, x.SourceChainID[:])
|
|
ob.SetBytes(unsignedMessagePayloadAt, []byte(x.Payload))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads UnsignedMessage out of the buffer that arrived.
|
|
func (x *UnsignedMessage) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("UnsignedMessage: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.NetworkID = uint32(o.Uint32(unsignedMessageNetworkIDAt))
|
|
copy(x.SourceChainID[:], o.BytesFixed(unsignedMessageSourceChainIDAt, 32))
|
|
x.Payload = []uint8(append([]byte(nil), o.Bytes(unsignedMessagePayloadAt)...))
|
|
return nil
|
|
}
|