zksync-sdk/zksync2-go

.GetBlockByNumber() return error

Closed this issue · 5 comments

.GetBlockByNumber() return error "transaction type not supported",the block height is 5145518.
The following is response from rpc node.

{ "jsonrpc": "2.0", "result": { "baseFeePerGas": "0x362db6eb", "difficulty": "0x0", "extraData": "0x", "gasLimit": "0xffffffff", "gasUsed": "0x2115690", "hash": "0x579c463556ac2cbbb3619121c8a35df23bbed885162f13bbb20b88471612aaed", "l1BatchNumber": "0x11f9e", "l1BatchTimestamp": "0x64536c0a", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "miner": "0x0000000000000000000000000000000000000000", "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "nonce": "0x0000000000000000", "number": "0x4e83ae", "parentHash": "0xcb0ec3280d99b017fb760539413b5347e7d9c239b85dba1314381e2f63d87860", "receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", "sealFields": [], "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "size": "0x0", "stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x64536f43", "totalDifficulty": "0x0", "transactions": [ { "blockHash": "0x579c463556ac2cbbb3619121c8a35df23bbed885162f13bbb20b88471612aaed", "blockNumber": "0x4e83ae", "chainId": "0x118", "from": "0x524757053f1530a6ed5825130dadbed2466b2dd4", "gas": "0x7d3a08", "gasPrice": "0x362db6eb", "hash": "0xc85288ec7de61407c1b333e46c430eaae7e46c96a37370eed672bdce31d86b77", "input": "0x", "l1BatchNumber": "0x11f9e", "l1BatchTxIndex": "0x248", "maxFeePerGas": "0x5386bc7a", "maxPriorityFeePerGas": "0x5386bc7a", "nonce": "0x277a", "r": "0x6cebcf239acbcda534c9d43cde81a9bd88c45ce32f16091d83bb16def0ba787e", "s": "0x294b34ea7fc606c3ec4307abfb8005769dd88050864a7288105f73a040f4a4fc", "to": "0x61d2fc53e4a1d57def662bfd4110eb16fa99ddb6", "transactionIndex": "0x0", "type": "0x71", "v": "0x1", "value": "0xb1a2bc2ec50000" }, { "blockHash": "0x579c463556ac2cbbb3619121c8a35df23bbed885162f13bbb20b88471612aaed", "blockNumber": "0x4e83ae", "chainId": "0x118", "from": "0x3acf326aaabfba39a40311ca2c757f856003370e", "gas": "0xbaed588", "gasPrice": "0x362db6eb", "hash": "0xb9d7d038ce757e5f6a8bc69f486d19bcfa7f8eb92537dd31edc8d848690a163e", "input": "0x793647d80000000000000000000000004ed75454062a2fd60929f386a371ada8a65f103a0000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003acf326aaabfba39a40311ca2c757f856003370e00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000008200000000000000000000000000000000000000000000000000000000000000be00000000000000000000000000000000000000000000000000000000000000fa0000000000000000000000000000000000000000000000000000000000000039b01000000000100e1783b82a18dfe6c2ef35f38edc836c4b495df2c919bbe7f562e915a527e668278847883e844c37b4342c1ea88bd555c45f219d84e7adc0986c29e1bfe2a4a1a0164536f3b00000000001aa27839d641b07743c0cb5f68c51f8cd31d2c0762bec00dc6fcd25433ef1ab5b6000000000130896e0150325748000300010001020005009d41b0bf6e145a9f1296879040f2822fb5896addc7fbd4c1d94806e98f144f6d3a672fbb7d9ec665cfbe8c2ffa643ba321a047b7a72d7b6d7c3d8fb120fc40954b00000000000187040000000000000026fffffff6000000000001874700000000000000300100000001000000020000000064536f3b0000000064536f3b0000000064536f3a000000000001870400000000000000260000000064536f3a230abfe0ec3b460bd55fc4fb36356716329915145497202b8eb8bf1af6a0a3b9fe650f0367d4a7ef9815a593ea15d36593f0643aaaf0149bb04be67ab851decd0000000083fc1c840000000000127facfffffff8000000008421f8de000000000015cd450100000001000000020000000064536f3b0000000064536f3b0000000064536f3a0000000083fbec3b000000000013ed2d0000000064536f3ad1ff89ed8e67dfc99d6c6bd3e2cf47db21900c98f5a239fe21e59480a8da0e6b64ae1fc7ceacf2cd59bee541382ff3770d847e63c40eb6cf2413e7de5e93078a000000001fe35401000000000003eb68fffffff8000000001fddd57800000000000490b80100000001000000020000000064536f3b0000000064536f3b0000000064536f3a000000001fe35401000000000003d7df0000000064536f3a4fe17ca403512d0003bfb1993de595e2dc3a01977935b0ec7718e98ba5ad0a9541f3625971ca2ed2263e78573fe5ce23e13d2558ed3f2e47ab0f84fb9e7ae7220000000005f5c3b30000000000006705fffffff80000000005f5bf170000000000005cb10100000001000000020000000064536f3b0000000064536f3b0000000064536f3a0000000005f5c3b300000000000067050000000064536f3aa4b430a1ce2c68685e0c0e54a60340854fe15ce154e2f0b39927968e447cf93b1fc18861232290221461220bd4e2acd1dcdfbc89c84092c93c18bdc7756c15880000000005f6737c0000000000005a8efffffff80000000005f66c4700000000000063910100000001000000020000000064536f3b0000000064536f3b0000000064536f3a0000000005f6737c0000000000005a8e0000000064536f3a0000000000000000000000000000000000000000000000000000000000000000000000039b0100000000010088743119e5e080659d190afaced910e28e239c7e56606c1c4ed8e568a4cd28ae088f48216814a7445311df69d9dbe06df78fef2ca2f4352297a58f120e15005e0164536f3b00000000001aa27839d641b07743c0cb5f68c51f8cd31d2c0762bec00dc6fcd25433ef1ab5b6000000000130896d0150325748000300010001020005009d28fe05d2708c6571182a7c9d1ff457a221b465edf5ea9af1373f9562d16b8d15f9c0172ba10dfa4d19088d94f5bf61d3b54d5bd7483a322a982e1373ee8ea31b000002a53311ca7300000000264232b8fffffff8000002a562f850200000000030f17ff40100000001000000020000000064536f3b0000000064536f3b0000000064536f3a000002a53cf3f076000000002fd1c1530000000064536f3a8b38db700e8b34640e681ec9a73e89608bda29415547a224f96585192b4b9dc794bce4aee88fdfa5b58d81090bd6b3784717fa6df85419d9f04433bb3d615d5c0000000005ab751f0000000000009b9dfffffff80000000005aa8f31000000000000a9ae0100000001000000020000000064536f3b0000000064536f3b0000000064536f3a0000000005ab730b00000000000099890000000064536f3a3b69a3cf075646c5fd8148b705b8107e61a1a253d5d8a84355dcb628b3f1d12031775e1d6897129e8a84eeba975778fb50015b88039e9bc140bbd839694ac0ae000000000078d0200000000000001a9ffffffff8000000000079020d00000000000011890100000001000000020000000064536f3b0000000064536f3b0000000064536f3a000000000078d2a500000000000018190000000064536f3a48667de4448a204153aa90b89afd68f054c0e59596c4dac7af45be8ae5a9e9cd05a934cb3bbadef93b525978ab5bd3d5ce3b8fc6717b9ea182a688c5d8ee8e02000000000f28aedc000000000001a2e9fffffff8000000000f34a41300000000000180bb0100000001000000020000000064536f3b0000000064536f3b0000000064536f3a000000000f28aedc000000000001a2e90000000064536f3a56d0721e607dc033ff02bee21b9918e13bcceb97e279a2d1fa2888f0056add3db5622d32f36dc820af288aab779133ef1205d3123bbe256603849b820de48b87000000001faf0f75000000000002225bfffffff8000000001fcc2792000000000002ac530100000001000000020000000064536f3b0000000064536f3b0000000064536f3a000000001faf0f7500000000000218510000000064536f3a0000000000000000000000000000000000000000000000000000000000000000000000039b0100000000010016e68b4af79f5b635231a7e7bded02871e5fda81bc52ed2ca5fd59d3e15e30731a61bd81d587864198023745d8640cdd734c93f53b612f7fb1cd54175409f0ed0064536f3b00000000001aa27839d641b07743c0cb5f68c51f8cd31d2c0762bec00dc6fcd25433ef1ab5b600000000013089730150325748000300010001020005009d431cc2fd0ef4af4bc7c85fffae2f63d51b26d162179682d149ae619b1221c00bfc309467defa4b198c6b5bd59c08db4b9dfb27ddbcc32f31560f217b4ff8fc2b0000002c30d4f5b90000000007578487fffffff80000002c2335deb0000000000812ff730100000001000000020000000064536f3b0000000064536f3b0000000064536f3a0000002c30d4f5b900000000075784870000000064536f3af42aaf884c7b1454894170be0aaf1db39b4b78d3a56a27fd49bd8b39ef2c33d7651071f8c7ab2321b6bdd3bc79b94a50841a92a6e065f9e3b8b9926a8fb5a5d10000002d711d127800000000149d35d2fffffff80000002d676f1f000000000015dd34560100000001000000020000000064536f3b0000000064536f3b0000000064536f3a0000002d711d127800000000149d35d20000000064536f3a1801eb03803af0244523ee2a86c3f27b126abe8904db4b45a82adb5fe21708b4ca80ba6dc32e08d06f1aa886011eed1d77c77be9eb761cc10d72b7d0a2fd57a60000002c4b91d159000000000331bda7fffffff80000002c4084345800000000031cb79e0100000001000000020000000064536f3b0000000064536f3b0000000064536f3a0000002c4b20c5c00000000002f34eca0000000064536f3a7ddf0d82af531f0af109d5e9ce9ec27ba9f00e9ee8ab71c912afffa16d715836b7abd25a76ddaffdf847224f03198ccb92723f90b2429cf33f0eecb96e352a860000002c46c7559900000000200f8d88fffffff80000002c37fcf630000000001cc8232a0100000001000000020000000064536f3b0000000064536f3b0000000064536f3a0000002c46c7559900000000200f8d880000000064536f3ad5a5c2f30e06bd6f38e01c2c4c8cdd7ca7c1c12d47a7336e459fc6db4171bae660fd61b2d90eba47f281505a88869b66133d9dc58f203b019f5aa47f1b39343e0000002d2366ea1a0000000022b037f9fffffff80000002d21b4c3980000000022aefd900100000001000000020000000064536f3b000000006447fcf2000000006447fcf00000002d2366ea1a0000000022b037f9000000006447fcf20000000000000000000000000000000000000000000000000000000000000000000000039b010000000001005621125b5cc47e65542b3354daffc823d8c571700f493977c2812e675f7552c422222583d5d701122853068cf7bb3b5fd012270074a398be3fe287a2f058a27c0164536f3b00000000001aa27839d641b07743c0cb5f68c51f8cd31d2c0762bec00dc6fcd25433ef1ab5b6000000000130896a0150325748000300010001020005009db8104aadc85157eadd671370cfdbe85ee370ef0e2ac0422b302890526096df1883be4ed61dd8a3518d198098ce37240c494710a7b9d85e35d9fceac21df08994000000002a22b2a20000000000065d02fffffff8000000002a37550800000000000599da0100000001000000020000000064536f3b0000000064536f3a0000000064536f37000000002a2226e6000000000005d1460000000064536f3aff9b2f0b40487a69177a2760eb06dfc4a086792be9966e7fd18264f9be1e97e0997e0bf451cb36b4aea096e6b5c254d700922211dd933d9d17c467f0d6f34321000000020d6cf8e0000000000055a5eafffffff8000000020e288b3c00000000003ae3f60100000001000000020000000064536f3b0000000064536f3b0000000064536f3a000000020d6d36ff00000000004e0ecd0000000064536f3acc87847c1a87d5603101d7949777baa2beee2321b9f99d71e987fab0f52df666d2c2c1f2bba8e0964f9589e060c2ee97f5e19057267ac3284caef3bd50bd2cb50000000005f040bf000000000000b8bffffffff80000000005efd7e7000000000000b97f0100000001000000020000000064536f3b0000000064536f3b0000000064536f3a0000000005f040bf000000000000b51b0000000064536f3a35e66aaf5b9c68a610208f45e9a03c7f9cb5f6ca0156532ded7e2fc276ce837b27e867f0f4f61076456d1a73b14c7edc1cf5cef4f4d6193a33424288f11bd0f4000000000b240543000000000001fb5afffffff8000000000b24c314000000000001e76d0100000001000000020000000064536f3b0000000064536f3b0000000064536f3a000000000b23ee5b00000000000208ca0000000064536f3a082d489fc47462af441f2c0b60883287deb54a29ff3c5ca3f3fcdf8aa2784bcc71334dcd37620ce3c33e3bafef04cc80dec083042e49b734315b36d1aad7991f000000000cb70f89000000000001bb2efffffff8000000000cb736c60000000000017cd80100000001000000020000000064536f3b0000000064536f3a0000000064536f37000000000cb70f89000000000001bb2e0000000064536f3a0000000000000000000000000000000000000000000000000000000000000000000000039b0100000000010029b4ec9f14bd054a1cc5310b83676514e0c09a1bd81c2f82bea730de397a32e0630180d74996b06cb450483399d3c6b8a4cad49a9ceda09dcd9ff0137cb470c50164536f3b00000000001aa27839d641b07743c0cb5f68c51f8cd31d2c0762bec00dc6fcd25433ef1ab5b600000000013089690150325748000300010001020005009d7b0b1a58a54e5aa24e28f2311acf9edcb4689f22bac65d131249870040176185d6b3bc030a8bbb7dd9de46fb564c34bb7f860dead8985eb16a49cdc62f8ab3a500000001a94775c0000000000056b3ccfffffff800000001a8e54bac00000000005669460100000001000000020000000064536f3b0000000064536f3a0000000064536f3700000001a9477b9c000000000060fc8a0000000064536f3a1dc9fc22544655b453008cc68559639a8f74d584d94f84ac945b36c957afd9db73dc009953c83c944690037ea477df627657f45c14f16ad3a61089c5a3f9f4f200000000025643600000000000005106fffffff8000000000257900300000000000053cd0100000001000000020000000064536f3b0000000064536f3a0000000064536f3700000000025646f90000000000004b670000000064536f3a17222352da167878654cb84119be343ef62b079f85528d4b079da396c497812ecb1743d0e3e3eace7e84b8230dc082829813e3ab04e91b503c08e9a441c0ea8b0000000016e84ddd000000000002b343fffffff80000000016ef6a1200000000000308620100000001000000020000000064536f3b0000000064536f3b0000000064536f3a0000000016e84ddd000000000002b3430000000064536f3aeaa4bdf732d22d3487eb6e023fea350a31a24c0c7ccbedb3fbd48c8e390307b844a93dddd8effa54ea51076c4e851b6cbbfd938e82eb90197de38fe8876bb66e000000003b06072d00000000000477eefffffff8000000003b294d7600000000000594230100000001000000020000000064536f3b0000000064536f3b0000000064536f3a000000003b065f15000000000004cfd50000000064536f3a2fcc153fe438323a56df1aba9b3fbf91e96f428f4511434ed8e7360757ecdc5737f40d2898159e8f2e52b93cb78f47cc3829a31e525ab975c49cc5c5d91763780000000008050c9d0000000000012711fffffff80000000008028e22000000000000e9910100000001000000020000000064536f3b0000000064536f3a0000000064536f370000000008050c9d00000000000127110000000064536f3a0000000000", "l1BatchNumber": "0x11f9e", "l1BatchTxIndex": "0x249", "maxFeePerGas": "0x5386bc7a", "maxPriorityFeePerGas": "0x5386bc7a", "nonce": "0xd2", "r": "0x87f73a94ad24e24c8891e0ade306d7745bc41a70ac239cacdcd64d5cdf8480cb", "s": "0x12db2daebe564cd1a7942d65b9810b8240dca48dcb22b49ea356ca2af04fb812", "to": "0xd78b4ad524c136bc822cba23ab6785ecbc55d180", "transactionIndex": "0x1", "type": "0x0", "v": "0x0", "value": "0x5" } ], "transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", "uncles": [] }, "id": 1 }

wmh commented

Same issue here. The result from rpc response is good, but something went wrong after parsed by go-ethereum.

tacshi commented

For me the error is: invalid transaction v, r, s values, demo:

package main

import (
	"fmt"
	"strconv"

	"github.com/zksync-sdk/zksync2-go/clients"
	"github.com/zksync-sdk/zksync2-go/types"
)

func main() {
	zp, err := clients.NewDefaultProvider("https://mainnet.era.zksync.io")
	if err != nil {
		panic(err)
	}
	block, err := zp.GetBlockByNumber(types.BlockNumber(strconv.FormatInt(int64(5145518), 16)))
	if err != nil {
		panic(err)
	}
	fmt.Printf("%+v\n", block)
}

zkSync is incompatible with ethereum, a possible solution:

dudebing99/go-ethereum@e901bb0

-               plainV = byte(v.Uint64() - 27)
+               if v.Uint64() == 27 || v.Uint64() == 28 {
+                       plainV = byte(v.Uint64() - 27)
+               }
  1. clone go-ethereum repo
  2. modify sanityCheckSignature()
  3. publish your own repo
  4. import your own repo

This issue is a duplicate of #7. Forking the repository to make it compatible is not a good option because it drastically increases the maintenance effort. The idea is to make the SDK compatible with Geth. This issue will be addressed in the next release.

Fixed in v0.3.0 version.