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

Need help on the meaning of transaction types #92

Closed
arc0035 opened this issue Dec 1, 2023 · 10 comments
Closed

Need help on the meaning of transaction types #92

arc0035 opened this issue Dec 1, 2023 · 10 comments

Comments

@arc0035
Copy link

arc0035 commented Dec 1, 2023

Here I want to know what the transaction type represents:

      "id": "0x4e190ef706c38599b0dce720c60175c08366507ca05f8791658c76b2f29a3d65",
      "layer": 40000,
      "block": "0x2814f69e4b6e03bf2504bdabffa8e7ff9fd4e433",
      "blockIndex": 0,
      "index": 0,
      "state": 6,
      "timestamp": 1701321600,
      "maxGas": 36218,
      "gasPrice": 1,
      "gasUsed": 0,
      "fee": 36218,
      "amount": 98999963782,
      "counter": 5,
      "type": 3,
      "signature": "0x28aa4249187fd9e16f9e998deb02462cd8d22e2b818d57edd3550b734fe202cfeb07d42799753541b8c32ff39aa3428d80290bdce7212a5eae5fe4a849a11b0b",
      "pubKey": "",
      "sender": "sm1qqqqqq8j3a7r0cgss9c8352qamp33smzgmhvlqse0uuuy",
      "receiver": "sm1qqqqqq82d3yv8m632dsn237wg6sa3frsy2eruysclwgvm",
      "svmData": ""

Maybe type = 1 means spawn and type=3 means single wallet spend, but what for multisig?

@kacpersaw
Copy link
Contributor

https://github.com/spacemeshos/explorer-backend/blob/master/pkg/transactionparser/transaction/transaction_types.go

Spawn = 1
Multisig = 2
Spend = 3

Currently multisig txs are not supported by explorer.

@arc0035
Copy link
Author

arc0035 commented Dec 1, 2023

Well understood. Btw, does it mean that even there is a valid multisig tx, currently it wouldn't be returned by the explorer backend api (for example layer/{layerNum}/txs), right?

@kacpersaw
Copy link
Contributor

Yes, correct

@arc0035
Copy link
Author

arc0035 commented Dec 1, 2023

Thanks for you reply!
Sorry but before closing this issue I have one last question. Currently we are tracking all single-sig txs in the mesh via explorer api (we cannot do this by GRPC due to spacemeshos/go-spacemesh#5315). We need to ensure that:

  • No single wallet spending tx is missing
  • Every single wallet spending tx we load from the explorer whose state is 6 and type=3 is a successful transaction. We are scared to fetch a failed transaction as a successful one.
  • No duplicate tx. For example I fetch a tx in layer/block A and then meet it again in layer/block B
  • It should be stable, even no domain name change

Does the explorer api can meet our requirements?

@kacpersaw
Copy link
Contributor

I think it will be better if you run your own instance of explorer (collector and apiserver), that way you will be sure about your requirements. Our service has some additional caching systems and other features applied to it, so I don't think it would be applicable to your needs because of a delay and so on.

@lrettig
Copy link
Member

lrettig commented Dec 4, 2023

Every single wallet spending tx we load from the explorer whose state is 6 and type=3 is a successful transaction. We are scared to fetch a failed transaction as a successful one.

There are no failed transactions in Spacemesh today. If a transaction is included in a block it may be regarded as successful. There's a little bit more info on this here: https://github.com/spacemeshos/wiki/wiki/Integration-guide#tracking

I cannot speak to anything specific to the explorer API as I'm not familiar with it.

@lrettig
Copy link
Member

lrettig commented Dec 4, 2023

Maybe type = 1 means spawn and type=3 means single wallet spend, but what for multisig?

You can also tell tx type from the template address after decoding the tx, see https://github.com/spacemeshos/wiki/wiki/Integration-guide#decoding

@arc0035
Copy link
Author

arc0035 commented Dec 5, 2023

Hi !

Really appreciate your replies.

So one last question:

since on layer could contains multiple blocks, for example https://mainnet-explorer-api.spacemesh.network/layers/{}/blocks could possibly returns multiple blocks for one layer, how could I determine which block is the canonical one?
@kacpersaw @lrettig

@lrettig
Copy link
Member

lrettig commented Dec 5, 2023

I don't think this is currently exposed in api v1. We'll address this in api v2.

With respect to the actual protocol, the relevant code is here:

https://github.com/spacemeshos/go-spacemesh/blob/3d8eedfd44c6f9f8987e604b768596f6001fe703/common/types/result/result.go#L17-L31

Blocks are sorted by block ID:

https://github.com/spacemeshos/go-spacemesh/blob/3d8eedfd44c6f9f8987e604b768596f6001fe703/tortoise/state.go#L393-L400

So the protocol says, among the known blocks for a given layer sorted by block ID, the canonical block for a given layer is the first valid block (as passed by Tortoise), or if there is no valid block, it's the first non-invalid block that the Hare output. Failing both of these, the layer is empty.

@dshulyak correct me if I got any of this wrong.

@arc0035
Copy link
Author

arc0035 commented Dec 17, 2023

Close this issue for now

@arc0035 arc0035 closed this as completed Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants