diff --git a/Cargo.lock b/Cargo.lock index ab962b0e..4fd17895 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -208,9 +208,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.3.15" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942c7cd7ae39e91bde4820d74132e9862e62c2f386c3aa90ccf55949f5bad63a" +checksum = "07dbbf24db18d609b1462965249abdf49129ccad073ec257da372adc83259c60" dependencies = [ "brotli", "flate2", @@ -239,7 +239,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -250,7 +250,7 @@ checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -400,9 +400,9 @@ dependencies = [ [[package]] name = "brotli" -version = "3.5.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d640d25bc63c50fb1f0b545ffd80207d2e10a4c965530809b40ba3386825c391" +checksum = "125740193d7fee5cc63ab9e16c2fdc4e07c74ba755cc53b327d6ea029e9fc569" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -411,9 +411,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.5.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f" +checksum = "65622a320492e09b5e0ac436b14c54ff68199bac392d0e89a6832c4518eea525" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -468,7 +468,7 @@ checksum = "4da9a32f3fed317401fa3c862968128267c3106685286e15d5aaa3d7389c2f60" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -504,6 +504,21 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "casper-binary-port" +version = "1.0.0" +source = "git+https://github.com/casper-network/casper-node?branch=feat-2.0#288f0be84226806a70d5818a25480c3c2d346fab" +dependencies = [ + "bincode", + "casper-types", + "once_cell", + "rand", + "schemars", + "serde", + "serde-map-to-array", + "thiserror", +] + [[package]] name = "casper-event-listener" version = "1.0.0" @@ -551,7 +566,7 @@ dependencies = [ "futures-util", "hex", "hex_fmt", - "http", + "http 0.2.12", "hyper", "indexmap 2.2.6", "itertools 0.10.5", @@ -609,7 +624,7 @@ dependencies = [ "bytes", "env_logger", "futures", - "http", + "http 0.2.12", "hyper", "itertools 0.10.5", "metrics", @@ -631,11 +646,12 @@ dependencies = [ "base16", "bincode", "bytes", + "casper-binary-port", "casper-json-rpc", "casper-types", "datasize", "futures", - "http", + "http 0.2.12", "hyper", "juliet", "metrics", @@ -687,7 +703,7 @@ dependencies = [ [[package]] name = "casper-types" version = "3.0.0" -source = "git+https://github.com/casper-network/casper-node?branch=feat-2.0#a9afd2e1739b1404e05c9c9bebdb8bdec5f5cd1c" +source = "git+https://github.com/casper-network/casper-node?branch=feat-2.0#288f0be84226806a70d5818a25480c3c2d346fab" dependencies = [ "base16", "base64 0.13.1", @@ -730,9 +746,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "1fd97381a8cc6493395a5afc4c691c1084b3768db713b73aa215217aa245d153" dependencies = [ "jobserver", "libc", @@ -788,7 +804,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.0", + "strsim 0.11.1", ] [[package]] @@ -800,7 +816,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -876,9 +892,9 @@ dependencies = [ [[package]] name = "crc" -version = "3.0.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" +checksum = "c2b432c56615136f8dba245fed7ec3d5518c500a31108661067e61e72fe7e6bc" dependencies = [ "crc-catalog", ] @@ -986,7 +1002,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1019,9 +1035,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "pem-rfc7468", @@ -1056,7 +1072,7 @@ checksum = "d150dea618e920167e5973d70ae6ece4385b7164e0d799fe7c122dd0a5d912ad" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1498,7 +1514,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1544,9 +1560,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "a06fddc2749e0528d2813f95e050e87e52c8cbbae56223b9babf73b3e53b0cc6" dependencies = [ "cfg-if", "js-sys", @@ -1827,7 +1843,7 @@ checksum = "1dff438f14e67e7713ab9332f5fd18c8f20eb7eb249494f6c2bf170522224032" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -2074,16 +2090,16 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", "indexmap 2.2.6", "slab", "tokio", @@ -2125,7 +2141,7 @@ dependencies = [ "base64 0.21.7", "bytes", "headers-core", - "http", + "http 0.2.12", "httpdate", "mime", "sha1", @@ -2137,7 +2153,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" dependencies = [ - "http", + "http 0.2.12", ] [[package]] @@ -2239,6 +2255,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -2246,7 +2273,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", "pin-project-lite", ] @@ -2279,7 +2306,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.12", "http-body", "httparse", "httpdate", @@ -2345,7 +2372,7 @@ checksum = "0122b7114117e64a63ac49f752a5ca4624d534c7b1c7de796ac196381cd2d947" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -2517,13 +2544,12 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.5.0", "libc", - "redox_syscall 0.4.1", ] [[package]] @@ -2597,9 +2623,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "memmap2" @@ -2688,7 +2714,7 @@ dependencies = [ "bytes", "encoding_rs", "futures-util", - "http", + "http 0.2.12", "httparse", "log", "memchr", @@ -2915,7 +2941,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -2926,9 +2952,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.101" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -3109,14 +3135,14 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -3407,9 +3433,9 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", @@ -3472,7 +3498,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.12", "http-body", "hyper", "hyper-tls", @@ -3582,7 +3608,7 @@ dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", "rust-embed-utils", - "syn 2.0.55", + "syn 2.0.58", "walkdir", ] @@ -3661,9 +3687,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" [[package]] name = "rusty-fork" @@ -3767,7 +3793,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", "thiserror", ] @@ -3786,9 +3812,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.2" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -3799,9 +3825,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" dependencies = [ "core-foundation-sys", "libc", @@ -3849,7 +3875,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -3955,9 +3981,9 @@ dependencies = [ [[package]] name = "similar" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21" +checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640" [[package]] name = "slab" @@ -4333,9 +4359,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "structopt" @@ -4402,7 +4428,7 @@ dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", "rustversion", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -4435,9 +4461,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.55" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", @@ -4554,7 +4580,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -4637,9 +4663,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", @@ -4662,7 +4688,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -4700,9 +4726,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" dependencies = [ "futures-util", "log", @@ -4781,7 +4807,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -4844,14 +4870,14 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tungstenite" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" dependencies = [ "byteorder", "bytes", "data-encoding", - "http", + "http 1.1.0", "httparse", "log", "rand", @@ -5007,7 +5033,7 @@ dependencies = [ "proc-macro-error", "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5119,16 +5145,16 @@ dependencies = [ [[package]] name = "warp" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e92e22e03ff1230c03a1a8ee37d2f89cd489e2e541b7550d6afad96faed169" +checksum = "4378d202ff965b011c64817db11d5829506d3404edeadb61f190d111da3f231c" dependencies = [ "async-compression", "bytes", "futures-channel", "futures-util", "headers", - "http", + "http 0.2.12", "hyper", "log", "mime", @@ -5136,13 +5162,11 @@ dependencies = [ "multer", "percent-encoding", "pin-project", - "rustls-pemfile", "scoped-tls", "serde", "serde_json", "serde_urlencoded", "tokio", - "tokio-stream", "tokio-tungstenite", "tokio-util", "tower-service", @@ -5182,7 +5206,7 @@ dependencies = [ "once_cell", "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", "wasm-bindgen-shared", ] @@ -5216,7 +5240,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5577,7 +5601,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5627,9 +5651,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.9+zstd.1.5.5" +version = "2.0.10+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" +checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" dependencies = [ "cc", "pkg-config", diff --git a/Cargo.toml b/Cargo.toml index 474afcca..7c2a0bc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,14 +7,14 @@ members = [ "metrics", "rpc_sidecar", "sidecar", - "types" + "types", ] [workspace.dependencies] anyhow = "1" async-stream = "0.3.4" async-trait = "0.1.77" -casper-types = { git = "https://github.com/casper-network/casper-node", branch="feat-2.0" } +casper-types = { git = "https://github.com/casper-network/casper-node", branch = "feat-2.0" } casper-event-sidecar = { path = "./event_sidecar", version = "1.0.0" } casper-event-types = { path = "./types", version = "1.0.0" } casper-rpc-sidecar = { path = "./rpc_sidecar", version = "1.0.0" } diff --git a/event_sidecar/src/types/sse_events.rs b/event_sidecar/src/types/sse_events.rs index 64d17eed..21f79033 100644 --- a/event_sidecar/src/types/sse_events.rs +++ b/event_sidecar/src/types/sse_events.rs @@ -46,7 +46,7 @@ pub fn random_execution_result(rng: &mut TestRng) -> ExecutionResult { ExecutionResult::V1(result_v1) } 1 => { - let result_v2: ExecutionResultV2 = rng.gen(); + let result_v2 = ExecutionResultV2::random(rng); ExecutionResult::V2(result_v2) } _ => panic!("Unexpected value"), diff --git a/resources/test/rpc_schema.json b/resources/test/rpc_schema.json index 6608e80c..32dc6f16 100644 --- a/resources/test/rpc_schema.json +++ b/resources/test/rpc_schema.json @@ -166,12 +166,12 @@ "name": "transaction", "value": { "Version1": { - "hash": "2576738ea0aac682f434cdee280ccfbc8aa208cfc110460f612a23c297acdce5", + "hash": "52a75f3651e450cc2c3ed534bf130bae2515950707d70bb60067aada30b97ca8", "header": { "chain_name": "casper-example", "timestamp": "2020-11-17T00:39:24.072Z", "ttl": "1h", - "body_hash": "d2433e28993036fbdf7c963cd753893fefe619e7dbb5c0cafa5cb03bcf3ff9db", + "body_hash": "8c36f401d829378219b676ac6cceef90b08171499f5f5726ab5021df46d8b824", "pricing_mode": { "Fixed": { "gas_price_tolerance": 5 @@ -186,8 +186,10 @@ [ "source", { - "cl_type": "URef", - "bytes": "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a07", + "cl_type": { + "Option": "URef" + }, + "bytes": "010a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a07", "parsed": "uref-0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a-007" } ], @@ -207,18 +209,6 @@ "parsed": "30000000000" } ], - [ - "to", - { - "cl_type": { - "Option": { - "ByteArray": 32 - } - }, - "bytes": "012828282828282828282828282828282828282828282828282828282828282828", - "parsed": "2828282828282828282828282828282828282828282828282828282828282828" - } - ], [ "id", { @@ -237,7 +227,7 @@ "approvals": [ { "signer": "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c", - "signature": "017650934fca4d5f4107058c68b1c4ce66aac965164a3c6f8070753c4bb2623119ea1fb9046b8324dcba20c9fd141bb1364953638ecd65d57c283132845134e50c" + "signature": "012eaaf83b1ed367ed424c859974bc5115a62d6b10d635f4b39d380414c4abcb2d54c01b7b96e0d27e00ed913f05f06d7bee9c25c31bbd8e9215961e61f835250d" } ] } @@ -249,7 +239,7 @@ "value": { "api_version": "2.0.0", "transaction_hash": { - "Version1": "2576738ea0aac682f434cdee280ccfbc8aa208cfc110460f612a23c297acdce5" + "Version1": "52a75f3651e450cc2c3ed534bf130bae2515950707d70bb60067aada30b97ca8" } } } @@ -392,25 +382,48 @@ "block_height": 10, "execution_result": { "Version2": { - "Success": { - "effects": [ - { - "key": "account-hash-2c4a11c062a8a337bfc97e27fd66291caeb2c65865dcb5d3ef3759c4c97efecb", - "kind": { - "AddUInt64": 8 - } - }, - { - "key": "deploy-af684263911154d26fa05be9963171802801a0b6aff8f199b7391eacb8edc9e1", - "kind": "Identity" + "initiator": { + "PublicKey": "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c" + }, + "error_message": null, + "limit": "123456", + "consumed": "100000", + "cost": "246912", + "payment": [ + { + "source": "uref-0101010101010101010101010101010101010101010101010101010101010101-001" + } + ], + "transfers": [ + { + "Version2": { + "transaction_hash": { + "Version1": "0101010101010101010101010101010101010101010101010101010101010101" + }, + "from": { + "AccountHash": "account-hash-0202020202020202020202020202020202020202020202020202020202020202" + }, + "to": "account-hash-0303030303030303030303030303030303030303030303030303030303030303", + "source": "uref-0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a-007", + "target": "uref-1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b-000", + "amount": "1000000000000", + "gas": "2500000000", + "id": 999 } - ], - "transfers": [ - "transfer-5959595959595959595959595959595959595959595959595959595959595959", - "transfer-8282828282828282828282828282828282828282828282828282828282828282" - ], - "cost": "123456" - } + } + ], + "effects": [ + { + "key": "account-hash-2c4a11c062a8a337bfc97e27fd66291caeb2c65865dcb5d3ef3759c4c97efecb", + "kind": { + "AddUInt64": 8 + } + }, + { + "key": "deploy-af684263911154d26fa05be9963171802801a0b6aff8f199b7391eacb8edc9e1", + "kind": "Identity" + } + ] } } } @@ -490,7 +503,7 @@ { "name": "transaction_hash", "value": { - "Version1": "2576738ea0aac682f434cdee280ccfbc8aa208cfc110460f612a23c297acdce5" + "Version1": "52a75f3651e450cc2c3ed534bf130bae2515950707d70bb60067aada30b97ca8" } }, { @@ -504,12 +517,12 @@ "api_version": "2.0.0", "transaction": { "Version1": { - "hash": "2576738ea0aac682f434cdee280ccfbc8aa208cfc110460f612a23c297acdce5", + "hash": "52a75f3651e450cc2c3ed534bf130bae2515950707d70bb60067aada30b97ca8", "header": { "chain_name": "casper-example", "timestamp": "2020-11-17T00:39:24.072Z", "ttl": "1h", - "body_hash": "d2433e28993036fbdf7c963cd753893fefe619e7dbb5c0cafa5cb03bcf3ff9db", + "body_hash": "8c36f401d829378219b676ac6cceef90b08171499f5f5726ab5021df46d8b824", "pricing_mode": { "Fixed": { "gas_price_tolerance": 5 @@ -524,8 +537,10 @@ [ "source", { - "cl_type": "URef", - "bytes": "0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a07", + "cl_type": { + "Option": "URef" + }, + "bytes": "010a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a07", "parsed": "uref-0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a-007" } ], @@ -545,18 +560,6 @@ "parsed": "30000000000" } ], - [ - "to", - { - "cl_type": { - "Option": { - "ByteArray": 32 - } - }, - "bytes": "012828282828282828282828282828282828282828282828282828282828282828", - "parsed": "2828282828282828282828282828282828282828282828282828282828282828" - } - ], [ "id", { @@ -575,7 +578,7 @@ "approvals": [ { "signer": "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c", - "signature": "017650934fca4d5f4107058c68b1c4ce66aac965164a3c6f8070753c4bb2623119ea1fb9046b8324dcba20c9fd141bb1364953638ecd65d57c283132845134e50c" + "signature": "012eaaf83b1ed367ed424c859974bc5115a62d6b10d635f4b39d380414c4abcb2d54c01b7b96e0d27e00ed913f05f06d7bee9c25c31bbd8e9215961e61f835250d" } ] } @@ -584,25 +587,48 @@ "block_height": 10, "execution_result": { "Version2": { - "Success": { - "effects": [ - { - "key": "account-hash-2c4a11c062a8a337bfc97e27fd66291caeb2c65865dcb5d3ef3759c4c97efecb", - "kind": { - "AddUInt64": 8 - } - }, - { - "key": "deploy-af684263911154d26fa05be9963171802801a0b6aff8f199b7391eacb8edc9e1", - "kind": "Identity" + "initiator": { + "PublicKey": "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c" + }, + "error_message": null, + "limit": "123456", + "consumed": "100000", + "cost": "246912", + "payment": [ + { + "source": "uref-0101010101010101010101010101010101010101010101010101010101010101-001" + } + ], + "transfers": [ + { + "Version2": { + "transaction_hash": { + "Version1": "0101010101010101010101010101010101010101010101010101010101010101" + }, + "from": { + "AccountHash": "account-hash-0202020202020202020202020202020202020202020202020202020202020202" + }, + "to": "account-hash-0303030303030303030303030303030303030303030303030303030303030303", + "source": "uref-0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a-007", + "target": "uref-1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b-000", + "amount": "1000000000000", + "gas": "2500000000", + "id": 999 } - ], - "transfers": [ - "transfer-5959595959595959595959595959595959595959595959595959595959595959", - "transfer-8282828282828282828282828282828282828282828282828282828282828282" - ], - "cost": "123456" - } + } + ], + "effects": [ + { + "key": "account-hash-2c4a11c062a8a337bfc97e27fd66291caeb2c65865dcb5d3ef3759c4c97efecb", + "kind": { + "AddUInt64": 8 + } + }, + { + "key": "deploy-af684263911154d26fa05be9963171802801a0b6aff8f199b7391eacb8edc9e1", + "kind": "Identity" + } + ] } } } @@ -803,7 +829,7 @@ "args": [], "ret": "Unit", "access": "Public", - "entry_point_type": "Session" + "entry_point_type": "Caller" } } ], @@ -1685,14 +1711,20 @@ "block_hash": "0707070707070707070707070707070707070707070707070707070707070707", "transfers": [ { - "deploy_hash": "0000000000000000000000000000000000000000000000000000000000000000", - "from": "account-hash-0000000000000000000000000000000000000000000000000000000000000000", - "to": null, - "source": "uref-0000000000000000000000000000000000000000000000000000000000000000-000", - "target": "uref-0000000000000000000000000000000000000000000000000000000000000000-000", - "amount": "0", - "gas": "0", - "id": null + "Version2": { + "transaction_hash": { + "Version1": "0101010101010101010101010101010101010101010101010101010101010101" + }, + "from": { + "AccountHash": "account-hash-0202020202020202020202020202020202020202020202020202020202020202" + }, + "to": "account-hash-0303030303030303030303030303030303030303030303030303030303030303", + "source": "uref-0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a-007", + "target": "uref-1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b-000", + "amount": "1000000000000", + "gas": "2500000000", + "id": 999 + } } ] } @@ -2995,8 +3027,9 @@ "Classic": { "type": "object", "required": [ - "gas_price", - "payment_amount" + "gas_price_tolerance", + "payment_amount", + "standard_payment" ], "properties": { "payment_amount": { @@ -3005,11 +3038,15 @@ "format": "uint64", "minimum": 0.0 }, - "gas_price": { - "description": "User-specified gas_price tolerance (minimum 1).", + "gas_price_tolerance": { + "description": "User-specified gas_price tolerance (minimum 1). This is interpreted to mean \"do not include this transaction in a block if the current gas price is greater than this number\"", "type": "integer", - "format": "uint64", + "format": "uint8", "minimum": 0.0 + }, + "standard_payment": { + "description": "Standard payment.", + "type": "boolean" } }, "additionalProperties": false @@ -3033,7 +3070,7 @@ "gas_price_tolerance": { "description": "User-specified gas_price tolerance (minimum 1). This is interpreted to mean \"do not include this transaction in a block if the current gas price is greater than this number\"", "type": "integer", - "format": "uint64", + "format": "uint8", "minimum": 0.0 } }, @@ -3053,7 +3090,8 @@ "type": "object", "required": [ "paid_amount", - "receipt" + "receipt", + "strike_price" ], "properties": { "receipt": { @@ -3066,11 +3104,15 @@ }, "paid_amount": { "description": "Price paid in the past to reserve space in a future block.", - "allOf": [ - { - "$ref": "#/components/schemas/U512" - } - ] + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "strike_price": { + "description": "The gas price at the time of reservation.", + "type": "integer", + "format": "uint8", + "minimum": 0.0 } }, "additionalProperties": false @@ -3080,10 +3122,6 @@ } ] }, - "U512": { - "description": "Decimal representation of a 512-bit integer.", - "type": "string" - }, "InitiatorAddr": { "description": "The address of the initiator of a TransactionV1.", "oneOf": [ @@ -3244,10 +3282,10 @@ "description": "Hex-encoded entity address identifying the invocable entity.", "type": "object", "required": [ - "InvocableEntity" + "ByHash" ], "properties": { - "InvocableEntity": { + "ByHash": { "type": "string" } }, @@ -3257,10 +3295,10 @@ "description": "The alias identifying the invocable entity.", "type": "object", "required": [ - "InvocableEntityAlias" + "ByName" ], "properties": { - "InvocableEntityAlias": { + "ByName": { "type": "string" } }, @@ -3270,10 +3308,10 @@ "description": "The address and optional version identifying the package.", "type": "object", "required": [ - "Package" + "ByPackageHash" ], "properties": { - "Package": { + "ByPackageHash": { "type": "object", "required": [ "addr" @@ -3302,17 +3340,17 @@ "description": "The alias and optional version identifying the package.", "type": "object", "required": [ - "PackageAlias" + "ByPackageName" ], "properties": { - "PackageAlias": { + "ByPackageName": { "type": "object", "required": [ - "alias" + "name" ], "properties": { - "alias": { - "description": "The package alias.", + "name": { + "description": "The package name.", "type": "string" }, "version": { @@ -3586,7 +3624,7 @@ ] }, "transfers": { - "description": "A record of Transfers performed while executing the deploy.", + "description": "A record of version 1 Transfers performed while executing the deploy.", "type": "array", "items": { "$ref": "#/components/schemas/TransferAddr" @@ -3851,14 +3889,14 @@ "additionalProperties": false }, { - "description": "Writes the given Transfer to global state.", + "description": "Writes the given version 1 Transfer to global state.", "type": "object", "required": [ "WriteTransfer" ], "properties": { "WriteTransfer": { - "$ref": "#/components/schemas/Transfer" + "$ref": "#/components/schemas/TransferV1" } }, "additionalProperties": false @@ -4060,7 +4098,7 @@ ] }, "transfers": { - "description": "Transfers performed by the Deploy.", + "description": "Version 1 transfers performed by the Deploy.", "type": "array", "items": { "$ref": "#/components/schemas/TransferAddr" @@ -4094,13 +4132,17 @@ "additionalProperties": false }, "TransferAddr": { - "description": "Hex-encoded transfer address.", + "description": "Hex-encoded version 1 transfer address.", "type": "string" }, "URef": { "description": "Hex-encoded, formatted URef.", "type": "string" }, + "U512": { + "description": "Decimal representation of a 512-bit integer.", + "type": "string" + }, "EraInfo": { "description": "Auction metadata. Intended to be recorded at each era.", "type": "object", @@ -4203,8 +4245,8 @@ } ] }, - "Transfer": { - "description": "Represents a transfer from one purse to another", + "TransferV1": { + "description": "Represents a version 1 transfer from one purse to another.", "type": "object", "required": [ "amount", @@ -4704,103 +4746,221 @@ "additionalProperties": false }, "ExecutionResultV2": { - "description": "The result of executing a single deploy.", + "description": "The result of executing a single transaction.", + "type": "object", + "required": [ + "consumed", + "cost", + "effects", + "initiator", + "limit", + "payment", + "transfers" + ], + "properties": { + "initiator": { + "description": "Who initiated this transaction.", + "allOf": [ + { + "$ref": "#/components/schemas/InitiatorAddr" + } + ] + }, + "error_message": { + "description": "If there is no error message, this execution was processed successfully. If there is an error message, this execution failed to fully process for the stated reason.", + "type": [ + "string", + "null" + ] + }, + "limit": { + "description": "What was the maximum allowed gas limit for this transaction?.", + "allOf": [ + { + "$ref": "#/components/schemas/Gas" + } + ] + }, + "consumed": { + "description": "How much gas was consumed executing this transaction.", + "allOf": [ + { + "$ref": "#/components/schemas/Gas" + } + ] + }, + "cost": { + "description": "How much was paid for this transaction.", + "allOf": [ + { + "$ref": "#/components/schemas/U512" + } + ] + }, + "payment": { + "description": "Breakdown of payments made to cover the cost.", + "type": "array", + "items": { + "$ref": "#/components/schemas/PaymentInfo" + } + }, + "transfers": { + "description": "A record of transfers performed while executing this transaction.", + "type": "array", + "items": { + "$ref": "#/components/schemas/Transfer" + } + }, + "effects": { + "description": "The effects of executing this transaction.", + "allOf": [ + { + "$ref": "#/components/schemas/Effects" + } + ] + } + }, + "additionalProperties": false + }, + "Gas": { + "description": "The `Gas` struct represents a `U512` amount of gas.", + "allOf": [ + { + "$ref": "#/components/schemas/U512" + } + ] + }, + "PaymentInfo": { + "description": "Breakdown of payments made to cover the cost.", + "type": "object", + "required": [ + "source" + ], + "properties": { + "source": { + "description": "Source purse used for payment of the transaction.", + "allOf": [ + { + "$ref": "#/components/schemas/URef" + } + ] + } + } + }, + "Transfer": { + "description": "A versioned wrapper for a transfer.", "oneOf": [ { - "description": "The result of a failed execution.", + "description": "A version 1 transfer.", "type": "object", "required": [ - "Failure" + "Version1" ], "properties": { - "Failure": { - "type": "object", - "required": [ - "cost", - "effects", - "error_message", - "transfers" - ], - "properties": { - "effects": { - "description": "The effects of executing the deploy.", - "allOf": [ - { - "$ref": "#/components/schemas/Effects" - } - ] - }, - "transfers": { - "description": "A record of transfers performed while executing the deploy.", - "type": "array", - "items": { - "$ref": "#/components/schemas/TransferAddr" - } - }, - "cost": { - "description": "The cost in Motes of executing the deploy.", - "allOf": [ - { - "$ref": "#/components/schemas/U512" - } - ] - }, - "error_message": { - "description": "The error message associated with executing the deploy.", - "type": "string" - } - }, - "additionalProperties": false + "Version1": { + "$ref": "#/components/schemas/TransferV1" } }, "additionalProperties": false }, { - "description": "The result of a successful execution.", + "description": "A version 2 transfer.", "type": "object", "required": [ - "Success" + "Version2" ], "properties": { - "Success": { - "type": "object", - "required": [ - "cost", - "effects", - "transfers" - ], - "properties": { - "effects": { - "description": "The effects of executing the deploy.", - "allOf": [ - { - "$ref": "#/components/schemas/Effects" - } - ] - }, - "transfers": { - "description": "A record of transfers performed while executing the deploy.", - "type": "array", - "items": { - "$ref": "#/components/schemas/TransferAddr" - } - }, - "cost": { - "description": "The cost in Motes of executing the deploy.", - "allOf": [ - { - "$ref": "#/components/schemas/U512" - } - ] - } - }, - "additionalProperties": false + "Version2": { + "$ref": "#/components/schemas/TransferV2" } }, "additionalProperties": false } ] }, + "TransferV2": { + "description": "Represents a version 2 transfer from one purse to another.", + "type": "object", + "required": [ + "amount", + "from", + "gas", + "source", + "target", + "transaction_hash" + ], + "properties": { + "transaction_hash": { + "description": "Transaction that created the transfer.", + "allOf": [ + { + "$ref": "#/components/schemas/TransactionHash" + } + ] + }, + "from": { + "description": "Entity from which transfer was executed.", + "allOf": [ + { + "$ref": "#/components/schemas/InitiatorAddr" + } + ] + }, + "to": { + "description": "Account to which funds are transferred.", + "anyOf": [ + { + "$ref": "#/components/schemas/AccountHash" + }, + { + "type": "null" + } + ] + }, + "source": { + "description": "Source purse.", + "allOf": [ + { + "$ref": "#/components/schemas/URef" + } + ] + }, + "target": { + "description": "Target purse.", + "allOf": [ + { + "$ref": "#/components/schemas/URef" + } + ] + }, + "amount": { + "description": "Transfer amount.", + "allOf": [ + { + "$ref": "#/components/schemas/U512" + } + ] + }, + "gas": { + "description": "Gas.", + "allOf": [ + { + "$ref": "#/components/schemas/Gas" + } + ] + }, + "id": { + "description": "User-defined ID.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, "Effects": { "description": "A log of all transforms produced during execution.", "type": "array", @@ -4826,7 +4986,7 @@ "additionalProperties": false }, "TransformKindV2": { - "description": "Representation of a single transformation occurring during execution.\n\nNote that all arithmetic variants of [`TransformKind`] are commutative which means that a given collection of them can be executed in any order to produce the same end result.", + "description": "Representation of a single transformation occurring during execution.\n\nNote that all arithmetic variants of `TransformKindV2` are commutative which means that a given collection of them can be executed in any order to produce the same end result.", "oneOf": [ { "description": "An identity transformation that does not modify a value in the global state.\n\nCreated as a result of reading from the global state.", @@ -5026,14 +5186,14 @@ "additionalProperties": false }, { - "description": "A `Transfer`.", + "description": "A version 1 (legacy) transfer.", "type": "object", "required": [ - "Transfer" + "LegacyTransfer" ], "properties": { - "Transfer": { - "$ref": "#/components/schemas/Transfer" + "LegacyTransfer": { + "$ref": "#/components/schemas/TransferV1" } }, "additionalProperties": false @@ -5473,21 +5633,21 @@ "description": "Context of method execution\n\nMost significant bit represents version i.e. - 0b0 -> 0.x/1.x (session & contracts) - 0b1 -> 2.x and later (introduced installer, utility entry points)", "oneOf": [ { - "description": "Runs as session code (caller) Deprecated, retained to allow read back of legacy stored session.", + "description": "Runs using the calling entity's context. In v1.x this was used for both \"session\" code run using the originating Account's context, and also for \"StoredSession\" code that ran in the caller's context. While this made systemic sense due to the way the runtime context nesting works, this dual usage was very confusing to most human beings.\n\nIn v2.x the renamed Caller variant is exclusively used for wasm run using the initiating account entity's context. Previously installed 1.x stored session code should continue to work as the binary value matches but we no longer allow such logic to be upgraded, nor do we allow new stored session to be installed.", "type": "string", "enum": [ - "Session" + "Caller" ] }, { - "description": "Runs within called entity's context (called)", + "description": "Runs using the called entity's context.", "type": "string", "enum": [ - "AddressableEntity" + "Called" ] }, { - "description": "This entry point is intended to extract a subset of bytecode. Runs within called entity's context (called)", + "description": "Extract a subset of bytecode and installs it as a new smart contract. Runs using the called entity's context.", "type": "string", "enum": [ "Factory" diff --git a/rpc_sidecar/Cargo.toml b/rpc_sidecar/Cargo.toml index b2edfdae..ffd1e3ad 100644 --- a/rpc_sidecar/Cargo.toml +++ b/rpc_sidecar/Cargo.toml @@ -19,6 +19,7 @@ bincode = "1" bytes = "1.5.0" casper-json-rpc = { version = "1.0.0", path = "../json_rpc" } casper-types = { workspace = true, features = ["datasize", "json-schema", "std"] } +casper-binary-port = { git = "https://github.com/casper-network/casper-node.git", branch = "feat-2.0" } datasize = { workspace = true, features = ["detailed", "fake_clock-types"] } futures = { workspace = true } http = "0.2.1" @@ -44,6 +45,7 @@ warp = { version = "0.3.6", features = ["compression"] } [dev-dependencies] assert-json-diff = "2" casper-types = { workspace = true, features = ["datasize", "json-schema", "std", "testing"] } +casper-binary-port = { git = "https://github.com/casper-network/casper-node.git", branch = "feat-2.0", features = ["testing"] } pretty_assertions = "0.7.2" regex = "1" tempfile = "3" @@ -56,7 +58,7 @@ vergen = { version = "8.2.1", default-features = false, features = [ ] } [features] -testing = ["casper-types/testing"] +testing = ["casper-types/testing", "casper-binary-port/testing"] [package.metadata.deb] revision = "0" diff --git a/rpc_sidecar/src/node_client.rs b/rpc_sidecar/src/node_client.rs index f557592f..1279055b 100644 --- a/rpc_sidecar/src/node_client.rs +++ b/rpc_sidecar/src/node_client.rs @@ -1,18 +1,27 @@ use crate::{config::ExponentialBackoffConfig, NodeClientConfig, SUPPORTED_PROTOCOL_VERSION}; use anyhow::Error as AnyhowError; use async_trait::async_trait; +use metrics::rpc::{inc_disconnect, observe_reconnect_time}; +use serde::de::DeserializeOwned; +use std::{ + convert::{TryFrom, TryInto}, + future::Future, + net::SocketAddr, + sync::Arc, + time::Duration, +}; + +use casper_binary_port::{ + BinaryRequest, BinaryRequestHeader, BinaryResponse, BinaryResponseAndRequest, + ConsensusValidatorChanges, DictionaryItemIdentifier, DictionaryQueryResult, ErrorCode, + GetRequest, GetTrieFullResult, GlobalStateQueryResult, GlobalStateRequest, InformationRequest, + NodeStatus, PayloadEntity, RecordId, SpeculativeExecutionResult, TransactionWithExecutionInfo, +}; use casper_types::{ - binary_port::{ - BinaryRequest, BinaryRequestHeader, BinaryResponse, BinaryResponseAndRequest, - ConsensusValidatorChanges, DictionaryItemIdentifier, DictionaryQueryResult, - ErrorCode as BinaryPortError, GetRequest, GetTrieFullResult, GlobalStateQueryResult, - GlobalStateRequest, InformationRequest, NodeStatus, PayloadEntity, RecordId, - SpeculativeExecutionResult, TransactionWithExecutionInfo, - }, bytesrepr::{self, FromBytes, ToBytes}, AvailableBlockRange, BlockHash, BlockHeader, BlockIdentifier, ChainspecRawBytes, Digest, GlobalStateIdentifier, Key, KeyTag, Peers, ProtocolVersion, SignedBlock, StoredValue, - Timestamp, Transaction, TransactionHash, Transfer, + Transaction, TransactionHash, Transfer, }; use juliet::{ io::IoCoreBuilder, @@ -20,15 +29,9 @@ use juliet::{ rpc::{JulietRpcClient, JulietRpcServer, RpcBuilder}, ChannelConfiguration, ChannelId, }; -use metrics::rpc::{inc_disconnect, observe_reconnect_time}; -use serde::de::DeserializeOwned; use std::{ - convert::{TryFrom, TryInto}, fmt::{self, Display, Formatter}, - future::Future, - net::SocketAddr, - sync::Arc, - time::{Duration, Instant}, + time::Instant, }; use tokio::{ net::{ @@ -129,19 +132,9 @@ pub trait NodeClient: Send + Sync { async fn exec_speculatively( &self, - state_root_hash: Digest, - block_time: Timestamp, - protocol_version: ProtocolVersion, transaction: Transaction, - exec_at_block: BlockHeader, ) -> Result { - let request = BinaryRequest::TrySpeculativeExec { - transaction, - state_root_hash, - block_time, - protocol_version, - speculative_exec_at_block: exec_at_block, - }; + let request = BinaryRequest::TrySpeculativeExec { transaction }; let resp = self.send_request(request).await?; parse_response::(&resp.into())?.ok_or(Error::EmptyEnvelope) } @@ -259,15 +252,14 @@ pub enum Error { impl Error { fn from_error_code(code: u8) -> Self { - match BinaryPortError::try_from(code) { - Ok(BinaryPortError::FunctionDisabled) => Self::FunctionIsDisabled, - Ok(BinaryPortError::InvalidTransaction) => Self::InvalidTransaction, - Ok(BinaryPortError::RootNotFound) => Self::UnknownStateRootHash, - Ok(BinaryPortError::QueryFailedToExecute) => Self::QueryFailedToExecute, - Ok( - err @ (BinaryPortError::WasmPreprocessing - | BinaryPortError::InvalidDeployItemVariant), - ) => Self::SpecExecutionFailed(err.to_string()), + match ErrorCode::try_from(code) { + Ok(ErrorCode::FunctionDisabled) => Self::FunctionIsDisabled, + Ok(ErrorCode::InvalidTransaction) => Self::InvalidTransaction, + Ok(ErrorCode::RootNotFound) => Self::UnknownStateRootHash, + Ok(ErrorCode::FailedQuery) => Self::QueryFailedToExecute, + Ok(err @ (ErrorCode::WasmPreprocessing | ErrorCode::InvalidItemVariant)) => { + Self::SpecExecutionFailed(err.to_string()) + } Ok(err) => Self::UnexpectedNodeError { message: err.to_string(), code, diff --git a/rpc_sidecar/src/rpcs/account.rs b/rpc_sidecar/src/rpcs/account.rs index a5ccc7b3..79b851bd 100644 --- a/rpc_sidecar/src/rpcs/account.rs +++ b/rpc_sidecar/src/rpcs/account.rs @@ -151,13 +151,10 @@ impl RpcWithParams for PutTransaction { #[cfg(test)] mod tests { - use casper_types::{ - binary_port::{ - BinaryRequest, BinaryResponse, BinaryResponseAndRequest, - ErrorCode as BinaryPortErrorCode, - }, - testing::TestRng, + use casper_binary_port::{ + BinaryRequest, BinaryResponse, BinaryResponseAndRequest, ErrorCode as BinaryPortErrorCode, }; + use casper_types::testing::TestRng; use pretty_assertions::assert_eq; use crate::{rpcs::ErrorCode, SUPPORTED_PROTOCOL_VERSION}; diff --git a/rpc_sidecar/src/rpcs/chain.rs b/rpc_sidecar/src/rpcs/chain.rs index e3c66ae2..43aaa1f9 100644 --- a/rpc_sidecar/src/rpcs/chain.rs +++ b/rpc_sidecar/src/rpcs/chain.rs @@ -37,7 +37,7 @@ static GET_BLOCK_TRANSFERS_RESULT: Lazy = Lazy::new(|| GetBlockTransfersResult { api_version: DOCS_EXAMPLE_API_VERSION, block_hash: Some(*BlockHash::example()), - transfers: Some(vec![Transfer::default()]), + transfers: Some(vec![Transfer::example().clone()]), }); static GET_STATE_ROOT_HASH_PARAMS: Lazy = Lazy::new(|| GetStateRootHashParams { @@ -403,15 +403,13 @@ mod tests { use std::convert::TryFrom; use crate::{ClientError, SUPPORTED_PROTOCOL_VERSION}; + use casper_binary_port::{ + BinaryRequest, BinaryResponse, BinaryResponseAndRequest, GetRequest, + GlobalStateQueryResult, GlobalStateRequest, InformationRequestTag, RecordId, + }; use casper_types::{ - binary_port::{ - BinaryRequest, BinaryResponse, BinaryResponseAndRequest, GetRequest, - GlobalStateQueryResult, GlobalStateRequest, InformationRequestTag, RecordId, - }, - system::auction::EraInfo, - testing::TestRng, - Block, BlockSignaturesV1, BlockSignaturesV2, ChainNameDigest, DeployHash, SignedBlock, - TestBlockBuilder, TestBlockV1Builder, + system::auction::EraInfo, testing::TestRng, Block, BlockSignaturesV1, BlockSignaturesV2, + ChainNameDigest, SignedBlock, TestBlockBuilder, TestBlockV1Builder, }; use pretty_assertions::assert_eq; use rand::Rng; @@ -481,16 +479,7 @@ mod tests { let mut transfers = vec![]; for _ in 0..rng.gen_range(0..10) { - transfers.push(Transfer::new( - DeployHash::random(rng), - rng.gen(), - Some(rng.gen()), - rng.gen(), - rng.gen(), - rng.gen(), - rng.gen(), - Some(rng.gen()), - )); + transfers.push(Transfer::random(rng)); } let signatures = BlockSignaturesV2::new( *block.hash(), diff --git a/rpc_sidecar/src/rpcs/common.rs b/rpc_sidecar/src/rpcs/common.rs index b32bfbaa..b84c99d0 100644 --- a/rpc_sidecar/src/rpcs/common.rs +++ b/rpc_sidecar/src/rpcs/common.rs @@ -1,13 +1,14 @@ +use casper_binary_port::GlobalStateQueryResult; use once_cell::sync::Lazy; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::rpcs::error::Error; use casper_types::{ - account::AccountHash, addressable_entity::EntityKindTag, binary_port::GlobalStateQueryResult, - bytesrepr::ToBytes, global_state::TrieMerkleProof, Account, AddressableEntity, - AddressableEntityHash, AvailableBlockRange, BlockHeader, BlockIdentifier, - GlobalStateIdentifier, Key, SignedBlock, StoredValue, URef, U512, + account::AccountHash, addressable_entity::EntityKindTag, bytesrepr::ToBytes, + global_state::TrieMerkleProof, Account, AddressableEntity, AddressableEntityHash, + AvailableBlockRange, BlockHeader, BlockIdentifier, GlobalStateIdentifier, Key, SignedBlock, + StoredValue, URef, U512, }; use crate::NodeClient; diff --git a/rpc_sidecar/src/rpcs/info.rs b/rpc_sidecar/src/rpcs/info.rs index c238e94c..69cd95bd 100644 --- a/rpc_sidecar/src/rpcs/info.rs +++ b/rpc_sidecar/src/rpcs/info.rs @@ -3,12 +3,12 @@ use std::{collections::BTreeMap, str, sync::Arc}; use async_trait::async_trait; +use casper_binary_port::MinimalBlockInfo; use once_cell::sync::Lazy; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use casper_types::{ - binary_port::MinimalBlockInfo, execution::{ExecutionResult, ExecutionResultV2}, ActivationPoint, AvailableBlockRange, Block, BlockHash, BlockSynchronizerStatus, ChainspecRawBytes, Deploy, DeployHash, Digest, EraId, ExecutionInfo, NextUpgrade, Peers, @@ -526,11 +526,11 @@ mod tests { use std::convert::TryFrom; use crate::{rpcs::ErrorCode, ClientError, SUPPORTED_PROTOCOL_VERSION}; + use casper_binary_port::{ + BinaryRequest, BinaryResponse, BinaryResponseAndRequest, GetRequest, InformationRequest, + InformationRequestTag, TransactionWithExecutionInfo, + }; use casper_types::{ - binary_port::{ - BinaryRequest, BinaryResponse, BinaryResponseAndRequest, GetRequest, - InformationRequest, InformationRequestTag, TransactionWithExecutionInfo, - }, bytesrepr::{FromBytes, ToBytes}, testing::TestRng, BlockHash, TransactionV1, diff --git a/rpc_sidecar/src/rpcs/speculative_exec.rs b/rpc_sidecar/src/rpcs/speculative_exec.rs index a8311539..7df8935a 100644 --- a/rpc_sidecar/src/rpcs/speculative_exec.rs +++ b/rpc_sidecar/src/rpcs/speculative_exec.rs @@ -3,35 +3,28 @@ use std::{str, sync::Arc}; use async_trait::async_trait; +use casper_binary_port::SpeculativeExecutionResult; use once_cell::sync::Lazy; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use casper_types::{ - contract_messages::Messages, execution::ExecutionResultV2, BlockHash, BlockIdentifier, Deploy, - Transaction, -}; +use casper_types::{Deploy, Transaction}; use super::{ - common, docs::{DocExample, DOCS_EXAMPLE_API_VERSION}, ApiVersion, Error, NodeClient, RpcError, RpcWithParams, CURRENT_API_VERSION, }; static SPECULATIVE_EXEC_TXN_PARAMS: Lazy = Lazy::new(|| SpeculativeExecTxnParams { - block_identifier: Some(BlockIdentifier::Hash(*BlockHash::example())), transaction: Transaction::doc_example().clone(), }); static SPECULATIVE_EXEC_TXN_RESULT: Lazy = Lazy::new(|| SpeculativeExecTxnResult { api_version: DOCS_EXAMPLE_API_VERSION, - block_hash: *BlockHash::example(), - execution_result: ExecutionResultV2::example().clone(), - messages: Vec::new(), + execution_result: SpeculativeExecutionResult::example().clone(), }); static SPECULATIVE_EXEC_PARAMS: Lazy = Lazy::new(|| SpeculativeExecParams { - block_identifier: Some(BlockIdentifier::Hash(*BlockHash::example())), deploy: Deploy::doc_example().clone(), }); @@ -39,8 +32,6 @@ static SPECULATIVE_EXEC_PARAMS: Lazy = Lazy::new(|| Specu #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(deny_unknown_fields)] pub struct SpeculativeExecTxnParams { - /// Block hash on top of which to execute the transaction. - pub block_identifier: Option, /// Transaction to execute. pub transaction: Transaction, } @@ -58,12 +49,8 @@ pub struct SpeculativeExecTxnResult { /// The RPC API version. #[schemars(with = "String")] pub api_version: ApiVersion, - /// Hash of the block on top of which the transaction was executed. - pub block_hash: BlockHash, - /// Result of the execution. - pub execution_result: ExecutionResultV2, - /// Messages emitted during execution. - pub messages: Messages, + /// Result of the speculative execution. + pub execution_result: SpeculativeExecutionResult, } impl DocExample for SpeculativeExecTxnResult { @@ -85,7 +72,7 @@ impl RpcWithParams for SpeculativeExecTxn { node_client: Arc, params: Self::RequestParams, ) -> Result { - handle_request(node_client, params.block_identifier, params.transaction).await + handle_request(node_client, params.transaction).await } } @@ -93,8 +80,6 @@ impl RpcWithParams for SpeculativeExecTxn { #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(deny_unknown_fields)] pub struct SpeculativeExecParams { - /// Block hash on top of which to execute the deploy. - pub block_identifier: Option, /// Deploy to execute. pub deploy: Deploy, } @@ -118,39 +103,22 @@ impl RpcWithParams for SpeculativeExec { node_client: Arc, params: Self::RequestParams, ) -> Result { - handle_request(node_client, params.block_identifier, params.deploy.into()).await + handle_request(node_client, params.deploy.into()).await } } async fn handle_request( node_client: Arc, - identifier: Option, transaction: Transaction, ) -> Result { - let block_header = common::get_block_header(&*node_client, identifier).await?; - let block_hash = block_header.block_hash(); - let state_root_hash = *block_header.state_root_hash(); - let block_time = block_header.timestamp(); - let protocol_version = block_header.protocol_version(); - - let (execution_result, messages) = node_client - .exec_speculatively( - state_root_hash, - block_time, - protocol_version, - transaction, - block_header, - ) + let speculative_execution_result = node_client + .exec_speculatively(transaction) .await - .map_err(|err| Error::NodeRequest("speculatively executing a transaction", err))? - .into_inner() - .ok_or(Error::SpecExecReturnedNothing)?; + .map_err(|err| Error::NodeRequest("speculatively executing a transaction", err))?; Ok(SpeculativeExecTxnResult { api_version: CURRENT_API_VERSION, - block_hash, - execution_result, - messages, + execution_result: speculative_execution_result, }) } @@ -158,14 +126,11 @@ async fn handle_request( mod tests { use std::convert::TryFrom; - use casper_types::{ - binary_port::{ - BinaryRequest, BinaryResponse, BinaryResponseAndRequest, GetRequest, - InformationRequestTag, SpeculativeExecutionResult, - }, - testing::TestRng, - Block, TestBlockBuilder, + use casper_binary_port::{ + BinaryRequest, BinaryResponse, BinaryResponseAndRequest, GetRequest, InformationRequestTag, + SpeculativeExecutionResult, }; + use casper_types::testing::TestRng; use pretty_assertions::assert_eq; use crate::{ClientError, SUPPORTED_PROTOCOL_VERSION}; @@ -176,27 +141,20 @@ mod tests { async fn should_spec_exec() { let rng = &mut TestRng::new(); let deploy = Deploy::random(rng); - let block = Block::V2(TestBlockBuilder::new().build(rng)); - let execution_result = ExecutionResultV2::random(rng); + let execution_result = SpeculativeExecutionResult::random(rng); let res = SpeculativeExec::do_handle_request( Arc::new(ValidSpecExecMock { - block: block.clone(), execution_result: execution_result.clone(), }), - SpeculativeExecParams { - block_identifier: Some(BlockIdentifier::Hash(*block.hash())), - deploy, - }, + SpeculativeExecParams { deploy }, ) .await .expect("should handle request"); assert_eq!( res, SpeculativeExecTxnResult { - block_hash: *block.hash(), execution_result, - messages: Messages::new(), api_version: CURRENT_API_VERSION, } ) @@ -206,35 +164,27 @@ mod tests { async fn should_spec_exec_txn() { let rng = &mut TestRng::new(); let transaction = Transaction::random(rng); - let block = Block::V2(TestBlockBuilder::new().build(rng)); - let execution_result = ExecutionResultV2::random(rng); + let execution_result = SpeculativeExecutionResult::random(rng); let res = SpeculativeExecTxn::do_handle_request( Arc::new(ValidSpecExecMock { - block: block.clone(), execution_result: execution_result.clone(), }), - SpeculativeExecTxnParams { - block_identifier: Some(BlockIdentifier::Hash(*block.hash())), - transaction, - }, + SpeculativeExecTxnParams { transaction }, ) .await .expect("should handle request"); assert_eq!( res, SpeculativeExecTxnResult { - block_hash: *block.hash(), execution_result, - messages: Messages::new(), api_version: CURRENT_API_VERSION, } ) } struct ValidSpecExecMock { - block: Block, - execution_result: ExecutionResultV2, + execution_result: SpeculativeExecutionResult, } #[async_trait] @@ -250,7 +200,7 @@ mod tests { { Ok(BinaryResponseAndRequest::new( BinaryResponse::from_value( - self.block.clone_header(), + self.execution_result.clone(), SUPPORTED_PROTOCOL_VERSION, ), &[], @@ -258,10 +208,7 @@ mod tests { } BinaryRequest::TrySpeculativeExec { .. } => Ok(BinaryResponseAndRequest::new( BinaryResponse::from_value( - SpeculativeExecutionResult::new(Some(( - self.execution_result.clone(), - Messages::new(), - ))), + self.execution_result.clone(), SUPPORTED_PROTOCOL_VERSION, ), &[], diff --git a/rpc_sidecar/src/rpcs/state.rs b/rpc_sidecar/src/rpcs/state.rs index 087dfad2..b9796ac8 100644 --- a/rpc_sidecar/src/rpcs/state.rs +++ b/rpc_sidecar/src/rpcs/state.rs @@ -13,12 +13,12 @@ use super::{ ApiVersion, Error, NodeClient, RpcError, RpcWithOptionalParams, RpcWithParams, CURRENT_API_VERSION, }; +use casper_binary_port::DictionaryItemIdentifier; #[cfg(test)] use casper_types::testing::TestRng; use casper_types::{ account::{Account, AccountHash}, addressable_entity::EntityKindTag, - binary_port::DictionaryItemIdentifier, bytesrepr::Bytes, system::{ auction::{ @@ -1009,14 +1009,14 @@ mod tests { }; use crate::{rpcs::ErrorCode, ClientError, SUPPORTED_PROTOCOL_VERSION}; + use casper_binary_port::{ + BinaryRequest, BinaryResponse, BinaryResponseAndRequest, DictionaryQueryResult, GetRequest, + GlobalStateQueryResult, GlobalStateRequest, InformationRequestTag, + }; use casper_types::{ addressable_entity::{ ActionThresholds, AssociatedKeys, EntityKindTag, MessageTopics, NamedKeys, }, - binary_port::{ - BinaryRequest, BinaryResponse, BinaryResponseAndRequest, DictionaryQueryResult, - GetRequest, GlobalStateQueryResult, GlobalStateRequest, InformationRequestTag, - }, global_state::{TrieMerkleProof, TrieMerkleProofStep}, system::auction::{Bid, BidKind, ValidatorBid}, testing::TestRng, diff --git a/rpc_sidecar/src/testing/mod.rs b/rpc_sidecar/src/testing/mod.rs index e96b747c..d8c35b9f 100644 --- a/rpc_sidecar/src/testing/mod.rs +++ b/rpc_sidecar/src/testing/mod.rs @@ -1,11 +1,8 @@ use std::time::Duration; use bytes::{BufMut, BytesMut}; -use casper_types::{ - binary_port::{BinaryResponse, BinaryResponseAndRequest, GlobalStateQueryResult}, - bytesrepr::ToBytes, - CLValue, ProtocolVersion, StoredValue, -}; +use casper_binary_port::{BinaryResponse, BinaryResponseAndRequest, GlobalStateQueryResult}; +use casper_types::{bytesrepr::ToBytes, CLValue, ProtocolVersion, StoredValue}; use juliet::{ io::IoCoreBuilder, protocol::ProtocolBuilder, diff --git a/types/src/sse_data.rs b/types/src/sse_data.rs index cdf0b82a..906e812a 100644 --- a/types/src/sse_data.rs +++ b/types/src/sse_data.rs @@ -224,10 +224,8 @@ impl SseData { /// Returns a random `SseData::Step`. pub fn random_step(rng: &mut TestRng) -> Self { - let execution_effects = match ExecutionResultV2::random(rng) { - ExecutionResultV2::Success { effects, .. } - | ExecutionResultV2::Failure { effects, .. } => effects, - }; + let execution_effects = ExecutionResultV2::random(rng); + SseData::Step { era_id: EraId::new(rng.gen()), execution_effects: to_raw_value(&execution_effects).unwrap(),