Move API and abort codes¶
Structs, events, functions and abort codes of the three Move packages in
stealth_name_service/Move/: bridge_source, bridge_abstract_account
and bridge_target.
None of the three packages declares an entry function. Everything callable is public fun, invoked
from a programmable transaction block (PTB). The sender of a bridged destination transaction is the
BridgeAA object itself, not a keypair. Background:
The Move packages and
Account abstraction and BridgeAA.
The legacy package is not here
The older abstract_account package (the ENABLE_AA path) is deprecated and its Move source is
not in this repository. Only the three packages below are. Use Track C: One-time bridge
setup; background in Legacy: the abstract_account path.
| Package | Module | Source file | Role |
|---|---|---|---|
bridge_source |
bridge_source::bridge_source |
stealth_name_service/Move/bridge_source/sources/bridge_source.move |
Emits CrossChainRequest and RequestAcknowledged on the source chain |
bridge_abstract_account |
bridge_abstract_account::bridge_abstract_account |
stealth_name_service/Move/bridge_abstract_account/sources/bridge_abstract_account.move |
The BridgeAA account and its authenticator on the destination chain |
bridge_target |
bridge_target::bridge_target |
stealth_name_service/Move/bridge_target/sources/bridge_target.move |
An all-pure landing call on the destination chain |
bridge_source¶
Source-chain half of the bridge. A caller describes a Move call it wants run on another chain; the module emits it as an event. Nothing here is trusted by the destination: the authenticator re-verifies everything.
Structs and events¶
| Name | Abilities | Fields | Notes |
|---|---|---|---|
SourceConfig |
key |
id, chain_id: u64 |
Per-deployment configuration, frozen at creation. Frozen rather than shared so that requests stay on the consensus-free fast path. |
CrossChainRequest |
copy, drop |
request_id: address, source_chain_id: u64, source_sender: address, target_chain_id: u64, target_package: address, target_module: vector<u8>, target_function: vector<u8>, args: vector<vector<u8>>, type_args: vector<vector<u8>> |
Event emitted by request. After request_id, the field order mirrors CrossChainIntent. args are BCS-encoded and positional; type_args are BCS-encoded type tags. |
RequestAcknowledged |
copy, drop |
request_id: address, source_chain_id: u64, dest_tx_digest: vector<u8>, acknowledged_by: address |
Event emitted by the acknowledgement functions. A relayer assertion, not a verified receipt. |
Functions¶
| Function | Parameters | Effect |
|---|---|---|
create_config |
chain_id: u64, ctx |
Creates a SourceConfig and freezes it. chain_id must match the source_chain_id of the destination ACL entries, or every request fails the ACL lookup. |
request |
config: &SourceConfig, target_chain_id: u64, target_package: address, target_module: vector<u8>, target_function: vector<u8>, args: vector<vector<u8>>, type_args: vector<vector<u8>>, ctx |
Emits CrossChainRequest. request_id is ctx.fresh_object_address(), source_chain_id comes from the config, source_sender is the transaction sender. args must be the exact bytes the destination call receives, because the authenticator compares them byte for byte. |
acknowledge |
config: &SourceConfig, request_id: address, dest_tx_digest: vector<u8>, ctx |
Emits RequestAcknowledged with source_chain_id from the config. Takes an object argument, so only a keystore-signed transaction can call it (BRIDGE_ACK_SIGNER=eoa). |
acknowledge_pure |
source_chain_id: u64, request_id: address, dest_tx_digest: vector<u8>, ctx |
All-pure variant, so a BridgeAA can execute it (BRIDGE_ACK_SIGNER=aa). The chain id is asserted by the caller instead of read from the config. |
intent_bytes |
req: &CrossChainRequest |
Returns the canonical BCS encoding of the CrossChainIntent the request describes: the BCS of each field from source_chain_id to type_args, concatenated, without request_id. |
chain_id |
self: &SourceConfig |
Returns the chain id. |
request_id, source_chain_id, source_sender, target_chain_id, target_package, target_module, target_function, args, type_args |
req: &CrossChainRequest |
Accessors for the event fields. |
ack_request_id, ack_source_chain_id, ack_dest_tx_digest, ack_acknowledged_by |
ack: &RequestAcknowledged |
Accessors for the acknowledgement fields. |
Abort codes¶
| Code | Constant | Message | Raised by |
|---|---|---|---|
0 |
EEmptyTargetModule |
target_module must not be empty. |
request |
1 |
EEmptyTargetFunction |
target_function must not be empty. |
request |
bridge_abstract_account¶
The destination account. A BridgeAA is a shared object with no private key. It authenticates a
transaction by checking signed CrossChainIntents against an access control list (ACL) and then
checking that the transaction really contains the described calls.
Structs¶
| Name | Abilities | Fields | Notes |
|---|---|---|---|
BridgeAA |
key |
id |
The account. The chain id and the ACL entries are dynamic fields on its id. |
ChainIdFieldName |
copy, drop, store |
none | Dynamic-field key under which the account's chain_id: u64 is stored. |
AclKey |
copy, drop, store |
source_chain_id: u64, source_sender: address |
ACL entry key. |
AclEntry |
copy, drop, store |
pk_bytes: vector<u8>, scheme: u8 |
ACL value: the public key that vouches for that sender. scheme 0 is ed25519 (32-byte key), 1 is secp256k1 (33-byte key). |
CrossChainIntent |
copy, drop |
source_chain_id: u64, source_sender: address, target_chain_id: u64, target_package: address, target_module: vector<u8>, target_function: vector<u8>, args: vector<vector<u8>>, type_args: vector<vector<u8>> |
What the relayer signs. BCS-encoded and passed to the authenticator as bytes. |
The signed message is INTENT_DOMAIN_TAG, then the BCS of the account's own address, then the BCS of
the intent. INTENT_DOMAIN_TAG is bridge_abstract_account::CrossChainIntent::v1. The tag and the
account address stop a signature being replayed against another contract or another account.
The module emits no events.
Functions¶
| Function | Parameters | Effect |
|---|---|---|
create |
chain_id: u64, initial_source_chain_ids: vector<u64>, initial_source_senders: vector<address>, initial_pk_bytes: vector<vector<u8>>, initial_schemes: vector<u8>, authenticator: AuthenticatorFunctionRefV1<BridgeAA>, ctx |
Creates a BridgeAA bound to chain_id, with one ACL entry per index of the four parallel vectors, and registers it as an account. At least one entry is required. |
bridge_authenticator |
account: &BridgeAA, intents: vector<vector<u8>>, signatures: vector<vector<u8>>, auth_ctx: &AuthContext, _ctx |
The authenticator (#[authenticator]). Order of checks below. |
rotate_auth_function_ref_v1 |
self: &mut BridgeAA, authenticator, ctx |
Replaces the attached authenticator and returns the old reference. Sender must be the account. |
add_acl_entry |
self: &mut BridgeAA, source_chain_id: u64, source_sender: address, pk_bytes: vector<u8>, scheme: u8, ctx |
Adds or overwrites an ACL entry after validating the key. Sender must be the account. |
remove_acl_entry |
self: &mut BridgeAA, source_chain_id: u64, source_sender: address, ctx |
Removes an entry, revoking that sender's bridging rights. Sender must be the account. Aborts if the entry does not exist (df::remove). |
borrow_uid |
self: &BridgeAA |
Returns &UID. |
account_address |
self: &BridgeAA |
Returns the account address. |
chain_id |
self: &BridgeAA |
Returns the chain id the account is bound to. |
has_acl_entry |
self: &BridgeAA, source_chain_id: u64, source_sender: address |
Returns whether an entry exists. |
The three admin functions require ctx.sender() to equal the account's own address, which only
happens after a successful bridge_authenticator run. That is why create refuses an empty ACL and
why bridge_acl_add submits MoveAuthenticator transactions.
Authenticator check order¶
bridge_authenticator aborts at the first failing check, in this order
(bridge_authenticator(), verify_intent_signatures() and verify_ptb_matches_intents() in the
source):
- There is at least one intent (
ENoIntents), and as many signatures as intents (ELengthMismatch). - Every intent decodes as BCS with no trailing bytes. Trailing bytes abort with
EInvalidSignature, which prevents two byte strings decoding to the same intent. - For each intent, in order:
- Target chain.
target_chain_idequals the account'schain_id(EWrongTargetChain). - ACL. An entry exists for
(source_chain_id, source_sender)(ESenderNotInAcl). - Signature. The signature is valid over the signed message, under the entry's key and scheme
(
EInvalidSignature).
- Target chain.
- PTB match. Every intent has at least one matching Move call among the transaction's commands
(
ENoMatchingCall). A call matches when all of these hold:- package, module and function equal the intent's;
- the number of arguments equals
args.length(); - the BCS of each type argument equals the intent's
type_args[k], in order, with the same count; - every argument is a pure input (not an object, not a
Result) whose bytes equalargs[j].
Because only pure calls can match, an object-taking function such as bridge_source::acknowledge
can never be authorised by an intent. That is why acknowledge_pure exists.
Abort codes¶
| Code | Constant | Message | Raised by |
|---|---|---|---|
0 |
ELengthMismatch |
intents and signatures length mismatch. |
bridge_authenticator |
1 |
ESenderNotInAcl |
Source sender not in ACL. |
bridge_authenticator (ACL lookup) |
2 |
EInvalidSignature |
Invalid intent signature. |
signature check; also an intent with trailing bytes |
3 |
ENoMatchingCall |
No matching PTB call for intent. |
bridge_authenticator (PTB match) |
4 |
EWrongTargetChain |
Intent target_chain_id does not match this BridgeAA's chain. |
bridge_authenticator |
5 |
ETransactionSenderIsNotTheAccount |
Transaction must be signed by the account. |
the three admin functions |
6 |
ENoIntents |
bridge_authenticator requires at least one intent; empty-intent authentication is not allowed. |
bridge_authenticator |
7 |
EInvalidPublicKeyLength |
Public key length does not match the declared signature scheme. |
create, add_acl_entry |
8 |
EDegeneratePublicKey |
Public key must not be the all-zero/degenerate key. |
create, add_acl_entry |
9 |
EUnsupportedScheme |
Unsupported signature scheme. |
create, add_acl_entry (scheme other than 0 or 1) |
10 |
ENoInitialAclEntries |
create requires at least one initial ACL entry; ... |
create |
11 |
EInitialAclLengthMismatch |
Initial ACL entry vectors must have matching lengths. |
create |
For troubleshooting these codes against real failures, see Troubleshooting and Managing the ACL.
bridge_target¶
An all-pure landing target on the destination chain. The authenticator only matches calls whose every
argument is pure, so this module gives a bridged intent something to run end to end. It emits an event
instead of mutating state, so there is no shared object to contend on. bridge_acl_add and
bridge_aa_coins also use record as the anchor call that satisfies the authenticator.
Structs and events¶
| Name | Abilities | Fields | Notes |
|---|---|---|---|
Recorded |
copy, drop |
source_chain_id: u64, nonce: u64, payload: vector<u8>, executed_by: address |
Event emitted by record. For a bridged call, executed_by is the BridgeAA address. |
Functions¶
| Function | Parameters | Effect |
|---|---|---|
record |
source_chain_id: u64, nonce: u64, payload: vector<u8>, ctx |
Emits Recorded. |
source_chain_id, nonce, payload, executed_by |
rec: &Recorded |
Accessors for the event fields. |
The package defines no abort codes.