kevinheavey / anchor-bankrun

An Anchor wrapper for solana-bankrun
MIT License
12 stars 4 forks source link

Getting 'Signature verification failed' in methods.x.view() #8

Open metaproph3t opened 9 months ago

metaproph3t commented 9 months ago

When I try to use the .view() functionality provided by Anchor, I get a 'Signature verification failed' error.

For example, the following code gives this error (in bankrun, but not in normal anchor):

await clobProgram.methods                                                                                                                         
        .getMarketMakerBalances(failMM.publicKey)                                                                                                       
        .accounts({                                                                                                                                     
          orderBook: failMarket,                                                                                                                        
        })                                                                                                                                                                                                                                                                        
       .view();

A workaround is to pass the signer as a payer, like so:

await clobProgram.methods                                                                                                                         
        .getMarketMakerBalances(failMM.publicKey)                                                                                                       
        .accounts({                                                                                                                                     
          orderBook: failMarket,                                                                                                                        
        })                                                         
       .signers([payer])                                                                                                                                                                                                               
       .view();
kevinheavey commented 9 months ago

For the first code block, can you check if the ._signers attribute is empty in both regular anchor and anchor-bankrun? One guess is that BanksServer is checking signatures and solana-test-validator is not

GuidoDipietro commented 2 months ago

The standard simulateTransaction RPC method has additional config parameters such as sigVerify and replaceRecentBlockhash which are used extensively across different implementations, as we often don't care about those aspects when simulating a tx (such as when calculating CU).

Perhaps it is related to that?