Skip to content

Conversation

@xiaying-peng
Copy link
Contributor

Fixes # .

Motivation

Solution

Open questions

@xiaying-peng xiaying-peng requested a review from GeekArthur April 24, 2024 21:31
if err := h.parser.ExpectedOperations(intent, observed, false, true); err != nil {
return fmt.Errorf("confirmed transaction did not match intent: %w", err)
errMsg := fmt.Errorf("confirmed transaction did not match intent: %w", err)
if !isValidStakingOperation(intent, intentMetadata) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if confirmed transaction did not match intent but staking operation is valid, then we won't catch the error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is used for check:construction only, we never full tested staking txns in check:construction.
Staking operation looks like this:

  "network_identifier": {
    "blockchain": "abc",
    "network": "testnet"
  },
  "operations": [
    {
      "operation_identifier": {
        "index": 0
      },
      "type": "stake",
      "status": "",
      "account": {
        "address": "dydx12c0xh69avh8xd0z76as9as4mcy0cfncukmmd7z",
        "metadata": {}
      },
      "amount": {
        "value": "5000000",
        "currency": {
          "symbol": "COSMOSDYDX",
          "decimals": 18
        }
      }
    }
  ],
  "suggested_fee_multiplier": 2,
  "metadata": {
    "gas_adjustment": 0.5,
    "validator_src_address": "dydxvaloper10lzv79d96l7jh07z76ry6cnn6ftnnl8fgketzu",
    "validator_dst_address": ""
  }
}

The amount in the preprocess API is a positive number, but our block API interprets staking as two operations; the first one is negative. Hence we get an intent mismatch.

@xiaying-peng xiaying-peng merged commit c3d7547 into master Apr 24, 2024
@xiaying-peng xiaying-peng deleted the validate-staking branch April 24, 2024 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants