Bonfida / token-vesting

A Vesting Contract for the Solana Blockchain
https://vesting.bonfida.org/
Other
252 stars 167 forks source link

Use Processor::process_instruction and turn on no-entrypoint #3

Closed joncinque closed 3 years ago

joncinque commented 3 years ago

The main change is to go from using process_instruction from the entrypoint to its Processor variant, and then pulling in the vesting program dependency with the no-entrypoint feature turned on.

I still get the issue of /tmp getting filled up with gigabytes of garbage within minute, but that'll likely be a change on the ProgramTest side to suppress all logging in the fuzz environment.

Lcchy commented 3 years ago

Thanks, loading the native code now works indeed. The downside is that this suppresses some log printing from the program that we do in entrypoint.rs:20. This gives less detailed output when debugging a (non-reproducible) fuzzing crash as for example:

[2021-01-20T15:42:40.999091872Z INFO  solana_program_test] "token_vesting" program loaded as native code
[2021-01-20T15:42:41.109117118Z DEBUG solana_runtime::message_processor] Program log: Beginning processing
[2021-01-20T15:42:41.109167766Z DEBUG solana_runtime::message_processor] Program log: Instruction unpacked
[2021-01-20T15:42:41.109181800Z DEBUG solana_runtime::message_processor] Program log: Instruction: Unlock
This crashfile didn't trigger any panics...

instead of:

[2021-01-20T15:42:53.473581980Z INFO  solana_program_test] "token_vesting" BPF program from /home/lcchy/repos/bonfida/token-vesting/program/target/deploy/token_vesting.so, modified 40 seconds ago
[2021-01-20T15:42:53.620866354Z DEBUG solana_runtime::message_processor] Program VestingbGKPFXCWuBvfkegQfZyiNwAJb9Ss623VQ5DA invoke [1]
[2021-01-20T15:42:53.621387003Z DEBUG solana_runtime::message_processor] Program log: Entrypoint
[2021-01-20T15:42:53.621433093Z DEBUG solana_runtime::message_processor] Program log: Beginning processing
[2021-01-20T15:42:53.621540037Z DEBUG solana_runtime::message_processor] Program log: Instruction unpacked
[2021-01-20T15:42:53.621570822Z DEBUG solana_runtime::message_processor] Program log: Instruction: Unlock
[2021-01-20T15:42:53.621783372Z DEBUG solana_runtime::message_processor] Program log: Error: InvalidSeeds
[2021-01-20T15:42:53.621997247Z DEBUG solana_rbpf::vm] BPF instructions executed: 364
[2021-01-20T15:42:53.622017132Z DEBUG solana_rbpf::vm] Max frame depth reached: 5
[2021-01-20T15:42:53.622095949Z DEBUG solana_runtime::message_processor] Program VestingbGKPFXCWuBvfkegQfZyiNwAJb9Ss623VQ5DA consumed 4083 of 200000 compute units
[2021-01-20T15:42:53.622167856Z DEBUG solana_runtime::message_processor] Program VestingbGKPFXCWuBvfkegQfZyiNwAJb9Ss623VQ5DA failed: Provided seeds do not result in a valid address
This crashfile didn't trigger any panics...

But we can still force the bpf to be loaded by using the BPF_OUT_DIR env variable and get the extra logging output while this PR is applied so I think it is good to go!

joncinque commented 3 years ago

Hm, I'm wondering how we can get both of those... you can enable some specific logs based on the fuzzing_debug configuration. See https://github.com/rust-fuzz/honggfuzz-rs#conditional-compilation for more info