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

Bug: calldata format error when proxying deploy transactions #370

Closed
xJonathanLEI opened this issue Jun 10, 2022 · 1 comment · Fixed by #372
Closed

Bug: calldata format error when proxying deploy transactions #370

xJonathanLEI opened this issue Jun 10, 2022 · 1 comment · Fixed by #372
Assignees

Comments

@xJonathanLEI
Copy link
Contributor

xJonathanLEI commented Jun 10, 2022

Description

When forwarding DEPLOY transactions to the sequencer gateway, the node incorrectly encodes constructor_calldata elements as hex strings, while the sequencer actually expects decimal representations.

(Let's take a moment to appreciate the inconsistencies in the gateway APIs lol)

This inconsistency is taken care of in starknet-rs:

#[serde_as]
#[derive(Debug, Serialize)]
pub struct DeployTransaction {
    pub constructor_calldata: Vec<FieldElement>,
    #[serde_as(as = "UfeHex")]
    pub contract_address_salt: FieldElement,
    pub contract_definition: ContractDefinition,
}

(FieldElement serializes as decimal representation by default, so without serde_as on constructor_calldata it just uses decimal.)

Steps to reproduce

Send this request to a running node (adding in abi because of #369):

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "starknet_addDeployTransaction",
  "params": [
    "0x1",
    ["0x2"],
    {
      "abi": [],
      "entry_points_by_type": {
        "CONSTRUCTOR": [],
        "EXTERNAL": [],
        "L1_HANDLER": []
      },
      "program": "____INSERT_VALID_PROGRAM_CODE_HERE____"
    }
  ]
}

Expected result

Transaction can be successfully submitted.

Actual result

Transaction submission fails with:

{
  "jsonrpc": "2.0",
  "error": {
    "code": -32000,
    "message": "StarknetError { code: MalformedRequest, message: \"{'constructor_calldata': {0: ['Expected int string, got: \\\"0x2\\\".']}}\" }"
  },
  "id": 1
}
@CHr15F0x CHr15F0x self-assigned this Jun 10, 2022
@CHr15F0x
Copy link
Member

Hmm looks like we forgot to add #[serde_as(as = "Vec<ConstructorParamAsDecimalStr>")] to the very field.
Thanks for spotting 🙏 .

CHr15F0x added a commit that referenced this issue Jun 10, 2022
Fix: calldata format error when proxying deploy transactions #370
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

Successfully merging a pull request may close this issue.

2 participants