Search code examples
anchorsmartcontractssolanaanchor-solana

anchor-spl v0.30.1 solana-spl 1.18.17 error[E0308]: mismatched types


I'm building solana smart contract with anchor. anchor version is 0.30.1 solana-cli version is 1.18.17 first time, I built and deploy smart contract without any issue. But after I add this two lines, I get too long errors.

use anchor_spl::token::{self, Token, TokenAccount, Mint, Transfer};
use std::cmp::min;

I don't understand why this occurs error. How can I solve this issue?

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/instruction.rs:784:27
    |
784 |         instructions.push(verify_pubkey_validity(None, proof_data));
    |                      ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Instruction`, found `solana_program::instruction::Instruction`
    |                      |
    |                      arguments to this method are incorrect
    |
    = note: `solana_program::instruction::Instruction` and `Instruction` have similar names, but are actually distinct types
note: `solana_program::instruction::Instruction` is defined in crate `solana_program`
   --> src/instruction.rs:332:1
note: `Instruction` is defined in crate `solana_program`
   --> src/instruction.rs:329:1
    = note: perhaps two different versions of crate `solana_program` are being used?
note: method defined here
   --> /home/runner/work/platform-tools/platform-tools/out/rust/library/alloc/src/vec/mod.rs:1880:12

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/instruction.rs:887:27
    |
887 |         instructions.push(verify_zero_balance(None, proof_data));
    |                      ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Instruction`, found `solana_program::instruction::Instruction`
    |                      |
    |                      arguments to this method are incorrect
    |
    = note: `solana_program::instruction::Instruction` and `Instruction` have similar names, but are actually distinct types
note: `solana_program::instruction::Instruction` is defined in crate `solana_program`
   --> src/instruction.rs:332:1
note: `Instruction` is defined in crate `solana_program`
   --> src/instruction.rs:329:1
    = note: perhaps two different versions of crate `solana_program` are being used?
note: method defined here
   --> /home/runner/work/platform-tools/platform-tools/out/rust/library/alloc/src/vec/mod.rs:1880:12

error[E0308]: mismatched types
    --> src/extension/confidential_transfer/instruction.rs:1018:27
     |
1018 |         instructions.push(verify_withdraw(None, proof_data));
     |                      ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Instruction`, found `solana_program::instruction::Instruction`
     |                      |
     |                      arguments to this method are incorrect
     |
     = note: `solana_program::instruction::Instruction` and `Instruction` have similar names, but are actually distinct types
note: `solana_program::instruction::Instruction` is defined in crate `solana_program`
    --> src/instruction.rs:332:1
note: `Instruction` is defined in crate `solana_program`
    --> src/instruction.rs:329:1
     = note: perhaps two different versions of crate `solana_program` are being used?
note: method defined here
    --> /home/runner/work/platform-tools/platform-tools/out/rust/library/alloc/src/vec/mod.rs:1880:12

error[E0308]: mismatched types
    --> src/extension/confidential_transfer/instruction.rs:1111:27
     |
1111 |         instructions.push(verify_transfer(None, proof_data));
     |                      ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Instruction`, found `solana_program::instruction::Instruction`
     |                      |
     |                      arguments to this method are incorrect
     |
     = note: `solana_program::instruction::Instruction` and `Instruction` have similar names, but are actually distinct types
note: `solana_program::instruction::Instruction` is defined in crate `solana_program`
    --> src/instruction.rs:332:1
note: `Instruction` is defined in crate `solana_program`
    --> src/instruction.rs:329:1
     = note: perhaps two different versions of crate `solana_program` are being used?
note: method defined here
    --> /home/runner/work/platform-tools/platform-tools/out/rust/library/alloc/src/vec/mod.rs:1880:12

error[E0308]: mismatched types
    --> src/extension/confidential_transfer/instruction.rs:1204:27
     |
1204 |         instructions.push(verify_transfer_with_fee(None, proof_data));
     |                      ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Instruction`, found `solana_program::instruction::Instruction`
     |                      |
     |                      arguments to this method are incorrect
     |
     = note: `solana_program::instruction::Instruction` and `Instruction` have similar names, but are actually distinct types
note: `solana_program::instruction::Instruction` is defined in crate `solana_program`
    --> src/instruction.rs:332:1
note: `Instruction` is defined in crate `solana_program`
    --> src/instruction.rs:329:1
     = note: perhaps two different versions of crate `solana_program` are being used?
note: method defined here
    --> /home/runner/work/platform-tools/platform-tools/out/rust/library/alloc/src/vec/mod.rs:1880:12

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:197:48
    |
197 |                         context_state_account: equality_proof_context_state_account_info.key,
    |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:198:50
    |
198 |                         context_state_authority: context_state_account_authority_info.key,
    |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:200:21
    |
195 |                 &zk_token_proof_instruction::close_context_state(
    |                  ----------------------------------------------- arguments to this function are incorrect
...
200 |                     lamport_destination_account_info.key,
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?
note: function defined here
   --> src/zk_token_proof_instruction.rs:364:8

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:195:17
    |
194 |               invoke(
    |               ------ arguments to this function are incorrect
195 | /                 &zk_token_proof_instruction::close_context_state(
196 | |                     ContextStateInfo {
197 | |                         context_state_account: equality_proof_context_state_account_info.key,
198 | |                         context_state_authority: context_state_account_authority_info.key,
199 | |                     },
200 | |                     lamport_destination_account_info.key,
201 | |                 ),
    | |_________________^ expected `Instruction`, found `solana_program::instruction::Instruction`
    |
    = note: `solana_program::instruction::Instruction` and `Instruction` have similar names, but are actually distinct types
note: `solana_program::instruction::Instruction` is defined in crate `solana_program`
   --> src/instruction.rs:332:1
note: `Instruction` is defined in crate `solana_program`
   --> src/instruction.rs:329:1
    = note: perhaps two different versions of crate `solana_program` are being used?
note: function defined here
   --> src/program.rs:132:8

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:213:48
    |
213 |                           context_state_account: ciphertext_validity_proof_context_state_account_info
    |  ________________________________________________^
214 | |                             .key,
    | |________________________________^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:215:50
    |
215 |                         context_state_authority: context_state_account_authority_info.key,
    |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:217:21
    |
211 |                 &zk_token_proof_instruction::close_context_state(
    |                  ----------------------------------------------- arguments to this function are incorrect
...
217 |                     lamport_destination_account_info.key,
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?
note: function defined here
   --> src/zk_token_proof_instruction.rs:364:8

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:211:17
    |
210 |               invoke(
    |               ------ arguments to this function are incorrect
211 | /                 &zk_token_proof_instruction::close_context_state(
212 | |                     ContextStateInfo {
213 | |                         context_state_account: ciphertext_validity_proof_context_state_account_info
214 | |                             .key,
...   |
217 | |                     lamport_destination_account_info.key,
218 | |                 ),
    | |_________________^ expected `Instruction`, found `solana_program::instruction::Instruction`
    |
    = note: `solana_program::instruction::Instruction` and `Instruction` have similar names, but are actually distinct types
note: `solana_program::instruction::Instruction` is defined in crate `solana_program`
   --> src/instruction.rs:332:1
note: `Instruction` is defined in crate `solana_program`
   --> src/instruction.rs:329:1
    = note: perhaps two different versions of crate `solana_program` are being used?
note: function defined here
   --> src/program.rs:132:8

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:230:48
    |
230 |                         context_state_account: range_proof_context_state_account_info.key,
    |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:231:50
    |
231 |                         context_state_authority: context_state_account_authority_info.key,
    |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:233:21
    |
228 |                 &zk_token_proof_instruction::close_context_state(
    |                  ----------------------------------------------- arguments to this function are incorrect
...
233 |                     lamport_destination_account_info.key,
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?
note: function defined here
   --> src/zk_token_proof_instruction.rs:364:8

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:228:17
    |
227 |               invoke(
    |               ------ arguments to this function are incorrect
228 | /                 &zk_token_proof_instruction::close_context_state(
229 | |                     ContextStateInfo {
230 | |                         context_state_account: range_proof_context_state_account_info.key,
231 | |                         context_state_authority: context_state_account_authority_info.key,
232 | |                     },
233 | |                     lamport_destination_account_info.key,
234 | |                 ),
    | |_________________^ expected `Instruction`, found `solana_program::instruction::Instruction`
    |
    = note: `solana_program::instruction::Instruction` and `Instruction` have similar names, but are actually distinct types
note: `solana_program::instruction::Instruction` is defined in crate `solana_program`
   --> src/instruction.rs:332:1
note: `Instruction` is defined in crate `solana_program`
   --> src/instruction.rs:329:1
    = note: perhaps two different versions of crate `solana_program` are being used?
note: function defined here
   --> src/program.rs:132:8

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:373:48
    |
373 |                         context_state_account: equality_proof_context_state_account_info.key,
    |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:374:50
    |
374 |                         context_state_authority: context_state_account_authority_info.key,
    |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:376:21
    |
371 |                 &zk_token_proof_instruction::close_context_state(
    |                  ----------------------------------------------- arguments to this function are incorrect
...
376 |                     lamport_destination_account_info.key,
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?
note: function defined here
   --> src/zk_token_proof_instruction.rs:364:8

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:371:17
    |
370 |               invoke(
    |               ------ arguments to this function are incorrect
371 | /                 &zk_token_proof_instruction::close_context_state(
372 | |                     ContextStateInfo {
373 | |                         context_state_account: equality_proof_context_state_account_info.key,
374 | |                         context_state_authority: context_state_account_authority_info.key,
375 | |                     },
376 | |                     lamport_destination_account_info.key,
377 | |                 ),
    | |_________________^ expected `Instruction`, found `solana_program::instruction::Instruction`
    |
    = note: `solana_program::instruction::Instruction` and `Instruction` have similar names, but are actually distinct types
note: `solana_program::instruction::Instruction` is defined in crate `solana_program`
   --> src/instruction.rs:332:1
note: `Instruction` is defined in crate `solana_program`
   --> src/instruction.rs:329:1
    = note: perhaps two different versions of crate `solana_program` are being used?
note: function defined here
   --> src/program.rs:132:8

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:390:29
    |
390 | ...                   transfer_amount_ciphertext_validity_proof_context_state_account_info.key,
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:391:50
    |
391 |                         context_state_authority: context_state_account_authority_info.key,
    |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:393:21
    |
387 |                 &zk_token_proof_instruction::close_context_state(
    |                  ----------------------------------------------- arguments to this function are incorrect
...
393 |                     lamport_destination_account_info.key,
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?
note: function defined here
   --> src/zk_token_proof_instruction.rs:364:8

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:387:17
    |
386 |               invoke(
    |               ------ arguments to this function are incorrect
387 | /                 &zk_token_proof_instruction::close_context_state(
388 | |                     ContextStateInfo {
389 | |                         context_state_account:
390 | |                             transfer_amount_ciphertext_validity_proof_context_state_account_info.key,
...   |
393 | |                     lamport_destination_account_info.key,
394 | |                 ),
    | |_________________^ expected `Instruction`, found `solana_program::instruction::Instruction`
    |
    = note: `solana_program::instruction::Instruction` and `Instruction` have similar names, but are actually distinct types
note: `solana_program::instruction::Instruction` is defined in crate `solana_program`
   --> src/instruction.rs:332:1
note: `Instruction` is defined in crate `solana_program`
   --> src/instruction.rs:329:1
    = note: perhaps two different versions of crate `solana_program` are being used?
note: function defined here
   --> src/program.rs:132:8

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:406:48
    |
406 |                         context_state_account: fee_sigma_proof_context_state_account_info.key,
    |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:407:50
    |
407 |                         context_state_authority: context_state_account_authority_info.key,
    |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `solana_program::pubkey::Pubkey`, found `Pubkey`
    |
    = note: `Pubkey` and `solana_program::pubkey::Pubkey` have similar names, but are actually distinct types
note: `Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:88:1
note: `solana_program::pubkey::Pubkey` is defined in crate `solana_program`
   --> src/pubkey.rs:96:1
    = note: perhaps two different versions of crate `solana_program` are being used?

error[E0308]: mismatched types
   --> src/extension/confidential_transfer/verify_proof.rs:409:21
    |
404 |                 &zk_token_proof_instruction::close_context_state(
    |                  ----------------------------------------------- arguments to this function are incorrect

...

I think this is because version matching issue. Why I get this issue with anchor?


Solution

  • To fix this problem, you can downgrade Solana v2 dependencies by manually editing your lock file or simply running:

    cargo update -p [email protected] --precise 1.18.17