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

validate staking ops #415

Merged
merged 2 commits into from
Apr 24, 2024
Merged

validate staking ops #415

merged 2 commits into from
Apr 24, 2024

Conversation

xiaying-peng
Copy link
Contributor

Fixes # .

Motivation

Solution

Open questions

@@ -81,7 +83,10 @@ func (h *BroadcastStorageHandler) TransactionConfirmed(
}

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
10 checks passed
@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