Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solana TokeBridge RegsiterChain #4171

Open
BonusGned opened this issue Nov 26, 2024 · 1 comment
Open

Solana TokeBridge RegsiterChain #4171

BonusGned opened this issue Nov 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@BonusGned
Copy link

Description and context

My contracts:

  • Core contract address: 25xyTc2vmJLxPWg4fewf7t4tvHdwFHacLeUXXofyXzbu
  • Token Bridge address: 8TCRqE8C4KNwDWk84NyD87thGtUjhsLwUZy7wQUWNyEa

I tried register ethereum Chain on my solana devnet program.
I call postVaa func from sdk with my VAA for registerChain, after I tried send insctruction for regsiterChain on tokenBridge.
I got InvalidOwner error:

Instruction created. Preparing transaction...
Sending transaction...
(node:26574) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Error creating or sending transaction: SendTransactionError: Simulation failed.
Message: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0.
Logs:
[
  "Program 8TCRqE8C4KNwDWk84NyD87thGtUjhsLwUZy7wQUWNyEa invoke [1]",
  "Program log: Error: InvalidOwner(25xyTc2vmJLxPWg4fewf7t4tvHdwFHacLeUXXofyXzbu)",
  "Program 8TCRqE8C4KNwDWk84NyD87thGtUjhsLwUZy7wQUWNyEa consumed 26373 of 200000 compute units",
  "Program 8TCRqE8C4KNwDWk84NyD87thGtUjhsLwUZy7wQUWNyEa failed: custom program error: 0x0"
].
Catch the `SendTransactionError` and call `getLogs()` on it for full details.
    at Connection.sendEncodedTransaction (/Users/boncho/projects/ultron/wormhole/wormhole-scaffolding/solana/node_modules/@solana/web3.js/src/connection.ts:6045:13)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Connection.sendRawTransaction (/Users/boncho/projects/ultron/wormhole/wormhole-scaffolding/solana/node_modules/@solana/web3.js/src/connection.ts:6001:20)
    at async Connection.sendTransaction (/Users/boncho/projects/ultron/wormhole/wormhole-scaffolding/solana/node_modules/@solana/web3.js/src/connection.ts:5989:12)
    at async sendAndConfirmTransaction (/Users/boncho/projects/ultron/wormhole/wormhole-scaffolding/solana/node_modules/@solana/web3.js/src/utils/send-and-confirm-transaction.ts:36:21)
    at async registerChain (/Users/boncho/projects/ultron/wormhole/wormhole-scaffolding/solana/ts/sdk/tokenBridge/registeChain.ts:25:27) {
  signature: '',
  transactionMessage: 'Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0',
  transactionLogs: [
    'Program 8TCRqE8C4KNwDWk84NyD87thGtUjhsLwUZy7wQUWNyEa invoke [1]',
    'Program log: Error: InvalidOwner(25xyTc2vmJLxPWg4fewf7t4tvHdwFHacLeUXXofyXzbu)',
    'Program 8TCRqE8C4KNwDWk84NyD87thGtUjhsLwUZy7wQUWNyEa consumed 26373 of 200000 compute units',
    'Program 8TCRqE8C4KNwDWk84NyD87thGtUjhsLwUZy7wQUWNyEa failed: custom program error: 0x0'
  ]
}

script postVaa:

import { postVaaSolana } from "@certusone/wormhole-sdk";
import { NodeWallet } from "@certusone/wormhole-sdk/lib/cjs/solana";
import { connection, payer, WORMHOLE_PID } from "../const";

export async function postCustomVAA(wormholeMessageBuffer: Buffer) {
	const wallet = NodeWallet.fromSecretKey(payer.secretKey);
	console.log("Posting VAA...");
	const transactions = await postVaaSolana(
		connection,
		wallet.signTransaction,
		WORMHOLE_PID,
		wallet.key(),
		wormholeMessageBuffer,
	);
	console.log("Posted VAA...");
	console.log("Transaction successful!", transactions);
}

async function postVaaMessage() {
	const vaaMessage = "01000000010200dc397f72adad509e0b9e38327db45de54cdc159fa541d3537fa331d051d789200684b0d58462748db15650a4cfaec5df669af30e4ce928a5c1179198c1185f360101b15c4f462643c38575f638f8264e6e193d1e2b61d9d573a564dcfd96ca041b4717051500bdba94180a0b6c91bb2917ac686bf880a70efe1b314779588286db4900000000000000000900010000000000000000000000000000000000000000000000000000000000000004000000000000000920000000000000000000000000000000000000000000546f6b656e4272696467650100000002000000000000000000000000b3acb4a8f7cc941ab347390d3e6fc2418b49f82c"

	const wormholeMessageBuffer = Buffer.from(vaaMessage, "hex");
	await postCustomVAA(wormholeMessageBuffer);
}

postVaaMessage();

script registerChain:

import * as tokenBridge from "@certusone/wormhole-sdk/lib/cjs/solana/tokenBridge";
import { connection, payer, TOKEN_BRIDGE_PID, WORMHOLE_PID } from "../const";
import { Transaction, sendAndConfirmTransaction } from "@solana/web3.js";

async function registerChain() {
    const vaaMessage =
        "01000000010200dc397f72adad509e0b9e38327db45de54cdc159fa541d3537fa331d051d789200684b0d58462748db15650a4cfaec5df669af30e4ce928a5c1179198c1185f360101b15c4f462643c38575f638f8264e6e193d1e2b61d9d573a564dcfd96ca041b4717051500bdba94180a0b6c91bb2917ac686bf880a70efe1b314779588286db4900000000000000000900010000000000000000000000000000000000000000000000000000000000000004000000000000000920000000000000000000000000000000000000000000546f6b656e4272696467650100000002000000000000000000000000b3acb4a8f7cc941ab347390d3e6fc2418b49f82c";
    const vaaMessageBuffer = Buffer.from(vaaMessage, "hex");
    try {
        const instruction = tokenBridge.createRegisterChainInstruction(
            TOKEN_BRIDGE_PID,
            WORMHOLE_PID,
            payer.publicKey,
            vaaMessageBuffer,
        );
        console.log("Instruction created. Preparing transaction...");

        // Create a transaction and add the instruction to it
        const transaction = new Transaction().add(instruction);

        // Sending the transaction
        console.log("Sending transaction...");
        const signature = await sendAndConfirmTransaction(connection, transaction, [
            payer,
        ]);

        console.log("Transaction successful! Signature:", signature);
    } catch (error) {
        console.error("Error creating or sending transaction:", error);
    }
}

registerChain();

I was able to update guardian set without any problems on solana. I understand that this is due to the fact that it happened on a core contract...

On the ethereum side I successfully registered solana without any problems, what am I missing on solana?

@BonusGned BonusGned added the bug Something isn't working label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants
@BonusGned and others