-
Notifications
You must be signed in to change notification settings - Fork 761
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
Add missing depositTxWithNonce case to MarshalJSON / SourceHash / Mint #395
Add missing depositTxWithNonce case to MarshalJSON / SourceHash / Mint #395
Conversation
there are also other places we don't account for op-geth/core/types/transaction.go Lines 339 to 356 in d5a9661
|
…action.Mint functions
Decided to add these 2 cases as well. |
When this was first implemented, it was only ever used (and only ever intended to be used) as part of unmarshalling. It was there to allow Where are you seeing |
@ajsutton at one point I was passing a Here's a clearer example. Working curl: > curl -d '{"id":0,"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0xd997de74d8811229534c858983b5374bc5a9e93628c6ade2ef25618a64031a9d"]}' -H "Content-Type: application/json" https://mainnet.base.org | jq
{
"jsonrpc": "2.0",
"result": {
"blockHash": "0x46229f33f7edae5fee95599ba5a3f8925e146bf0651cb0dec4441f53889f4431",
"blockNumber": "0x13db7d9",
"depositReceiptVersion": "0x1",
"from": "0x6ce6e24c7469aae61548c15c235389ac8f1ea10a",
"gas": "0x186a0",
"gasPrice": "0x0",
"hash": "0xd997de74d8811229534c858983b5374bc5a9e93628c6ade2ef25618a64031a9d",
"input": "0x",
"mint": "0x4e28e2290f0000",
"nonce": "0x799",
"r": "0x0",
"s": "0x0",
"sourceHash": "0x9eb95bf237e38791cb4f83959620a2e2fe09da07d5613677ccf97bf56f29aba1",
"to": "0x6ce6e24c7469aae61548c15c235389ac8f1ea10a",
"transactionIndex": "0x1",
"type": "0x7e",
"v": "0x0",
"value": "0x4e28e2290f0000"
},
"id": 0
} Broken golang: package main
import (
"context"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
)
func main() {
ctx := context.Background()
client, _ := ethclient.DialContext(ctx, "https://mainnet.base.org")
tx, _, _ := client.TransactionByHash(ctx, common.HexToHash("0xd997de74d8811229534c858983b5374bc5a9e93628c6ade2ef25618a64031a9d"))
fmt.Println(tx.Mint())
fmt.Println(tx.SourceHash())
} Output:
|
I suspect we've broken something along the way. My understanding (might be wrong - it's going back a fair while) is that we should never have an instance of The It sounds like somewhere along the way you were getting a |
Yes, exactly this. Sorry, I should have given the example usage. I have a service running in an enclave that accepts transactions as input, see here: https://github.com/mdehoog/op-enclave/blob/c6c89e7a171ed2b883fb6488686a9026ef856b05/enclave/server.go#L236-L238 I've since switched to RLP (see base-org/op-enclave@3b7ae3f), partly as a workaround for this issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, that makes sense to me and settles my nerves. Definitely makes sense to support serialising to JSON so client users can take the tx they got from the API and re-serialize it. Thanks for bearing with me to understand it all.
ethereum-optimism#395) Also add depositTxWithNonce cases to Transaction.SourceHash and Transaction.Mint functions
Description
#55 added nonce support for deposit txs to
UnmarshalJSON
. However, we never added support forMarshalJSON
, which means marshallingdepositTxWithNonce
values results in mostlynull
values.Also added the
depositTxWithNonce
case to theTransaction.SourceHash
andTransaction.Mint
functions.Tests
Tested locally.