anza-xyz / agave

Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.
https://www.anza.xyz/
Apache License 2.0
463 stars 228 forks source link

What should be placed in the instruction data? #3685

Closed Subway2023 closed 1 week ago

Subway2023 commented 1 week 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![],
}],
steviez commented 1 week ago

Hi @Subway2023 - we do not offer developer support on GH. You can try out Stack Exchange: https://solana.stackexchange.com/