diff --git a/Cargo.lock b/Cargo.lock index b97127f..8481fc1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1539,16 +1539,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" -[[package]] -name = "colored" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" -dependencies = [ - "lazy_static", - "windows-sys 0.48.0", -] - [[package]] name = "concurrent-queue" version = "2.5.0" @@ -1585,17 +1575,18 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "contract-client" -version = "0.1.6" +version = "1.0.0-rc1" +source = "git+ssh://git@github.com/subsquid/subsquid-network.git#784430bc9cbab91a987b3037b20677891e3153ba" dependencies = [ - "anyhow", "async-trait", "clap", "ethers", + "libp2p", "log", - "simple_logger", - "subsquid-network-transport", + "serde", "thiserror", "tokio", + "tokio-stream", "url", ] @@ -3566,7 +3557,7 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libp2p" version = "0.54.0" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "bytes", "either", @@ -3604,7 +3595,7 @@ dependencies = [ [[package]] name = "libp2p-allow-block-list" version = "0.3.0" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "libp2p-core", "libp2p-identity", @@ -3615,7 +3606,7 @@ dependencies = [ [[package]] name = "libp2p-autonat" version = "0.12.0" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "async-trait", "asynchronous-codec", @@ -3635,7 +3626,7 @@ dependencies = [ [[package]] name = "libp2p-connection-limits" version = "0.3.1" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "libp2p-core", "libp2p-identity", @@ -3646,7 +3637,7 @@ dependencies = [ [[package]] name = "libp2p-core" version = "0.41.2" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "either", "fnv", @@ -3674,7 +3665,7 @@ dependencies = [ [[package]] name = "libp2p-dcutr" version = "0.11.0" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "asynchronous-codec", "either", @@ -3696,7 +3687,7 @@ dependencies = [ [[package]] name = "libp2p-dns" version = "0.41.1" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "async-trait", "futures", @@ -3711,7 +3702,7 @@ dependencies = [ [[package]] name = "libp2p-gossipsub" version = "0.46.1" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "asynchronous-codec", "base64 0.22.1", @@ -3742,7 +3733,7 @@ dependencies = [ [[package]] name = "libp2p-identify" version = "0.44.2" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "asynchronous-codec", "either", @@ -3783,7 +3774,7 @@ dependencies = [ [[package]] name = "libp2p-kad" version = "0.46.0" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "arrayvec", "asynchronous-codec", @@ -3812,7 +3803,7 @@ dependencies = [ [[package]] name = "libp2p-mdns" version = "0.45.1" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "data-encoding", "futures", @@ -3832,7 +3823,7 @@ dependencies = [ [[package]] name = "libp2p-metrics" version = "0.14.1" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "futures", "instant", @@ -3852,7 +3843,7 @@ dependencies = [ [[package]] name = "libp2p-noise" version = "0.44.0" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "asynchronous-codec", "bytes", @@ -3877,7 +3868,7 @@ dependencies = [ [[package]] name = "libp2p-ping" version = "0.44.1" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "either", "futures", @@ -3894,7 +3885,7 @@ dependencies = [ [[package]] name = "libp2p-quic" version = "0.10.3" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "bytes", "futures", @@ -3917,7 +3908,7 @@ dependencies = [ [[package]] name = "libp2p-relay" version = "0.17.2" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "asynchronous-codec", "bytes", @@ -3941,7 +3932,7 @@ dependencies = [ [[package]] name = "libp2p-request-response" version = "0.26.2" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "async-trait", "futures", @@ -3960,7 +3951,7 @@ dependencies = [ [[package]] name = "libp2p-swarm" version = "0.44.2" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "either", "fnv", @@ -3982,7 +3973,7 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" version = "0.34.2" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -3993,7 +3984,7 @@ dependencies = [ [[package]] name = "libp2p-tcp" version = "0.41.0" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "futures", "futures-timer", @@ -4009,7 +4000,7 @@ dependencies = [ [[package]] name = "libp2p-tls" version = "0.3.0" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "futures", "futures-rustls", @@ -4027,7 +4018,7 @@ dependencies = [ [[package]] name = "libp2p-upnp" version = "0.2.2" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "futures", "futures-timer", @@ -4042,7 +4033,7 @@ dependencies = [ [[package]] name = "libp2p-yamux" version = "0.45.1" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "either", "futures", @@ -4104,7 +4095,7 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "logs-collector" -version = "0.4.4" +version = "1.0.0-rc1" dependencies = [ "anyhow", "async-trait", @@ -4280,7 +4271,7 @@ checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" [[package]] name = "multistream-select" version = "0.13.0" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "bytes", "futures", @@ -4376,7 +4367,7 @@ dependencies = [ [[package]] name = "network-scheduler" -version = "0.4.5" +version = "1.0.0-rc1" dependencies = [ "anyhow", "async-trait", @@ -4531,15 +4522,6 @@ dependencies = [ "syn 2.0.63", ] -[[package]] -name = "num_threads" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" -dependencies = [ - "libc", -] - [[package]] name = "object" version = "0.32.2" @@ -5220,7 +5202,7 @@ checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" [[package]] name = "query-gateway" -version = "0.4.4" +version = "1.0.0-rc1" dependencies = [ "anyhow", "axum", @@ -5268,7 +5250,7 @@ dependencies = [ [[package]] name = "quick-protobuf-codec" version = "0.3.1" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "asynchronous-codec", "bytes", @@ -5845,7 +5827,7 @@ checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" [[package]] name = "rw-stream-sink" version = "0.4.0" -source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=ea39732a#ea39732a0476b23f1f43440eb74fca43019dac56" +source = "git+https://github.com/Wiezzel/rust-libp2p.git?rev=d03dec17#d03dec17e9257071aef91bd984e982f355bd7acc" dependencies = [ "futures", "pin-project", @@ -6239,18 +6221,6 @@ dependencies = [ "time", ] -[[package]] -name = "simple_logger" -version = "4.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e7e46c8c90251d47d08b28b8a419ffb4aede0f87c2eea95e17d1d5bacbf3ef1" -dependencies = [ - "colored", - "log", - "time", - "windows-sys 0.48.0", -] - [[package]] name = "siphasher" version = "0.3.11" @@ -6400,8 +6370,8 @@ dependencies = [ [[package]] name = "subsquid-messages" -version = "0.2.3" -source = "git+ssh://git@github.com/subsquid/subsquid-network.git#e0898841d48efd34697040aae05e0523605c9f4b" +version = "1.0.0-rc1" +source = "git+ssh://git@github.com/subsquid/subsquid-network.git#784430bc9cbab91a987b3037b20677891e3153ba" dependencies = [ "anyhow", "hex", @@ -6415,13 +6385,14 @@ dependencies = [ [[package]] name = "subsquid-network-transport" -version = "0.4.6" -source = "git+ssh://git@github.com/subsquid/subsquid-network.git#e0898841d48efd34697040aae05e0523605c9f4b" +version = "1.0.0-rc1" +source = "git+ssh://git@github.com/subsquid/subsquid-network.git#784430bc9cbab91a987b3037b20677891e3153ba" dependencies = [ "anyhow", "async-trait", "bimap", "clap", + "contract-client", "derivative", "env_logger", "futures", @@ -6618,9 +6589,7 @@ checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", - "libc", "num-conv", - "num_threads", "powerfmt", "serde", "time-core", diff --git a/Cargo.toml b/Cargo.toml index 9d7eda6..bd59df4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,5 +3,6 @@ members = ["crates/*"] resolver = "2" [workspace.dependencies] -subsquid-messages = { git = "ssh://git@github.com/subsquid/subsquid-network.git", version = "0.2.3" } -subsquid-network-transport = { git = "ssh://git@github.com/subsquid/subsquid-network.git", version = "0.4.6" } +contract-client = { git = "ssh://git@github.com/subsquid/subsquid-network.git", version = "1.0.0-rc1" } +subsquid-messages = { git = "ssh://git@github.com/subsquid/subsquid-network.git", version = "1.0.0-rc1" } +subsquid-network-transport = { git = "ssh://git@github.com/subsquid/subsquid-network.git", version = "1.0.0-rc1" } diff --git a/crates/contract-client/Cargo.toml b/crates/contract-client/Cargo.toml deleted file mode 100644 index e0b051c..0000000 --- a/crates/contract-client/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "contract-client" -version = "0.1.6" -edition = "2021" - -[dependencies] - -async-trait = "0.1" -clap = { version = "4", features = ["derive", "env"] } -ethers = { version = "2", features = ["ws"] } -log = "0.4" -thiserror = "1" -tokio = { version = "1", features = ["sync"] } -url = "2" - -subsquid-network-transport = { workspace = true } - -[dev-dependencies] -anyhow = "1" -simple_logger = "4" -tokio = { version = "1", features = ["macros", "rt-multi-thread"] } diff --git a/crates/contract-client/abi/AllocationsViewer.json b/crates/contract-client/abi/AllocationsViewer.json deleted file mode 100644 index 370bc58..0000000 --- a/crates/contract-client/abi/AllocationsViewer.json +++ /dev/null @@ -1,73 +0,0 @@ -[ - { - "inputs":[ - { - "internalType":"contract IGatewayRegistry", - "name":"_gatewayRegistry", - "type":"address" - } - ], - "stateMutability":"nonpayable", - "type":"constructor" - }, - { - "inputs":[ - ], - "name":"gatewayRegistry", - "outputs":[ - { - "internalType":"contract IGatewayRegistry", - "name":"", - "type":"address" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"workerId", - "type":"uint256" - }, - { - "internalType":"uint256", - "name":"pageNumber", - "type":"uint256" - }, - { - "internalType":"uint256", - "name":"perPage", - "type":"uint256" - } - ], - "name":"getAllocations", - "outputs":[ - { - "components":[ - { - "internalType":"bytes", - "name":"gatewayId", - "type":"bytes" - }, - { - "internalType":"uint256", - "name":"allocated", - "type":"uint256" - }, - { - "internalType":"address", - "name":"operator", - "type":"address" - } - ], - "internalType":"struct AllocationsViewer.Allocation[]", - "name":"", - "type":"tuple[]" - } - ], - "stateMutability":"view", - "type":"function" - } - ] diff --git a/crates/contract-client/abi/GatewayRegistry.json b/crates/contract-client/abi/GatewayRegistry.json deleted file mode 100644 index e2723c6..0000000 --- a/crates/contract-client/abi/GatewayRegistry.json +++ /dev/null @@ -1,1455 +0,0 @@ -[ - { - "inputs":[ - - ], - "stateMutability":"nonpayable", - "type":"constructor" - }, - { - "inputs":[ - - ], - "name":"AccessControlBadConfirmation", - "type":"error" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"account", - "type":"address" - }, - { - "internalType":"bytes32", - "name":"neededRole", - "type":"bytes32" - } - ], - "name":"AccessControlUnauthorizedAccount", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"EnforcedPause", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"ExpectedPause", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"InvalidInitialization", - "type":"error" - }, - { - "inputs":[ - - ], - "name":"NotInitializing", - "type":"error" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"gateway", - "type":"address" - }, - { - "indexed":false, - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - }, - { - "indexed":false, - "internalType":"uint256[]", - "name":"workerIds", - "type":"uint256[]" - }, - { - "indexed":false, - "internalType":"uint256[]", - "name":"shares", - "type":"uint256[]" - } - ], - "name":"AllocatedCUs", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"gatewayOperator", - "type":"address" - }, - { - "indexed":false, - "internalType":"uint128", - "name":"lockEnd", - "type":"uint128" - } - ], - "name":"AutoextensionDisabled", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"gatewayOperator", - "type":"address" - } - ], - "name":"AutoextensionEnabled", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":false, - "internalType":"uint256", - "name":"newBlockTime", - "type":"uint256" - } - ], - "name":"AverageBlockTimeChanged", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"strategy", - "type":"address" - } - ], - "name":"DefaultStrategyChanged", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"gatewayOperator", - "type":"address" - }, - { - "indexed":false, - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - }, - { - "indexed":false, - "internalType":"address", - "name":"newAddress", - "type":"address" - } - ], - "name":"GatewayAddressChanged", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":false, - "internalType":"uint64", - "name":"version", - "type":"uint64" - } - ], - "name":"Initialized", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":false, - "internalType":"uint256", - "name":"newCuPerSQD", - "type":"uint256" - } - ], - "name":"ManaChanged", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":false, - "internalType":"uint256", - "name":"newAmount", - "type":"uint256" - } - ], - "name":"MaxGatewaysPerClusterChanged", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"gatewayOperator", - "type":"address" - }, - { - "indexed":false, - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - }, - { - "indexed":false, - "internalType":"string", - "name":"metadata", - "type":"string" - } - ], - "name":"MetadataChanged", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":false, - "internalType":"address", - "name":"account", - "type":"address" - } - ], - "name":"Paused", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"gatewayOperator", - "type":"address" - }, - { - "indexed":true, - "internalType":"bytes32", - "name":"id", - "type":"bytes32" - }, - { - "indexed":false, - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - } - ], - "name":"Registered", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"bytes32", - "name":"role", - "type":"bytes32" - }, - { - "indexed":true, - "internalType":"bytes32", - "name":"previousAdminRole", - "type":"bytes32" - }, - { - "indexed":true, - "internalType":"bytes32", - "name":"newAdminRole", - "type":"bytes32" - } - ], - "name":"RoleAdminChanged", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"bytes32", - "name":"role", - "type":"bytes32" - }, - { - "indexed":true, - "internalType":"address", - "name":"account", - "type":"address" - }, - { - "indexed":true, - "internalType":"address", - "name":"sender", - "type":"address" - } - ], - "name":"RoleGranted", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"bytes32", - "name":"role", - "type":"bytes32" - }, - { - "indexed":true, - "internalType":"address", - "name":"account", - "type":"address" - }, - { - "indexed":true, - "internalType":"address", - "name":"sender", - "type":"address" - } - ], - "name":"RoleRevoked", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"gatewayOperator", - "type":"address" - }, - { - "indexed":false, - "internalType":"uint256", - "name":"amount", - "type":"uint256" - }, - { - "indexed":false, - "internalType":"uint128", - "name":"lockStart", - "type":"uint128" - }, - { - "indexed":false, - "internalType":"uint128", - "name":"lockEnd", - "type":"uint128" - }, - { - "indexed":false, - "internalType":"uint256", - "name":"computationUnits", - "type":"uint256" - } - ], - "name":"Staked", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"strategy", - "type":"address" - }, - { - "indexed":false, - "internalType":"bool", - "name":"isAllowed", - "type":"bool" - } - ], - "name":"StrategyAllowed", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":false, - "internalType":"address", - "name":"account", - "type":"address" - } - ], - "name":"Unpaused", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"gatewayOperator", - "type":"address" - }, - { - "indexed":false, - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - } - ], - "name":"Unregistered", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"gatewayOperator", - "type":"address" - }, - { - "indexed":false, - "internalType":"uint256", - "name":"amount", - "type":"uint256" - } - ], - "name":"Unstaked", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"gatewayOperator", - "type":"address" - }, - { - "indexed":false, - "internalType":"address", - "name":"strategy", - "type":"address" - } - ], - "name":"UsedStrategyChanged", - "type":"event" - }, - { - "inputs":[ - - ], - "name":"DEFAULT_ADMIN_ROLE", - "outputs":[ - { - "internalType":"bytes32", - "name":"", - "type":"bytes32" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"PAUSER_ROLE", - "outputs":[ - { - "internalType":"bytes32", - "name":"", - "type":"bytes32" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"amount", - "type":"uint256" - } - ], - "name":"addStake", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256[]", - "name":"workerIds", - "type":"uint256[]" - }, - { - "internalType":"uint256[]", - "name":"cus", - "type":"uint256[]" - } - ], - "name":"allocateComputationUnits", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"averageBlockTime", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"operator", - "type":"address" - } - ], - "name":"canUnstake", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"amount", - "type":"uint256" - }, - { - "internalType":"uint256", - "name":"durationBlocks", - "type":"uint256" - } - ], - "name":"computationUnitsAmount", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - } - ], - "name":"computationUnitsAvailable", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"defaultStrategy", - "outputs":[ - { - "internalType":"address", - "name":"", - "type":"address" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"disableAutoExtension", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"enableAutoExtension", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"", - "type":"address" - } - ], - "name":"gatewayByAddress", - "outputs":[ - { - "internalType":"bytes32", - "name":"gatewayId", - "type":"bytes32" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"pageNumber", - "type":"uint256" - }, - { - "internalType":"uint256", - "name":"perPage", - "type":"uint256" - } - ], - "name":"getActiveGateways", - "outputs":[ - { - "internalType":"bytes[]", - "name":"", - "type":"bytes[]" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"getActiveGatewaysCount", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - } - ], - "name":"getCluster", - "outputs":[ - { - "internalType":"bytes[]", - "name":"clusterPeerIds", - "type":"bytes[]" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - } - ], - "name":"getGateway", - "outputs":[ - { - "components":[ - { - "internalType":"address", - "name":"operator", - "type":"address" - }, - { - "internalType":"address", - "name":"ownAddress", - "type":"address" - }, - { - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - }, - { - "internalType":"string", - "name":"metadata", - "type":"string" - } - ], - "internalType":"struct IGatewayRegistry.Gateway", - "name":"", - "type":"tuple" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - } - ], - "name":"getMetadata", - "outputs":[ - { - "internalType":"string", - "name":"", - "type":"string" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"operator", - "type":"address" - } - ], - "name":"getMyGateways", - "outputs":[ - { - "internalType":"bytes[]", - "name":"", - "type":"bytes[]" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes32", - "name":"role", - "type":"bytes32" - } - ], - "name":"getRoleAdmin", - "outputs":[ - { - "internalType":"bytes32", - "name":"", - "type":"bytes32" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"operator", - "type":"address" - } - ], - "name":"getStake", - "outputs":[ - { - "components":[ - { - "internalType":"uint256", - "name":"amount", - "type":"uint256" - }, - { - "internalType":"uint128", - "name":"lockStart", - "type":"uint128" - }, - { - "internalType":"uint128", - "name":"lockEnd", - "type":"uint128" - }, - { - "internalType":"uint128", - "name":"duration", - "type":"uint128" - }, - { - "internalType":"bool", - "name":"autoExtension", - "type":"bool" - }, - { - "internalType":"uint256", - "name":"oldCUs", - "type":"uint256" - } - ], - "internalType":"struct IGatewayRegistry.Stake", - "name":"", - "type":"tuple" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - } - ], - "name":"getUsedStrategy", - "outputs":[ - { - "internalType":"address", - "name":"", - "type":"address" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes32", - "name":"role", - "type":"bytes32" - }, - { - "internalType":"address", - "name":"account", - "type":"address" - } - ], - "name":"grantRole", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes32", - "name":"role", - "type":"bytes32" - }, - { - "internalType":"address", - "name":"account", - "type":"address" - } - ], - "name":"hasRole", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"contract IERC20WithMetadata", - "name":"_token", - "type":"address" - }, - { - "internalType":"contract IRouter", - "name":"_router", - "type":"address" - } - ], - "name":"initialize", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"strategy", - "type":"address" - } - ], - "name":"isStrategyAllowed", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"mana", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"maxGatewaysPerCluster", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"pause", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"paused", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - } - ], - "name":"register", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - }, - { - "internalType":"string", - "name":"metadata", - "type":"string" - }, - { - "internalType":"address", - "name":"gatewayAddress", - "type":"address" - } - ], - "name":"register", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - }, - { - "internalType":"string", - "name":"metadata", - "type":"string" - } - ], - "name":"register", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes[]", - "name":"peerId", - "type":"bytes[]" - }, - { - "internalType":"string[]", - "name":"metadata", - "type":"string[]" - }, - { - "internalType":"address[]", - "name":"gatewayAddress", - "type":"address[]" - } - ], - "name":"register", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes32", - "name":"role", - "type":"bytes32" - }, - { - "internalType":"address", - "name":"callerConfirmation", - "type":"address" - } - ], - "name":"renounceRole", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes32", - "name":"role", - "type":"bytes32" - }, - { - "internalType":"address", - "name":"account", - "type":"address" - } - ], - "name":"revokeRole", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"router", - "outputs":[ - { - "internalType":"contract IRouter", - "name":"", - "type":"address" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"_newAverageBlockTime", - "type":"uint256" - } - ], - "name":"setAverageBlockTime", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - }, - { - "internalType":"address", - "name":"newAddress", - "type":"address" - } - ], - "name":"setGatewayAddress", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"strategy", - "type":"address" - }, - { - "internalType":"bool", - "name":"isAllowed", - "type":"bool" - }, - { - "internalType":"bool", - "name":"isDefault", - "type":"bool" - } - ], - "name":"setIsStrategyAllowed", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"_newMana", - "type":"uint256" - } - ], - "name":"setMana", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"_maxGatewaysPerCluster", - "type":"uint256" - } - ], - "name":"setMaxGatewaysPerCluster", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - }, - { - "internalType":"string", - "name":"metadata", - "type":"string" - } - ], - "name":"setMetadata", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"amount", - "type":"uint256" - }, - { - "internalType":"uint128", - "name":"durationBlocks", - "type":"uint128" - } - ], - "name":"stake", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"amount", - "type":"uint256" - }, - { - "internalType":"uint128", - "name":"durationBlocks", - "type":"uint128" - }, - { - "internalType":"bool", - "name":"withAutoExtension", - "type":"bool" - } - ], - "name":"stake", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"operator", - "type":"address" - } - ], - "name":"staked", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes4", - "name":"interfaceId", - "type":"bytes4" - } - ], - "name":"supportsInterface", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"token", - "outputs":[ - { - "internalType":"contract IERC20WithMetadata", - "name":"", - "type":"address" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"unpause", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"peerId", - "type":"bytes" - } - ], - "name":"unregister", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bytes[]", - "name":"peerId", - "type":"bytes[]" - } - ], - "name":"unregister", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"unstake", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"strategy", - "type":"address" - } - ], - "name":"useStrategy", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - } -] \ No newline at end of file diff --git a/crates/contract-client/abi/NetworkController.json b/crates/contract-client/abi/NetworkController.json deleted file mode 100644 index 193787b..0000000 --- a/crates/contract-client/abi/NetworkController.json +++ /dev/null @@ -1,591 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "uint128", - "name": "_epochLength", - "type": "uint128" - }, - { - "internalType": "uint256", - "name": "_bondAmount", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "_allowedVestedTargets", - "type": "address[]" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - - ], - "name": "AccessControlBadConfirmation", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "neededRole", - "type": "bytes32" - } - ], - "name": "AccessControlUnauthorizedAccount", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "isAllowed", - "type": "bool" - } - ], - "name": "AllowedVestedTargetUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "bondAmount", - "type": "uint256" - } - ], - "name": "BondAmountUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "newDelegationLimitCoefficientInBP", - "type": "uint256" - } - ], - "name": "DelegationLimitCoefficientInBPUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint128", - "name": "epochLength", - "type": "uint128" - } - ], - "name": "EpochLengthUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "previousAdminRole", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "newAdminRole", - "type": "bytes32" - } - ], - "name": "RoleAdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleGranted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleRevoked", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint128", - "name": "storagePerWorkerInGb", - "type": "uint128" - } - ], - "name": "StoragePerWorkerInGbUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "target", - "type": "uint256" - } - ], - "name": "TargetCapacityUpdated", - "type": "event" - }, - { - "inputs": [ - - ], - "name": "DEFAULT_ADMIN_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - - ], - "name": "bondAmount", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - - ], - "name": "delegationLimit", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - - ], - "name": "delegationLimitCoefficientInBP", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - - ], - "name": "epochLength", - "outputs": [ - { - "internalType": "uint128", - "name": "", - "type": "uint128" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - - ], - "name": "epochNumber", - "outputs": [ - { - "internalType": "uint128", - "name": "", - "type": "uint128" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - - ], - "name": "firstEpochBlock", - "outputs": [ - { - "internalType": "uint128", - "name": "", - "type": "uint128" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - } - ], - "name": "getRoleAdmin", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "grantRole", - "outputs": [ - - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "hasRole", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "isAllowedVestedTarget", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - - ], - "name": "nextEpoch", - "outputs": [ - { - "internalType": "uint128", - "name": "", - "type": "uint128" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "callerConfirmation", - "type": "address" - } - ], - "name": "renounceRole", - "outputs": [ - - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "revokeRole", - "outputs": [ - - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "bool", - "name": "isAllowed", - "type": "bool" - } - ], - "name": "setAllowedVestedTarget", - "outputs": [ - - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_bondAmount", - "type": "uint256" - } - ], - "name": "setBondAmount", - "outputs": [ - - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_delegationLimitCoefficientInBP", - "type": "uint256" - } - ], - "name": "setDelegationLimitCoefficient", - "outputs": [ - - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint128", - "name": "_epochLength", - "type": "uint128" - } - ], - "name": "setEpochLength", - "outputs": [ - - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint128", - "name": "_storagePerWorkerInGb", - "type": "uint128" - } - ], - "name": "setStoragePerWorkerInGb", - "outputs": [ - - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "target", - "type": "uint256" - } - ], - "name": "setTargetCapacity", - "outputs": [ - - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - - ], - "name": "storagePerWorkerInGb", - "outputs": [ - { - "internalType": "uint128", - "name": "", - "type": "uint128" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes4", - "name": "interfaceId", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - - ], - "name": "targetCapacityGb", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } -] \ No newline at end of file diff --git a/crates/contract-client/abi/Strategy.json b/crates/contract-client/abi/Strategy.json deleted file mode 100644 index f2351dd..0000000 --- a/crates/contract-client/abi/Strategy.json +++ /dev/null @@ -1,72 +0,0 @@ -[ - { - "inputs":[ - { - "internalType":"contract IRouter", - "name":"_router", - "type":"address" - }, - { - "internalType":"contract IGatewayRegistry", - "name":"_gatewayRegistry", - "type":"address" - } - ], - "stateMutability":"nonpayable", - "type":"constructor" - }, - { - "inputs":[ - { - "internalType":"bytes", - "name":"gatewayId", - "type":"bytes" - }, - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "name":"computationUnitsPerEpoch", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"gatewayRegistry", - "outputs":[ - { - "internalType":"contract IGatewayRegistry", - "name":"", - "type":"address" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"router", - "outputs":[ - { - "internalType":"contract IRouter", - "name":"", - "type":"address" - } - ], - "stateMutability":"view", - "type":"function" - } -] diff --git a/crates/contract-client/abi/WorkerRegistration.json b/crates/contract-client/abi/WorkerRegistration.json deleted file mode 100644 index 930d1fb..0000000 --- a/crates/contract-client/abi/WorkerRegistration.json +++ /dev/null @@ -1,693 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "contract IERC20", - "name": "_tSQD", - "type": "address" - }, - { - "internalType": "contract IRouter", - "name": "_router", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "workerId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "ExcessiveBondReturned", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "previousAdminRole", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "newAdminRole", - "type": "bytes32" - } - ], - "name": "RoleAdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleGranted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleRevoked", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "workerId", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "deregistedAt", - "type": "uint256" - } - ], - "name": "WorkerDeregistered", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "workerId", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "bytes", - "name": "peerId", - "type": "bytes" - }, - { - "indexed": true, - "internalType": "address", - "name": "registrar", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "registeredAt", - "type": "uint256" - } - ], - "name": "WorkerRegistered", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "workerId", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "WorkerWithdrawn", - "type": "event" - }, - { - "inputs": [], - "name": "DEFAULT_ADMIN_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "activeStake", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "activeWorkerIds", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "bondAmount", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "peerId", - "type": "bytes" - } - ], - "name": "deregister", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "effectiveTVL", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "epochLength", - "outputs": [ - { - "internalType": "uint128", - "name": "", - "type": "uint128" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getActiveWorkerCount", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getActiveWorkerIds", - "outputs": [ - { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getActiveWorkers", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "creator", - "type": "address" - }, - { - "internalType": "bytes", - "name": "peerId", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "bond", - "type": "uint256" - }, - { - "internalType": "uint128", - "name": "registeredAt", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "deregisteredAt", - "type": "uint128" - } - ], - "internalType": "struct WorkerRegistration.Worker[]", - "name": "", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getAllWorkersCount", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "getOwnedWorkers", - "outputs": [ - { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - } - ], - "name": "getRoleAdmin", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "index", - "type": "uint256" - } - ], - "name": "getWorkerByIndex", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "creator", - "type": "address" - }, - { - "internalType": "bytes", - "name": "peerId", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "bond", - "type": "uint256" - }, - { - "internalType": "uint128", - "name": "registeredAt", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "deregisteredAt", - "type": "uint128" - } - ], - "internalType": "struct WorkerRegistration.Worker", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "grantRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "hasRole", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "lockPeriod", - "outputs": [ - { - "internalType": "uint128", - "name": "", - "type": "uint128" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "nextEpoch", - "outputs": [ - { - "internalType": "uint128", - "name": "", - "type": "uint128" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "peerId", - "type": "bytes" - } - ], - "name": "register", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "renounceRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "peerId", - "type": "bytes" - } - ], - "name": "returnExcessiveBond", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "revokeRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "router", - "outputs": [ - { - "internalType": "contract IRouter", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes4", - "name": "interfaceId", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "tSQD", - "outputs": [ - { - "internalType": "contract IERC20", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "peerId", - "type": "bytes" - } - ], - "name": "withdraw", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "peerId", - "type": "bytes" - } - ], - "name": "workerIds", - "outputs": [ - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "workers", - "outputs": [ - { - "internalType": "address", - "name": "creator", - "type": "address" - }, - { - "internalType": "bytes", - "name": "peerId", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "bond", - "type": "uint256" - }, - { - "internalType": "uint128", - "name": "registeredAt", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "deregisteredAt", - "type": "uint128" - } - ], - "stateMutability": "view", - "type": "function" - } - ] \ No newline at end of file diff --git a/crates/contract-client/examples/get_active_workers.rs b/crates/contract-client/examples/get_active_workers.rs deleted file mode 100644 index 96dd2bd..0000000 --- a/crates/contract-client/examples/get_active_workers.rs +++ /dev/null @@ -1,26 +0,0 @@ -use simple_logger::SimpleLogger; - -use contract_client; -use contract_client::RpcArgs; - -#[tokio::main] -async fn main() -> anyhow::Result<()> { - SimpleLogger::new() - .with_level(log::LevelFilter::Info) - .env() - .init()?; - - let rpc_url = std::env::args() - .nth(1) - .unwrap_or("http://127.0.0.1:8545/".to_string()); - let l1_rpc_url = std::env::args().nth(2); - - let client = contract_client::get_client(&RpcArgs { - rpc_url, - l1_rpc_url, - }) - .await?; - let workers = client.active_workers().await?; - workers.iter().for_each(|w| println!("{w:?}")); - Ok(()) -} diff --git a/crates/contract-client/examples/get_allocations.rs b/crates/contract-client/examples/get_allocations.rs deleted file mode 100644 index 8c373d2..0000000 --- a/crates/contract-client/examples/get_allocations.rs +++ /dev/null @@ -1,27 +0,0 @@ -use clap::Parser; -use simple_logger::SimpleLogger; -use subsquid_network_transport::PeerId; - -use contract_client; -use contract_client::RpcArgs; - -#[derive(Parser)] -struct Cli { - #[command(flatten)] - rpc: RpcArgs, - client_id: PeerId, -} - -#[tokio::main] -async fn main() -> anyhow::Result<()> { - SimpleLogger::new() - .with_level(log::LevelFilter::Info) - .env() - .init()?; - let cli: Cli = Cli::parse(); - - let client = contract_client::get_client(&cli.rpc).await?; - let allocations = client.current_allocations(cli.client_id, None).await?; - allocations.iter().for_each(|w| println!("{w:?}")); - Ok(()) -} diff --git a/crates/contract-client/examples/get_gateways.rs b/crates/contract-client/examples/get_gateways.rs deleted file mode 100644 index 727cd98..0000000 --- a/crates/contract-client/examples/get_gateways.rs +++ /dev/null @@ -1,28 +0,0 @@ -use clap::Parser; -use simple_logger::SimpleLogger; -use subsquid_network_transport::PeerId; - -use contract_client; -use contract_client::RpcArgs; - -#[derive(Parser)] -struct Cli { - #[command(flatten)] - rpc: RpcArgs, - worker_id: PeerId, -} - -#[tokio::main] -async fn main() -> anyhow::Result<()> { - SimpleLogger::new() - .with_level(log::LevelFilter::Info) - .env() - .init()?; - let cli = Cli::parse(); - - let client = contract_client::get_client(&cli.rpc).await?; - let on_chain_id = client.worker_id(cli.worker_id).await?; - let clusters = client.all_gateways(on_chain_id).await?; - clusters.iter().for_each(|c| println!("{c:?}")); - Ok(()) -} diff --git a/crates/contract-client/src/cli.rs b/crates/contract-client/src/cli.rs deleted file mode 100644 index 5e19c90..0000000 --- a/crates/contract-client/src/cli.rs +++ /dev/null @@ -1,36 +0,0 @@ -use clap::Args; - -use crate::Address; - -#[derive(Args)] -pub struct RpcArgs { - #[arg( - long, - env, - help = "Blockchain RPC URL", - default_value = "http://127.0.0.1:8545/" - )] - pub rpc_url: String, - #[arg( - long, - env, - help = "Layer 1 blockchain RPC URL. If not provided, rpc_url is assumed to be L1" - )] - pub l1_rpc_url: Option, - #[command(flatten)] - pub contract_addrs: ContractAddrs, -} - -#[derive(Args)] -pub struct ContractAddrs { - #[arg(long, env)] - pub gateway_registry_contract_addr: Address, - #[arg(long, env)] - pub worker_registration_contract_addr: Address, - #[arg(long, env)] - pub network_controller_contract_addr: Address, - #[arg(long, env)] - pub allocations_viewer_contract_addr: Address, - #[arg(long, env)] - pub multicall_contract_addr: Option
, -} diff --git a/crates/contract-client/src/client.rs b/crates/contract-client/src/client.rs deleted file mode 100644 index bf3a6d1..0000000 --- a/crates/contract-client/src/client.rs +++ /dev/null @@ -1,357 +0,0 @@ -use std::collections::HashMap; -use std::iter::zip; -use std::sync::Arc; -use std::time::{Duration, SystemTime, UNIX_EPOCH}; - -use async_trait::async_trait; -use ethers::prelude::{BlockId, Bytes, JsonRpcClient, Middleware, Multicall, Provider}; -use subsquid_network_transport::PeerId; - -use crate::cli::ContractAddrs; -use crate::contracts::{ - AllocationsViewer, GatewayRegistry, NetworkController, Strategy, WorkerRegistration, -}; -use crate::transport::Transport; -use crate::{contracts, Address, ClientError, RpcArgs, U256}; - -#[derive(Debug, Clone)] -pub struct Allocation { - pub worker_peer_id: PeerId, - pub worker_onchain_id: U256, - pub computation_units: U256, -} - -#[derive(Debug, Clone)] -pub struct GatewayCluster { - pub operator_addr: Address, - pub gateway_ids: Vec, - pub allocated_computation_units: U256, -} - -#[derive(Debug, Clone, Eq, PartialEq)] -pub struct Worker { - pub peer_id: PeerId, - pub onchain_id: U256, - pub address: Address, - pub bond: U256, - pub registered_at: u128, - pub deregistered_at: Option, -} - -impl Worker { - fn new(worker: contracts::Worker, onchain_id: U256) -> Result { - let peer_id = PeerId::from_bytes(&worker.peer_id)?; - let deregistered_at = (worker.deregistered_at > 0).then_some(worker.deregistered_at); - Ok(Self { - peer_id, - onchain_id, - address: worker.creator, - bond: worker.bond, - registered_at: worker.registered_at, - deregistered_at, - }) - } -} - -#[async_trait] -pub trait Client: Send + Sync { - /// Using regular clone is not possible for trait objects - fn clone_client(&self) -> Box; - - /// Get the current epoch number - async fn current_epoch(&self) -> Result; - - /// Get the time when the current epoch started - async fn current_epoch_start(&self) -> Result; - - /// Get the on-chain ID for the worker - async fn worker_id(&self, peer_id: PeerId) -> Result; - - /// Get current active worker set - async fn active_workers(&self) -> Result, ClientError>; - - /// Check if client is registered on chain - async fn is_client_registered(&self, client_id: PeerId) -> Result; - - /// Get client's allocations for the current epoch. - async fn current_allocations( - &self, - client_id: PeerId, - worker_ids: Option>, - ) -> Result, ClientError>; - - /// Get the current list of all gateway clusters with their allocated CUs - async fn all_gateways(&self, worker_id: U256) -> Result, ClientError>; -} - -pub async fn get_client( - RpcArgs { - rpc_url, - l1_rpc_url, - contract_addrs, - }: &RpcArgs, -) -> Result, ClientError> { - let l1_transport = match l1_rpc_url { - None => None, - Some(rpc_url) => Some(Transport::connect(rpc_url).await?), - }; - let l2_transport = Transport::connect(rpc_url).await?; - - match (l1_transport, l2_transport) { - (None, Transport::Http(provider)) => { - log::warn!("Layer 1 RPC URL not provided. Assuming the main RPC URL is L1"); - let client = Arc::new(provider); - Ok(RpcProvider::new(client.clone(), client, contract_addrs).await?) - } - (None, Transport::Ws(provider)) => { - log::warn!("Layer 1 RPC URL not provided. Assuming the main RPC URL is L1"); - let client = Arc::new(provider); - Ok(RpcProvider::new(client.clone(), client, contract_addrs).await?) - } - (Some(Transport::Http(l1_provider)), Transport::Http(l2_provider)) => { - let (l1_client, l2_client) = (Arc::new(l1_provider), Arc::new(l2_provider)); - Ok(RpcProvider::new(l1_client, l2_client, contract_addrs).await?) - } - (Some(Transport::Http(l1_provider)), Transport::Ws(l2_provider)) => { - let (l1_client, l2_client) = (Arc::new(l1_provider), Arc::new(l2_provider)); - Ok(RpcProvider::new(l1_client, l2_client, contract_addrs).await?) - } - (Some(Transport::Ws(l1_provider)), Transport::Http(l2_provider)) => { - let (l1_client, l2_client) = (Arc::new(l1_provider), Arc::new(l2_provider)); - Ok(RpcProvider::new(l1_client, l2_client, contract_addrs).await?) - } - (Some(Transport::Ws(l1_provider)), Transport::Ws(l2_provider)) => { - let (l1_client, l2_client) = (Arc::new(l1_provider), Arc::new(l2_provider)); - Ok(RpcProvider::new(l1_client, l2_client, contract_addrs).await?) - } - } -} - -#[derive(Clone)] -struct RpcProvider { - l1_client: Arc>, - l2_client: Arc>, - gateway_registry: GatewayRegistry>, - network_controller: NetworkController>, - worker_registration: WorkerRegistration>, - allocations_viewer: AllocationsViewer>, - default_strategy_addr: Address, - multicall_contract_addr: Option
, -} - -impl RpcProvider -where - L1: JsonRpcClient + Clone + 'static, - L2: JsonRpcClient + Clone + 'static, -{ - pub async fn new( - l1_client: Arc>, - l2_client: Arc>, - contract_addrs: &ContractAddrs, - ) -> Result, ClientError> { - let gateway_registry = GatewayRegistry::get( - l2_client.clone(), - contract_addrs.gateway_registry_contract_addr, - ); - let default_strategy_addr = gateway_registry.default_strategy().call().await?; - let network_controller = NetworkController::get( - l2_client.clone(), - contract_addrs.network_controller_contract_addr, - ); - let worker_registration = WorkerRegistration::get( - l2_client.clone(), - contract_addrs.worker_registration_contract_addr, - ); - let allocations_viewer = AllocationsViewer::get( - l2_client.clone(), - contract_addrs.allocations_viewer_contract_addr, - ); - Ok(Box::new(Self { - l1_client, - l2_client, - gateway_registry, - worker_registration, - network_controller, - allocations_viewer, - default_strategy_addr, - multicall_contract_addr: contract_addrs.multicall_contract_addr, - })) - } - - async fn multicall(&self) -> Result>, ClientError> { - Ok(contracts::multicall(self.l2_client.clone(), self.multicall_contract_addr).await?) - } -} - -#[async_trait] -impl Client for RpcProvider -where - L1: JsonRpcClient + Clone + 'static, - L2: JsonRpcClient + Clone + 'static, -{ - fn clone_client(&self) -> Box { - Box::new(self.clone()) - } - - async fn current_epoch(&self) -> Result { - let epoch = self - .network_controller - .epoch_number() - .call() - .await? - .try_into() - .expect("Epoch number should not exceed u32 range"); - Ok(epoch) - } - - async fn current_epoch_start(&self) -> Result { - let next_epoch_start_block = self.network_controller.next_epoch().call().await?; - let epoch_length_blocks = self.network_controller.epoch_length().call().await?; - let block_num: u64 = (next_epoch_start_block - epoch_length_blocks) - .try_into() - .expect("Epoch number should not exceed u64 range"); - log::debug!("Current epoch: {block_num} Epoch length: {epoch_length_blocks} Next epoch: {next_epoch_start_block}"); - // Blocks returned by `next_epoch()` and `epoch_length()` are **L1 blocks** - let block = self - .l1_client - .get_block(BlockId::Number(block_num.into())) - .await? - .ok_or(ClientError::BlockNotFound)?; - Ok(UNIX_EPOCH + Duration::from_secs(block.timestamp.as_u64())) - } - - async fn worker_id(&self, peer_id: PeerId) -> Result { - let peer_id = peer_id.to_bytes().into(); - let id: U256 = self.worker_registration.worker_ids(peer_id).call().await?; - Ok(id) - } - - async fn active_workers(&self) -> Result, ClientError> { - let workers_call = self.worker_registration.method("getActiveWorkers", ())?; - let onchain_ids_call = self.worker_registration.method("getActiveWorkerIds", ())?; - let mut multicall = self.multicall().await?; - multicall - .add_call::>(workers_call, false) - .add_call::>(onchain_ids_call, false); - let (workers, onchain_ids): (Vec, Vec) = multicall.call().await?; - - let workers = workers - .into_iter() - .zip(onchain_ids) - .filter_map( - |(worker, onchain_id)| match Worker::new(worker, onchain_id) { - Ok(worker) => Some(worker), - Err(e) => { - log::debug!("Error reading worker from chain: {e:?}"); - None - } - }, - ) - .collect(); - Ok(workers) - } - - async fn is_client_registered(&self, client_id: PeerId) -> Result { - let client_id = client_id.to_bytes().into(); - let gateway_info: contracts::Gateway = - self.gateway_registry.get_gateway(client_id).call().await?; - Ok(gateway_info.operator != Address::zero()) - } - - async fn current_allocations( - &self, - client_id: PeerId, - workers: Option>, - ) -> Result, ClientError> { - let workers = match workers { - Some(workers) => workers, - None => self.active_workers().await?, - }; - if workers.is_empty() { - return Ok(vec![]); - } - - let gateway_id: Bytes = client_id.to_bytes().into(); - let strategy_addr = self - .gateway_registry - .get_used_strategy(gateway_id.clone()) - .call() - .await?; - let strategy = Strategy::get(strategy_addr, self.l2_client.clone()); - - // A little hack to make less requests: default strategy distributes CUs evenly, - // so we can just query for one worker and return the same number for all. - if strategy_addr == self.default_strategy_addr { - let first_worker_id = workers.first().expect("non empty").onchain_id; - let cus_per_epoch = strategy - .computation_units_per_epoch(gateway_id, first_worker_id) - .call() - .await?; - return Ok(workers - .into_iter() - .map(|w| Allocation { - worker_peer_id: w.peer_id, - worker_onchain_id: w.onchain_id, - computation_units: cus_per_epoch, - }) - .collect()); - } - - let mut multicall = self.multicall().await?; - for worker in workers.iter() { - multicall.add_call::( - strategy.method( - "computationUnitsPerEpoch", - (gateway_id.clone(), worker.onchain_id), - )?, - false, - ); - } - let compute_units: Vec = multicall.call_array().await?; - Ok(zip(workers, compute_units) - .map(|(w, cus)| Allocation { - worker_peer_id: w.peer_id, - worker_onchain_id: w.onchain_id, - computation_units: cus, - }) - .collect()) - } - - async fn all_gateways(&self, worker_id: U256) -> Result, ClientError> { - const GATEWAYS_PAGE_SIZE: U256 = U256([10000, 0, 0, 0]); - - let latest_block = self.l2_client.get_block_number().await?; - - let mut clusters = HashMap::new(); - for page in 0.. { - let allocations = self - .allocations_viewer - .get_allocations(worker_id, page.into(), GATEWAYS_PAGE_SIZE) - .block(latest_block) - .call() - .await?; - let page_size = U256::from(allocations.len()); - - for allocation in allocations { - let gateway_peer_id = match PeerId::from_bytes(&allocation.gateway_id) { - Ok(peer_id) => peer_id, - _ => continue, - }; - clusters - .entry(allocation.operator) - .or_insert_with(|| GatewayCluster { - operator_addr: allocation.operator, - gateway_ids: Vec::new(), - allocated_computation_units: allocation.allocated, - }) - .gateway_ids - .push(gateway_peer_id); - } - - if page_size < GATEWAYS_PAGE_SIZE { - break; - } - } - Ok(clusters.into_values().collect()) - } -} diff --git a/crates/contract-client/src/contracts.rs b/crates/contract-client/src/contracts.rs deleted file mode 100644 index a545de4..0000000 --- a/crates/contract-client/src/contracts.rs +++ /dev/null @@ -1,52 +0,0 @@ -use ethers::contract::abigen; -use ethers::prelude::{Multicall, MulticallError}; -use ethers::providers::Middleware; -use std::sync::Arc; - -use crate::Address; - -pub use gateway_registry::Gateway; -pub use worker_registration::Worker; - -abigen!(GatewayRegistry, "abi/GatewayRegistry.json"); -abigen!(NetworkController, "abi/NetworkController.json"); -abigen!(Strategy, "abi/Strategy.json"); -abigen!(WorkerRegistration, "abi/WorkerRegistration.json"); -abigen!(AllocationsViewer, "abi/AllocationsViewer.json"); - -impl GatewayRegistry { - pub fn get(client: Arc, addr: Address) -> Self { - Self::new(addr, client) - } -} - -impl WorkerRegistration { - pub fn get(client: Arc, addr: Address) -> Self { - Self::new(addr, client) - } -} - -impl NetworkController { - pub fn get(client: Arc, addr: Address) -> Self { - Self::new(addr, client) - } -} - -impl AllocationsViewer { - pub fn get(client: Arc, addr: Address) -> Self { - Self::new(addr, client) - } -} - -impl Strategy { - pub fn get(addr: impl Into
, client: Arc) -> Self { - Self::new(addr, client) - } -} - -pub async fn multicall( - client: Arc, - addr: Option
, -) -> Result, MulticallError> { - Multicall::new(client, addr).await -} diff --git a/crates/contract-client/src/error.rs b/crates/contract-client/src/error.rs deleted file mode 100644 index 6551391..0000000 --- a/crates/contract-client/src/error.rs +++ /dev/null @@ -1,39 +0,0 @@ -use ethers::contract::{ContractError, MulticallError}; -use ethers::prelude::{AbiError, Middleware}; -use subsquid_network_transport::IdParseError; - -#[derive(Debug, thiserror::Error)] -pub enum ClientError { - #[error("Invalid RPC URL: {0:?}")] - InvalidRpcUrl(#[from] url::ParseError), - #[error("Invalid Peer ID: {0:?}")] - InvalidPeerId(#[from] IdParseError), - #[error("Contract error: {0}")] - Contract(String), - #[error("RPC provider error: {0}")] - Provider(#[from] ethers::providers::ProviderError), - #[error("Unsupported RPC protocol")] - InvalidProtocol, - #[error("Transaction receipt missing")] - TxReceiptMissing, - #[error("Block not found")] - BlockNotFound, -} - -impl From> for ClientError { - fn from(err: ContractError) -> Self { - Self::Contract(err.to_string()) - } -} - -impl From> for ClientError { - fn from(err: MulticallError) -> Self { - Self::Contract(err.to_string()) - } -} - -impl From for ClientError { - fn from(err: AbiError) -> Self { - Self::Contract(err.to_string()) - } -} diff --git a/crates/contract-client/src/lib.rs b/crates/contract-client/src/lib.rs deleted file mode 100644 index 85a6bb8..0000000 --- a/crates/contract-client/src/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -mod cli; -mod client; -mod contracts; -mod error; -mod transport; - -pub use ethers::types::{Address, U256}; - -pub use cli::RpcArgs; -pub use client::{get_client, Allocation, Client, GatewayCluster, Worker}; -pub use error::ClientError; diff --git a/crates/contract-client/src/transport.rs b/crates/contract-client/src/transport.rs deleted file mode 100644 index fdea136..0000000 --- a/crates/contract-client/src/transport.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::ClientError; -use ethers::prelude::{Http, Provider, Ws}; - -pub enum Transport { - Http(Provider), - Ws(Provider), -} - -impl Transport { - pub async fn connect(rpc_url: &str) -> Result { - if rpc_url.starts_with("http") { - Ok(Transport::Http(Provider::try_from(rpc_url)?)) - } else if rpc_url.starts_with("ws") { - Ok(Transport::Ws(Provider::connect(rpc_url).await?)) - } else { - Err(ClientError::InvalidProtocol) - } - } -} diff --git a/crates/logs-collector/Cargo.toml b/crates/logs-collector/Cargo.toml index ad6675d..1c936fb 100644 --- a/crates/logs-collector/Cargo.toml +++ b/crates/logs-collector/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "logs-collector" -version = "0.4.4" +version = "1.0.0-rc1" edition = "2021" [dependencies] @@ -17,6 +17,6 @@ serde_json = "1" serde_repr = "0.1" tokio = { version = "1", features = ["full"] } -contract-client = { version = "0.1", path = "../contract-client" } +contract-client = { workspace = true } subsquid-messages = { workspace = true } subsquid-network-transport = { workspace = true, features = ["logs-collector"] } diff --git a/crates/logs-collector/src/cli.rs b/crates/logs-collector/src/cli.rs index ffac1cb..dfc31eb 100644 --- a/crates/logs-collector/src/cli.rs +++ b/crates/logs-collector/src/cli.rs @@ -1,5 +1,4 @@ use clap::{Args, Parser}; -use contract_client::RpcArgs; use subsquid_network_transport::TransportArgs; #[derive(Args)] @@ -23,9 +22,6 @@ pub struct Cli { #[command(flatten)] pub clickhouse: ClickhouseArgs, - #[command(flatten)] - pub rpc: RpcArgs, - #[arg( long, env, diff --git a/crates/logs-collector/src/main.rs b/crates/logs-collector/src/main.rs index 10513a9..d242c2c 100644 --- a/crates/logs-collector/src/main.rs +++ b/crates/logs-collector/src/main.rs @@ -26,12 +26,11 @@ async fn main() -> anyhow::Result<()> { // Build P2P transport let transport_builder = P2PTransportBuilder::from_cli(args.transport).await?; + let contract_client: Arc = + transport_builder.contract_client().into(); let (incoming_messages, transport_handle) = transport_builder.build_logs_collector(Default::default())?; - let contract_client: Arc = - contract_client::get_client(&args.rpc).await?.into(); - let storage = ClickhouseStorage::new(args.clickhouse).await?; let epoch_seal_timeout = Duration::from_secs(args.epoch_seal_timeout_sec as u64); let logs_collector = LogsCollector::new(storage, contract_client.clone(), epoch_seal_timeout); diff --git a/crates/network-scheduler/Cargo.toml b/crates/network-scheduler/Cargo.toml index a8de815..5c03e48 100644 --- a/crates/network-scheduler/Cargo.toml +++ b/crates/network-scheduler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "network-scheduler" -version = "0.4.5" +version = "1.0.0-rc1" edition = "2021" [dependencies] @@ -34,6 +34,6 @@ sha3 = "0.10" tokio = { version = "1", features = ["full"] } url = "2.5.0" -contract-client = { version = "0.1", path = "../contract-client" } +contract-client = { workspace = true } subsquid-messages = { workspace = true, features = ["semver"] } subsquid-network-transport = { workspace = true, features = ["scheduler", "metrics"] } diff --git a/crates/network-scheduler/src/cli.rs b/crates/network-scheduler/src/cli.rs index 2164617..4e771d0 100644 --- a/crates/network-scheduler/src/cli.rs +++ b/crates/network-scheduler/src/cli.rs @@ -3,7 +3,6 @@ use std::path::PathBuf; use std::time::Duration; use clap::Parser; -use contract_client::RpcArgs; use serde::{Deserialize, Serialize}; use serde_with::{serde_as, DurationSeconds}; use tokio::sync::OnceCell; @@ -69,9 +68,6 @@ pub struct Cli { #[command(flatten)] pub transport: TransportArgs, - #[command(flatten)] - pub rpc: RpcArgs, - #[arg( long, env, diff --git a/crates/network-scheduler/src/main.rs b/crates/network-scheduler/src/main.rs index 9d7f033..5be5670 100644 --- a/crates/network-scheduler/src/main.rs +++ b/crates/network-scheduler/src/main.rs @@ -37,6 +37,7 @@ async fn main() -> anyhow::Result<()> { // Build P2P transport let transport_builder = P2PTransportBuilder::from_cli(args.transport).await?; + let contract_client: Box = transport_builder.contract_client(); let local_peer_id = transport_builder.local_peer_id(); let (incoming_messages, transport_handle) = transport_builder.build_scheduler(Default::default())?; @@ -45,7 +46,6 @@ async fn main() -> anyhow::Result<()> { let storage = S3Storage::new(local_peer_id).await; let incoming_units = storage.get_incoming_units().await; let scheduler = storage.load_scheduler().await?; - let contract_client = contract_client::get_client(&args.rpc).await?; Server::new( incoming_messages, diff --git a/crates/query-gateway/Cargo.toml b/crates/query-gateway/Cargo.toml index b036c4c..df3bc23 100644 --- a/crates/query-gateway/Cargo.toml +++ b/crates/query-gateway/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "query-gateway" -version = "0.4.4" +version = "1.0.0-rc1" edition = "2021" [dependencies] @@ -28,6 +28,6 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread", "signal"] } tokio-rusqlite = "0.5" uuid = { version = "1", features = ["v4", "fast-rng"] } -contract-client = { version = "0.1", path = "../contract-client" } +contract-client = { workspace = true } subsquid-messages = { workspace = true, features = ["semver"] } subsquid-network-transport = { workspace = true, features = ["gateway"] } diff --git a/crates/query-gateway/src/main.rs b/crates/query-gateway/src/main.rs index 6ac2e90..849b46a 100644 --- a/crates/query-gateway/src/main.rs +++ b/crates/query-gateway/src/main.rs @@ -3,7 +3,6 @@ use std::path::PathBuf; use std::sync::Arc; use clap::Parser; -use contract_client::RpcArgs; use env_logger::Env; use subsquid_network_transport::TransportArgs; @@ -31,9 +30,6 @@ struct Cli { #[command(flatten)] pub transport: TransportArgs, - #[command(flatten)] - pub rpc: RpcArgs, - #[arg( long, env = "HTTP_LISTEN_ADDR", @@ -64,14 +60,14 @@ async fn main() -> anyhow::Result<()> { // Build P2P transport let transport_builder = P2PTransportBuilder::from_cli(args.transport).await?; + let contract_client = transport_builder.contract_client(); let local_peer_id = transport_builder.local_peer_id(); let (incoming_messages, transport_handle) = transport_builder.build_gateway(GatewayConfig::new(Config::get().logs_collector_id))?; // Instantiate contract client and check RPC connection - let contract_client = contract_client::get_client(&args.rpc).await?; anyhow::ensure!( - contract_client.is_client_registered(local_peer_id).await?, + contract_client.is_gateway_registered(local_peer_id).await?, "Client not registered on chain" );