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

Debugging native rust functions #17098

Open
yuvalelmo opened this issue Apr 9, 2024 · 5 comments
Open

Debugging native rust functions #17098

yuvalelmo opened this issue Apr 9, 2024 · 5 comments
Assignees
Labels
cli Command line tools doc-issue Issue submitted using the Doc issue template

Comments

@yuvalelmo
Copy link

Hi,
I am trying to debug some CLI Commands, which will ultimately call a move function, that in it's turn is calling a native rust function.
The way I'm debugging the code now is using the IDE's debugger, with the sub commands provided in the debugging configuration arguments.
It allows me to debug the code on the part of the client_commands.rs file, but I cannot manage to debug the native function that is called from the move code, which is implemented inside sui-move-natives.
I tried to put some breakpoints in there, but unfortunately this won't do the trick.

Is it possible to debug this kind of functions? If so, then how do I do this?
Thanks!

@yuvalelmo yuvalelmo added the doc-issue Issue submitted using the Doc issue template label Apr 9, 2024
@stefan-mysten stefan-mysten added the cli Command line tools label Apr 9, 2024
@yuvalelmo
Copy link
Author

yuvalelmo commented Apr 11, 2024

Another problem I have is that whenever I call this move function from the CLI, I get this error:

RPC call failed: ErrorObject { code: ServerError(-32002), message: "Failed to sign transaction by a quorum of validators because of locked objects. Retried a conflicting transaction Some(TransactionDigest(FnUF397ofhPF4rdbRPaXkF5yUG8M1RDTnj11oqsMV2ws)), success: Some(false)", data: Some(RawValue({"FnUF397ofhPF4rdbRPaXkF5yUG8M1RDTnj11oqsMV2ws":[["0x1166b06d4fdbb7a3c4cec1fad93b2daf70716fd586d3658816c0a9d7b0a026df",11,"EoN6VqGqXXpToVbP3ARTdiJbpYd2h9jocV3YPk4e469J"],["0x1166b06d4fdbb7a3c4cec1fad93b2daf70716fd586d3658816c0a9d7b0a026df",11,"EoN6VqGqXXpToVbP3ARTdiJbpYd2h9jocV3YPk4e469J"],["0x1166b06d4fdbb7a3c4cec1fad93b2daf70716fd586d3658816c0a9d7b0a026df",11,"EoN6VqGqXXpToVbP3ARTdiJbpYd2h9jocV3YPk4e469J"],["0x1166b06d4fdbb7a3c4cec1fad93b2daf70716fd586d3658816c0a9d7b0a026df",11,"EoN6VqGqXXpToVbP3ARTdiJbpYd2h9jocV3YPk4e469J"]]})) }

@amnn
Copy link
Contributor

amnn commented Apr 11, 2024

Hi @yuvalelmo, you should be able to set a breakpoint in a native function, but it's possible that the issue you're facing comes from the fact that there are multiple copies of the native functions (one for each execution version) and you may have set the breakpoint in a version that is not currently being used?

If you are running the network locally, then you will almost certainly be using this copy of sui-move-natives: https://github.com/MystenLabs/sui/tree/dd84ebd015b15cffbae1537833bbdb55b2840e8f/sui-execution/latest/sui-move-natives

But note that there is a v0, v1, and v2 as well.

@yuvalelmo
Copy link
Author

yuvalelmo commented Apr 14, 2024

Ok, thanks. I'll try this.
Looks like my other problem is making it impossible to even get to the relevant function.
I saw on other issues in this repo the the conflicting transaction happens because of locking the gas object.
I tried running the transaction from another sui address, and also tried it with just a different gas object ID instead of using a default one, but no outcome from this.

Maybe you have any input regarding this?
on the network logs i can see this line a few times in a row (probably because of retry mechanism)

2024-04-14T12:44:07.274572Z  INFO node{name=k#8dcff6d1..}:validator_state_process_tx{tx_digest=TransactionDigest(4NxigJB9hyJnvhDXmckro5DsScmPACC1q4LFTMg7tNd2)}: sui_core::authority::authority_store: Cannot acquire lock: conflicting transaction! prev_tx_digest=TransactionDigest(82uaGcNzmaivR1ND2yBb5J1i6S47JbB1VdQ5KihDd4Wm) cur_tx_digest=TransactionDigest(4NxigJB9hyJnvhDXmckro5DsScmPACC1q4LFTMg7tNd2)

Also, In the explorer, I cannot find any of these transactions 82uaGcNzmaivR1ND2yBb5J1i6S47JbB1VdQ5KihDd4Wm nor 4NxigJB9hyJnvhDXmckro5DsScmPACC1q4LFTMg7tNd2

@yuvalelmo
Copy link
Author

yuvalelmo commented Apr 15, 2024

Hey, I just noticed this error now on the node logs. it happens whenever I run this function from another address.

thread '<unnamed><unnamed>thread '' panicked at ' panicked at <unnamed>.../sui-execution/latest/sui-adapter/src/programmable_transactions/context.rs' panicked at .../sui-execution/latest/sui-adapter/src/programmable_transactions/context.rs770
.../sui-execution/latest/sui-adapter/src/programmable_transactions/context.rs::2024-04-15T08:43:00.351591Z ERROR node{name=k#99f25ef6..}:execution_driver{tx_digest=TransactionDigest(3SU3MyBjWFuZF1t7H4qFdz9KYKkzUZnShGJA3fiSRNyA)}: telemetry_subscribers: panicked at .../sui-execution/latest/sui-adapter/src/programmable_transactions/context.rs:770:21:

The only serialization I do to the arguments I send to the function is from object to bcs bytes, then to SuiJsonValue like this:

fn serialize_argument<T: serde::Serialize>(object: &T) -> Result<SuiJsonValue, Error> {
    let serialized_numbers = bcs::to_bytes(object)?
        .iter()
        .map(|v| Value::Number(Number::from (*v)))
        .collect();
    let object_as_sui_json = SuiJsonValue::new(Value::Array(serialized_numbers))?;
    Ok(object_as_sui_json)
}

@amnn
Copy link
Contributor

amnn commented Apr 16, 2024

Hi @yuvalelmo, the error that you've shared above looks like it's garbled and incomplete. Can you share the full message, with the stacktrace for the panic, and the steps you took to reproduce it? This includes changes to the validator codebase, e.g. to introduce the native function. It sounds like the problem you are facing is not related to the native function, but some other change, because you are not reaching the point at which the native function would have been called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Command line tools doc-issue Issue submitted using the Doc issue template
Projects
None yet
Development

No branches or pull requests

7 participants