explorer icon indicating copy to clipboard operation
explorer copied to clipboard

Sandbox contract calls responding with 400 errors

Open whoabuddy opened this issue 2 years ago • 3 comments

Describe the bug

Certain contract calls from the sandbox are failing with HTTP 400 errors starting after the instability this weekend.


If I call get-pox-info from ST000000000000000000002AMW42H.pox on testnet, the payload info is:

URL:
https://stacks-node-api.testnet.stacks.co/v2/contracts/call-read/ST000000000000000000002AMW42H/pox/get-pox-info

Payload:
{"sender":"ST113N3MMPZRMJJRZH6JTHA5CB7TBZH1EH4C22GFV","arguments":[]}

and the response is:

(ok (tuple (current-rejection-votes u0) (first-burnchain-block-height u2000000) (min-amount-ustx u5175407755455) (prepare-cycle-length u50) (rejection-fraction u12) (reward-cycle-id u398) (reward-cycle-length u1050) (total-liquid-supply-ustx u41403262043641960)))

If I call is-pox-active from ST000000000000000000002AMW42H.pox on testnet and pass a reward cycle, I receive the HTTP 400 error. The payload info is:

URL:
https://stacks-node-api.testnet.stacks.co/v2/contracts/call-read/ST000000000000000000002AMW42H/pox/is-pox-active

Payload:
{"sender":"ST113N3MMPZRMJJRZH6JTHA5CB7TBZH1EH4C22GFV","arguments":["0x1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55"]}

and the response is:

Failed to load resource: the server responded with a status of 400 ()

If I call get-stacker-info from ST000000000000000000002AMW42H.pox on testnet and pass a principal, I receive the HTTP 400 error. The payload info is:

URL:
https://stacks-node-api.testnet.stacks.co/v2/contracts/call-read/ST000000000000000000002AMW42H/pox/get-stacker-info

Payload:
{"sender":"ST113N3MMPZRMJJRZH6JTHA5CB7TBZH1EH4C22GFV","arguments":["0x5,26,66,58,142,148,183,241,73,75,31,137,165,168,168,172,89,244,191,196,46,137"]}

To Reproduce

This was noticed initially with the CityCoins contracts, but seems to affect anything that passes the values above as payloads. Iirc these should be hex-encoded Clarity values but above looks like a raw Buffer or Uint8Array with the Clarity type as the first value.

Expected behavior

Contract calls from the sandbox return a response.

Screenshots

image

whoabuddy avatar Jan 30 '23 19:01 whoabuddy

Tagging these two issues as well since they are related to creating/passing sandbox function arguments:

  • #965
  • #956

whoabuddy avatar Jan 30 '23 19:01 whoabuddy

FYI - this was fixed after @He1DAr rolled back some changes, here are the differences in the contract call payload from the working version.

Calling is-pox-active from ST000000000000000000002AMW42H.pox with a uint:

{"sender":"ST113N3MMPZRMJJRZH6JTHA5CB7TBZH1EH4C22GFV","arguments":["0x010000000000000000000000000000018e"]}

Calling executed-at in ST355N8734E5PVX9538H2QGMFP38RE211D9E2B4X5.base-dao with a principal:

{"sender":"ST113N3MMPZRMJJRZH6JTHA5CB7TBZH1EH4C22GFV","arguments":["0x061aca5aa0e3238b6df5251a222bc28fb0d18708216a14636369703031322d626f6f7473747261702d7632"]}

whoabuddy avatar Jan 31 '23 16:01 whoabuddy

@BLuEScioN let's keep this in mind for when we bring back postconditions

andresgalante avatar Feb 23 '23 13:02 andresgalante