babylonchain / babylon

Main repo for Babylon full node
https://babylonchain.io
Other
230 stars 153 forks source link

Sporadic failures of TestBTCStakingTestSuite/Test8BTCDelegationFeeGrantTyped e2e test #693

Open KonradStaniec opened 3 weeks ago

KonradStaniec commented 3 weeks ago

https://app.circleci.com/pipelines/github/babylonchain/babylon/2759/workflows/5a560144-469d-439b-982b-601a0bd4ee04/jobs/6507

KonradStaniec commented 1 week ago

Some initial investigation.

For each broadcasted transaction, response is printed using PrintProto function which first marshalls given message to json and later convert it to yaml using yaml.JSONToYAML(out) conversion (from package "sigs.k8s.io/yaml")

Problem arise if marshalled json contrain control characters. Then conversion will return an error:

yaml: control characters are not allowed

In one of the failed tests, response from node is:

{
  "height": "0",
  "txhash": "2ACF964F1DA8937764352ABC02C5B53E7ADDDF6E659D3FD3870B13F773BD4B75",
  "codespace": "sdk",
  "code": 38,
  "data": "",
  "raw_log": "��[�o\u001b��r�\\\f�(�W\u001a�Y does not allow to pay fees for \r�7���r�T�3۸�I\u0006#�V~: fee-grant not found: not found",
  "logs": [],
  "info": "",
  "gas_wanted": "0",
  "gas_used": "0",
  "tx": null,
  "timestamp": "",
  "events": []
}

calling JSONToYAML will fail for this paylonad due to control character in raw_log field.

This control characters are there due to the fact, that ante handler which checks for fee grants returns direct byte addresses instead of bech32 encoded strings - https://github.com/cosmos/cosmos-sdk/blob/main/x/auth/ante/fee.go#L101

Conclusion:

  1. This is bug on the side of cosmos-sdk. Either conversion JSONToYAML should properly handle conversion with control characters or all returned errors should be properly encoded strings and not random byte arrays. Imo it should be the second option.