solana-labs / solana

Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.
https://solanalabs.com
Apache License 2.0
13.2k stars 4.3k forks source link

What should be placed in the instruction data? #35691

Closed Subway2023 closed 3 hours ago

Subway2023 commented 3 hours ago

Problem

I replaced hello_solana_program.so with my own C.so in integration_test.rs, but the execution failed. My command is as follows:

contract C {
    function f() public pure returns (uint r1)
    {
        uint8 a=0;
        r1=a+1234;
    }
}
solang compile --target solana C.sol --output ./output

replace hello_solana_program.so with C.so, then perform test and print result

cargo test --package solana-svm --test integration_sbw_test -- svm_integration --exact --show-output

there is error:

Result: [Executed { details: TransactionExecutionDetails { status: Err(InstructionError(0, InvalidAccountData)), log_messages: Some(["Program 1111111QLbz7JHiBTspS962RLKV8GndWFwiEaqKM invoke [1]", "Program is not deployed", "Program 1111111QLbz7JHiBTspS962RLKV8GndWFwiEaqKM failed: invalid account data for instruction"]), inner_instructions: None, durable_nonce_fee: None, return_data: None, executed_units: 0, accounts_data_len_delta: 0 }, programs_modified_by_tx: LoadedProgramsForTxBatch { entries: {}, slot: 5, environments: ProgramRuntimeEnvironments { program_runtime_v1: FunctionRegistry { map: {544561597: ([115, 111, 108, 95, 108, 111, 103, 95], 110517777804608), 930151202: ([115, 111, 108, 95, 109, 101, 109, 115, 101, 116, 95], 110517778118528), 1904002211: ([115, 111, 108, 95, 109, 101, 109, 99, 112, 121, 95], 110517778114016), 3069975057: ([97, 98, 111, 114, 116], 110517777846288)} }
, program_runtime_v2: FunctionRegistry { map: {} }
 }, hit_max_limit: false } }]
thread 'svm_integration' panicked at svm/tests/integration_sbw_test.rs:260:5:
assertion failed: result.execution_results[0].details().unwrap().status.is_ok()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Analyze

I suspect the error is caused by not assigning a value to the data field of the instruction, but I'm not sure what value should be assigned, shown in code

instructions: vec![CompiledInstruction {
    program_id_index: 1,
    accounts: vec![],
    data: vec![],
}],
github-actions[bot] commented 3 hours ago

This repository is no longer in use. Please re-open this issue in the agave repo: https://github.com/anza-xyz/agave