diff --git a/Cargo.lock b/Cargo.lock index 54ddae43..3f6c8503 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,9 +68,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59febb24956a41c29bb5f450978fbe825bd6456b3f80586c8bd558dc882e7b6a" +checksum = "bbcc41e8a11a4975b18ec6afba2cc48d591fa63336a4c526dacb50479a8d6b35" dependencies = [ "alloy-consensus", "alloy-contract", @@ -107,9 +107,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88e1edea70787c33e11197d3f32ae380f3db19e6e061e539a5bcf8184a6b326" +checksum = "f4138dc275554afa6f18c4217262ac9388790b2fc393c2dfe03c51d357abf013" dependencies = [ "alloy-eips", "alloy-primitives", @@ -125,9 +125,9 @@ dependencies = [ [[package]] name = "alloy-consensus-any" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b1bb53f40c0273cd1975573cd457b39213e68584e36d1401d25fd0398a1d65" +checksum = "0fa04e1882c31288ce1028fdf31b6ea94cfa9eafa2e497f903ded631c8c6a42c" dependencies = [ "alloy-consensus", "alloy-eips", @@ -139,9 +139,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b668c78c4b1f12f474ede5a85e8ce550d0aa1ef7d49fd1d22855a43b960e725" +checksum = "5f21886c1fea0626f755a49b2ac653b396fb345233f6170db2da3d0ada31560c" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -155,7 +155,7 @@ dependencies = [ "alloy-transport", "futures", "futures-util", - "thiserror 2.0.3", + "thiserror 2.0.11", ] [[package]] @@ -202,9 +202,9 @@ dependencies = [ [[package]] name = "alloy-eip7702" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c986539255fb839d1533c128e190e557e52ff652c9ef62939e233a81dd93f7e" +checksum = "cabf647eb4650c91a9d38cb6f972bb320009e7e9d61765fb688a86f1563b33e8" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -215,9 +215,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9fadfe089e9ccc0650473f2d4ef0a28bc015bbca5631d9f0f09e49b557fdb3" +checksum = "52dd5869ed09e399003e0e0ec6903d981b2a92e74c5d37e6b40890bad2517526" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -233,10 +233,11 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2a4cf7b70f3495788e74ce1c765260ffe38820a2a774ff4aacb62e31ea73f9" +checksum = "e7d2a7fe5c1a9bd6793829ea21a636f30fc2b3f5d2e7418ba86d96e41dd1f460" dependencies = [ + "alloy-eips", "alloy-primitives", "alloy-serde", "alloy-trie", @@ -257,23 +258,23 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e29040b9d5fe2fb70415531882685b64f8efd08dfbd6cc907120650504821105" +checksum = "2008bedb8159a255b46b7c8614516eda06679ea82f620913679afbd8031fea72" dependencies = [ "alloy-primitives", "alloy-sol-types", "serde", "serde_json", - "thiserror 2.0.3", + "thiserror 2.0.11", "tracing", ] [[package]] name = "alloy-network" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510cc00b318db0dfccfdd2d032411cfae64fc144aef9679409e014145d3dacc4" +checksum = "4556f01fe41d0677495df10a648ddcf7ce118b0e8aa9642a0e2b6dd1fb7259de" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -291,14 +292,14 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 2.0.3", + "thiserror 2.0.11", ] [[package]] name = "alloy-network-primitives" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9081c099e798b8a2bba2145eb82a9a146f01fc7a35e9ab6e7b43305051f97550" +checksum = "f31c3c6b71340a1d076831823f09cb6e02de01de5c6630a9631bdb36f947ff80" dependencies = [ "alloy-consensus", "alloy-eips", @@ -337,9 +338,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc2dfaddd9a30aa870a78a4e1316e3e115ec1e12e552cbc881310456b85c1f24" +checksum = "5a22c4441b3ebe2d77fa9cf629ba68c3f713eb91779cff84275393db97eddd82" dependencies = [ "alloy-chains", "alloy-consensus", @@ -368,7 +369,7 @@ dependencies = [ "schnellru", "serde", "serde_json", - "thiserror 2.0.3", + "thiserror 2.0.11", "tokio", "tracing", "url", @@ -377,9 +378,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "695809e743628d54510c294ad17a4645bd9f465aeb0d20ee9ce9877c9712dc9c" +checksum = "2269fd635f7b505f27c63a3cb293148cd02301efce4c8bdd9ff54fbfc4a20e23" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -390,7 +391,7 @@ dependencies = [ "serde_json", "tokio", "tokio-stream", - "tower 0.5.1", + "tower 0.5.2", "tracing", ] @@ -418,9 +419,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "531137b283547d5b9a5cafc96b006c64ef76810c681d606f28be9781955293b6" +checksum = "d06a292b37e182e514903ede6e623b9de96420e8109ce300da288a96d88b7e4b" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -436,7 +437,7 @@ dependencies = [ "serde_json", "tokio", "tokio-stream", - "tower 0.5.1", + "tower 0.5.2", "tracing", "url", "wasmtimer", @@ -444,9 +445,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3410a472ce26c457e9780f708ee6bd540b30f88f1f31fdab7a11d00bd6aa1aee" +checksum = "9383845dd924939e7ab0298bbfe231505e20928907d7905aa3bf112287305e06" dependencies = [ "alloy-primitives", "alloy-rpc-types-engine", @@ -457,9 +458,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-any" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed98e1af55a7d856bfa385f30f63d8d56be2513593655c904a8f4a7ec963aa3e" +checksum = "ca445cef0eb6c2cf51cfb4e214fbf1ebd00893ae2e6f3b944c8101b07990f988" dependencies = [ "alloy-consensus-any", "alloy-rpc-types-eth", @@ -468,9 +469,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03bd16fa4959255ebf4a7702df08f325e5631df5cdca07c8a8e58bdc10fe02e3" +checksum = "4a5f821f30344862a0b6eb9a1c2eb91dfb2ff44c7489f37152a526cdcab79264" dependencies = [ "alloy-consensus", "alloy-eips", @@ -484,9 +485,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8737d7a6e37ca7bba9c23e9495c6534caec6760eb24abc9d5ffbaaba147818e1" +checksum = "0938bc615c02421bd86c1733ca7205cc3d99a122d9f9bff05726bd604b76a5c2" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -496,17 +497,17 @@ dependencies = [ "alloy-rlp", "alloy-serde", "alloy-sol-types", - "derive_more", "itertools 0.13.0", "serde", "serde_json", + "thiserror 2.0.11", ] [[package]] name = "alloy-serde" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5851bf8d5ad33014bd0c45153c603303e730acc8a209450a7ae6b4a12c2789e2" +checksum = "ae0465c71d4dced7525f408d84873aeebb71faf807d22d74c4a426430ccd9b55" dependencies = [ "alloy-primitives", "serde", @@ -515,9 +516,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e10ca565da6500cca015ba35ee424d59798f2e1b85bc0dd8f81dafd401f029a" +checksum = "9bfa395ad5cc952c82358d31e4c68b27bf4a89a5456d9b27e226e77dac50e4ff" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -526,14 +527,14 @@ dependencies = [ "auto_impl", "elliptic-curve", "k256", - "thiserror 2.0.3", + "thiserror 2.0.11", ] [[package]] name = "alloy-signer-aws" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e774d4203ad7dbeba06876c8528a169b7cb56770bd900bc061e6a2c2756a736" +checksum = "0eb06810c34427d499863817eb506acf57cb9ded9224b374116cae4e22dbd4e9" dependencies = [ "alloy-consensus", "alloy-network", @@ -543,15 +544,15 @@ dependencies = [ "aws-sdk-kms", "k256", "spki", - "thiserror 2.0.3", + "thiserror 2.0.11", "tracing", ] [[package]] name = "alloy-signer-gcp" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9843facd50077d2010ac0ef9e9176f8a06f2e2c8e653d83d82859803c623c6fc" +checksum = "d629e63fec8802ad53706d46e8eceeeae2b135c6648d0de41669a523bf17df4a" dependencies = [ "alloy-consensus", "alloy-network", @@ -561,15 +562,15 @@ dependencies = [ "gcloud-sdk", "k256", "spki", - "thiserror 2.0.3", + "thiserror 2.0.11", "tracing", ] [[package]] name = "alloy-signer-ledger" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08367716d2eee6f15f0f7ee2e855decbfedd12be12fe5f490a2d2717deda95bf" +checksum = "b426789566a19252cb46b757d91543a6f8e70330c72f312b86c5878595d092ef" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -581,15 +582,15 @@ dependencies = [ "coins-ledger", "futures-util", "semver 1.0.23", - "thiserror 2.0.3", + "thiserror 2.0.11", "tracing", ] [[package]] name = "alloy-signer-local" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47fababf5a745133490cde927d48e50267f97d3d1209b9fc9f1d1d666964d172" +checksum = "fbdc63ce9eda1283fcbaca66ba4a414b841c0e3edbeef9c86a71242fc9e84ccc" dependencies = [ "alloy-consensus", "alloy-network", @@ -600,7 +601,7 @@ dependencies = [ "coins-bip39", "k256", "rand", - "thiserror 2.0.3", + "thiserror 2.0.11", ] [[package]] @@ -678,9 +679,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "538a04a37221469cac0ce231b737fd174de2fdfcdd843bdd068cb39ed3e066ad" +checksum = "d17722a198f33bbd25337660787aea8b8f57814febb7c746bc30407bdfc39448" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -688,9 +689,9 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 2.0.3", + "thiserror 2.0.11", "tokio", - "tower 0.5.1", + "tower 0.5.2", "tracing", "url", "wasmtimer", @@ -698,24 +699,24 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ed40eb1e1265b2911512f6aa1dcece9702d078f5a646730c45e39e2be00ac1c" +checksum = "6e1509599021330a31c4a6816b655e34bf67acb1cc03c564e09fd8754ff6c5de" dependencies = [ "alloy-json-rpc", "alloy-transport", "reqwest 0.12.9", "serde_json", - "tower 0.5.1", + "tower 0.5.2", "tracing", "url", ] [[package]] name = "alloy-transport-ipc" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a172a59d24706b26a79a837f86d51745cb26ca6f8524712acd0208a14cff95" +checksum = "fa4da44bc9a5155ab599666d26decafcf12204b72a80eeaba7c5e234ee8ac205" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -732,9 +733,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.8.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fba0e39d181d13c266dbb8ca54ed584a2c66d6e9279afca89c7a6b1825e98abb" +checksum = "58011745b2f17b334db40df9077d75b181f78360a5bc5c35519e15d4bfce15e2" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -830,9 +831,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "anymap3" @@ -1445,7 +1446,7 @@ dependencies = [ "sync_wrapper 1.0.2", "tokio", "tokio-tungstenite", - "tower 0.5.1", + "tower 0.5.2", "tower-layer", "tower-service", "tracing", @@ -1489,7 +1490,7 @@ dependencies = [ "mime", "pin-project-lite", "serde", - "tower 0.5.1", + "tower 0.5.2", "tower-layer", "tower-service", ] @@ -2921,7 +2922,7 @@ dependencies = [ "serde_json", "tokio", "tonic", - "tower 0.5.1", + "tower 0.5.2", "tower-layer", "tower-util", "tracing", @@ -3349,7 +3350,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.8", "tokio", "tower-service", "tracing", @@ -3781,6 +3782,7 @@ dependencies = [ "serde_json", "sqlx", "tap_core", + "tap_graph", "test-assets", "thegraph-core", "thegraph-graphql-http", @@ -3789,7 +3791,7 @@ dependencies = [ "tokio-test", "tokio-util", "tonic", - "tower 0.5.1", + "tower 0.5.2", "tower-http", "tower-service", "tower-test", @@ -3833,6 +3835,7 @@ dependencies = [ "sqlx", "tap_aggregator", "tap_core", + "tap_graph", "tempfile", "test-assets", "test-log", @@ -4181,9 +4184,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.167" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libm" @@ -5235,7 +5238,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15" dependencies = [ "bytes", - "heck 0.4.1", + "heck 0.5.0", "itertools 0.13.0", "log", "multimap", @@ -5347,7 +5350,7 @@ dependencies = [ "rustc-hash", "rustls 0.23.19", "socket2 0.5.8", - "thiserror 2.0.3", + "thiserror 2.0.11", "tokio", "tracing", ] @@ -5366,7 +5369,7 @@ dependencies = [ "rustls 0.23.19", "rustls-pki-types", "slab", - "thiserror 2.0.3", + "thiserror 2.0.11", "tinyvec", "tracing", "web-time", @@ -6268,18 +6271,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.216" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.216" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", @@ -6993,8 +6996,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tap_aggregator" -version = "0.3.3" -source = "git+https://github.com/semiotic-ai/timeline-aggregation-protocol?rev=6af1add#6af1add4a326c77100491ba353050cb38f319631" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b452be9e6ab589ec37982decd29619385fa9d92e7da0e8bbcf4e1acc1fa4e3e2" dependencies = [ "alloy", "anyhow", @@ -7008,33 +7012,76 @@ dependencies = [ "prometheus", "prost", "rayon", - "ruint", "serde", "serde_json", "strum", "tap_core", + "tap_graph", "tokio", "tonic", "tonic-build", - "tower 0.4.13", + "tower 0.5.2", "tracing-subscriber", ] [[package]] name = "tap_core" -version = "2.0.0" -source = "git+https://github.com/semiotic-ai/timeline-aggregation-protocol?rev=6af1add#6af1add4a326c77100491ba353050cb38f319631" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b19dbe7a2fc8d7fb77d0a5ba62de024011962697635d7318b8d794fc5d600263" dependencies = [ "alloy", "anyhow", - "anymap3", "async-trait", "rand", "serde", - "thiserror 1.0.69", + "tap_eip712_message", + "tap_graph", + "tap_receipt", + "thiserror 2.0.11", "tokio", ] +[[package]] +name = "tap_eip712_message" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eec2bd0598536230f5da725915e984755f88f54c8b08c9de8d4b1697b0928fb" +dependencies = [ + "alloy", + "serde", + "thiserror 2.0.11", +] + +[[package]] +name = "tap_graph" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4584a4d91845f691bcd928a442808a6df7ca2d55614f671065d4511f33d604" +dependencies = [ + "alloy", + "rand", + "serde", + "tap_eip712_message", + "tap_receipt", + "thiserror 2.0.11", +] + +[[package]] +name = "tap_receipt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52f4b3fead95af86139e5857f1b5c674bab824848be4edafe4ddbc6b6db8e9a" +dependencies = [ + "alloy", + "anyhow", + "anymap3", + "async-trait", + "serde", + "tap_eip712_message", + "thiserror 2.0.11", +] + [[package]] name = "tempfile" version = "3.14.0" @@ -7056,6 +7103,7 @@ dependencies = [ "indexer-allocation", "lazy_static", "tap_core", + "tap_graph", "thegraph-core", "tokio", "typed-builder", @@ -7104,15 +7152,15 @@ dependencies = [ [[package]] name = "thegraph-core" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bcee8212008d3f49e00b4d052b6c3c7b422d8fd7c8c92efe9aa608762473293" +checksum = "31f1e8a2f6a297fa0d528764f86360f76006dd0460f4d1993b0f5211ebf14807" dependencies = [ "alloy", "bs58", "serde", "serde_with", - "thiserror 1.0.69", + "thiserror 2.0.11", ] [[package]] @@ -7139,11 +7187,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.3" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" dependencies = [ - "thiserror-impl 2.0.3", + "thiserror-impl 2.0.11", ] [[package]] @@ -7159,9 +7207,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.3" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", @@ -7254,9 +7302,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.1" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", @@ -7272,9 +7320,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", @@ -7472,14 +7520,14 @@ dependencies = [ [[package]] name = "tower" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" dependencies = [ "futures-core", "futures-util", "pin-project-lite", - "sync_wrapper 0.1.2", + "sync_wrapper 1.0.2", "tokio", "tower-layer", "tower-service", @@ -7553,8 +7601,8 @@ dependencies = [ "governor", "http 1.1.0", "pin-project 1.1.8", - "thiserror 2.0.3", - "tower 0.5.1", + "thiserror 2.0.11", + "tower 0.5.2", "tracing", ] diff --git a/Cargo.toml b/Cargo.toml index fa9784de..8b14c0e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,14 +52,15 @@ uuid = { version = "1.11.0", features = ["v7"] } tracing = { version = "0.1.40", default-features = false } bigdecimal = "0.4.3" build-info = "0.0.39" -tap_core = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", rev = "6af1add", default-features = false } -tap_aggregator = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", rev = "6af1add", default-features = false } +tap_core = { version = "3.0.0", default-features = false } +tap_aggregator = { version = "0.4.0", default-features = false } +tap_graph = { version = "0.1.0", default-features = false } tracing-subscriber = { version = "0.3", features = [ "json", "env-filter", "ansi", ], default-features = false } -thegraph-core = { version = "0.10.0", features = [ +thegraph-core = { version = "0.11.0", features = [ "attestation", "alloy-eip712", "alloy-sol-types", @@ -67,7 +68,7 @@ thegraph-core = { version = "0.10.0", features = [ "alloy-signers", "alloy-signer-local", "alloy-signer-mnemonic", - "serde" + "serde", ] } thegraph-graphql-http = { version = "0.3.2", features = ["reqwest"] } graphql_client = { version = "0.14.0", features = ["reqwest-rustls"] } diff --git a/crates/service/Cargo.toml b/crates/service/Cargo.toml index 31c73720..08e0fe4e 100644 --- a/crates/service/Cargo.toml +++ b/crates/service/Cargo.toml @@ -37,6 +37,7 @@ async-graphql-axum = "7.0.11" base64.workspace = true graphql = { git = "https://github.com/edgeandnode/toolshed", tag = "graphql-v0.3.0" } tap_core.workspace = true +tap_graph.workspace = true uuid.workspace = true typed-builder.workspace = true tower_governor = { version = "0.5.0", features = ["axum"] } diff --git a/crates/service/src/error.rs b/crates/service/src/error.rs index 86a13622..309f0636 100644 --- a/crates/service/src/error.rs +++ b/crates/service/src/error.rs @@ -29,6 +29,10 @@ pub enum IndexerServiceError { #[error("Issues with provided receipt: {0}")] TapCoreError(#[from] tap_core::Error), + + #[error("Issues with provided receipt: {0}")] + Eip712Error(#[from] tap_core::signed_message::Eip712Error), + #[error("There was an error while accessing escrow account: {0}")] EscrowAccount(#[from] EscrowAccountsError), } @@ -38,13 +42,13 @@ impl StatusCodeExt for IndexerServiceError { use IndexerServiceError as E; match &self { E::TapCoreError(ref error) => match error { - TapError::SignatureError(_) - | TapError::ReceiptError(ReceiptError::CheckFailure(_)) => StatusCode::BAD_REQUEST, + TapError::ReceiptError(ReceiptError::CheckFailure(_)) => StatusCode::BAD_REQUEST, _ => StatusCode::INTERNAL_SERVER_ERROR, }, E::EscrowAccount(_) | E::ReceiptNotFound => StatusCode::PAYMENT_REQUIRED, E::DeploymentIdNotFound => StatusCode::INTERNAL_SERVER_ERROR, E::AxumError(_) | E::SerializationError(_) => StatusCode::BAD_GATEWAY, + E::Eip712Error(_) => StatusCode::BAD_REQUEST, } } } diff --git a/crates/service/src/middleware/allocation.rs b/crates/service/src/middleware/allocation.rs index b6790a5d..dd71a369 100644 --- a/crates/service/src/middleware/allocation.rs +++ b/crates/service/src/middleware/allocation.rs @@ -8,7 +8,7 @@ use axum::{ middleware::Next, response::Response, }; -use tap_core::receipt::SignedReceipt; +use tap_graph::SignedReceipt; use thegraph_core::{alloy::primitives::Address, DeploymentId}; use tokio::sync::watch; diff --git a/crates/service/src/middleware/auth/tap.rs b/crates/service/src/middleware/auth/tap.rs index 68a58b7a..8976f064 100644 --- a/crates/service/src/middleware/auth/tap.rs +++ b/crates/service/src/middleware/auth/tap.rs @@ -18,8 +18,9 @@ use axum::{ }; use tap_core::{ manager::{adapters::ReceiptStore, Manager}, - receipt::{Context, SignedReceipt}, + receipt::Context, }; +use tap_graph::{ReceiptAggregateVoucher, SignedReceipt}; use tower_http::auth::AsyncAuthorizeRequest; use crate::{error::IndexerServiceError, middleware::prometheus_metrics::MetricLabels}; @@ -30,7 +31,7 @@ use crate::{error::IndexerServiceError, middleware::prometheus_metrics::MetricLa /// /// Requires SignedReceipt, MetricLabels and Arc extensions pub fn tap_receipt_authorize( - tap_manager: Arc>, + tap_manager: Arc>, failed_receipt_metric: &'static prometheus::CounterVec, ) -> impl AsyncAuthorizeRequest< B, @@ -40,7 +41,7 @@ pub fn tap_receipt_authorize( > + Clone + Send where - T: ReceiptStore + Sync + Send + 'static, + T: ReceiptStore + Sync + Send + 'static, B: Send, { move |request: Request| { @@ -88,12 +89,9 @@ mod tests { use sqlx::PgPool; use tap_core::{ manager::Manager, - receipt::{ - checks::{Check, CheckError, CheckList, CheckResult}, - state::Checking, - ReceiptWithState, - }, + receipt::checks::{Check, CheckError, CheckList, CheckResult}, }; + use tap_graph::SignedReceipt; use test_assets::{ assert_while_retry, create_signed_receipt, SignedReceiptRequest, TAP_EIP712_DOMAIN, }; @@ -105,7 +103,7 @@ mod tests { auth::tap_receipt_authorize, prometheus_metrics::{MetricLabelProvider, MetricLabels}, }, - tap::IndexerTapContext, + tap::{CheckingReceipt, IndexerTapContext}, }; #[fixture] @@ -133,11 +131,11 @@ mod tests { struct MyCheck; #[async_trait::async_trait] - impl Check for MyCheck { + impl Check for MyCheck { async fn check( &self, _: &tap_core::receipt::Context, - receipt: &ReceiptWithState, + receipt: &CheckingReceipt, ) -> CheckResult { if receipt.signed_receipt().message.nonce == FAILED_NONCE { Err(CheckError::Failed(anyhow::anyhow!("Failed"))) diff --git a/crates/service/src/middleware/sender.rs b/crates/service/src/middleware/sender.rs index ecfb48d0..d6ec7fe3 100644 --- a/crates/service/src/middleware/sender.rs +++ b/crates/service/src/middleware/sender.rs @@ -7,7 +7,7 @@ use axum::{ response::Response, }; use indexer_monitor::EscrowAccounts; -use tap_core::receipt::SignedReceipt; +use tap_graph::SignedReceipt; use thegraph_core::alloy::{primitives::Address, sol_types::Eip712Domain}; use tokio::sync::watch; diff --git a/crates/service/src/middleware/tap_receipt.rs b/crates/service/src/middleware/tap_receipt.rs index 3d068443..ab8ef959 100644 --- a/crates/service/src/middleware/tap_receipt.rs +++ b/crates/service/src/middleware/tap_receipt.rs @@ -33,7 +33,7 @@ mod tests { }; use axum_extra::headers::Header; use reqwest::StatusCode; - use tap_core::receipt::SignedReceipt; + use tap_graph::SignedReceipt; use test_assets::{create_signed_receipt, SignedReceiptRequest}; use tower::ServiceExt; diff --git a/crates/service/src/service/tap_receipt_header.rs b/crates/service/src/service/tap_receipt_header.rs index 814b2c93..053c6ffa 100644 --- a/crates/service/src/service/tap_receipt_header.rs +++ b/crates/service/src/service/tap_receipt_header.rs @@ -4,7 +4,7 @@ use axum_extra::headers::{self, Header, HeaderName, HeaderValue}; use lazy_static::lazy_static; use prometheus::{register_counter, Counter}; -use tap_core::receipt::SignedReceipt; +use tap_graph::SignedReceipt; #[derive(Debug, PartialEq)] pub struct TapReceipt(pub SignedReceipt); diff --git a/crates/service/src/tap.rs b/crates/service/src/tap.rs index e6ca2b48..9637a873 100644 --- a/crates/service/src/tap.rs +++ b/crates/service/src/tap.rs @@ -7,7 +7,8 @@ use indexer_allocation::Allocation; use indexer_monitor::EscrowAccounts; use receipt_store::{DatabaseReceipt, InnerContext}; use sqlx::PgPool; -use tap_core::receipt::checks::ReceiptCheck; +use tap_core::receipt::{checks::ReceiptCheck, state::Checking, ReceiptWithState}; +use tap_graph::SignedReceipt; use thegraph_core::alloy::{primitives::Address, sol_types::Eip712Domain}; use tokio::sync::{ mpsc::{self, Sender}, @@ -26,6 +27,8 @@ mod receipt_store; pub use checks::value_check::AgoraQuery; +pub type CheckingReceipt = ReceiptWithState; + const GRACE_PERIOD: u64 = 60; #[derive(Clone)] @@ -48,7 +51,7 @@ impl IndexerTapContext { escrow_accounts: Receiver, timestamp_error_tolerance: Duration, receipt_max_value: u128, - ) -> Vec { + ) -> Vec> { vec![ Arc::new(AllocationEligible::new(indexer_allocations)), Arc::new(SenderBalanceCheck::new(escrow_accounts)), diff --git a/crates/service/src/tap/checks/allocation_eligible.rs b/crates/service/src/tap/checks/allocation_eligible.rs index 94d8505a..ab243715 100644 --- a/crates/service/src/tap/checks/allocation_eligible.rs +++ b/crates/service/src/tap/checks/allocation_eligible.rs @@ -5,14 +5,13 @@ use std::collections::HashMap; use anyhow::anyhow; use indexer_allocation::Allocation; -use tap_core::receipt::{ - checks::{Check, CheckError, CheckResult}, - state::Checking, - ReceiptWithState, -}; +use tap_core::receipt::checks::{Check, CheckError, CheckResult}; +use tap_graph::SignedReceipt; use thegraph_core::alloy::primitives::Address; use tokio::sync::watch::Receiver; +use crate::tap::CheckingReceipt; + pub struct AllocationEligible { indexer_allocations: Receiver>, } @@ -25,11 +24,11 @@ impl AllocationEligible { } } #[async_trait::async_trait] -impl Check for AllocationEligible { +impl Check for AllocationEligible { async fn check( &self, _: &tap_core::receipt::Context, - receipt: &ReceiptWithState, + receipt: &CheckingReceipt, ) -> CheckResult { let allocation_id = receipt.signed_receipt().message.allocation_id; if !self diff --git a/crates/service/src/tap/checks/deny_list_check.rs b/crates/service/src/tap/checks/deny_list_check.rs index 7a0d716f..3821c246 100644 --- a/crates/service/src/tap/checks/deny_list_check.rs +++ b/crates/service/src/tap/checks/deny_list_check.rs @@ -8,14 +8,11 @@ use std::{ }; use sqlx::{postgres::PgListener, PgPool}; -use tap_core::receipt::{ - checks::{Check, CheckError, CheckResult}, - state::Checking, - ReceiptWithState, -}; +use tap_core::receipt::checks::{Check, CheckError, CheckResult}; +use tap_graph::SignedReceipt; use thegraph_core::alloy::primitives::Address; -use crate::middleware::Sender; +use crate::{middleware::Sender, tap::CheckingReceipt}; pub struct DenyListCheck { sender_denylist: Arc>>, @@ -153,12 +150,8 @@ impl DenyListCheck { } #[async_trait::async_trait] -impl Check for DenyListCheck { - async fn check( - &self, - ctx: &tap_core::receipt::Context, - _: &ReceiptWithState, - ) -> CheckResult { +impl Check for DenyListCheck { + async fn check(&self, ctx: &tap_core::receipt::Context, _: &CheckingReceipt) -> CheckResult { let Sender(receipt_sender) = ctx .get::() .ok_or(CheckError::Failed(anyhow::anyhow!("Could not find sender")))?; @@ -191,7 +184,7 @@ impl Drop for DenyListCheck { #[cfg(test)] mod tests { use sqlx::PgPool; - use tap_core::receipt::{checks::Check, Context, ReceiptWithState}; + use tap_core::receipt::{checks::Check, Context}; use test_assets::{self, create_signed_receipt, SignedReceiptRequest, TAP_SENDER}; use thegraph_core::alloy::hex::ToHexExt; @@ -220,7 +213,7 @@ mod tests { let deny_list_check = new_deny_list_check(pgpool.clone()).await; - let checking_receipt = ReceiptWithState::new(signed_receipt); + let checking_receipt = CheckingReceipt::new(signed_receipt); let mut ctx = Context::new(); ctx.insert(Sender(TAP_SENDER.1)); @@ -239,7 +232,7 @@ mod tests { let deny_list_check = new_deny_list_check(pgpool.clone()).await; // Check that the receipt is valid - let checking_receipt = ReceiptWithState::new(signed_receipt); + let checking_receipt = CheckingReceipt::new(signed_receipt); let mut ctx = Context::new(); ctx.insert(Sender(TAP_SENDER.1)); diff --git a/crates/service/src/tap/checks/receipt_max_val_check.rs b/crates/service/src/tap/checks/receipt_max_val_check.rs index e4dbcbd4..a2a1655c 100644 --- a/crates/service/src/tap/checks/receipt_max_val_check.rs +++ b/crates/service/src/tap/checks/receipt_max_val_check.rs @@ -6,11 +6,10 @@ pub struct ReceiptMaxValueCheck { receipt_max_value: u128, } -use tap_core::receipt::{ - checks::{Check, CheckError, CheckResult}, - state::Checking, - ReceiptWithState, -}; +use tap_core::receipt::checks::{Check, CheckError, CheckResult}; +use tap_graph::SignedReceipt; + +use crate::tap::CheckingReceipt; impl ReceiptMaxValueCheck { pub fn new(receipt_max_value: u128) -> Self { @@ -19,11 +18,11 @@ impl ReceiptMaxValueCheck { } #[async_trait::async_trait] -impl Check for ReceiptMaxValueCheck { +impl Check for ReceiptMaxValueCheck { async fn check( &self, _: &tap_core::receipt::Context, - receipt: &ReceiptWithState, + receipt: &CheckingReceipt, ) -> CheckResult { let receipt_value = receipt.signed_receipt().message.value; @@ -42,19 +41,20 @@ mod tests { use std::time::{Duration, SystemTime}; use tap_core::{ - receipt::{checks::Check, state::Checking, Context, Receipt, ReceiptWithState}, - signed_message::EIP712SignedMessage, + receipt::{checks::Check, Context}, + signed_message::Eip712SignedMessage, tap_eip712_domain, }; + use tap_graph::Receipt; use thegraph_core::alloy::{ primitives::{address, Address}, signers::local::{coins_bip39::English, MnemonicBuilder, PrivateKeySigner}, }; use super::*; - use crate::tap::Eip712Domain; + use crate::tap::{CheckingReceipt, Eip712Domain}; - fn create_signed_receipt_with_custom_value(value: u128) -> ReceiptWithState { + fn create_signed_receipt_with_custom_value(value: u128) -> CheckingReceipt { let index: u32 = 0; let wallet: PrivateKeySigner = MnemonicBuilder::::default() .phrase("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about") @@ -75,7 +75,7 @@ mod tests { let value: u128 = value; let nonce: u64 = 10; - let receipt = EIP712SignedMessage::new( + let receipt = Eip712SignedMessage::new( &eip712_domain_separator, Receipt { allocation_id: address!("abababababababababababababababababababab"), @@ -86,7 +86,7 @@ mod tests { &wallet, ) .unwrap(); - ReceiptWithState::::new(receipt) + CheckingReceipt::new(receipt) } const RECEIPT_LIMIT: u128 = 10; diff --git a/crates/service/src/tap/checks/sender_balance_check.rs b/crates/service/src/tap/checks/sender_balance_check.rs index a7f1708f..c127e431 100644 --- a/crates/service/src/tap/checks/sender_balance_check.rs +++ b/crates/service/src/tap/checks/sender_balance_check.rs @@ -3,15 +3,12 @@ use anyhow::anyhow; use indexer_monitor::EscrowAccounts; -use tap_core::receipt::{ - checks::{Check, CheckError, CheckResult}, - state::Checking, - ReceiptWithState, -}; +use tap_core::receipt::checks::{Check, CheckError, CheckResult}; +use tap_graph::SignedReceipt; use thegraph_core::alloy::primitives::U256; use tokio::sync::watch::Receiver; -use crate::middleware::Sender; +use crate::{middleware::Sender, tap::CheckingReceipt}; pub struct SenderBalanceCheck { escrow_accounts: Receiver, @@ -24,12 +21,8 @@ impl SenderBalanceCheck { } #[async_trait::async_trait] -impl Check for SenderBalanceCheck { - async fn check( - &self, - ctx: &tap_core::receipt::Context, - _: &ReceiptWithState, - ) -> CheckResult { +impl Check for SenderBalanceCheck { + async fn check(&self, ctx: &tap_core::receipt::Context, _: &CheckingReceipt) -> CheckResult { let escrow_accounts_snapshot = self.escrow_accounts.borrow(); let Sender(receipt_sender) = ctx diff --git a/crates/service/src/tap/checks/timestamp_check.rs b/crates/service/src/tap/checks/timestamp_check.rs index fde2fb82..05e29905 100644 --- a/crates/service/src/tap/checks/timestamp_check.rs +++ b/crates/service/src/tap/checks/timestamp_check.rs @@ -8,11 +8,10 @@ pub struct TimestampCheck { timestamp_error_tolerance: Duration, } -use tap_core::receipt::{ - checks::{Check, CheckError, CheckResult}, - state::Checking, - ReceiptWithState, -}; +use tap_core::receipt::checks::{Check, CheckError, CheckResult}; +use tap_graph::SignedReceipt; + +use crate::tap::CheckingReceipt; impl TimestampCheck { pub fn new(timestamp_error_tolerance: Duration) -> Self { @@ -23,11 +22,11 @@ impl TimestampCheck { } #[async_trait::async_trait] -impl Check for TimestampCheck { +impl Check for TimestampCheck { async fn check( &self, _: &tap_core::receipt::Context, - receipt: &ReceiptWithState, + receipt: &CheckingReceipt, ) -> CheckResult { let timestamp_now = SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH) @@ -52,21 +51,20 @@ mod tests { use std::time::{Duration, SystemTime}; use tap_core::{ - receipt::{checks::Check, state::Checking, Context, Receipt, ReceiptWithState}, - signed_message::EIP712SignedMessage, + receipt::{checks::Check, Context}, + signed_message::Eip712SignedMessage, tap_eip712_domain, }; + use tap_graph::Receipt; use thegraph_core::alloy::{ primitives::{address, Address}, signers::local::{coins_bip39::English, MnemonicBuilder, PrivateKeySigner}, }; use super::TimestampCheck; - use crate::tap::Eip712Domain; + use crate::tap::{CheckingReceipt, Eip712Domain}; - fn create_signed_receipt_with_custom_timestamp( - timestamp_ns: u64, - ) -> ReceiptWithState { + fn create_signed_receipt_with_custom_timestamp(timestamp_ns: u64) -> CheckingReceipt { let index: u32 = 0; let wallet: PrivateKeySigner = MnemonicBuilder::::default() .phrase("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about") @@ -78,7 +76,7 @@ mod tests { tap_eip712_domain(1, Address::from([0x11u8; 20])); let value: u128 = 1234; let nonce: u64 = 10; - let receipt = EIP712SignedMessage::new( + let receipt = Eip712SignedMessage::new( &eip712_domain_separator, Receipt { allocation_id: address!("abababababababababababababababababababab"), @@ -89,7 +87,7 @@ mod tests { &wallet, ) .unwrap(); - ReceiptWithState::::new(receipt) + CheckingReceipt::new(receipt) } #[tokio::test] diff --git a/crates/service/src/tap/checks/value_check.rs b/crates/service/src/tap/checks/value_check.rs index 0caf3785..a0a68f4f 100644 --- a/crates/service/src/tap/checks/value_check.rs +++ b/crates/service/src/tap/checks/value_check.rs @@ -17,12 +17,12 @@ use sqlx::{ }; use tap_core::receipt::{ checks::{Check, CheckError, CheckResult}, - state::Checking, - Context, ReceiptWithState, + Context, }; +use tap_graph::SignedReceipt; use thegraph_core::DeploymentId; -use crate::database::cost_model; +use crate::{database::cost_model, tap::CheckingReceipt}; // we only accept receipts with minimal 1 wei grt const MINIMAL_VALUE: u128 = 1; @@ -303,8 +303,8 @@ impl MinimumValue { } #[async_trait::async_trait] -impl Check for MinimumValue { - async fn check(&self, ctx: &Context, receipt: &ReceiptWithState) -> CheckResult { +impl Check for MinimumValue { + async fn check(&self, ctx: &Context, receipt: &CheckingReceipt) -> CheckResult { let agora_query = ctx .get() .ok_or(CheckError::Failed(anyhow!("Could not find agora query")))?; @@ -365,13 +365,14 @@ mod tests { use std::time::Duration; use sqlx::PgPool; - use tap_core::receipt::{checks::Check, Context, ReceiptWithState}; + use tap_core::receipt::{checks::Check, Context}; use test_assets::{create_signed_receipt, flush_messages, SignedReceiptRequest}; use tokio::time::sleep; use super::{AgoraQuery, MinimumValue}; - use crate::database::cost_model::test::{ - self, add_cost_models, global_cost_model, to_db_models, + use crate::{ + database::cost_model::test::{self, add_cost_models, global_cost_model, to_db_models}, + tap::CheckingReceipt, }; #[sqlx::test(migrations = "../../migrations")] @@ -491,7 +492,7 @@ mod tests { let signed_receipt = create_signed_receipt(SignedReceiptRequest::builder().value(0).build()).await; - let receipt = ReceiptWithState::new(signed_receipt); + let receipt = CheckingReceipt::new(signed_receipt); assert!( check.check(&ctx, &receipt).await.is_err(), @@ -500,7 +501,7 @@ mod tests { let signed_receipt = create_signed_receipt(SignedReceiptRequest::builder().value(1).build()).await; - let receipt = ReceiptWithState::new(signed_receipt); + let receipt = CheckingReceipt::new(signed_receipt); assert!( check.check(&ctx, &receipt).await.is_ok(), "Should accept if value is more than 0 for any query" @@ -522,7 +523,7 @@ mod tests { ) .await; - let receipt = ReceiptWithState::new(signed_receipt); + let receipt = CheckingReceipt::new(signed_receipt); assert!( check.check(&ctx, &receipt).await.is_ok(), @@ -540,7 +541,7 @@ mod tests { create_signed_receipt(SignedReceiptRequest::builder().value(minimal_value).build()) .await; - let receipt = ReceiptWithState::new(signed_receipt); + let receipt = CheckingReceipt::new(signed_receipt); check .check(&ctx, &receipt) .await @@ -553,7 +554,7 @@ mod tests { ) .await; - let receipt = ReceiptWithState::new(signed_receipt); + let receipt = CheckingReceipt::new(signed_receipt); check .check(&ctx, &receipt) .await @@ -588,7 +589,7 @@ mod tests { ) .await; - let receipt = ReceiptWithState::new(signed_receipt); + let receipt = CheckingReceipt::new(signed_receipt); assert!( check.check(&ctx, &receipt).await.is_err(), @@ -601,7 +602,7 @@ mod tests { .build(), ) .await; - let receipt = ReceiptWithState::new(signed_receipt); + let receipt = CheckingReceipt::new(signed_receipt); check .check(&ctx, &receipt) .await @@ -613,7 +614,7 @@ mod tests { .build(), ) .await; - let receipt = ReceiptWithState::new(signed_receipt); + let receipt = CheckingReceipt::new(signed_receipt); check .check(&ctx, &receipt) .await diff --git a/crates/service/src/tap/receipt_store.rs b/crates/service/src/tap/receipt_store.rs index 2d284197..d33cd0ca 100644 --- a/crates/service/src/tap/receipt_store.rs +++ b/crates/service/src/tap/receipt_store.rs @@ -4,15 +4,13 @@ use anyhow::anyhow; use bigdecimal::num_bigint::BigInt; use sqlx::{types::BigDecimal, PgPool}; -use tap_core::{ - manager::adapters::ReceiptStore, - receipt::{state::Checking, ReceiptWithState}, -}; +use tap_core::manager::adapters::ReceiptStore; +use tap_graph::SignedReceipt; use thegraph_core::alloy::{hex::ToHexExt, sol_types::Eip712Domain}; use tokio::{sync::mpsc::Receiver, task::JoinHandle}; use tokio_util::sync::CancellationToken; -use super::{AdapterError, IndexerTapContext}; +use super::{AdapterError, CheckingReceipt, IndexerTapContext}; #[derive(Clone)] pub struct InnerContext { @@ -96,13 +94,10 @@ impl IndexerTapContext { } #[async_trait::async_trait] -impl ReceiptStore for IndexerTapContext { +impl ReceiptStore for IndexerTapContext { type AdapterError = AdapterError; - async fn store_receipt( - &self, - receipt: ReceiptWithState, - ) -> Result { + async fn store_receipt(&self, receipt: CheckingReceipt) -> Result { let db_receipt = DatabaseReceipt::from_receipt(receipt, &self.domain_separator)?; self.receipt_producer.send(db_receipt).await.map_err(|e| { tracing::error!("Failed to queue receipt for storage: {}", e); @@ -124,10 +119,7 @@ pub struct DatabaseReceipt { } impl DatabaseReceipt { - fn from_receipt( - receipt: ReceiptWithState, - separator: &Eip712Domain, - ) -> anyhow::Result { + fn from_receipt(receipt: CheckingReceipt, separator: &Eip712Domain) -> anyhow::Result { let receipt = receipt.signed_receipt(); let allocation_id = receipt.message.allocation_id.encode_hex(); let signature = receipt.signature.as_bytes().to_vec(); diff --git a/crates/tap-agent/Cargo.toml b/crates/tap-agent/Cargo.toml index 387968e8..3649159f 100644 --- a/crates/tap-agent/Cargo.toml +++ b/crates/tap-agent/Cargo.toml @@ -29,6 +29,7 @@ tracing.workspace = true prometheus.workspace = true axum.workspace = true tap_core.workspace = true +tap_graph.workspace = true tokio = { workspace = true, features = ["rt-multi-thread"] } lazy_static.workspace = true thegraph-core.workspace = true diff --git a/crates/tap-agent/src/agent/sender_account.rs b/crates/tap-agent/src/agent/sender_account.rs index de0f53d0..33436b37 100644 --- a/crates/tap-agent/src/agent/sender_account.rs +++ b/crates/tap-agent/src/agent/sender_account.rs @@ -22,7 +22,7 @@ use ractor::{Actor, ActorProcessingErr, ActorRef, MessagingErr, SupervisionEvent use reqwest::Url; use sqlx::PgPool; use tap_aggregator::grpc::tap_aggregator_client::TapAggregatorClient; -use tap_core::rav::SignedRAV; +use tap_graph::SignedRav; use thegraph_core::alloy::{ hex::ToHexExt, primitives::{Address, U256}, @@ -98,7 +98,7 @@ type Balance = U256; pub enum ReceiptFees { NewReceipt(u128, u64), UpdateValue(UnaggregatedReceipts), - RavRequestResponse((UnaggregatedReceipts, anyhow::Result>)), + RavRequestResponse((UnaggregatedReceipts, anyhow::Result>)), Retry, } @@ -109,7 +109,7 @@ pub enum SenderAccountMessage { NewAllocationId(Address), UpdateReceiptFees(Address, ReceiptFees), UpdateInvalidReceiptFees(Address, UnaggregatedReceipts), - UpdateRav(SignedRAV), + UpdateRav(SignedRav), #[cfg(test)] GetSenderFeeTracker(ractor::RpcReplyPort), #[cfg(test)] @@ -281,7 +281,7 @@ impl State { }; allocation - .cast(SenderAllocationMessage::TriggerRAVRequest) + .cast(SenderAllocationMessage::TriggerRavRequest) .map_err(|e| { anyhow::anyhow!( "Error while sending and waiting message for actor {allocation_id}. Error: {e}" @@ -296,7 +296,7 @@ impl State { fn finalize_rav_request( &mut self, allocation_id: Address, - rav_response: (UnaggregatedReceipts, anyhow::Result>), + rav_response: (UnaggregatedReceipts, anyhow::Result>), ) { self.sender_fee_tracker.finish_rav_request(allocation_id); let (fees, rav_result) = rav_response; diff --git a/crates/tap-agent/src/agent/sender_allocation.rs b/crates/tap-agent/src/agent/sender_allocation.rs index 2f948809..bc4b6647 100644 --- a/crates/tap-agent/src/agent/sender_allocation.rs +++ b/crates/tap-agent/src/agent/sender_allocation.rs @@ -12,17 +12,21 @@ use indexer_monitor::{EscrowAccounts, SubgraphClient}; use prometheus::{register_counter_vec, register_histogram_vec, CounterVec, HistogramVec}; use ractor::{Actor, ActorProcessingErr, ActorRef}; use sqlx::{types::BigDecimal, PgPool}; -use tap_aggregator::grpc::{tap_aggregator_client::TapAggregatorClient, RavRequest}; +use tap_aggregator::grpc::{ + tap_aggregator_client::TapAggregatorClient, RavRequest as AggregatorRequest, +}; use tap_core::{ - manager::adapters::RAVRead, - rav::{RAVRequest, ReceiptAggregateVoucher, SignedRAV}, + manager::adapters::RavRead, + rav_request::RavRequest, receipt::{ checks::{Check, CheckList}, + rav::AggregationError, state::Failed, Context, ReceiptWithState, }, - signed_message::EIP712SignedMessage, + signed_message::Eip712SignedMessage, }; +use tap_graph::{ReceiptAggregateVoucher, SignedRav, SignedReceipt}; use thegraph_core::alloy::{hex::ToHexExt, primitives::Address, sol_types::Eip712Domain}; use thiserror::Error; use tokio::sync::watch::Receiver; @@ -80,6 +84,9 @@ pub enum RavError { #[error(transparent)] TapCore(#[from] tap_core::Error), + #[error(transparent)] + AggregationError(#[from] AggregationError), + #[error(transparent)] Grpc(#[from] tonic::Status), @@ -90,7 +97,8 @@ pub enum RavError { Other(#[from] anyhow::Error), } -type TapManager = tap_core::manager::Manager; +type TapManager = + tap_core::manager::Manager; /// Manages unaggregated fees and the TAP lifecyle for a specific (allocation, sender) pair. pub struct SenderAllocation; @@ -98,7 +106,7 @@ pub struct SenderAllocation; pub struct SenderAllocationState { unaggregated_fees: UnaggregatedReceipts, invalid_receipts_fees: UnaggregatedReceipts, - latest_rav: Option, + latest_rav: Option, pgpool: PgPool, tap_manager: TapManager, allocation_id: Address, @@ -148,7 +156,7 @@ pub struct SenderAllocationArgs { #[derive(Debug)] pub enum SenderAllocationMessage { NewReceipt(NewReceiptNotification), - TriggerRAVRequest, + TriggerRavRequest, #[cfg(any(test, feature = "test"))] GetUnaggregatedReceipts(ractor::RpcReplyPort), } @@ -305,7 +313,7 @@ impl Actor for SenderAllocation { ReceiptFees::NewReceipt(fees, timestamp_ns), ))?; } - SenderAllocationMessage::TriggerRAVRequest => { + SenderAllocationMessage::TriggerRavRequest => { let rav_result = if state.unaggregated_fees.value > 0 { state.request_rav().await.map(|_| state.latest_rav.clone()) } else { @@ -345,7 +353,7 @@ impl SenderAllocationState { config, }: SenderAllocationArgs, ) -> anyhow::Result { - let required_checks: Vec> = vec![ + let required_checks: Vec + Send + Sync>> = vec![ Arc::new( AllocationId::new( config.indexer_address, @@ -524,9 +532,9 @@ impl SenderAllocationState { /// Request a RAV from the sender's TAP aggregator. Only one RAV request will be running at a /// time through the use of an internal guard. - async fn rav_requester_single(&mut self) -> Result { + async fn rav_requester_single(&mut self) -> Result { tracing::trace!("rav_requester_single()"); - let RAVRequest { + let RavRequest { valid_receipts, previous_rav, invalid_receipts, @@ -545,7 +553,7 @@ impl SenderAllocationState { invalid_receipts.is_empty(), ) { // All receipts are invalid - (Err(tap_core::Error::NoValidReceiptsForRAVRequest), true, false) => { + (Err(AggregationError::NoValidReceiptsForRavRequest), true, false) => { tracing::warn!( "Found {} invalid receipts for allocation {} and sender {}.", invalid_receipts.len(), @@ -589,7 +597,7 @@ impl SenderAllocationState { .map(|r| r.signed_receipt().clone()) .collect(); - let rav_request = RavRequest::new(valid_receipts, previous_rav); + let rav_request = AggregatorRequest::new(valid_receipts, previous_rav); let rav_response_time_start = Instant::now(); @@ -645,7 +653,7 @@ impl SenderAllocationState { // The 3 errors below signal an invalid RAV, which should be about problems with the // sender. The sender could be malicious. Err( - e @ tap_core::Error::InvalidReceivedRAV { + e @ tap_core::Error::InvalidReceivedRav { expected_rav: _, received_rav: _, } @@ -673,7 +681,7 @@ impl SenderAllocationState { } Ok(signed_rav) } - (Err(tap_core::Error::NoValidReceiptsForRAVRequest), true, true) => Err(anyhow!( + (Err(AggregationError::NoValidReceiptsForRavRequest), true, true) => Err(anyhow!( "It looks like there are no valid receipts for the RAV request.\ This may happen if your `rav_request_trigger_value` is too low \ and no receipts were found outside the `rav_request_timestamp_buffer_ms`.\ @@ -723,7 +731,7 @@ impl SenderAllocationState { async fn store_invalid_receipts( &mut self, - receipts: &[ReceiptWithState], + receipts: &[ReceiptWithState], ) -> anyhow::Result<()> { let reciepts_len = receipts.len(); let mut reciepts_signers = Vec::with_capacity(reciepts_len); @@ -826,7 +834,7 @@ impl SenderAllocationState { async fn store_failed_rav( &self, expected_rav: &ReceiptAggregateVoucher, - rav: &EIP712SignedMessage, + rav: &Eip712SignedMessage, reason: &str, ) -> anyhow::Result<()> { sqlx::query!( @@ -873,9 +881,9 @@ pub mod tests { use tap_aggregator::grpc::{tap_aggregator_client::TapAggregatorClient, RavResponse}; use tap_core::receipt::{ checks::{Check, CheckError, CheckList, CheckResult}, - state::Checking, - Context, ReceiptWithState, + Context, }; + use tap_graph::SignedReceipt; use test_assets::{ flush_messages, ALLOCATION_ID_0, TAP_EIP712_DOMAIN as TAP_EIP712_DOMAIN_SEPARATOR, TAP_SENDER as SENDER, TAP_SIGNER as SIGNER, @@ -897,6 +905,7 @@ pub mod tests { sender_accounts_manager::NewReceiptNotification, unaggregated_receipts::UnaggregatedReceipts, }, + tap::CheckingReceipt, test::{ actors::{create_mock_sender_account, TestableActor}, create_rav, create_received_receipt, get_grpc_url, store_batch_receipts, @@ -1205,7 +1214,7 @@ pub mod tests { // Trigger a RAV request manually and wait for updated fees. sender_allocation - .cast(SenderAllocationMessage::TriggerRAVRequest) + .cast(SenderAllocationMessage::TriggerRavRequest) .unwrap(); flush_messages(¬ify).await; @@ -1286,7 +1295,7 @@ pub mod tests { // Trigger a RAV request manually and wait for updated fees. sender_allocation - .cast(SenderAllocationMessage::TriggerRAVRequest) + .cast(SenderAllocationMessage::TriggerRavRequest) .unwrap(); flush_messages(¬ify).await; @@ -1341,7 +1350,7 @@ pub mod tests { const AMOUNT_OF_RECEIPTS: u64 = 1000; execute(pgpool, AMOUNT_OF_RECEIPTS, |pgpool| async move { // Add receipts to the database. - let mut receipts: Vec> = Vec::with_capacity(1000); + let mut receipts = Vec::with_capacity(1000); for i in 0..AMOUNT_OF_RECEIPTS { let receipt = create_received_receipt(&ALLOCATION_ID_0, &SIGNER.0, i, i + 1, i.into()); @@ -1565,11 +1574,11 @@ pub mod tests { struct FailingCheck; #[async_trait::async_trait] - impl Check for FailingCheck { + impl Check for FailingCheck { async fn check( &self, _: &tap_core::receipt::Context, - _receipt: &ReceiptWithState, + _receipt: &CheckingReceipt, ) -> CheckResult { Err(CheckError::Failed(anyhow::anyhow!("Failing check"))) } @@ -1656,7 +1665,7 @@ pub mod tests { // Trigger a RAV request manually and wait for updated fees. // this should fail because there's no receipt with valid timestamp sender_allocation - .cast(SenderAllocationMessage::TriggerRAVRequest) + .cast(SenderAllocationMessage::TriggerRavRequest) .unwrap(); flush_messages(¬ify).await; @@ -1742,7 +1751,7 @@ pub mod tests { // Trigger a RAV request manually and wait for updated fees. // this should fail because there's no receipt with valid timestamp sender_allocation - .cast(SenderAllocationMessage::TriggerRAVRequest) + .cast(SenderAllocationMessage::TriggerRavRequest) .unwrap(); flush_messages(¬ify).await; diff --git a/crates/tap-agent/src/tap/context/checks.rs b/crates/tap-agent/src/tap/context/checks.rs index e48d2819..ae7ceaed 100644 --- a/crates/tap-agent/src/tap/context/checks.rs +++ b/crates/tap-agent/src/tap/context/checks.rs @@ -3,7 +3,6 @@ mod allocation_id; mod signature; -mod value; pub use allocation_id::AllocationId; pub use signature::Signature; diff --git a/crates/tap-agent/src/tap/context/checks/allocation_id.rs b/crates/tap-agent/src/tap/context/checks/allocation_id.rs index 734d4dd4..651b0c2d 100644 --- a/crates/tap-agent/src/tap/context/checks/allocation_id.rs +++ b/crates/tap-agent/src/tap/context/checks/allocation_id.rs @@ -7,14 +7,13 @@ use anyhow::anyhow; use indexer_monitor::SubgraphClient; use indexer_query::{tap_transactions, TapTransactions}; use indexer_watcher::new_watcher; -use tap_core::receipt::{ - checks::{Check, CheckError, CheckResult}, - state::Checking, - ReceiptWithState, -}; +use tap_core::receipt::checks::{Check, CheckError, CheckResult}; +use tap_graph::SignedReceipt; use thegraph_core::alloy::primitives::Address; use tokio::sync::watch::Receiver; +use crate::tap::CheckingReceipt; + pub struct AllocationId { tap_allocation_redeemed: Receiver, allocation_id: Address, @@ -46,11 +45,11 @@ impl AllocationId { } #[async_trait::async_trait] -impl Check for AllocationId { +impl Check for AllocationId { async fn check( &self, _: &tap_core::receipt::Context, - receipt: &ReceiptWithState, + receipt: &CheckingReceipt, ) -> CheckResult { let allocation_id = receipt.signed_receipt().message.allocation_id; // TODO: Remove the if block below? Each TAP Monitor is specific to an allocation diff --git a/crates/tap-agent/src/tap/context/checks/signature.rs b/crates/tap-agent/src/tap/context/checks/signature.rs index c750557e..9eb49935 100644 --- a/crates/tap-agent/src/tap/context/checks/signature.rs +++ b/crates/tap-agent/src/tap/context/checks/signature.rs @@ -3,14 +3,13 @@ use anyhow::anyhow; use indexer_monitor::EscrowAccounts; -use tap_core::receipt::{ - checks::{Check, CheckError, CheckResult}, - state::Checking, - ReceiptWithState, -}; +use tap_core::receipt::checks::{Check, CheckError, CheckResult}; +use tap_graph::SignedReceipt; use thegraph_core::alloy::{primitives::U256, sol_types::Eip712Domain}; use tokio::sync::watch::Receiver; +use crate::tap::CheckingReceipt; + pub struct Signature { domain_separator: Eip712Domain, escrow_accounts: Receiver, @@ -26,11 +25,11 @@ impl Signature { } #[async_trait::async_trait] -impl Check for Signature { +impl Check for Signature { async fn check( &self, _: &tap_core::receipt::Context, - receipt: &ReceiptWithState, + receipt: &CheckingReceipt, ) -> CheckResult { let signer = receipt .signed_receipt() diff --git a/crates/tap-agent/src/tap/context/checks/value.rs b/crates/tap-agent/src/tap/context/checks/value.rs deleted file mode 100644 index 414095d1..00000000 --- a/crates/tap-agent/src/tap/context/checks/value.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs. -// SPDX-License-Identifier: Apache-2.0 - -use std::{ - collections::HashMap, - sync::{Arc, RwLock}, -}; - -use anyhow::anyhow; -use tap_core::{ - receipt::{ - checks::{Check, CheckError, CheckResult}, - state::Checking, - ReceiptWithState, - }, - signed_message::MessageId, -}; - -use crate::tap::context::error::AdapterError; - -pub struct Value { - query_appraisals: Option>>>, -} - -#[async_trait::async_trait] -impl Check for Value { - async fn check( - &self, - _: &tap_core::receipt::Context, - receipt: &ReceiptWithState, - ) -> CheckResult { - let value = receipt.signed_receipt().message.value; - let query_id = receipt.signed_receipt().unique_hash(); - - let query_appraisals = self.query_appraisals.as_ref().expect( - "Query appraisals should be initialized. The opposite should never happen when \ - receipts value checking is enabled.", - ); - let query_appraisals_read = query_appraisals.read().unwrap(); - let appraised_value = query_appraisals_read - .get(&query_id) - .ok_or(AdapterError::ValidationError { - error: "No appraised value found for query".to_string(), - }) - .map_err(|e| CheckError::Failed(e.into()))?; - if value != *appraised_value { - return Err(CheckError::Failed(anyhow!( - "Value different from appraised_value. value: {}, appraised_value: {}", - value, - *appraised_value - ))); - } - Ok(()) - } -} diff --git a/crates/tap-agent/src/tap/context/escrow.rs b/crates/tap-agent/src/tap/context/escrow.rs index 268448c1..db86f2b4 100644 --- a/crates/tap-agent/src/tap/context/escrow.rs +++ b/crates/tap-agent/src/tap/context/escrow.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use async_trait::async_trait; -use tap_core::manager::adapters::EscrowHandler as EscrowAdapterTrait; +use tap_core::manager::adapters::SignatureChecker; use thegraph_core::alloy::primitives::Address; use super::{error::AdapterError, TapAgentContext}; @@ -22,17 +22,9 @@ impl From for AdapterError { // In any case, we don't want to fail a receipt because of this. // The receipt is fine, just the escrow account that is not. #[async_trait] -impl EscrowAdapterTrait for TapAgentContext { +impl SignatureChecker for TapAgentContext { type AdapterError = AdapterError; - async fn get_available_escrow(&self, _signer: Address) -> Result { - Ok(0) - } - - async fn subtract_escrow(&self, _signer: Address, _value: u128) -> Result<(), AdapterError> { - Ok(()) - } - async fn verify_signer(&self, signer: Address) -> Result { let escrow_accounts = self.escrow_accounts.borrow(); let sender = escrow_accounts diff --git a/crates/tap-agent/src/tap/context/rav.rs b/crates/tap-agent/src/tap/context/rav.rs index 4ac2cf44..3c84c5ef 100644 --- a/crates/tap-agent/src/tap/context/rav.rs +++ b/crates/tap-agent/src/tap/context/rav.rs @@ -8,10 +8,8 @@ use bigdecimal::{ ToPrimitive, }; use sqlx::types::{chrono, BigDecimal}; -use tap_core::{ - manager::adapters::{RAVRead, RAVStore}, - rav::{ReceiptAggregateVoucher, SignedRAV}, -}; +use tap_core::manager::adapters::{RavRead, RavStore}; +use tap_graph::{ReceiptAggregateVoucher, SignedRav}; #[allow(deprecated)] use thegraph_core::alloy::signers::Signature; use thegraph_core::alloy::{hex::ToHexExt, primitives::Address}; @@ -19,10 +17,10 @@ use thegraph_core::alloy::{hex::ToHexExt, primitives::Address}; use super::{error::AdapterError, TapAgentContext}; #[async_trait::async_trait] -impl RAVRead for TapAgentContext { +impl RavRead for TapAgentContext { type AdapterError = AdapterError; - async fn last_rav(&self) -> Result, Self::AdapterError> { + async fn last_rav(&self) -> Result, Self::AdapterError> { let row = sqlx::query!( r#" SELECT signature, allocation_id, timestamp_ns, value_aggregate @@ -78,7 +76,7 @@ impl RAVRead for TapAgentContext { timestampNs: timestamp_ns, valueAggregate: value_aggregate, }; - Ok(Some(SignedRAV { + Ok(Some(SignedRav { message: rav, signature, })) @@ -89,10 +87,10 @@ impl RAVRead for TapAgentContext { } #[async_trait::async_trait] -impl RAVStore for TapAgentContext { +impl RavStore for TapAgentContext { type AdapterError = AdapterError; - async fn update_last_rav(&self, rav: SignedRAV) -> Result<(), Self::AdapterError> { + async fn update_last_rav(&self, rav: SignedRav) -> Result<(), Self::AdapterError> { let signature_bytes: Vec = rav.signature.as_bytes().to_vec(); let _fut = sqlx::query!( @@ -142,7 +140,7 @@ mod test { use crate::test::{create_rav, ALLOCATION_ID_0}; #[derive(Debug)] - struct TestableRav(SignedRAV); + struct TestableRav(SignedRav); impl Eq for TestableRav {} diff --git a/crates/tap-agent/src/tap/context/receipt.rs b/crates/tap-agent/src/tap/context/receipt.rs index b01e6112..0d179701 100644 --- a/crates/tap-agent/src/tap/context/receipt.rs +++ b/crates/tap-agent/src/tap/context/receipt.rs @@ -9,14 +9,12 @@ use std::{ use bigdecimal::{num_bigint::ToBigInt, ToPrimitive}; use sqlx::{postgres::types::PgRange, types::BigDecimal}; -use tap_core::{ - manager::adapters::{safe_truncate_receipts, ReceiptDelete, ReceiptRead}, - receipt::{state::Checking, Receipt, ReceiptWithState, SignedReceipt}, -}; +use tap_core::manager::adapters::{safe_truncate_receipts, ReceiptDelete, ReceiptRead}; +use tap_graph::{Receipt, SignedReceipt}; use thegraph_core::alloy::{hex::ToHexExt, primitives::Address}; use super::{error::AdapterError, TapAgentContext}; -use crate::tap::signers_trimmed; +use crate::tap::{signers_trimmed, CheckingReceipt}; impl From for AdapterError { fn from(error: TryFromIntError) -> Self { AdapterError::ReceiptRead { @@ -71,14 +69,14 @@ fn rangebounds_to_pgrange>(range: R) -> PgRange } #[async_trait::async_trait] -impl ReceiptRead for TapAgentContext { +impl ReceiptRead for TapAgentContext { type AdapterError = AdapterError; async fn retrieve_receipts_in_timestamp_range + Send>( &self, timestamp_range_ns: R, receipts_limit: Option, - ) -> Result>, Self::AdapterError> { + ) -> Result, Self::AdapterError> { let signers = signers_trimmed(self.escrow_accounts.clone(), self.sender) .await .map_err(|e| AdapterError::ReceiptRead { @@ -147,10 +145,10 @@ impl ReceiptRead for TapAgentContext { signature, }; - Ok(ReceiptWithState::new(signed_receipt)) + Ok(CheckingReceipt::new(signed_receipt)) }) - .collect::>, AdapterError>>()?; + .collect::, AdapterError>>()?; safe_truncate_receipts(&mut receipts, receipts_limit); @@ -200,10 +198,7 @@ mod test { use indexer_monitor::EscrowAccounts; use lazy_static::lazy_static; use sqlx::PgPool; - use tap_core::{ - manager::adapters::{ReceiptDelete, ReceiptRead}, - receipt::{state::Checking, Receipt, ReceiptWithState, SignedReceipt}, - }; + use tap_core::manager::adapters::{ReceiptDelete, ReceiptRead}; use test_assets::{ ALLOCATION_ID_0, ALLOCATION_ID_1, TAP_EIP712_DOMAIN as TAP_EIP712_DOMAIN_SEPARATOR, TAP_SENDER as SENDER, TAP_SIGNER as SIGNER, @@ -262,13 +257,13 @@ mod test { async fn retrieve_range_and_check + Send>( storage_adapter: &TapAgentContext, escrow_accounts: Receiver, - received_receipt_vec: &[ReceiptWithState], + received_receipt_vec: &[CheckingReceipt], range: R, ) -> anyhow::Result<()> { let escrow_accounts_snapshot = escrow_accounts.borrow(); // Filtering the received receipts by timestamp range - let received_receipt_vec: Vec> = received_receipt_vec + let received_receipt_vec: Vec<_> = received_receipt_vec .iter() .filter(|received_receipt| { range.contains(&received_receipt.signed_receipt().message.timestamp_ns) @@ -312,7 +307,7 @@ mod test { async fn remove_range_and_check + Send>( storage_adapter: &TapAgentContext, escrow_accounts: Receiver, - received_receipt_vec: &[ReceiptWithState], + received_receipt_vec: &[CheckingReceipt], range: R, ) -> anyhow::Result<()> { let escrow_accounts_snapshot = escrow_accounts.borrow(); @@ -335,7 +330,7 @@ mod test { // Remove the received receipts by timestamp range for the correct (allocation_id, // sender) - let received_receipt_vec: Vec<(u64, &ReceiptWithState)> = received_receipt_vec + let received_receipt_vec: Vec<_> = received_receipt_vec .iter() .filter(|(_, received_receipt)| { if (received_receipt.signed_receipt().message.allocation_id diff --git a/crates/tap-agent/src/tap/mod.rs b/crates/tap-agent/src/tap/mod.rs index d4b11d92..e5042802 100644 --- a/crates/tap-agent/src/tap/mod.rs +++ b/crates/tap-agent/src/tap/mod.rs @@ -2,9 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 use indexer_monitor::EscrowAccounts; +use tap_core::receipt::{state::Checking, ReceiptWithState}; +use tap_graph::SignedReceipt; use thegraph_core::alloy::{hex::ToHexExt, primitives::Address}; use tokio::sync::watch::Receiver; +pub type CheckingReceipt = ReceiptWithState; + pub mod context; pub async fn signers_trimmed( diff --git a/crates/tap-agent/src/test.rs b/crates/tap-agent/src/test.rs index 6c4277e6..7924942c 100644 --- a/crates/tap-agent/src/test.rs +++ b/crates/tap-agent/src/test.rs @@ -17,12 +17,8 @@ use ractor::{concurrency::JoinHandle, Actor, ActorRef}; use reqwest::Url; use sqlx::{types::BigDecimal, PgPool}; use tap_aggregator::server::run_server; -use tap_core::{ - rav::{ReceiptAggregateVoucher, SignedRAV}, - receipt::{state::Checking, Receipt, ReceiptWithState, SignedReceipt}, - signed_message::EIP712SignedMessage, - tap_eip712_domain, -}; +use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain}; +use tap_graph::{Receipt, ReceiptAggregateVoucher, SignedRav, SignedReceipt}; use test_assets::{flush_messages, TAP_SENDER as SENDER, TAP_SIGNER as SIGNER}; use thegraph_core::alloy::{ primitives::{address, hex::ToHexExt, Address, U256}, @@ -47,7 +43,7 @@ use crate::{ SenderAccountsManager, SenderAccountsManagerArgs, SenderAccountsManagerMessage, }, }, - tap::context::AdapterError, + tap::{context::AdapterError, CheckingReceipt}, }; lazy_static! { @@ -246,8 +242,8 @@ pub fn create_rav( signer_wallet: PrivateKeySigner, timestamp_ns: u64, value_aggregate: u128, -) -> SignedRAV { - EIP712SignedMessage::new( +) -> SignedRav { + Eip712SignedMessage::new( &TAP_EIP712_DOMAIN_SEPARATOR, ReceiptAggregateVoucher { allocationId: allocation_id, @@ -267,8 +263,8 @@ pub fn create_received_receipt( nonce: u64, timestamp_ns: u64, value: u128, -) -> ReceiptWithState { - let receipt = EIP712SignedMessage::new( +) -> CheckingReceipt { + let receipt = Eip712SignedMessage::new( &TAP_EIP712_DOMAIN_SEPARATOR, Receipt { allocation_id: *allocation_id, @@ -279,7 +275,7 @@ pub fn create_received_receipt( signer_wallet, ) .unwrap(); - ReceiptWithState::new(receipt) + CheckingReceipt::new(receipt) } pub async fn store_receipt(pgpool: &PgPool, signed_receipt: &SignedReceipt) -> anyhow::Result { @@ -311,7 +307,7 @@ pub async fn store_receipt(pgpool: &PgPool, signed_receipt: &SignedReceipt) -> a pub async fn store_batch_receipts( pgpool: &PgPool, - receipts: Vec>, + receipts: Vec, ) -> Result<(), AdapterError> { let receipts_len = receipts.len(); let mut signers = Vec::with_capacity(receipts_len); @@ -411,7 +407,7 @@ pub fn wallet(index: u32) -> (PrivateKeySigner, Address) { pub async fn store_rav( pgpool: &PgPool, - signed_rav: SignedRAV, + signed_rav: SignedRav, sender: Address, ) -> anyhow::Result<()> { store_rav_with_options(pgpool, signed_rav, sender, false, false).await @@ -448,7 +444,7 @@ async fn create_grpc_aggregator() -> (JoinHandle<()>, SocketAddr) { pub async fn store_rav_with_options( pgpool: &PgPool, - signed_rav: SignedRAV, + signed_rav: SignedRav, sender: Address, last: bool, final_rav: bool, @@ -693,7 +689,7 @@ pub mod actors { _state: &mut Self::State, ) -> Result<(), ActorProcessingErr> { match message { - SenderAllocationMessage::TriggerRAVRequest => { + SenderAllocationMessage::TriggerRavRequest => { self.triggered_rav_request.notify_one(); if let Some(sender_account) = self.sender_actor.as_ref() { let signed_rav = create_rav( diff --git a/crates/tap-agent/tests/tap_agent_test.rs b/crates/tap-agent/tests/tap_agent_test.rs index b4900312..f84618aa 100644 --- a/crates/tap-agent/tests/tap_agent_test.rs +++ b/crates/tap-agent/tests/tap_agent_test.rs @@ -18,7 +18,6 @@ use ractor::{call, concurrency::JoinHandle, Actor, ActorRef}; use reqwest::Url; use serde_json::json; use sqlx::PgPool; -use tap_core::receipt::{state::Checking, ReceiptWithState}; use test_assets::{ assert_while_retry, flush_messages, ALLOCATION_ID_0, ALLOCATION_ID_1, ALLOCATION_ID_2, ESCROW_ACCOUNTS_BALANCES, ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS, INDEXER_ADDRESS, @@ -120,8 +119,7 @@ async fn test_start_tap_agent(pgpool: PgPool) { // Add batch receits to the database. const AMOUNT_OF_RECEIPTS: u64 = 3000; let allocations = [ALLOCATION_ID_0, ALLOCATION_ID_1, ALLOCATION_ID_2]; - let mut receipts: Vec> = - Vec::with_capacity(AMOUNT_OF_RECEIPTS as usize); + let mut receipts = Vec::with_capacity(AMOUNT_OF_RECEIPTS as usize); for i in 0..AMOUNT_OF_RECEIPTS { // This would select the 3 defined allocations in order let allocation_selected = (i % 3) as usize; diff --git a/crates/test-assets/Cargo.toml b/crates/test-assets/Cargo.toml index 568c14b9..0585bd13 100644 --- a/crates/test-assets/Cargo.toml +++ b/crates/test-assets/Cargo.toml @@ -8,6 +8,7 @@ indexer-allocation = { path = "../allocation" } bip39 = "2.0.0" lazy_static.workspace = true tap_core.workspace = true +tap_graph.workspace = true thegraph-core.workspace = true typed-builder.workspace = true tokio.workspace = true diff --git a/crates/test-assets/src/lib.rs b/crates/test-assets/src/lib.rs index 9d7328f1..70482e1e 100644 --- a/crates/test-assets/src/lib.rs +++ b/crates/test-assets/src/lib.rs @@ -10,11 +10,8 @@ use std::{ use bip39::Mnemonic; use indexer_allocation::{Allocation, AllocationStatus, SubgraphDeployment}; use lazy_static::lazy_static; -use tap_core::{ - receipt::{Receipt, SignedReceipt}, - signed_message::EIP712SignedMessage, - tap_eip712_domain, -}; +use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain}; +use tap_graph::{Receipt, SignedReceipt}; use thegraph_core::{ alloy::{ primitives::{address, Address, U256}, @@ -339,7 +336,7 @@ pub async fn create_signed_receipt( ) -> SignedReceipt { let (wallet, _) = &*self::TAP_SIGNER; - EIP712SignedMessage::new( + Eip712SignedMessage::new( &self::TAP_EIP712_DOMAIN, Receipt { allocation_id,