Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set a future signature_expiration_ledger when using an Env::from_ledger_snapshot_file #1436

Open
kalepail opened this issue Jul 24, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@kalepail
Copy link

kalepail commented Jul 24, 2024

What version are you using?

soroban-sdk = "21.3.0"

% stellar --version
stellar 21.2.0 (2c8e512e88d9e29a6b66d63b23f60127675f3c46)
soroban-env 21.2.0 (8809852dcf8489f99407a5ceac12625ee3d14693)
soroban-env interface version 90194313216
stellar-xdr 21.2.0 (9bea881f2057e412fdbb98875841626bf77b4b88)
xdr curr (70180d5e8d9caee9e8645ed8a38c36a8cf403cd9)

What did you do?

let signature_expiration_ledger = env.ledger().sequence() + 1;

solver_client
    .set_auths(&[SorobanAuthorizationEntry {
        credentials: SorobanCredentials::Address(SorobanAddressCredentials {
            address: puzzle_id.clone().try_into().unwrap(),
            nonce,
            signature_expiration_ledger,
            signature: Signature {
                address: address.clone(),
                signature: BytesN::from_array(
                    &env,
                    &keypair.sign(payload.to_array().as_slice()).to_bytes(),
                ),
            }
            .try_into()
            .unwrap(),
        }),
        root_invocation,
    }])
    .call(&puzzle_id, &sac);

Note it works when using the current ledger sequence and not advancing it at all. But that's not what the signature_expiration_ledger is really intended to be set to.

What did you expect to see?

A successful test. (it works when using Env::default)

What did you see instead?

thread 'test::test' panicked at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-env-host-21.2.0/src/host.rs:768:9:
HostError: Error(Auth, InvalidInput)

Event log (newest first):
   0: [Diagnostic Event] topics:[error, Error(Auth, InvalidInput)], data:"escalating error to panic"
   1: [Diagnostic Event] topics:[error, Error(Auth, InvalidInput)], data:["contract call failed", call, [CCPYY3EQZQ6SQE2XRHCU5VVH4DCR3ZCNRHIS5ITCSMBK2WOPMN56LEAV, CDGOXJBEKI3MQDB3J477NN3HAQBDCNK5YYB2ZKAG24US53RXW44QIF6Z]]
   2: [Failed Diagnostic Event (not emitted)] contract:CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM, topics:[error, Error(Auth, InvalidInput)], data:"caught error from function"
   3: [Failed Diagnostic Event (not emitted)] contract:CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM, topics:[error, Error(Auth, InvalidInput)], data:"escalating error to panic"
   4: [Failed Diagnostic Event (not emitted)] contract:CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM, topics:[error, Error(Auth, InvalidInput)], data:["signature expiration is too late", CCPYY3EQZQ6SQE2XRHCU5VVH4DCR3ZCNRHIS5ITCSMBK2WOPMN56LEAV, 705663, 705664]
   5: [Failed Diagnostic Event (not emitted)] contract:CCPYY3EQZQ6SQE2XRHCU5VVH4DCR3ZCNRHIS5ITCSMBK2WOPMN56LEAV, topics:[fn_return, __check_auth], data:Void
   6: [Failed Diagnostic Event (not emitted)] contract:CDGOXJBEKI3MQDB3J477NN3HAQBDCNK5YYB2ZKAG24US53RXW44QIF6Z, topics:[fn_return, transfer], data:Void
   7: [Failed Contract Event (not emitted)] contract:CDGOXJBEKI3MQDB3J477NN3HAQBDCNK5YYB2ZKAG24US53RXW44QIF6Z, topics:[transfer, CCPYY3EQZQ6SQE2XRHCU5VVH4DCR3ZCNRHIS5ITCSMBK2WOPMN56LEAV, GCQXHDLSMF6YR53VNE6JXEBT3C53THISP2U2YDYESQG5BEBVBRNU4HZH, "PUZZLE:GCUY5ECTBWZ5JGLXPPKSK4Y34RIMN2AEO4UNGQRRBF6AVVDSXSWLJLEN"], data:10000000
   8: [Failed Diagnostic Event (not emitted)] contract:CCPYY3EQZQ6SQE2XRHCU5VVH4DCR3ZCNRHIS5ITCSMBK2WOPMN56LEAV, topics:[fn_call, Bytes(cceba4245236c80c3b4f3ff6b767040231355dc603aca806d7292eee37b73904), transfer], data:[CCPYY3EQZQ6SQE2XRHCU5VVH4DCR3ZCNRHIS5ITCSMBK2WOPMN56LEAV, GCQXHDLSMF6YR53VNE6JXEBT3C53THISP2U2YDYESQG5BEBVBRNU4HZH, 10000000]
   9: [Failed Diagnostic Event (not emitted)] contract:CDGOXJBEKI3MQDB3J477NN3HAQBDCNK5YYB2ZKAG24US53RXW44QIF6Z, topics:[fn_return, balance], data:170141183460469231731687303715874105727
   10: [Failed Diagnostic Event (not emitted)] contract:CCPYY3EQZQ6SQE2XRHCU5VVH4DCR3ZCNRHIS5ITCSMBK2WOPMN56LEAV, topics:[fn_call, Bytes(cceba4245236c80c3b4f3ff6b767040231355dc603aca806d7292eee37b73904), balance], data:CCPYY3EQZQ6SQE2XRHCU5VVH4DCR3ZCNRHIS5ITCSMBK2WOPMN56LEAV
   11: [Failed Diagnostic Event (not emitted)] contract:CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM, topics:[fn_call, Bytes(9f8c6c90cc3d28135789c54ed6a7e0c51de44d89d12ea2629302ad59cf637be5), __check_auth], data:[Bytes(51650452f58d70dc8591b49869b618904cd37fda4d78fb2de06d566f8680352b), {address: GCQXHDLSMF6YR53VNE6JXEBT3C53THISP2U2YDYESQG5BEBVBRNU4HZH, signature: Bytes(4f54994aba9d19c62bc3f504708dff08c59ae7e7e6c765c37f6ab8754185197b00471dc6317282c7b4b10718107fd2cf4eee495456743f1671ca564411e8da0f)}, [[Contract, {args: [CDGOXJBEKI3MQDB3J477NN3HAQBDCNK5YYB2ZKAG24US53RXW44QIF6Z, 3514694388], contract: CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM, fn_name: call}]]]
   12: [Failed Diagnostic Event (not emitted)] contract:CDGOXJBEKI3MQDB3J477NN3HAQBDCNK5YYB2ZKAG24US53RXW44QIF6Z, topics:[fn_return, balance], data:170141183460469231731687303715874105727
   13: [Failed Diagnostic Event (not emitted)] contract:CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM, topics:[fn_call, Bytes(cceba4245236c80c3b4f3ff6b767040231355dc603aca806d7292eee37b73904), balance], data:CCPYY3EQZQ6SQE2XRHCU5VVH4DCR3ZCNRHIS5ITCSMBK2WOPMN56LEAV
   14: [Diagnostic Event] topics:[fn_call, Bytes(0000000000000000000000000000000000000000000000000000000000000001), call], data:[CCPYY3EQZQ6SQE2XRHCU5VVH4DCR3ZCNRHIS5ITCSMBK2WOPMN56LEAV, CDGOXJBEKI3MQDB3J477NN3HAQBDCNK5YYB2ZKAG24US53RXW44QIF6Z]
   15: [Diagnostic Event] contract:CDGOXJBEKI3MQDB3J477NN3HAQBDCNK5YYB2ZKAG24US53RXW44QIF6Z, topics:[fn_return, balance], data:170141183460469231731687303715874105727
   16: [Diagnostic Event] contract:CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4, topics:[fn_call, Bytes(cceba4245236c80c3b4f3ff6b767040231355dc603aca806d7292eee37b73904), balance], data:CCPYY3EQZQ6SQE2XRHCU5VVH4DCR3ZCNRHIS5ITCSMBK2WOPMN56LEAV
   17: [Diagnostic Event] contract:CDGOXJBEKI3MQDB3J477NN3HAQBDCNK5YYB2ZKAG24US53RXW44QIF6Z, topics:[fn_return, balance], data:10000000
   18: [Diagnostic Event] topics:[fn_call, Bytes(cceba4245236c80c3b4f3ff6b767040231355dc603aca806d7292eee37b73904), balance], data:GCQXHDLSMF6YR53VNE6JXEBT3C53THISP2U2YDYESQG5BEBVBRNU4HZH
   19: [Diagnostic Event] contract:CDGOXJBEKI3MQDB3J477NN3HAQBDCNK5YYB2ZKAG24US53RXW44QIF6Z, topics:[fn_return, balance], data:170141183460469231731687303715874105727
   20: [Diagnostic Event] topics:[fn_call, Bytes(cceba4245236c80c3b4f3ff6b767040231355dc603aca806d7292eee37b73904), balance], data:CCPYY3EQZQ6SQE2XRHCU5VVH4DCR3ZCNRHIS5ITCSMBK2WOPMN56LEAV

Backtrace (newest first):
   0: backtrace::backtrace::libunwind::trace
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/libunwind.rs:93:5
      backtrace::backtrace::trace_unsynchronized
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:66:5
   1: backtrace::backtrace::trace
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:53:14
   2: backtrace::capture::Backtrace::create
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:176:9
   3: backtrace::capture::Backtrace::new_unresolved
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:170:9
   4: soroban_env_host::host::error::<impl soroban_env_host::host::Host>::maybe_get_debug_info::{{closure}}
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-env-host-21.2.0/src/host/error.rs:293:37
   5: soroban_env_host::budget::Budget::with_shadow_mode
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-env-host-21.2.0/src/budget.rs:972:21
   6: soroban_env_host::host::Host::with_debug_mode
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-env-host-21.2.0/src/host.rs:615:24
   7: soroban_env_host::host::error::<impl soroban_env_host::host::Host>::maybe_get_debug_info
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-env-host-21.2.0/src/host/error.rs:290:13
   8: soroban_env_host::host::error::<impl soroban_env_host::host::Host>::error::{{closure}}
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-env-host-21.2.0/src/host/error.rs:274:23
   9: soroban_env_host::budget::Budget::with_shadow_mode
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-env-host-21.2.0/src/budget.rs:972:21
  10: soroban_env_host::host::Host::with_debug_mode
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-env-host-21.2.0/src/host.rs:615:24
  11: soroban_env_host::host::error::<impl soroban_env_host::host::Host>::error
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-env-host-21.2.0/src/host/error.rs:261:9
  12: <soroban_env_host::host::Host as soroban_env_common::env::EnvBase>::escalate_error_to_panic
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-env-host-21.2.0/src/host.rs:767:26
  13: soroban_sdk::env::internal::reject_err::{{closure}}
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-sdk-21.3.0/src/env.rs:52:23
  14: core::result::Result<T,E>::map_err
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/result.rs:829:27
  15: soroban_sdk::env::internal::reject_err
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-sdk-21.3.0/src/env.rs:52:9
  16: <soroban_sdk::env::Env as soroban_env_common::env::Env>::call
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-sdk-21.3.0/src/env.rs:1644:13
  17: soroban_sdk::env::Env::invoke_contract
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-sdk-21.3.0/src/env.rs:379:18
  18: solver::ContractClient::call
             at src/lib.rs:10:1
  19: solver::test::test
             at src/test.rs:127:5
  20: solver::test::test::{{closure}}
             at src/test.rs:24:10
  21: core::ops::function::FnOnce::call_once
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5


stack backtrace:
   0: rust_begin_unwind
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
   1: core::panicking::panic_fmt
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
   2: <soroban_env_host::host::Host as soroban_env_common::env::EnvBase>::escalate_error_to_panic
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-env-host-21.2.0/src/host.rs:768:9
   3: soroban_sdk::env::internal::reject_err::{{closure}}
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-sdk-21.3.0/src/env.rs:52:23
   4: core::result::Result<T,E>::map_err
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/result.rs:829:27
   5: soroban_sdk::env::internal::reject_err
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-sdk-21.3.0/src/env.rs:52:9
   6: <soroban_sdk::env::Env as soroban_env_common::env::Env>::call
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-sdk-21.3.0/src/env.rs:1644:13
   7: soroban_sdk::env::Env::invoke_contract
             at /Users/tylervanderhoeven/.cargo/registry/src/index.crates.io-6f17d22bba15001f/soroban-sdk-21.3.0/src/env.rs:379:18
   8: solver::ContractClient::call
             at ./src/lib.rs:10:1
   9: solver::test::test
             at ./src/test.rs:127:5
  10: solver::test::test::{{closure}}
             at ./src/test.rs:24:10
  11: core::ops::function::FnOnce::call_once
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
  12: core::ops::function::FnOnce::call_once
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Writing test snapshot file for test "test::test" to "test_snapshots/test/test.1.json".


failures:
    test::test

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.61s

error: test failed, to rerun pass `-p solver --lib`

 *  The terminal process "cargo 'test', '--package', 'solver', '--lib', '--', 'test::test', '--exact', '--show-output'" terminated with exit code: 101. 
 *  Terminal will be reused by tasks, press any key to close it. 
@kalepail kalepail added the bug Something isn't working label Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant