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

How to query the transaction detail which have the internal transfer by json-rpc api? #12697

Open
5 of 11 tasks
carrie143 opened this issue Nov 14, 2024 · 1 comment
Open
5 of 11 tasks
Labels
kind/bug Kind: Bug

Comments

@carrie143
Copy link

Checklist

  • This is not a security-related bug/issue. If it is, please follow please follow the security policy.
  • I have searched on the issue tracker and the lotus forum, and there is no existing related issue or discussion.
  • I am running the Latest release, the most recent RC(release canadiate) for the upcoming release or the dev branch(master), or have an issue updating to any of these.
  • I did not make any code changes to lotus.

Lotus component

  • lotus daemon - chain sync
  • lotus fvm/fevm - Lotus FVM and FEVM interactions
  • lotus miner/worker - sealing
  • lotus miner - proving(WindowPoSt/WinningPoSt)
  • lotus JSON-RPC API
  • lotus message management (mpool)
  • Other

Lotus Version

the latets

Repro Steps

1.I want to query the internal transfer detail in transaction,like:
https://filscan.io/message/bafy2bzacecy4adusijbg6qdjx6w7aifgkbrkgst2ovu42zghrupgy22g5sek6/#trade
There is a internal transfer,send 1000fil from f02260507 to f03024609
2. I try to call "Filecoin.ChainGetMessage",but don't return internal transfer detail,So any other json-rpc api to use?

Describe the Bug

~

Logging Information

~
@carrie143 carrie143 added the kind/bug Kind: Bug label Nov 14, 2024
@github-project-automation github-project-automation bot moved this to 📌 Triage in FilOz Nov 14, 2024
@rvagg
Copy link
Member

rvagg commented Nov 15, 2024

Good question, I'm not sure if there's a more efficient way to do this but here's my take on how you can get the full internal trace information:

First I need to find where the message was executed with StateSearchMsg:

$ curl -s -X POST -H "Content-Type: application/json" --data '{"method":"Filecoin.StateSearchMsg","params":[[],{"/":"bafy2bzacecy4adusijbg6qdjx6w7aifgkbrkgst2ovu42zghrupgy22g5sek6"},-1,false],"id":2,"jsonrpc":"2.0"}' http://127.0.0.1:1234/rpc/v1
{"id":2,"jsonrpc":"2.0","result":{"Message":{"/":"bafy2bzacecy4adusijbg6qdjx6w7aifgkbrkgst2ovu42zghrupgy22g5sek6"},"Receipt":{"ExitCode":0,"Return":"g/UAQA==","GasUsed":10986123,"EventsRoot":null},"ReturnDec":null,"TipSet":[{"/":"bafy2bzacecnv2vfsyjb6clcwojmxqv2nxoc5576v5p4mls6ynpaa7tuhkolu2"},{"/":"bafy2bzaceblf5v2k2z7g2mqleih5ut73dincvxvdct7exgash5c7ll3omnn32"}],"Height":3751470}}

So I know the tipset where the message was executed, but I need the parent state of epoch 3751470 because that's the base state upon which the message was executed. I could look it up with ChainGetTipSetByHeight with 3751469, but for accuracy, I should look up the parent tipset of the tipset that's been identified by StateSearchMsg, using ChainGetTipSet:

$ curl -s -X POST -H "Content-Type: application/json" --data '{"method":"Filecoin.ChainGetTipSet","params":[[{"/":"bafy2bzacecnv2vfsyjb6clcwojmxqv2nxoc5576v5p4mls6ynpaa7tuhkolu2"},{"/":"bafy2bzaceblf5v2k2z7g2mqleih5ut73dincvxvdct7exgash5c7ll3omnn32"}]],"id":2,"jsonrpc":"2.0"}' http://127.0.0.1:1234/rpc/v1 | jq '.result.Blocks[0].Parents' -c
[{"/":"bafy2bzacebpmxy7lnchw2j4jz2xde7jlhssv76fzsvkuh74m2u63rgx3i6hsm"},{"/":"bafy2bzacedzbv67vgie3so7vtf24tlaelrdiedpg36ecnixtl4mezd5yofene"},{"/":"bafy2bzaceddojcd4lkjs4jbto575fdbre6ztanllzvbpd7ihsvqn43f6vrxhg"},{"/":"bafy2bzaced7nl2ifbj5pv7l2jqgyk6ljjbuvneykhv3pvdbeuhpp46icwhwfg"},{"/":"bafy2bzaceapgmimjbfmhm42rahwsbmkzetu7lqmz4tdsc4clzc6ppu76oqf5w"}]

Now I have the tipset of the parent state so I can replay the transaction and see what happened, using StateReplay:

$ curl -s -X POST -H "Content-Type: application/json" --data '{"method":"Filecoin.StateReplay","params":[[{"/":"bafy2bzacebpmxy7lnchw2j4jz2xde7jlhssv76fzsvkuh74m2u63rgx3i6hsm"},{"/":"bafy2bzacedzbv67vgie3so7vtf24tlaelrdiedpg36ecnixtl4mezd5yofene"},{"/":"bafy2bzaceddojcd4lkjs4jbto575fdbre6ztanllzvbpd7ihsvqn43f6vrxhg"},{"/":"bafy2bzaced7nl2ifbj5pv7l2jqgyk6ljjbuvneykhv3pvdbeuhpp46icwhwfg"},{"/":"bafy2bzaceapgmimjbfmhm42rahwsbmkzetu7lqmz4tdsc4clzc6ppu76oqf5w"}],{"/":"bafy2bzacecy4adusijbg6qdjx6w7aifgkbrkgst2ovu42zghrupgy22g5sek6"}],"id":2,"jsonrpc":"2.0"}' http://127.0.0.1:1234/rpc/v1 | jq
...

If I jq that with jq .result.ExecutionTrace.Subcalls then I can see that msg that you're looking for:

[
  {
    "Msg": {
      "From": "f02260507",
      "To": "f03024609",
      "Value": "1000000000000000000000",
      "Method": 0,
      "Params": null,
      "ParamsCodec": 0,
      "GasLimit": 10878208,
      "ReadOnly": false
    },
    "MsgRct": {
      "ExitCode": 0,
      "Return": null,
      "ReturnCodec": 0
    },
...
]

If you're going to be rigorous about this then you'd want to look at all of the subcalls, there may be more than one, and you'd want to (a) look at the exit code of the original message to see that it's 0 and (b) the exit code of the internal subcall as well to make sure it's 0 (I think if the internal fails then the external will too though).

And to achieve all this you'll obviously need to have access to a node that has history that far back, since you're looking at a message from March.

Does that help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Kind: Bug
Projects
Status: 📌 Triage
Development

No branches or pull requests

2 participants