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

block_results result.devlier_tx[i].ResponseBase.Data does not identify msg #2055

Closed
r3v4s opened this issue May 8, 2024 · 0 comments
Closed
Assignees
Labels
🐞 bug Something isn't working investigating This behavior is still being tested out ❓ question Questions about Gno

Comments

@r3v4s
Copy link
Contributor

r3v4s commented May 8, 2024

block_results result.devlier_tx[i].ResponseBase.Data` does not identify msg

Description

deploy contract

package restest

func FuncNo() {}

func Func2() (string, string) {
	return "1", "2"
}

func Func3() (string, string, uint64) {
	return "3", "4", 5
}

multi-msg call via adena

await adena.DoContract({
  messages: [{
  "type": "/vm.m_call",
  "value": {
    "caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
    "send": "",
    "pkg_path": "gno.land/r/demo/restest",
    "func": "FuncNo",
    "args": []
  }
  },{
    "type": "/vm.m_call",
    "value": {
      "caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
      "send": "",
      "pkg_path": "gno.land/r/demo/restest",
      "func": "Func2",
      "args": []
    }
  },{
    "type": "/vm.m_call",
    "value": {
      "caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
      "send": "",
      "pkg_path": "gno.land/r/demo/restest",
      "func": "FuncNo",
      "args": []
    }
    },{
    "type": "/vm.m_call",
    "value": {
      "caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
      "send": "",
      "pkg_path": "gno.land/r/demo/restest",
      "func": "Func3",
      "args": []
    }
  },{
    "type": "/vm.m_call",
    "value": {
      "caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
      "send": "",
      "pkg_path": "gno.land/r/demo/restest",
      "func": "FuncNo",
      "args": []
    }
  }],
send: "",
gasFee: 1, 
gasWanted: 2000000
});

result from rpc block_results

https://rpc.gno.land/block_results?height=8924

{
  "jsonrpc": "2.0",
  "id": "",
  "result": {
    "height": "8924",
    "results": {
      "deliver_tx": [
        {
          "ResponseBase": {
            "Error": null,
            "Data": "KCIxIiBzdHJpbmcpCigiMiIgc3RyaW5nKSgiMyIgc3RyaW5nKQooIjQiIHN0cmluZykKKDUgdWludDY0KQ==",
            "Events": null,
            "Log": "msg:0,success:true,log:,events:[]\nmsg:1,success:true,log:,events:[]\nmsg:2,success:true,log:,events:[]\nmsg:3,success:true,log:,events:[]\nmsg:4,success:true,log:,events:[]",
            "Info": ""
          },
          "GasWanted": "2000000",
          "GasUsed": "168550"
        }
      ],
      "end_block": {
        "ResponseBase": {
          "Error": null,
          "Data": null,
          "Events": null,
          "Log": "",
          "Info": ""
        },
        "ValidatorUpdates": null,
        "ConsensusParams": null,
        "Events": null
      },
      "begin_block": {
        "ResponseBase": {
          "Error": null,
          "Data": null,
          "Events": null,
          "Log": "",
          "Info": ""
        }
      }
    }
  }
}

decoded data

("2" string)("3" string)
("4" string)
(5 uint64)

Problem

  1. unable to identify which msg(i.e which function) returned which response

Proposed solution

  1. return response with array
[ [], [("1" string),("2" string)], [], [("3" string),("4" string),(5 uint64)] ]
  1. return response with certain identifier(for example, use \n\n) // doesn't like it looks bit dirty
\n\n("1" string)\n("2" string)\n\n\n\n("3" string)\n("4" string)\n(5 uint64)\n\n
@r3v4s r3v4s added the 🐞 bug Something isn't working label May 8, 2024
@r3v4s r3v4s self-assigned this May 8, 2024
@r3v4s r3v4s moved this to Blocked by / Wishlist / Issues in 🤝🏻 Partner: Onbloc May 8, 2024
@r3v4s r3v4s assigned notJoon and r3v4s and unassigned r3v4s May 8, 2024
@r3v4s r3v4s added help wanted ❓ question Questions about Gno investigating This behavior is still being tested out labels May 8, 2024
@Kouteki Kouteki moved this from Triage to In Progress in 🧙‍♂️gno.land core team May 10, 2024
@Kouteki Kouteki added this to the 🏗4️⃣ test4.gno.land milestone May 10, 2024
@r3v4s r3v4s moved this from Backlog to In Review in 🤝🏻 Partner: Onbloc May 14, 2024
zivkovicmilos pushed a commit that referenced this issue May 15, 2024
… pair (#2063)

related to #2055 

I'm opening this pr to get some ideas.


Currently, keeper does make response data with `\n` as separator to
separate number of responses for single function.

https://github.com/gnolang/gno/blob/80575054429e07c221f1453104dd0ad29e33291c/gno.land/pkg/sdk/vm/keeper.go#L307-L312

If single function returns 2 string, response may look like this
```text
("1" string)
("2" string)
```

However as describe in #2055, response for single tx with multi-msg
really doesn't separate response values.

So this pr adds `\n\n` as a separator for every function.


### sample contract
```go
package returns

func FuncNo() {}

func Func2() (string, uint64) {
	return "asd", 123
}

func Func3() (int64, string, uint64) {
	return -1, "hmm", 78978
}

```

### call with multi-msg
```javascript
await adena.DoContract({
  messages: [
    {
      "type": "/vm.m_call",
      "value": {
        "caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
        "send": "",
        "pkg_path": "gno.land/r/r3v4/returns",
        "func": "FuncNo",
        "args": []
      }
    },
    {
      "type": "/vm.m_call",
      "value": {
        "caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
        "send": "",
        "pkg_path": "gno.land/r/r3v4/returns",
        "func": "Func2",
        "args": []
      }
    },
    {
      "type": "/vm.m_call",
      "value": {
        "caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
        "send": "",
        "pkg_path": "gno.land/r/r3v4/returns",
        "func": "FuncNo",
        "args": []
      }
    },
    {
      "type": "/vm.m_call",
      "value": {
        "caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
        "send": "",
        "pkg_path": "gno.land/r/r3v4/returns",
        "func": "Func3",
        "args": []
      }
    },
    {
      "type": "/vm.m_call",
      "value": {
        "caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
        "send": "",
        "pkg_path": "gno.land/r/r3v4/returns",
        "func": "FuncNo",
        "args": []
      }
    }
  ],
  gasFee: 1, 
  gasWanted: 2000000
});
```
### block_results from rpc with b64 encoded
```
KCJhc2QiIHN0cmluZykKKDEyMyB1aW50NjQpKC0xIGludDY0KQooImhtbSIgc3RyaW5nKQooNzg5NzggdWludDY0KQ
```
### b64 decoded
```
("asd" string)
(123 uint64)(-1 int64)
("hmm" string)
(78978 uint64)
```
two problem exists with above response
1. It needs to do something about function that doesn't return any value
2. It needs to divide results string for each function


### in this pr response b64 encoded
```
CgooImFzZCIgc3RyaW5nKQooMTIzIHVpbnQ2NCkKCgoKKC0xIGludDY0KQooImhtbSIgc3RyaW5nKQooNzg5NzggdWludDY0KQoKCgo
```

### decode b64 and divide by '\n\n'

![image](https://github.com/gnolang/gno/assets/104744707/cf4ee0b8-a0d3-4fb8-aa59-68c814f8ef5b)
From now, we know...
1. tx had 5 messages
2. first, third and fifth msg function doesn't return anything
3. second msg function return 2 values
4. fourth msg function return 3 values
leohhhn pushed a commit to leohhhn/gno that referenced this issue May 21, 2024
… pair (gnolang#2063)

related to gnolang#2055 

I'm opening this pr to get some ideas.


Currently, keeper does make response data with `\n` as separator to
separate number of responses for single function.

https://github.com/gnolang/gno/blob/80575054429e07c221f1453104dd0ad29e33291c/gno.land/pkg/sdk/vm/keeper.go#L307-L312

If single function returns 2 string, response may look like this
```text
("1" string)
("2" string)
```

However as describe in gnolang#2055, response for single tx with multi-msg
really doesn't separate response values.

So this pr adds `\n\n` as a separator for every function.


### sample contract
```go
package returns

func FuncNo() {}

func Func2() (string, uint64) {
	return "asd", 123
}

func Func3() (int64, string, uint64) {
	return -1, "hmm", 78978
}

```

### call with multi-msg
```javascript
await adena.DoContract({
  messages: [
    {
      "type": "/vm.m_call",
      "value": {
        "caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
        "send": "",
        "pkg_path": "gno.land/r/r3v4/returns",
        "func": "FuncNo",
        "args": []
      }
    },
    {
      "type": "/vm.m_call",
      "value": {
        "caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
        "send": "",
        "pkg_path": "gno.land/r/r3v4/returns",
        "func": "Func2",
        "args": []
      }
    },
    {
      "type": "/vm.m_call",
      "value": {
        "caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
        "send": "",
        "pkg_path": "gno.land/r/r3v4/returns",
        "func": "FuncNo",
        "args": []
      }
    },
    {
      "type": "/vm.m_call",
      "value": {
        "caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
        "send": "",
        "pkg_path": "gno.land/r/r3v4/returns",
        "func": "Func3",
        "args": []
      }
    },
    {
      "type": "/vm.m_call",
      "value": {
        "caller": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
        "send": "",
        "pkg_path": "gno.land/r/r3v4/returns",
        "func": "FuncNo",
        "args": []
      }
    }
  ],
  gasFee: 1, 
  gasWanted: 2000000
});
```
### block_results from rpc with b64 encoded
```
KCJhc2QiIHN0cmluZykKKDEyMyB1aW50NjQpKC0xIGludDY0KQooImhtbSIgc3RyaW5nKQooNzg5NzggdWludDY0KQ
```
### b64 decoded
```
("asd" string)
(123 uint64)(-1 int64)
("hmm" string)
(78978 uint64)
```
two problem exists with above response
1. It needs to do something about function that doesn't return any value
2. It needs to divide results string for each function


### in this pr response b64 encoded
```
CgooImFzZCIgc3RyaW5nKQooMTIzIHVpbnQ2NCkKCgoKKC0xIGludDY0KQooImhtbSIgc3RyaW5nKQooNzg5NzggdWludDY0KQoKCgo
```

### decode b64 and divide by '\n\n'

![image](https://github.com/gnolang/gno/assets/104744707/cf4ee0b8-a0d3-4fb8-aa59-68c814f8ef5b)
From now, we know...
1. tx had 5 messages
2. first, third and fifth msg function doesn't return anything
3. second msg function return 2 values
4. fourth msg function return 3 values
@zivkovicmilos zivkovicmilos moved this from In Review to Backlog in 🤝🏻 Partner: Onbloc Jun 10, 2024
@zivkovicmilos zivkovicmilos closed this as not planned Won't fix, can't repro, duplicate, stale Sep 11, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in 🤝🏻 Partner: Onbloc Sep 11, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in 🧙‍♂️gno.land core team Sep 11, 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 investigating This behavior is still being tested out ❓ question Questions about Gno
Projects
Status: Done
Development

No branches or pull requests

4 participants