Merge pull request #10102 from filecoin-project/iand/eth-openrpc-validate
itests: validate responses from ethereum json-rpc api
This commit is contained in:
commit
3e30e7a9ec
@ -628,6 +628,11 @@ workflows:
|
||||
suite: itest-eth_config
|
||||
target: "./itests/eth_config_test.go"
|
||||
|
||||
- test:
|
||||
name: test-itest-eth_conformance
|
||||
suite: itest-eth_conformance
|
||||
target: "./itests/eth_conformance_test.go"
|
||||
|
||||
- test:
|
||||
name: test-itest-eth_deploy
|
||||
suite: itest-eth_deploy
|
||||
|
@ -853,7 +853,7 @@ type FullNode interface {
|
||||
// reverse interface to the client, called after EthSubscribe
|
||||
type EthSubscriber interface {
|
||||
// note: the parameter is ethtypes.EthSubscriptionResponse serialized as json object
|
||||
EthSubscription(ctx context.Context, r jsonrpc.RawParams) error //rpc_method:eth_subscription notify:true
|
||||
EthSubscription(ctx context.Context, r jsonrpc.RawParams) error // rpc_method:eth_subscription notify:true
|
||||
}
|
||||
|
||||
type StorageAsk struct {
|
||||
|
Binary file not shown.
Binary file not shown.
@ -144,7 +144,7 @@ type EthBlock struct {
|
||||
GasLimit EthUint64 `json:"gasLimit"`
|
||||
GasUsed EthUint64 `json:"gasUsed"`
|
||||
Timestamp EthUint64 `json:"timestamp"`
|
||||
Extradata []byte `json:"extraData"`
|
||||
Extradata EthBytes `json:"extraData"`
|
||||
MixHash EthHash `json:"mixHash"`
|
||||
Nonce EthNonce `json:"nonce"`
|
||||
BaseFeePerGas EthBigInt `json:"baseFeePerGas"`
|
||||
@ -433,7 +433,7 @@ func EthHashFromTxBytes(b []byte) EthHash {
|
||||
}
|
||||
|
||||
type EthFeeHistory struct {
|
||||
OldestBlock uint64 `json:"oldestBlock"`
|
||||
OldestBlock EthUint64 `json:"oldestBlock"`
|
||||
BaseFeePerGas []EthBigInt `json:"baseFeePerGas"`
|
||||
GasUsedRatio []float64 `json:"gasUsedRatio"`
|
||||
Reward *[][]EthBigInt `json:"reward,omitempty"`
|
||||
|
@ -2342,7 +2342,7 @@ Inputs:
|
||||
Response:
|
||||
```json
|
||||
{
|
||||
"oldestBlock": 42,
|
||||
"oldestBlock": "0x5",
|
||||
"baseFeePerGas": [
|
||||
"0x0"
|
||||
],
|
||||
@ -2407,7 +2407,7 @@ Response:
|
||||
"gasLimit": "0x5",
|
||||
"gasUsed": "0x5",
|
||||
"timestamp": "0x5",
|
||||
"extraData": "Ynl0ZSBhcnJheQ==",
|
||||
"extraData": "0x07",
|
||||
"mixHash": "0x37690cfec6c1bf4c3b9288c7a5d783e98731e90b0a4c177c2a374c7a9427355e",
|
||||
"nonce": "0x0707070707070707",
|
||||
"baseFeePerGas": "0x0",
|
||||
@ -2451,7 +2451,7 @@ Response:
|
||||
"gasLimit": "0x5",
|
||||
"gasUsed": "0x5",
|
||||
"timestamp": "0x5",
|
||||
"extraData": "Ynl0ZSBhcnJheQ==",
|
||||
"extraData": "0x07",
|
||||
"mixHash": "0x37690cfec6c1bf4c3b9288c7a5d783e98731e90b0a4c177c2a374c7a9427355e",
|
||||
"nonce": "0x0707070707070707",
|
||||
"baseFeePerGas": "0x0",
|
||||
|
6
go.mod
6
go.mod
@ -62,10 +62,12 @@ require (
|
||||
github.com/gbrlsnchs/jwt/v3 v3.0.1
|
||||
github.com/gdamore/tcell/v2 v2.2.0
|
||||
github.com/go-kit/kit v0.12.0
|
||||
github.com/go-openapi/spec v0.19.11
|
||||
github.com/golang/mock v1.6.0
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/gregdhill/go-openrpc v0.0.0-20220114144539-ae6f44720487
|
||||
github.com/hako/durafmt v0.0.0-20200710122514-c0fb7b4da026
|
||||
github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e
|
||||
github.com/hashicorp/go-multierror v1.1.1
|
||||
@ -145,6 +147,7 @@ require (
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20221021053955-c138aae13722
|
||||
github.com/whyrusleeping/ledger-filecoin-go v0.9.1-0.20201010031517-c3dcc1bddce4
|
||||
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7
|
||||
github.com/xeipuuv/gojsonschema v1.2.0
|
||||
github.com/xorcare/golden v0.6.1-0.20191112154924-b87f686d7542
|
||||
go.opencensus.io v0.23.0
|
||||
go.opentelemetry.io/otel v1.11.1
|
||||
@ -213,7 +216,6 @@ require (
|
||||
github.com/go-ole/go-ole v1.2.5 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.3 // indirect
|
||||
github.com/go-openapi/jsonreference v0.19.4 // indirect
|
||||
github.com/go-openapi/spec v0.19.11 // indirect
|
||||
github.com/go-openapi/swag v0.19.11 // indirect
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
@ -324,6 +326,8 @@ require (
|
||||
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect
|
||||
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
|
||||
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||
github.com/zondax/hid v0.9.1 // indirect
|
||||
github.com/zondax/ledger-go v0.12.1 // indirect
|
||||
|
26
go.sum
26
go.sum
@ -451,6 +451,7 @@ github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwoh
|
||||
github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8=
|
||||
github.com/go-openapi/jsonreference v0.19.4 h1:3Vw+rh13uq2JFNxgnMTGE1rnoieU9FmyE1gvnyylsYg=
|
||||
github.com/go-openapi/jsonreference v0.19.4/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg=
|
||||
github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY=
|
||||
github.com/go-openapi/spec v0.19.7/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk=
|
||||
github.com/go-openapi/spec v0.19.11 h1:ogU5q8dtp3MMPn59a9VRrPKVxvJHEs5P7yNMR5sNnis=
|
||||
github.com/go-openapi/spec v0.19.11/go.mod h1:vqK/dIdLGCosfvYsQV3WfC7N3TiZSnGY2RZKoFK7X28=
|
||||
@ -464,6 +465,10 @@ github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
|
||||
github.com/gobuffalo/logger v1.0.0/go.mod h1:2zbswyIUa45I+c+FLXuWl9zSWEiVuthsk8ze5s8JvPs=
|
||||
github.com/gobuffalo/packd v0.3.0/go.mod h1:zC7QkmNkYVGKPw4tHpBQ+ml7W/3tIebgeo1b36chA3Q=
|
||||
github.com/gobuffalo/packr/v2 v2.6.0/go.mod h1:sgEE1xNZ6G0FNN5xn9pevVu4nywaxHvgup67xisti08=
|
||||
github.com/godbus/dbus v0.0.0-20190402143921-271e53dc4968/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
|
||||
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
@ -586,6 +591,8 @@ github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gregdhill/go-openrpc v0.0.0-20220114144539-ae6f44720487 h1:NyaWOSkqFK1d9o+HLfnMIGzrHuUUPeBNIZyi5Zoe/lY=
|
||||
github.com/gregdhill/go-openrpc v0.0.0-20220114144539-ae6f44720487/go.mod h1:a1eRkbhd3DYpRH2lnuUsVG+QMTI+v0hGnsis8C9hMrA=
|
||||
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0/go.mod h1:f5nM7jw/oeRSadq3xCzHAvxcr8HZnzsqU6ILg/0NiiE=
|
||||
@ -665,6 +672,7 @@ github.com/icza/backscanner v0.0.0-20210726202459-ac2ffc679f94 h1:9tcYMdi+7Rb1y0
|
||||
github.com/icza/backscanner v0.0.0-20210726202459-ac2ffc679f94/go.mod h1:GYeBD1CF7AqnKZK+UCytLcY3G+UKo0ByXX/3xfdNyqQ=
|
||||
github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6 h1:8UsGZ2rr2ksmEru6lToqnXgA8Mz1DP11X4zSJ159C3k=
|
||||
github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6/go.mod h1:xQig96I1VNBDIWGCdTt54nHt6EeI639SmHycLYL7FkA=
|
||||
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
|
||||
github.com/influxdata/influxdb1-client v0.0.0-20200827194710-b269163b24ab h1:HqW4xhhynfjrtEiiSGcQUd6vrK23iMam1FO8rI7mwig=
|
||||
@ -923,6 +931,7 @@ github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht
|
||||
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
|
||||
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4=
|
||||
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/jonboulle/clockwork v0.1.1-0.20190114141812-62fb9bc030d1/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ=
|
||||
@ -951,6 +960,7 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/kabukky/httpscerts v0.0.0-20150320125433-617593d7dcb3/go.mod h1:BYpt4ufZiIGv2nXn4gMxnfKV306n3mWXgNu/d2TqdTU=
|
||||
github.com/kami-zh/go-capturer v0.0.0-20171211120116-e492ea43421d/go.mod h1:P2viExyCEfeWGU259JnaQ34Inuec4R38JCyBx2edgD0=
|
||||
github.com/karrick/godirwalk v1.10.12/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
|
||||
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
|
||||
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
|
||||
github.com/kilic/bls12-381 v0.0.0-20200607163746-32e1441c8a9f/go.mod h1:XXfR6YFCRSrkEXbNlIyDsgXVNJWVUV30m/ebkVy9n6s=
|
||||
@ -976,6 +986,7 @@ github.com/klauspost/cpuid/v2 v2.1.1/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8t
|
||||
github.com/koalacxr/quantile v0.0.1 h1:wAW+SQ286Erny9wOjVww96t8ws+x5Zj6AKHDULUK+o0=
|
||||
github.com/koalacxr/quantile v0.0.1/go.mod h1:bGN/mCZLZ4lrSDHRQ6Lglj9chowGux8sGUIND+DQeD0=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/koron/go-ssdp v0.0.0-20180514024734-4a0ed625a78b/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk=
|
||||
github.com/koron/go-ssdp v0.0.0-20191105050749-2e1c40ed0b5d/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk=
|
||||
@ -990,6 +1001,7 @@ github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
@ -1693,6 +1705,7 @@ github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
|
||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg=
|
||||
@ -1779,6 +1792,7 @@ github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3
|
||||
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
@ -1795,6 +1809,8 @@ github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpP
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
|
||||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
|
||||
github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE=
|
||||
github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU=
|
||||
github.com/texttheater/golang-levenshtein v0.0.0-20180516184445-d188e65d659e/go.mod h1:XDKHRm5ThF8YJjx001LtgelzsoaEcvnA7lVWz9EeX3g=
|
||||
github.com/tidwall/gjson v1.6.0 h1:9VEQWz6LLMUsUl6PueE49ir4Ka6CzLymOAZDxpFsTDc=
|
||||
github.com/tidwall/gjson v1.6.0/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
|
||||
@ -1880,6 +1896,12 @@ github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7/go.
|
||||
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee h1:lYbXeSvJi5zk5GLKVuid9TVjS9a0OmLIDKTfoZBL6Ow=
|
||||
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee/go.mod h1:m2aV4LZI4Aez7dP5PMyVKEHhUyEJ/RjmPEDOpDvudHg=
|
||||
github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
||||
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
|
||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/xorcare/golden v0.6.0/go.mod h1:7T39/ZMvaSEZlBPoYfVFmsBLmUl3uz9IuzWj/U6FtvQ=
|
||||
github.com/xorcare/golden v0.6.1-0.20191112154924-b87f686d7542 h1:oWgZJmC1DorFZDpfMfWg7xk29yEOZiXmo/wZl+utTI8=
|
||||
@ -2004,6 +2026,7 @@ golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8U
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190618222545-ea8f1a30c443/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
@ -2191,12 +2214,14 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190524122548-abf6ff778158/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190524152521-dbbf3f1254d4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190526052359-791d8a0f4d09/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@ -2308,6 +2333,7 @@ golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBn
|
||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
|
520
itests/eth_conformance_test.go
Normal file
520
itests/eth_conformance_test.go
Normal file
@ -0,0 +1,520 @@
|
||||
package itests
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/spec"
|
||||
"github.com/gregdhill/go-openrpc/parse"
|
||||
orpctypes "github.com/gregdhill/go-openrpc/types"
|
||||
manet "github.com/multiformats/go-multiaddr/net"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/xeipuuv/gojsonschema"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-jsonrpc"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
||||
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||
"github.com/filecoin-project/lotus/itests/kit"
|
||||
)
|
||||
|
||||
// TODO generate this using reflection. It's the same as the EthAPI except every return value is a json.RawMessage
|
||||
type ethAPIRaw struct {
|
||||
EthAccounts func(context.Context) (json.RawMessage, error)
|
||||
EthBlockNumber func(context.Context) (json.RawMessage, error)
|
||||
EthCall func(context.Context, ethtypes.EthCall, string) (json.RawMessage, error)
|
||||
EthChainId func(context.Context) (json.RawMessage, error)
|
||||
EthEstimateGas func(context.Context, ethtypes.EthCall) (json.RawMessage, error)
|
||||
EthFeeHistory func(context.Context, ethtypes.EthUint64, string, []float64) (json.RawMessage, error)
|
||||
EthGasPrice func(context.Context) (json.RawMessage, error)
|
||||
EthGetBalance func(context.Context, ethtypes.EthAddress, string) (json.RawMessage, error)
|
||||
EthGetBlockByHash func(context.Context, ethtypes.EthHash, bool) (json.RawMessage, error)
|
||||
EthGetBlockByNumber func(context.Context, string, bool) (json.RawMessage, error)
|
||||
EthGetBlockTransactionCountByHash func(context.Context, ethtypes.EthHash) (json.RawMessage, error)
|
||||
EthGetBlockTransactionCountByNumber func(context.Context, ethtypes.EthUint64) (json.RawMessage, error)
|
||||
EthGetCode func(context.Context, ethtypes.EthAddress, string) (json.RawMessage, error)
|
||||
EthGetFilterChanges func(context.Context, ethtypes.EthFilterID) (json.RawMessage, error)
|
||||
EthGetFilterLogs func(context.Context, ethtypes.EthFilterID) (json.RawMessage, error)
|
||||
EthGetLogs func(context.Context, *ethtypes.EthFilterSpec) (json.RawMessage, error)
|
||||
EthGetStorageAt func(context.Context, ethtypes.EthAddress, ethtypes.EthBytes, string) (json.RawMessage, error)
|
||||
EthGetTransactionByBlockHashAndIndex func(context.Context, ethtypes.EthHash, ethtypes.EthUint64) (json.RawMessage, error)
|
||||
EthGetTransactionByBlockNumberAndIndex func(context.Context, ethtypes.EthUint64, ethtypes.EthUint64) (json.RawMessage, error)
|
||||
EthGetTransactionByHash func(context.Context, *ethtypes.EthHash) (json.RawMessage, error)
|
||||
EthGetTransactionCount func(context.Context, ethtypes.EthAddress, string) (json.RawMessage, error)
|
||||
EthGetTransactionReceipt func(context.Context, ethtypes.EthHash) (json.RawMessage, error)
|
||||
EthMaxPriorityFeePerGas func(context.Context) (json.RawMessage, error)
|
||||
EthNewBlockFilter func(context.Context) (json.RawMessage, error)
|
||||
EthNewFilter func(context.Context, *ethtypes.EthFilterSpec) (json.RawMessage, error)
|
||||
EthNewPendingTransactionFilter func(context.Context) (json.RawMessage, error)
|
||||
EthSendRawTransaction func(context.Context, ethtypes.EthBytes) (json.RawMessage, error)
|
||||
EthSubscribe func(context.Context, string, *ethtypes.EthSubscriptionParams) (json.RawMessage, error)
|
||||
EthUninstallFilter func(context.Context, ethtypes.EthFilterID) (json.RawMessage, error)
|
||||
EthUnsubscribe func(context.Context, ethtypes.EthSubscriptionID) (json.RawMessage, error)
|
||||
}
|
||||
|
||||
func TestEthOpenRPCConformance(t *testing.T) {
|
||||
kit.QuietAllLogsExcept("events", "messagepool")
|
||||
|
||||
// specs/eth_openrpc.json is built from https://github.com/ethereum/execution-apis
|
||||
specJSON, err := os.ReadFile("specs/eth_openrpc.json")
|
||||
require.NoError(t, err)
|
||||
|
||||
specParsed := orpctypes.NewOpenRPCSpec1()
|
||||
err = json.Unmarshal(specJSON, specParsed)
|
||||
require.NoError(t, err)
|
||||
parse.GetTypes(specParsed, specParsed.Objects)
|
||||
|
||||
schemas := make(map[string]spec.Schema)
|
||||
for _, method := range specParsed.Methods {
|
||||
if method.Result != nil {
|
||||
schemas[method.Name] = method.Result.Schema
|
||||
}
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer cancel()
|
||||
|
||||
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC(), kit.WithEthRPC())
|
||||
ens.InterconnectAll().BeginMining(10 * time.Millisecond)
|
||||
|
||||
contractHex, err := os.ReadFile("contracts/EventMatrix.hex")
|
||||
require.NoError(t, err)
|
||||
|
||||
// strip any trailing newlines from the file
|
||||
contractHex = bytes.TrimRight(contractHex, "\n")
|
||||
|
||||
contractBin, err := hex.DecodeString(string(contractHex))
|
||||
require.NoError(t, err)
|
||||
|
||||
senderKey, senderEthAddr, senderFilAddr := client.EVM().NewAccount()
|
||||
_, receiverEthAddr, _ := client.EVM().NewAccount()
|
||||
kit.SendFunds(ctx, t, client, senderFilAddr, types.FromFil(1000))
|
||||
|
||||
deployerAddr, err := client.EVM().WalletDefaultAddress(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
pendingTransactionFilterID, err := client.EthNewPendingTransactionFilter(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
blockFilterID, err := client.EthNewBlockFilter(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
filterAllLogs := kit.NewEthFilterBuilder().FromBlockEpoch(0).Filter()
|
||||
|
||||
logFilterID, err := client.EthNewFilter(ctx, filterAllLogs)
|
||||
require.NoError(t, err)
|
||||
|
||||
uninstallableFilterID, err := client.EthNewFilter(ctx, filterAllLogs)
|
||||
require.NoError(t, err)
|
||||
|
||||
rawSignedEthTx := createRawSignedEthTx(ctx, t, client, senderEthAddr, receiverEthAddr, senderKey, contractBin)
|
||||
|
||||
result := client.EVM().DeployContract(ctx, deployerAddr, contractBin)
|
||||
contractAddr, err := address.NewIDAddress(result.ActorID)
|
||||
require.NoError(t, err)
|
||||
|
||||
contractEthAddr := ethtypes.EthAddress(result.EthAddress)
|
||||
|
||||
messageWithEvents, blockHashWithMessage, blockNumberWithMessage := waitForMessageWithEvents(ctx, t, client, deployerAddr, contractAddr)
|
||||
|
||||
// create a json-rpc client that returns raw json responses
|
||||
var ethapi ethAPIRaw
|
||||
|
||||
netAddr, err := manet.ToNetAddr(client.ListenAddr)
|
||||
require.NoError(t, err)
|
||||
rpcAddr := "ws://" + netAddr.String() + "/rpc/v1"
|
||||
|
||||
closer, err := jsonrpc.NewClient(ctx, rpcAddr, "Filecoin", ðapi, nil)
|
||||
require.NoError(t, err)
|
||||
defer closer()
|
||||
|
||||
const skipUntilIssue10106 = "Skipped until EthTx is updated, see https://github.com/filecoin-project/lotus/issues/10106"
|
||||
|
||||
testCases := []struct {
|
||||
method string
|
||||
variant string // suffix applied to the test name to distinguish different variants of a method call
|
||||
call func(*ethAPIRaw) (json.RawMessage, error)
|
||||
skipReason string
|
||||
}{
|
||||
// Alphabetical order
|
||||
|
||||
{
|
||||
method: "eth_accounts",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthAccounts(context.Background())
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_blockNumber",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthBlockNumber(context.Background())
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_call",
|
||||
variant: "latest",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthCall(context.Background(), ethtypes.EthCall{
|
||||
From: &senderEthAddr,
|
||||
Data: contractBin,
|
||||
}, "latest")
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_chainId",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthChainId(context.Background())
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_estimateGas",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthEstimateGas(context.Background(), ethtypes.EthCall{
|
||||
From: &senderEthAddr,
|
||||
Data: contractBin,
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_feeHistory",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthFeeHistory(context.Background(), ethtypes.EthUint64(2), "", nil)
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_gasPrice",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGasPrice(context.Background())
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getBalance",
|
||||
variant: "blocknumber",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetBalance(context.Background(), contractEthAddr, "0x0")
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getBlockByHash",
|
||||
variant: "txhashes",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetBlockByHash(context.Background(), blockHashWithMessage, false)
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getBlockByHash",
|
||||
variant: "txfull",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetBlockByHash(context.Background(), blockHashWithMessage, true)
|
||||
},
|
||||
skipReason: skipUntilIssue10106,
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getBlockByNumber",
|
||||
variant: "earliest",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetBlockByNumber(context.Background(), "earliest", true)
|
||||
},
|
||||
skipReason: skipUntilIssue10106,
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getBlockByNumber",
|
||||
variant: "pending",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetBlockByNumber(context.Background(), "pending", true)
|
||||
},
|
||||
skipReason: skipUntilIssue10106,
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getBlockByNumber",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetBlockByNumber(context.Background(), blockNumberWithMessage.Hex(), true)
|
||||
},
|
||||
skipReason: skipUntilIssue10106,
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getBlockTransactionCountByHash",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetBlockTransactionCountByHash(context.Background(), blockHashWithMessage)
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getBlockTransactionCountByNumber",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetBlockTransactionCountByNumber(context.Background(), blockNumberWithMessage)
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getCode",
|
||||
variant: "blocknumber",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetCode(context.Background(), contractEthAddr, blockNumberWithMessage.Hex())
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getFilterChanges",
|
||||
variant: "pendingtransaction",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return a.EthGetFilterChanges(ctx, pendingTransactionFilterID)
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getFilterChanges",
|
||||
variant: "block",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return a.EthGetFilterChanges(ctx, blockFilterID)
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getFilterChanges",
|
||||
variant: "logs",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return a.EthGetFilterChanges(ctx, logFilterID)
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getFilterLogs",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return a.EthGetFilterLogs(ctx, logFilterID)
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getLogs",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetLogs(context.Background(), filterAllLogs)
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getStorageAt",
|
||||
variant: "blocknumber",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetStorageAt(context.Background(), contractEthAddr, ethtypes.EthBytes{0}, "0x0")
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getTransactionByBlockHashAndIndex",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetTransactionByBlockHashAndIndex(context.Background(), blockHashWithMessage, ethtypes.EthUint64(0))
|
||||
},
|
||||
skipReason: skipUntilIssue10106,
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getTransactionByBlockNumberAndIndex",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetTransactionByBlockNumberAndIndex(context.Background(), blockNumberWithMessage, ethtypes.EthUint64(0))
|
||||
},
|
||||
skipReason: skipUntilIssue10106,
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getTransactionByHash",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetTransactionByHash(context.Background(), &messageWithEvents)
|
||||
},
|
||||
skipReason: skipUntilIssue10106,
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getTransactionCount",
|
||||
variant: "blocknumber",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetTransactionCount(context.Background(), senderEthAddr, blockNumberWithMessage.Hex())
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_getTransactionReceipt",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthGetTransactionReceipt(context.Background(), messageWithEvents)
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_maxPriorityFeePerGas",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthMaxPriorityFeePerGas(context.Background())
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_newBlockFilter",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthNewBlockFilter(context.Background())
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_newFilter",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthNewFilter(context.Background(), filterAllLogs)
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_newPendingTransactionFilter",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthNewPendingTransactionFilter(context.Background())
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_sendRawTransaction",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthSendRawTransaction(context.Background(), rawSignedEthTx)
|
||||
},
|
||||
},
|
||||
{
|
||||
method: "eth_uninstallFilter",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return a.EthUninstallFilter(ctx, uninstallableFilterID)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
name := tc.method
|
||||
if tc.variant != "" {
|
||||
name += "_" + tc.variant
|
||||
}
|
||||
t.Run(name, func(t *testing.T) {
|
||||
if tc.skipReason != "" {
|
||||
t.Skipf(tc.skipReason)
|
||||
}
|
||||
|
||||
schema, ok := schemas[tc.method]
|
||||
require.True(t, ok, "method not found in openrpc spec")
|
||||
|
||||
resp, err := tc.call(ðapi)
|
||||
require.NoError(t, err)
|
||||
|
||||
respJson, err := json.Marshal(resp)
|
||||
require.NoError(t, err)
|
||||
|
||||
loader := gojsonschema.NewGoLoader(schema)
|
||||
resploader := gojsonschema.NewBytesLoader(respJson)
|
||||
result, err := gojsonschema.Validate(loader, resploader)
|
||||
require.NoError(t, err)
|
||||
|
||||
if !result.Valid() {
|
||||
if len(result.Errors()) == 1 && strings.Contains(result.Errors()[0].String(), "Must validate one and only one schema (oneOf)") {
|
||||
// Ignore this error, since it seems the openrpc spec can't handle it
|
||||
// New transaction and block filters have the same schema: an array of 32 byte hashes
|
||||
return
|
||||
}
|
||||
|
||||
niceRespJson, err := json.MarshalIndent(resp, "", " ")
|
||||
if err == nil {
|
||||
t.Logf("response was %s", niceRespJson)
|
||||
}
|
||||
|
||||
schemaJson, err := json.MarshalIndent(schema, "", " ")
|
||||
if err == nil {
|
||||
t.Logf("schema was %s", schemaJson)
|
||||
}
|
||||
|
||||
// check against https://www.jsonschemavalidator.net/
|
||||
|
||||
for _, desc := range result.Errors() {
|
||||
t.Logf("- %s\n", desc)
|
||||
}
|
||||
|
||||
t.Errorf("response did not validate")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func createRawSignedEthTx(ctx context.Context, t *testing.T, client *kit.TestFullNode, senderEthAddr ethtypes.EthAddress, receiverEthAddr ethtypes.EthAddress, senderKey *key.Key, contractBin []byte) []byte {
|
||||
gaslimit, err := client.EthEstimateGas(ctx, ethtypes.EthCall{
|
||||
From: &senderEthAddr,
|
||||
Data: contractBin,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
maxPriorityFeePerGas, err := client.EthMaxPriorityFeePerGas(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
tx := ethtypes.EthTxArgs{
|
||||
ChainID: build.Eip155ChainId,
|
||||
Value: big.NewInt(100),
|
||||
Nonce: 0,
|
||||
To: &receiverEthAddr,
|
||||
MaxFeePerGas: types.NanoFil,
|
||||
MaxPriorityFeePerGas: big.Int(maxPriorityFeePerGas),
|
||||
GasLimit: int(gaslimit),
|
||||
V: big.Zero(),
|
||||
R: big.Zero(),
|
||||
S: big.Zero(),
|
||||
}
|
||||
|
||||
client.EVM().SignTransaction(&tx, senderKey.PrivateKey)
|
||||
signed, err := tx.ToRlpSignedMsg()
|
||||
require.NoError(t, err)
|
||||
return signed
|
||||
}
|
||||
|
||||
func waitForMessageWithEvents(ctx context.Context, t *testing.T, client *kit.TestFullNode, sender address.Address, target address.Address) (ethtypes.EthHash, ethtypes.EthHash, ethtypes.EthUint64) {
|
||||
vals := []uint64{44, 27, 19, 12}
|
||||
inputData := []byte{}
|
||||
for _, v := range vals {
|
||||
buf := make([]byte, 32)
|
||||
binary.BigEndian.PutUint64(buf[24:], v)
|
||||
inputData = append(inputData, buf...)
|
||||
}
|
||||
|
||||
// send a message that exercises event logs
|
||||
ret, err := client.EVM().InvokeSolidity(ctx, sender, target, kit.EventMatrixContract.Fn["logEventThreeIndexedWithData"], inputData)
|
||||
require.NoError(t, err)
|
||||
require.True(t, ret.Receipt.ExitCode.IsSuccess(), "contract execution failed")
|
||||
|
||||
msgHash, err := client.EthGetTransactionHashByCid(ctx, ret.Message)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, msgHash)
|
||||
|
||||
ts, err := client.ChainGetTipSet(ctx, ret.TipSet)
|
||||
require.NoError(t, err)
|
||||
|
||||
blockNumber := ethtypes.EthUint64(ts.Height())
|
||||
|
||||
tsCid, err := ts.Key().Cid()
|
||||
require.NoError(t, err)
|
||||
|
||||
blockHash, err := ethtypes.EthHashFromCid(tsCid)
|
||||
require.NoError(t, err)
|
||||
return *msgHash, blockHash, blockNumber
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -117,11 +117,9 @@ func TestLegacyTransaction(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
_, err = client.EVM().EthSendRawTransaction(ctx, txBytes)
|
||||
require.ErrorContains(t, err, "legacy transaction is not supported")
|
||||
|
||||
}
|
||||
|
||||
func TestContractDeploymentValidSignature(t *testing.T) {
|
||||
|
||||
blockTime := 100 * time.Millisecond
|
||||
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC())
|
||||
|
||||
@ -270,7 +268,6 @@ func TestContractInvocation(t *testing.T) {
|
||||
|
||||
// Success.
|
||||
require.EqualValues(t, ethtypes.EthUint64(0x1), receipt.Status)
|
||||
|
||||
}
|
||||
|
||||
func deployContractTx(ctx context.Context, client *kit.TestFullNode, ethAddr ethtypes.EthAddress, contract []byte) (*ethtypes.EthTxArgs, error) {
|
||||
|
@ -319,7 +319,7 @@ func removeLeadingZeros(data []byte) []byte {
|
||||
}
|
||||
|
||||
func SetupFEVMTest(t *testing.T) (context.Context, context.CancelFunc, *TestFullNode) {
|
||||
//make all logs extra quiet for fevm tests
|
||||
// make all logs extra quiet for fevm tests
|
||||
lvl, err := logging.LevelFromString("error")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -354,3 +354,77 @@ func (e *EVM) TransferValueOrFail(ctx context.Context, fromAddr address.Address,
|
||||
require.NoError(e.t, err)
|
||||
require.Equal(e.t, exitcode.Ok, mLookup.Receipt.ExitCode)
|
||||
}
|
||||
|
||||
func NewEthFilterBuilder() *EthFilterBuilder {
|
||||
return &EthFilterBuilder{}
|
||||
}
|
||||
|
||||
type EthFilterBuilder struct {
|
||||
filter ethtypes.EthFilterSpec
|
||||
}
|
||||
|
||||
func (e *EthFilterBuilder) Filter() *ethtypes.EthFilterSpec { return &e.filter }
|
||||
|
||||
func (e *EthFilterBuilder) FromBlock(v string) *EthFilterBuilder {
|
||||
e.filter.FromBlock = &v
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EthFilterBuilder) FromBlockEpoch(v abi.ChainEpoch) *EthFilterBuilder {
|
||||
s := ethtypes.EthUint64(v).Hex()
|
||||
e.filter.FromBlock = &s
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EthFilterBuilder) ToBlock(v string) *EthFilterBuilder {
|
||||
e.filter.ToBlock = &v
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EthFilterBuilder) ToBlockEpoch(v abi.ChainEpoch) *EthFilterBuilder {
|
||||
s := ethtypes.EthUint64(v).Hex()
|
||||
e.filter.ToBlock = &s
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EthFilterBuilder) BlockHash(h ethtypes.EthHash) *EthFilterBuilder {
|
||||
e.filter.BlockHash = &h
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EthFilterBuilder) AddressOneOf(as ...ethtypes.EthAddress) *EthFilterBuilder {
|
||||
e.filter.Address = as
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EthFilterBuilder) Topic1OneOf(hs ...ethtypes.EthHash) *EthFilterBuilder {
|
||||
if len(e.filter.Topics) == 0 {
|
||||
e.filter.Topics = make(ethtypes.EthTopicSpec, 1)
|
||||
}
|
||||
e.filter.Topics[0] = hs
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EthFilterBuilder) Topic2OneOf(hs ...ethtypes.EthHash) *EthFilterBuilder {
|
||||
for len(e.filter.Topics) < 2 {
|
||||
e.filter.Topics = append(e.filter.Topics, nil)
|
||||
}
|
||||
e.filter.Topics[1] = hs
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EthFilterBuilder) Topic3OneOf(hs ...ethtypes.EthHash) *EthFilterBuilder {
|
||||
for len(e.filter.Topics) < 3 {
|
||||
e.filter.Topics = append(e.filter.Topics, nil)
|
||||
}
|
||||
e.filter.Topics[2] = hs
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EthFilterBuilder) Topic4OneOf(hs ...ethtypes.EthHash) *EthFilterBuilder {
|
||||
for len(e.filter.Topics) < 4 {
|
||||
e.filter.Topics = append(e.filter.Topics, nil)
|
||||
}
|
||||
e.filter.Topics[3] = hs
|
||||
return e
|
||||
}
|
||||
|
64
itests/kit/solidity.go
Normal file
64
itests/kit/solidity.go
Normal file
@ -0,0 +1,64 @@
|
||||
package kit
|
||||
|
||||
import (
|
||||
"golang.org/x/crypto/sha3"
|
||||
)
|
||||
|
||||
func EthTopicHash(sig string) []byte {
|
||||
hasher := sha3.NewLegacyKeccak256()
|
||||
hasher.Write([]byte(sig))
|
||||
return hasher.Sum(nil)
|
||||
}
|
||||
|
||||
func EthFunctionHash(sig string) []byte {
|
||||
hasher := sha3.NewLegacyKeccak256()
|
||||
hasher.Write([]byte(sig))
|
||||
return hasher.Sum(nil)[:4]
|
||||
}
|
||||
|
||||
// SolidityContractDef holds information about one of the test contracts
|
||||
type SolidityContractDef struct {
|
||||
Filename string // filename of the hex of the contract, e.g. contracts/EventMatrix.hex
|
||||
Fn map[string][]byte // mapping of function names to 32-bit selector
|
||||
Ev map[string][]byte // mapping of event names to 256-bit signature hashes
|
||||
}
|
||||
|
||||
var EventMatrixContract = SolidityContractDef{
|
||||
Filename: "contracts/EventMatrix.hex",
|
||||
Fn: map[string][]byte{
|
||||
"logEventZeroData": EthFunctionHash("logEventZeroData()"),
|
||||
"logEventOneData": EthFunctionHash("logEventOneData(uint256)"),
|
||||
"logEventTwoData": EthFunctionHash("logEventTwoData(uint256,uint256)"),
|
||||
"logEventThreeData": EthFunctionHash("logEventThreeData(uint256,uint256,uint256)"),
|
||||
"logEventFourData": EthFunctionHash("logEventFourData(uint256,uint256,uint256,uint256)"),
|
||||
"logEventOneIndexed": EthFunctionHash("logEventOneIndexed(uint256)"),
|
||||
"logEventTwoIndexed": EthFunctionHash("logEventTwoIndexed(uint256,uint256)"),
|
||||
"logEventThreeIndexed": EthFunctionHash("logEventThreeIndexed(uint256,uint256,uint256)"),
|
||||
"logEventOneIndexedWithData": EthFunctionHash("logEventOneIndexedWithData(uint256,uint256)"),
|
||||
"logEventTwoIndexedWithData": EthFunctionHash("logEventTwoIndexedWithData(uint256,uint256,uint256)"),
|
||||
"logEventThreeIndexedWithData": EthFunctionHash("logEventThreeIndexedWithData(uint256,uint256,uint256,uint256)"),
|
||||
},
|
||||
Ev: map[string][]byte{
|
||||
"EventZeroData": EthTopicHash("EventZeroData()"),
|
||||
"EventOneData": EthTopicHash("EventOneData(uint256)"),
|
||||
"EventTwoData": EthTopicHash("EventTwoData(uint256,uint256)"),
|
||||
"EventThreeData": EthTopicHash("EventThreeData(uint256,uint256,uint256)"),
|
||||
"EventFourData": EthTopicHash("EventFourData(uint256,uint256,uint256,uint256)"),
|
||||
"EventOneIndexed": EthTopicHash("EventOneIndexed(uint256)"),
|
||||
"EventTwoIndexed": EthTopicHash("EventTwoIndexed(uint256,uint256)"),
|
||||
"EventThreeIndexed": EthTopicHash("EventThreeIndexed(uint256,uint256,uint256)"),
|
||||
"EventOneIndexedWithData": EthTopicHash("EventOneIndexedWithData(uint256,uint256)"),
|
||||
"EventTwoIndexedWithData": EthTopicHash("EventTwoIndexedWithData(uint256,uint256,uint256)"),
|
||||
"EventThreeIndexedWithData": EthTopicHash("EventThreeIndexedWithData(uint256,uint256,uint256,uint256)"),
|
||||
},
|
||||
}
|
||||
|
||||
var EventsContract = SolidityContractDef{
|
||||
Filename: "contracts/events.bin",
|
||||
Fn: map[string][]byte{
|
||||
"log_zero_data": {0x00, 0x00, 0x00, 0x00},
|
||||
"log_zero_nodata": {0x00, 0x00, 0x00, 0x01},
|
||||
"log_four_data": {0x00, 0x00, 0x00, 0x02},
|
||||
},
|
||||
Ev: map[string][]byte{},
|
||||
}
|
4392
itests/specs/eth_openrpc.json
Normal file
4392
itests/specs/eth_openrpc.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -447,6 +447,11 @@ func (a *EthModule) EthGetCode(ctx context.Context, ethAddr ethtypes.EthAddress,
|
||||
return nil, xerrors.Errorf("cannot parse block param: %s", blkParam)
|
||||
}
|
||||
|
||||
// StateManager.Call will panic if there is no parent
|
||||
if ts.Height() == 0 {
|
||||
return nil, xerrors.Errorf("block param must not specify genesis block")
|
||||
}
|
||||
|
||||
// Try calling until we find a height with no migration.
|
||||
var res *api.InvocResult
|
||||
for {
|
||||
@ -637,7 +642,7 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount ethtypes.EthUint
|
||||
}
|
||||
|
||||
return ethtypes.EthFeeHistory{
|
||||
OldestBlock: oldestBlkHeight,
|
||||
OldestBlock: ethtypes.EthUint64(oldestBlkHeight),
|
||||
BaseFeePerGas: baseFeeArray,
|
||||
GasUsedRatio: gasUsedRatioArray,
|
||||
}, nil
|
||||
@ -962,7 +967,6 @@ func (a *EthModule) EthCall(ctx context.Context, tx ethtypes.EthCall, blkParam s
|
||||
if msg.To == builtintypes.EthereumAddressManagerActorAddr {
|
||||
// As far as I can tell, the Eth API always returns empty on contract deployment
|
||||
return ethtypes.EthBytes{}, nil
|
||||
|
||||
} else if len(invokeResult.MsgRct.Return) > 0 {
|
||||
return cbg.ReadByteArray(bytes.NewReader(invokeResult.MsgRct.Return), uint64(len(invokeResult.MsgRct.Return)))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user