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

fix(cast): duplicate data field #9558

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

chuwt
Copy link

@chuwt chuwt commented Dec 14, 2024

Motivation

fix the issue: #9327

Solution

Add two Transaction options:

Transaction options:
    --input-only-input
        Transaction input containing only the input field. By default, both the input
        and data fields will be set
    --input-only-data
        Transaction input containing only the data field. By default, both the input
        and data fields will be set

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

I don't know why a server would respond with a duplicate data field in this situation, do you know which client that is?

Comment on lines +186 to +189
tx.input = TransactionInput {
input: if tx_opts.input_only_data { None } else { Some(Bytes::new()) },
data: if tx_opts.input_only_input { None } else { Some(Bytes::new()) },
};
Copy link
Member

Choose a reason for hiding this comment

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

this feels a bit weird because this now set the input/data field to empty bytes,
I believe this would technically be equivalent to null as well, just feels odd

Copy link
Author

@chuwt chuwt Dec 15, 2024

Choose a reason for hiding this comment

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

Yeah, that's right, the reason is I don't want to make too many changes, so I set the fields to empty bytes or null, then we can check empty bytes or null when we building transaction rather than pass additional arguments

https://github.com/chuwt/foundry/blob/94e369e554338a1dc55c48bfeb301d55b260fa90/crates/cast/bin/tx.rs#L319-#L327

Comment on lines +79 to +87
/// Transaction input containing only the input field.
/// By default, both the input and data fields will be set.
#[arg(long, default_value = "false")]
pub input_only_input: bool,

/// Transaction input containing only the data field.
/// By default, both the input and data fields will be set.
#[arg(long, default_value = "false")]
pub input_only_data: bool,
Copy link
Member

Choose a reason for hiding this comment

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

I don't really like introducing additional fields for this behaviour, the only reason why we even set both fields is because some nodes are off spec and expect the legacy data field...

Copy link
Author

Choose a reason for hiding this comment

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

Totally agree, but now the node refuse the request if we se both fields.

Copy link
Author

Choose a reason for hiding this comment

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

Maybe we can only keep input_only_input because new nodes only accept the tx.input.

@chuwt
Copy link
Author

chuwt commented Dec 15, 2024

I don't know why a server would respond with a duplicate data field in this situation, do you know which client that is?

Here are the version I'm using:

os: Mac
nodejs: 22.12.0
block-node: hardhat 2.22.17
cast 0.2.0 (dabacec 2024-12-14T00:22:42.717187000Z)

Here is the response from the node

cast send 0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199 --value 100ether --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
Error: server returned an error response: error code -32602: duplicate field `data` at line 1 column 245, data: {"message":"duplicate field `data` at line 1 column 245","data":{"method":"eth_estimateGas","params":[{"from":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","to":"0x8626f6940e2eb28930efb4cef49b2d1f2c9c1199","maxFeePerGas":"0x9c25e9","maxPriorityFeePerGas":"0x1","value":"0x56bc75e2d63100000","input":"0x","data":"0x","nonce":"0x5","chainId":"0x7a69"},"pending"]}}

I guess the hardhat refuse the request because we both send data and input fields.

@chuwt chuwt requested a review from mattsse December 15, 2024 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants