From dee55c9077a4dbc3e9fcc5f4a629589b55641757 Mon Sep 17 00:00:00 2001 From: jeff <113397187+cyberhorsey@users.noreply.github.com> Date: Fri, 30 Jun 2023 17:55:18 -0700 Subject: [PATCH] feat(eventindexer): Alpha 4 event indexing (#14078) --- go.mod | 2 + go.sum | 4 + packages/eventindexer/.golangci.yml | 8 +- packages/eventindexer/ProverPool.json | 684 ++++++ packages/eventindexer/cli/cli.go | 11 +- .../contracts/proverpool/ProverPool.go | 1982 +++++++++++++++++ packages/eventindexer/event.go | 19 +- packages/eventindexer/http/cache.go | 9 + .../eventindexer/http/get_current_provers.go | 60 + packages/eventindexer/http/get_pos_stats.go | 56 + .../eventindexer/http/get_pos_stats_test.go | 50 + packages/eventindexer/http/get_stats.go | 24 +- .../eventindexer/http/get_unique_proposers.go | 23 +- .../eventindexer/http/get_unique_provers.go | 23 +- packages/eventindexer/http/routes.go | 1 + packages/eventindexer/http/server.go | 46 +- packages/eventindexer/http/server_test.go | 3 + .../indexer/filter_then_subscribe.go | 10 + .../indexer/save_block_proven_event.go | 8 +- .../indexer/save_slashed_event.go | 65 + packages/eventindexer/indexer/service.go | 24 +- .../1666650599_create_events_table.sql | 7 +- .../eventindexer/mock/event_repository.go | 7 + packages/eventindexer/prometheus.go | 8 + packages/eventindexer/repo/containers_test.go | 2 +- packages/eventindexer/repo/event.go | 40 + packages/eventindexer/repo/event_test.go | 49 + 27 files changed, 3174 insertions(+), 51 deletions(-) create mode 100644 packages/eventindexer/ProverPool.json create mode 100644 packages/eventindexer/contracts/proverpool/ProverPool.go create mode 100644 packages/eventindexer/http/cache.go create mode 100644 packages/eventindexer/http/get_current_provers.go create mode 100644 packages/eventindexer/http/get_pos_stats.go create mode 100644 packages/eventindexer/http/get_pos_stats_test.go create mode 100644 packages/eventindexer/indexer/save_slashed_event.go diff --git a/go.mod b/go.mod index 18d17b45c80..c1281095dc3 100644 --- a/go.mod +++ b/go.mod @@ -81,11 +81,13 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect github.com/opencontainers/runc v1.1.5 // indirect + github.com/patrickmn/go-cache v2.1.0+incompatible // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.39.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect + github.com/shopspring/decimal v1.3.1 // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/tklauser/go-sysconf v0.3.5 // indirect github.com/tklauser/numcpus v0.2.2 // indirect diff --git a/go.sum b/go.sum index e298e030acd..ebc49e81aae 100644 --- a/go.sum +++ b/go.sum @@ -752,6 +752,8 @@ github.com/opencontainers/selinux v1.6.0/go.mod h1:VVGKuOLlE7v4PJyT6h7mNWvq1rzqi github.com/opencontainers/selinux v1.8.0/go.mod h1:RScLhm78qiWa2gbVCcGkC7tCGdgk3ogry1nUQF8Evvo= github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8= github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= +github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= +github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= @@ -825,6 +827,8 @@ github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1 github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= +github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= diff --git a/packages/eventindexer/.golangci.yml b/packages/eventindexer/.golangci.yml index a58135057de..d60a818b118 100644 --- a/packages/eventindexer/.golangci.yml +++ b/packages/eventindexer/.golangci.yml @@ -28,12 +28,12 @@ linters: linters-settings: funlen: - lines: 137 - statements: 54 + lines: 200 + statements: 100 gocognit: - min-complexity: 43 + min-complexity: 60 lll: - line-length: 140 + line-length: 150 issues: exclude-rules: diff --git a/packages/eventindexer/ProverPool.json b/packages/eventindexer/ProverPool.json new file mode 100644 index 00000000000..13047c9fb00 --- /dev/null +++ b/packages/eventindexer/ProverPool.json @@ -0,0 +1,684 @@ +[ + { + "inputs": [], + "name": "INVALID_PARAMS", + "type": "error" + }, + { + "inputs": [], + "name": "NO_MATURE_EXIT", + "type": "error" + }, + { + "inputs": [], + "name": "PROVER_NOT_GOOD_ENOUGH", + "type": "error" + }, + { + "inputs": [], + "name": "RESOLVER_DENIED", + "type": "error" + }, + { + "inputs": [], + "name": "RESOLVER_INVALID_ADDR", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + } + ], + "name": "RESOLVER_ZERO_ADDR", + "type": "error" + }, + { + "inputs": [], + "name": "UNAUTHORIZED", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "addressManager", + "type": "address" + } + ], + "name": "AddressManagerChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "amount", + "type": "uint64" + } + ], + "name": "Exited", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "amount", + "type": "uint64" + } + ], + "name": "Slashed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "amount", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "rewardPerGas", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "currentCapacity", + "type": "uint16" + } + ], + "name": "Staked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "amount", + "type": "uint64" + } + ], + "name": "Withdrawn", + "type": "event" + }, + { + "inputs": [], + "name": "EXIT_PERIOD", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_CAPACITY_LOWER_BOUND", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_NUM_PROVERS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIN_SLASH_AMOUNT", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MIN_STAKE_PER_CAPACITY", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SLASH_POINTS", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "addressManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "blockId", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "name": "assignProver", + "outputs": [ + { + "internalType": "address", + "name": "prover", + "type": "address" + }, + { + "internalType": "uint32", + "name": "rewardPerGas", + "type": "uint32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "exit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getCapacity", + "outputs": [ + { + "internalType": "uint256", + "name": "capacity", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getProvers", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "stakedAmount", + "type": "uint64" + }, + { + "internalType": "uint16", + "name": "rewardPerGas", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "currentCapacity", + "type": "uint16" + }, + { + "internalType": "uint64", + "name": "weight", + "type": "uint64" + } + ], + "internalType": "struct ProverPool.Prover[]", + "name": "_provers", + "type": "tuple[]" + }, + { + "internalType": "address[]", + "name": "_stakers", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "getStaker", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "exitRequestedAt", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "exitAmount", + "type": "uint64" + }, + { + "internalType": "uint16", + "name": "maxCapacity", + "type": "uint16" + }, + { + "internalType": "uint8", + "name": "proverId", + "type": "uint8" + } + ], + "internalType": "struct ProverPool.Staker", + "name": "staker", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint64", + "name": "stakedAmount", + "type": "uint64" + }, + { + "internalType": "uint16", + "name": "rewardPerGas", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "currentCapacity", + "type": "uint16" + }, + { + "internalType": "uint64", + "name": "weight", + "type": "uint64" + } + ], + "internalType": "struct ProverPool.Prover", + "name": "prover", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "idToProver", + "outputs": [ + { + "internalType": "address", + "name": "prover", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_addressManager", + "type": "address" + } + ], + "name": "init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "provers", + "outputs": [ + { + "internalType": "uint64", + "name": "stakedAmount", + "type": "uint64" + }, + { + "internalType": "uint16", + "name": "rewardPerGas", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "currentCapacity", + "type": "uint16" + }, + { + "internalType": "uint64", + "name": "weight", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "releaseProver", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "internalType": "bool", + "name": "allowZeroAddress", + "type": "bool" + } + ], + "name": "resolve", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "internalType": "bool", + "name": "allowZeroAddress", + "type": "bool" + } + ], + "name": "resolve", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAddressManager", + "type": "address" + } + ], + "name": "setAddressManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "slashProver", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "amount", + "type": "uint64" + }, + { + "internalType": "uint16", + "name": "rewardPerGas", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "maxCapacity", + "type": "uint16" + } + ], + "name": "stake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "staker", + "type": "address" + } + ], + "name": "stakers", + "outputs": [ + { + "internalType": "uint64", + "name": "exitRequestedAt", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "exitAmount", + "type": "uint64" + }, + { + "internalType": "uint16", + "name": "maxCapacity", + "type": "uint16" + }, + { + "internalType": "uint8", + "name": "proverId", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/packages/eventindexer/cli/cli.go b/packages/eventindexer/cli/cli.go index 3e5442b5d62..9d45286a3d3 100644 --- a/packages/eventindexer/cli/cli.go +++ b/packages/eventindexer/cli/cli.go @@ -132,6 +132,7 @@ func Run( EthClient: l1EthClient, RPCClient: l1RpcClient, SrcTaikoAddress: common.HexToAddress(os.Getenv("L1_TAIKO_ADDRESS")), + ProverPoolAddress: common.HexToAddress(os.Getenv("PROVER_POOL_ADDRESS")), BlockBatchSize: uint64(blockBatchSize), SubscriptionBackoff: subscriptionBackoff, }) @@ -245,10 +246,12 @@ func newHTTPServer(db eventindexer.DB, l1EthClient *ethclient.Client) (*http.Ser } srv, err := http.NewServer(http.NewServerOpts{ - EventRepo: eventRepo, - StatRepo: statRepo, - Echo: echo.New(), - CorsOrigins: strings.Split(os.Getenv("CORS_ORIGINS"), ","), + EventRepo: eventRepo, + StatRepo: statRepo, + Echo: echo.New(), + CorsOrigins: strings.Split(os.Getenv("CORS_ORIGINS"), ","), + EthClient: l1EthClient, + ProverPoolAddress: common.HexToAddress(os.Getenv("PROVER_POOL_ADDRESS")), }) if err != nil { return nil, err diff --git a/packages/eventindexer/contracts/proverpool/ProverPool.go b/packages/eventindexer/contracts/proverpool/ProverPool.go new file mode 100644 index 00000000000..b2b3547fbee --- /dev/null +++ b/packages/eventindexer/contracts/proverpool/ProverPool.go @@ -0,0 +1,1982 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package proverpool + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// ProverPoolProver is an auto generated low-level Go binding around an user-defined struct. +type ProverPoolProver struct { + StakedAmount uint64 + RewardPerGas uint16 + CurrentCapacity uint16 + Weight uint64 +} + +// ProverPoolStaker is an auto generated low-level Go binding around an user-defined struct. +type ProverPoolStaker struct { + ExitRequestedAt uint64 + ExitAmount uint64 + MaxCapacity uint16 + ProverId uint8 +} + +// ProverPoolMetaData contains all meta data concerning the ProverPool contract. +var ProverPoolMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"INVALID_PARAMS\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NO_MATURE_EXIT\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PROVER_NOT_GOOD_ENOUGH\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RESOLVER_DENIED\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RESOLVER_INVALID_ADDR\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"name\",\"type\":\"bytes32\"}],\"name\":\"RESOLVER_ZERO_ADDR\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UNAUTHORIZED\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"addressManager\",\"type\":\"address\"}],\"name\":\"AddressManagerChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"amount\",\"type\":\"uint64\"}],\"name\":\"Exited\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"amount\",\"type\":\"uint64\"}],\"name\":\"Slashed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"amount\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"rewardPerGas\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"currentCapacity\",\"type\":\"uint16\"}],\"name\":\"Staked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"amount\",\"type\":\"uint64\"}],\"name\":\"Withdrawn\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"EXIT_PERIOD\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_CAPACITY_LOWER_BOUND\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_NUM_PROVERS\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MIN_SLASH_AMOUNT\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MIN_STAKE_PER_CAPACITY\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"SLASH_POINTS\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"addressManager\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"blockId\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"name\":\"assignProver\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"prover\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"rewardPerGas\",\"type\":\"uint32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"exit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCapacity\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"capacity\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getProvers\",\"outputs\":[{\"components\":[{\"internalType\":\"uint64\",\"name\":\"stakedAmount\",\"type\":\"uint64\"},{\"internalType\":\"uint16\",\"name\":\"rewardPerGas\",\"type\":\"uint16\"},{\"internalType\":\"uint16\",\"name\":\"currentCapacity\",\"type\":\"uint16\"},{\"internalType\":\"uint64\",\"name\":\"weight\",\"type\":\"uint64\"}],\"internalType\":\"structProverPool.Prover[]\",\"name\":\"_provers\",\"type\":\"tuple[]\"},{\"internalType\":\"address[]\",\"name\":\"_stakers\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getStaker\",\"outputs\":[{\"components\":[{\"internalType\":\"uint64\",\"name\":\"exitRequestedAt\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"exitAmount\",\"type\":\"uint64\"},{\"internalType\":\"uint16\",\"name\":\"maxCapacity\",\"type\":\"uint16\"},{\"internalType\":\"uint8\",\"name\":\"proverId\",\"type\":\"uint8\"}],\"internalType\":\"structProverPool.Staker\",\"name\":\"staker\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint64\",\"name\":\"stakedAmount\",\"type\":\"uint64\"},{\"internalType\":\"uint16\",\"name\":\"rewardPerGas\",\"type\":\"uint16\"},{\"internalType\":\"uint16\",\"name\":\"currentCapacity\",\"type\":\"uint16\"},{\"internalType\":\"uint64\",\"name\":\"weight\",\"type\":\"uint64\"}],\"internalType\":\"structProverPool.Prover\",\"name\":\"prover\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"idToProver\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"prover\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addressManager\",\"type\":\"address\"}],\"name\":\"init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"provers\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"stakedAmount\",\"type\":\"uint64\"},{\"internalType\":\"uint16\",\"name\":\"rewardPerGas\",\"type\":\"uint16\"},{\"internalType\":\"uint16\",\"name\":\"currentCapacity\",\"type\":\"uint16\"},{\"internalType\":\"uint64\",\"name\":\"weight\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"releaseProver\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"name\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"allowZeroAddress\",\"type\":\"bool\"}],\"name\":\"resolve\",\"outputs\":[{\"internalType\":\"addresspayable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"name\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"allowZeroAddress\",\"type\":\"bool\"}],\"name\":\"resolve\",\"outputs\":[{\"internalType\":\"addresspayable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAddressManager\",\"type\":\"address\"}],\"name\":\"setAddressManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"slashProver\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"amount\",\"type\":\"uint64\"},{\"internalType\":\"uint16\",\"name\":\"rewardPerGas\",\"type\":\"uint16\"},{\"internalType\":\"uint16\",\"name\":\"maxCapacity\",\"type\":\"uint16\"}],\"name\":\"stake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"}],\"name\":\"stakers\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"exitRequestedAt\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"exitAmount\",\"type\":\"uint64\"},{\"internalType\":\"uint16\",\"name\":\"maxCapacity\",\"type\":\"uint16\"},{\"internalType\":\"uint8\",\"name\":\"proverId\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// ProverPoolABI is the input ABI used to generate the binding from. +// Deprecated: Use ProverPoolMetaData.ABI instead. +var ProverPoolABI = ProverPoolMetaData.ABI + +// ProverPool is an auto generated Go binding around an Ethereum contract. +type ProverPool struct { + ProverPoolCaller // Read-only binding to the contract + ProverPoolTransactor // Write-only binding to the contract + ProverPoolFilterer // Log filterer for contract events +} + +// ProverPoolCaller is an auto generated read-only Go binding around an Ethereum contract. +type ProverPoolCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ProverPoolTransactor is an auto generated write-only Go binding around an Ethereum contract. +type ProverPoolTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ProverPoolFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ProverPoolFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ProverPoolSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ProverPoolSession struct { + Contract *ProverPool // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ProverPoolCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ProverPoolCallerSession struct { + Contract *ProverPoolCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ProverPoolTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ProverPoolTransactorSession struct { + Contract *ProverPoolTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ProverPoolRaw is an auto generated low-level Go binding around an Ethereum contract. +type ProverPoolRaw struct { + Contract *ProverPool // Generic contract binding to access the raw methods on +} + +// ProverPoolCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ProverPoolCallerRaw struct { + Contract *ProverPoolCaller // Generic read-only contract binding to access the raw methods on +} + +// ProverPoolTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ProverPoolTransactorRaw struct { + Contract *ProverPoolTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewProverPool creates a new instance of ProverPool, bound to a specific deployed contract. +func NewProverPool(address common.Address, backend bind.ContractBackend) (*ProverPool, error) { + contract, err := bindProverPool(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &ProverPool{ProverPoolCaller: ProverPoolCaller{contract: contract}, ProverPoolTransactor: ProverPoolTransactor{contract: contract}, ProverPoolFilterer: ProverPoolFilterer{contract: contract}}, nil +} + +// NewProverPoolCaller creates a new read-only instance of ProverPool, bound to a specific deployed contract. +func NewProverPoolCaller(address common.Address, caller bind.ContractCaller) (*ProverPoolCaller, error) { + contract, err := bindProverPool(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ProverPoolCaller{contract: contract}, nil +} + +// NewProverPoolTransactor creates a new write-only instance of ProverPool, bound to a specific deployed contract. +func NewProverPoolTransactor(address common.Address, transactor bind.ContractTransactor) (*ProverPoolTransactor, error) { + contract, err := bindProverPool(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ProverPoolTransactor{contract: contract}, nil +} + +// NewProverPoolFilterer creates a new log filterer instance of ProverPool, bound to a specific deployed contract. +func NewProverPoolFilterer(address common.Address, filterer bind.ContractFilterer) (*ProverPoolFilterer, error) { + contract, err := bindProverPool(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ProverPoolFilterer{contract: contract}, nil +} + +// bindProverPool binds a generic wrapper to an already deployed contract. +func bindProverPool(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := ProverPoolMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ProverPool *ProverPoolRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ProverPool.Contract.ProverPoolCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ProverPool *ProverPoolRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ProverPool.Contract.ProverPoolTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ProverPool *ProverPoolRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ProverPool.Contract.ProverPoolTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ProverPool *ProverPoolCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ProverPool.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ProverPool *ProverPoolTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ProverPool.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ProverPool *ProverPoolTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ProverPool.Contract.contract.Transact(opts, method, params...) +} + +// EXITPERIOD is a free data retrieval call binding the contract method 0xc04b5f65. +// +// Solidity: function EXIT_PERIOD() view returns(uint64) +func (_ProverPool *ProverPoolCaller) EXITPERIOD(opts *bind.CallOpts) (uint64, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "EXIT_PERIOD") + + if err != nil { + return *new(uint64), err + } + + out0 := *abi.ConvertType(out[0], new(uint64)).(*uint64) + + return out0, err + +} + +// EXITPERIOD is a free data retrieval call binding the contract method 0xc04b5f65. +// +// Solidity: function EXIT_PERIOD() view returns(uint64) +func (_ProverPool *ProverPoolSession) EXITPERIOD() (uint64, error) { + return _ProverPool.Contract.EXITPERIOD(&_ProverPool.CallOpts) +} + +// EXITPERIOD is a free data retrieval call binding the contract method 0xc04b5f65. +// +// Solidity: function EXIT_PERIOD() view returns(uint64) +func (_ProverPool *ProverPoolCallerSession) EXITPERIOD() (uint64, error) { + return _ProverPool.Contract.EXITPERIOD(&_ProverPool.CallOpts) +} + +// MAXCAPACITYLOWERBOUND is a free data retrieval call binding the contract method 0x35acc933. +// +// Solidity: function MAX_CAPACITY_LOWER_BOUND() view returns(uint32) +func (_ProverPool *ProverPoolCaller) MAXCAPACITYLOWERBOUND(opts *bind.CallOpts) (uint32, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "MAX_CAPACITY_LOWER_BOUND") + + if err != nil { + return *new(uint32), err + } + + out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) + + return out0, err + +} + +// MAXCAPACITYLOWERBOUND is a free data retrieval call binding the contract method 0x35acc933. +// +// Solidity: function MAX_CAPACITY_LOWER_BOUND() view returns(uint32) +func (_ProverPool *ProverPoolSession) MAXCAPACITYLOWERBOUND() (uint32, error) { + return _ProverPool.Contract.MAXCAPACITYLOWERBOUND(&_ProverPool.CallOpts) +} + +// MAXCAPACITYLOWERBOUND is a free data retrieval call binding the contract method 0x35acc933. +// +// Solidity: function MAX_CAPACITY_LOWER_BOUND() view returns(uint32) +func (_ProverPool *ProverPoolCallerSession) MAXCAPACITYLOWERBOUND() (uint32, error) { + return _ProverPool.Contract.MAXCAPACITYLOWERBOUND(&_ProverPool.CallOpts) +} + +// MAXNUMPROVERS is a free data retrieval call binding the contract method 0x62c0fd98. +// +// Solidity: function MAX_NUM_PROVERS() view returns(uint256) +func (_ProverPool *ProverPoolCaller) MAXNUMPROVERS(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "MAX_NUM_PROVERS") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MAXNUMPROVERS is a free data retrieval call binding the contract method 0x62c0fd98. +// +// Solidity: function MAX_NUM_PROVERS() view returns(uint256) +func (_ProverPool *ProverPoolSession) MAXNUMPROVERS() (*big.Int, error) { + return _ProverPool.Contract.MAXNUMPROVERS(&_ProverPool.CallOpts) +} + +// MAXNUMPROVERS is a free data retrieval call binding the contract method 0x62c0fd98. +// +// Solidity: function MAX_NUM_PROVERS() view returns(uint256) +func (_ProverPool *ProverPoolCallerSession) MAXNUMPROVERS() (*big.Int, error) { + return _ProverPool.Contract.MAXNUMPROVERS(&_ProverPool.CallOpts) +} + +// MINSLASHAMOUNT is a free data retrieval call binding the contract method 0x1972bc0d. +// +// Solidity: function MIN_SLASH_AMOUNT() view returns(uint64) +func (_ProverPool *ProverPoolCaller) MINSLASHAMOUNT(opts *bind.CallOpts) (uint64, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "MIN_SLASH_AMOUNT") + + if err != nil { + return *new(uint64), err + } + + out0 := *abi.ConvertType(out[0], new(uint64)).(*uint64) + + return out0, err + +} + +// MINSLASHAMOUNT is a free data retrieval call binding the contract method 0x1972bc0d. +// +// Solidity: function MIN_SLASH_AMOUNT() view returns(uint64) +func (_ProverPool *ProverPoolSession) MINSLASHAMOUNT() (uint64, error) { + return _ProverPool.Contract.MINSLASHAMOUNT(&_ProverPool.CallOpts) +} + +// MINSLASHAMOUNT is a free data retrieval call binding the contract method 0x1972bc0d. +// +// Solidity: function MIN_SLASH_AMOUNT() view returns(uint64) +func (_ProverPool *ProverPoolCallerSession) MINSLASHAMOUNT() (uint64, error) { + return _ProverPool.Contract.MINSLASHAMOUNT(&_ProverPool.CallOpts) +} + +// MINSTAKEPERCAPACITY is a free data retrieval call binding the contract method 0x7d62c057. +// +// Solidity: function MIN_STAKE_PER_CAPACITY() view returns(uint64) +func (_ProverPool *ProverPoolCaller) MINSTAKEPERCAPACITY(opts *bind.CallOpts) (uint64, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "MIN_STAKE_PER_CAPACITY") + + if err != nil { + return *new(uint64), err + } + + out0 := *abi.ConvertType(out[0], new(uint64)).(*uint64) + + return out0, err + +} + +// MINSTAKEPERCAPACITY is a free data retrieval call binding the contract method 0x7d62c057. +// +// Solidity: function MIN_STAKE_PER_CAPACITY() view returns(uint64) +func (_ProverPool *ProverPoolSession) MINSTAKEPERCAPACITY() (uint64, error) { + return _ProverPool.Contract.MINSTAKEPERCAPACITY(&_ProverPool.CallOpts) +} + +// MINSTAKEPERCAPACITY is a free data retrieval call binding the contract method 0x7d62c057. +// +// Solidity: function MIN_STAKE_PER_CAPACITY() view returns(uint64) +func (_ProverPool *ProverPoolCallerSession) MINSTAKEPERCAPACITY() (uint64, error) { + return _ProverPool.Contract.MINSTAKEPERCAPACITY(&_ProverPool.CallOpts) +} + +// SLASHPOINTS is a free data retrieval call binding the contract method 0xdd9fb65c. +// +// Solidity: function SLASH_POINTS() view returns(uint32) +func (_ProverPool *ProverPoolCaller) SLASHPOINTS(opts *bind.CallOpts) (uint32, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "SLASH_POINTS") + + if err != nil { + return *new(uint32), err + } + + out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) + + return out0, err + +} + +// SLASHPOINTS is a free data retrieval call binding the contract method 0xdd9fb65c. +// +// Solidity: function SLASH_POINTS() view returns(uint32) +func (_ProverPool *ProverPoolSession) SLASHPOINTS() (uint32, error) { + return _ProverPool.Contract.SLASHPOINTS(&_ProverPool.CallOpts) +} + +// SLASHPOINTS is a free data retrieval call binding the contract method 0xdd9fb65c. +// +// Solidity: function SLASH_POINTS() view returns(uint32) +func (_ProverPool *ProverPoolCallerSession) SLASHPOINTS() (uint32, error) { + return _ProverPool.Contract.SLASHPOINTS(&_ProverPool.CallOpts) +} + +// AddressManager is a free data retrieval call binding the contract method 0x3ab76e9f. +// +// Solidity: function addressManager() view returns(address) +func (_ProverPool *ProverPoolCaller) AddressManager(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "addressManager") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// AddressManager is a free data retrieval call binding the contract method 0x3ab76e9f. +// +// Solidity: function addressManager() view returns(address) +func (_ProverPool *ProverPoolSession) AddressManager() (common.Address, error) { + return _ProverPool.Contract.AddressManager(&_ProverPool.CallOpts) +} + +// AddressManager is a free data retrieval call binding the contract method 0x3ab76e9f. +// +// Solidity: function addressManager() view returns(address) +func (_ProverPool *ProverPoolCallerSession) AddressManager() (common.Address, error) { + return _ProverPool.Contract.AddressManager(&_ProverPool.CallOpts) +} + +// GetCapacity is a free data retrieval call binding the contract method 0xc40000d4. +// +// Solidity: function getCapacity() view returns(uint256 capacity) +func (_ProverPool *ProverPoolCaller) GetCapacity(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "getCapacity") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetCapacity is a free data retrieval call binding the contract method 0xc40000d4. +// +// Solidity: function getCapacity() view returns(uint256 capacity) +func (_ProverPool *ProverPoolSession) GetCapacity() (*big.Int, error) { + return _ProverPool.Contract.GetCapacity(&_ProverPool.CallOpts) +} + +// GetCapacity is a free data retrieval call binding the contract method 0xc40000d4. +// +// Solidity: function getCapacity() view returns(uint256 capacity) +func (_ProverPool *ProverPoolCallerSession) GetCapacity() (*big.Int, error) { + return _ProverPool.Contract.GetCapacity(&_ProverPool.CallOpts) +} + +// GetProvers is a free data retrieval call binding the contract method 0xc0bfd036. +// +// Solidity: function getProvers() view returns((uint64,uint16,uint16,uint64)[] _provers, address[] _stakers) +func (_ProverPool *ProverPoolCaller) GetProvers(opts *bind.CallOpts) (struct { + Provers []ProverPoolProver + Stakers []common.Address +}, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "getProvers") + + outstruct := new(struct { + Provers []ProverPoolProver + Stakers []common.Address + }) + if err != nil { + return *outstruct, err + } + + outstruct.Provers = *abi.ConvertType(out[0], new([]ProverPoolProver)).(*[]ProverPoolProver) + outstruct.Stakers = *abi.ConvertType(out[1], new([]common.Address)).(*[]common.Address) + + return *outstruct, err + +} + +// GetProvers is a free data retrieval call binding the contract method 0xc0bfd036. +// +// Solidity: function getProvers() view returns((uint64,uint16,uint16,uint64)[] _provers, address[] _stakers) +func (_ProverPool *ProverPoolSession) GetProvers() (struct { + Provers []ProverPoolProver + Stakers []common.Address +}, error) { + return _ProverPool.Contract.GetProvers(&_ProverPool.CallOpts) +} + +// GetProvers is a free data retrieval call binding the contract method 0xc0bfd036. +// +// Solidity: function getProvers() view returns((uint64,uint16,uint16,uint64)[] _provers, address[] _stakers) +func (_ProverPool *ProverPoolCallerSession) GetProvers() (struct { + Provers []ProverPoolProver + Stakers []common.Address +}, error) { + return _ProverPool.Contract.GetProvers(&_ProverPool.CallOpts) +} + +// GetStaker is a free data retrieval call binding the contract method 0xa23c44b1. +// +// Solidity: function getStaker(address addr) view returns((uint64,uint64,uint16,uint8) staker, (uint64,uint16,uint16,uint64) prover) +func (_ProverPool *ProverPoolCaller) GetStaker(opts *bind.CallOpts, addr common.Address) (struct { + Staker ProverPoolStaker + Prover ProverPoolProver +}, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "getStaker", addr) + + outstruct := new(struct { + Staker ProverPoolStaker + Prover ProverPoolProver + }) + if err != nil { + return *outstruct, err + } + + outstruct.Staker = *abi.ConvertType(out[0], new(ProverPoolStaker)).(*ProverPoolStaker) + outstruct.Prover = *abi.ConvertType(out[1], new(ProverPoolProver)).(*ProverPoolProver) + + return *outstruct, err + +} + +// GetStaker is a free data retrieval call binding the contract method 0xa23c44b1. +// +// Solidity: function getStaker(address addr) view returns((uint64,uint64,uint16,uint8) staker, (uint64,uint16,uint16,uint64) prover) +func (_ProverPool *ProverPoolSession) GetStaker(addr common.Address) (struct { + Staker ProverPoolStaker + Prover ProverPoolProver +}, error) { + return _ProverPool.Contract.GetStaker(&_ProverPool.CallOpts, addr) +} + +// GetStaker is a free data retrieval call binding the contract method 0xa23c44b1. +// +// Solidity: function getStaker(address addr) view returns((uint64,uint64,uint16,uint8) staker, (uint64,uint16,uint16,uint64) prover) +func (_ProverPool *ProverPoolCallerSession) GetStaker(addr common.Address) (struct { + Staker ProverPoolStaker + Prover ProverPoolProver +}, error) { + return _ProverPool.Contract.GetStaker(&_ProverPool.CallOpts, addr) +} + +// IdToProver is a free data retrieval call binding the contract method 0x2f88a7fe. +// +// Solidity: function idToProver(uint256 id) view returns(address prover) +func (_ProverPool *ProverPoolCaller) IdToProver(opts *bind.CallOpts, id *big.Int) (common.Address, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "idToProver", id) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// IdToProver is a free data retrieval call binding the contract method 0x2f88a7fe. +// +// Solidity: function idToProver(uint256 id) view returns(address prover) +func (_ProverPool *ProverPoolSession) IdToProver(id *big.Int) (common.Address, error) { + return _ProverPool.Contract.IdToProver(&_ProverPool.CallOpts, id) +} + +// IdToProver is a free data retrieval call binding the contract method 0x2f88a7fe. +// +// Solidity: function idToProver(uint256 id) view returns(address prover) +func (_ProverPool *ProverPoolCallerSession) IdToProver(id *big.Int) (common.Address, error) { + return _ProverPool.Contract.IdToProver(&_ProverPool.CallOpts, id) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ProverPool *ProverPoolCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ProverPool *ProverPoolSession) Owner() (common.Address, error) { + return _ProverPool.Contract.Owner(&_ProverPool.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ProverPool *ProverPoolCallerSession) Owner() (common.Address, error) { + return _ProverPool.Contract.Owner(&_ProverPool.CallOpts) +} + +// Provers is a free data retrieval call binding the contract method 0xfd1190ea. +// +// Solidity: function provers(uint256 ) view returns(uint64 stakedAmount, uint16 rewardPerGas, uint16 currentCapacity, uint64 weight) +func (_ProverPool *ProverPoolCaller) Provers(opts *bind.CallOpts, arg0 *big.Int) (struct { + StakedAmount uint64 + RewardPerGas uint16 + CurrentCapacity uint16 + Weight uint64 +}, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "provers", arg0) + + outstruct := new(struct { + StakedAmount uint64 + RewardPerGas uint16 + CurrentCapacity uint16 + Weight uint64 + }) + if err != nil { + return *outstruct, err + } + + outstruct.StakedAmount = *abi.ConvertType(out[0], new(uint64)).(*uint64) + outstruct.RewardPerGas = *abi.ConvertType(out[1], new(uint16)).(*uint16) + outstruct.CurrentCapacity = *abi.ConvertType(out[2], new(uint16)).(*uint16) + outstruct.Weight = *abi.ConvertType(out[3], new(uint64)).(*uint64) + + return *outstruct, err + +} + +// Provers is a free data retrieval call binding the contract method 0xfd1190ea. +// +// Solidity: function provers(uint256 ) view returns(uint64 stakedAmount, uint16 rewardPerGas, uint16 currentCapacity, uint64 weight) +func (_ProverPool *ProverPoolSession) Provers(arg0 *big.Int) (struct { + StakedAmount uint64 + RewardPerGas uint16 + CurrentCapacity uint16 + Weight uint64 +}, error) { + return _ProverPool.Contract.Provers(&_ProverPool.CallOpts, arg0) +} + +// Provers is a free data retrieval call binding the contract method 0xfd1190ea. +// +// Solidity: function provers(uint256 ) view returns(uint64 stakedAmount, uint16 rewardPerGas, uint16 currentCapacity, uint64 weight) +func (_ProverPool *ProverPoolCallerSession) Provers(arg0 *big.Int) (struct { + StakedAmount uint64 + RewardPerGas uint16 + CurrentCapacity uint16 + Weight uint64 +}, error) { + return _ProverPool.Contract.Provers(&_ProverPool.CallOpts, arg0) +} + +// Resolve is a free data retrieval call binding the contract method 0x6c6563f6. +// +// Solidity: function resolve(uint256 chainId, bytes32 name, bool allowZeroAddress) view returns(address) +func (_ProverPool *ProverPoolCaller) Resolve(opts *bind.CallOpts, chainId *big.Int, name [32]byte, allowZeroAddress bool) (common.Address, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "resolve", chainId, name, allowZeroAddress) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Resolve is a free data retrieval call binding the contract method 0x6c6563f6. +// +// Solidity: function resolve(uint256 chainId, bytes32 name, bool allowZeroAddress) view returns(address) +func (_ProverPool *ProverPoolSession) Resolve(chainId *big.Int, name [32]byte, allowZeroAddress bool) (common.Address, error) { + return _ProverPool.Contract.Resolve(&_ProverPool.CallOpts, chainId, name, allowZeroAddress) +} + +// Resolve is a free data retrieval call binding the contract method 0x6c6563f6. +// +// Solidity: function resolve(uint256 chainId, bytes32 name, bool allowZeroAddress) view returns(address) +func (_ProverPool *ProverPoolCallerSession) Resolve(chainId *big.Int, name [32]byte, allowZeroAddress bool) (common.Address, error) { + return _ProverPool.Contract.Resolve(&_ProverPool.CallOpts, chainId, name, allowZeroAddress) +} + +// Resolve0 is a free data retrieval call binding the contract method 0xa86f9d9e. +// +// Solidity: function resolve(bytes32 name, bool allowZeroAddress) view returns(address) +func (_ProverPool *ProverPoolCaller) Resolve0(opts *bind.CallOpts, name [32]byte, allowZeroAddress bool) (common.Address, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "resolve0", name, allowZeroAddress) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Resolve0 is a free data retrieval call binding the contract method 0xa86f9d9e. +// +// Solidity: function resolve(bytes32 name, bool allowZeroAddress) view returns(address) +func (_ProverPool *ProverPoolSession) Resolve0(name [32]byte, allowZeroAddress bool) (common.Address, error) { + return _ProverPool.Contract.Resolve0(&_ProverPool.CallOpts, name, allowZeroAddress) +} + +// Resolve0 is a free data retrieval call binding the contract method 0xa86f9d9e. +// +// Solidity: function resolve(bytes32 name, bool allowZeroAddress) view returns(address) +func (_ProverPool *ProverPoolCallerSession) Resolve0(name [32]byte, allowZeroAddress bool) (common.Address, error) { + return _ProverPool.Contract.Resolve0(&_ProverPool.CallOpts, name, allowZeroAddress) +} + +// Stakers is a free data retrieval call binding the contract method 0x9168ae72. +// +// Solidity: function stakers(address staker) view returns(uint64 exitRequestedAt, uint64 exitAmount, uint16 maxCapacity, uint8 proverId) +func (_ProverPool *ProverPoolCaller) Stakers(opts *bind.CallOpts, staker common.Address) (struct { + ExitRequestedAt uint64 + ExitAmount uint64 + MaxCapacity uint16 + ProverId uint8 +}, error) { + var out []interface{} + err := _ProverPool.contract.Call(opts, &out, "stakers", staker) + + outstruct := new(struct { + ExitRequestedAt uint64 + ExitAmount uint64 + MaxCapacity uint16 + ProverId uint8 + }) + if err != nil { + return *outstruct, err + } + + outstruct.ExitRequestedAt = *abi.ConvertType(out[0], new(uint64)).(*uint64) + outstruct.ExitAmount = *abi.ConvertType(out[1], new(uint64)).(*uint64) + outstruct.MaxCapacity = *abi.ConvertType(out[2], new(uint16)).(*uint16) + outstruct.ProverId = *abi.ConvertType(out[3], new(uint8)).(*uint8) + + return *outstruct, err + +} + +// Stakers is a free data retrieval call binding the contract method 0x9168ae72. +// +// Solidity: function stakers(address staker) view returns(uint64 exitRequestedAt, uint64 exitAmount, uint16 maxCapacity, uint8 proverId) +func (_ProverPool *ProverPoolSession) Stakers(staker common.Address) (struct { + ExitRequestedAt uint64 + ExitAmount uint64 + MaxCapacity uint16 + ProverId uint8 +}, error) { + return _ProverPool.Contract.Stakers(&_ProverPool.CallOpts, staker) +} + +// Stakers is a free data retrieval call binding the contract method 0x9168ae72. +// +// Solidity: function stakers(address staker) view returns(uint64 exitRequestedAt, uint64 exitAmount, uint16 maxCapacity, uint8 proverId) +func (_ProverPool *ProverPoolCallerSession) Stakers(staker common.Address) (struct { + ExitRequestedAt uint64 + ExitAmount uint64 + MaxCapacity uint16 + ProverId uint8 +}, error) { + return _ProverPool.Contract.Stakers(&_ProverPool.CallOpts, staker) +} + +// AssignProver is a paid mutator transaction binding the contract method 0xbd849fe9. +// +// Solidity: function assignProver(uint64 blockId, uint32 ) returns(address prover, uint32 rewardPerGas) +func (_ProverPool *ProverPoolTransactor) AssignProver(opts *bind.TransactOpts, blockId uint64, arg1 uint32) (*types.Transaction, error) { + return _ProverPool.contract.Transact(opts, "assignProver", blockId, arg1) +} + +// AssignProver is a paid mutator transaction binding the contract method 0xbd849fe9. +// +// Solidity: function assignProver(uint64 blockId, uint32 ) returns(address prover, uint32 rewardPerGas) +func (_ProverPool *ProverPoolSession) AssignProver(blockId uint64, arg1 uint32) (*types.Transaction, error) { + return _ProverPool.Contract.AssignProver(&_ProverPool.TransactOpts, blockId, arg1) +} + +// AssignProver is a paid mutator transaction binding the contract method 0xbd849fe9. +// +// Solidity: function assignProver(uint64 blockId, uint32 ) returns(address prover, uint32 rewardPerGas) +func (_ProverPool *ProverPoolTransactorSession) AssignProver(blockId uint64, arg1 uint32) (*types.Transaction, error) { + return _ProverPool.Contract.AssignProver(&_ProverPool.TransactOpts, blockId, arg1) +} + +// Exit is a paid mutator transaction binding the contract method 0xe9fad8ee. +// +// Solidity: function exit() returns() +func (_ProverPool *ProverPoolTransactor) Exit(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ProverPool.contract.Transact(opts, "exit") +} + +// Exit is a paid mutator transaction binding the contract method 0xe9fad8ee. +// +// Solidity: function exit() returns() +func (_ProverPool *ProverPoolSession) Exit() (*types.Transaction, error) { + return _ProverPool.Contract.Exit(&_ProverPool.TransactOpts) +} + +// Exit is a paid mutator transaction binding the contract method 0xe9fad8ee. +// +// Solidity: function exit() returns() +func (_ProverPool *ProverPoolTransactorSession) Exit() (*types.Transaction, error) { + return _ProverPool.Contract.Exit(&_ProverPool.TransactOpts) +} + +// Init is a paid mutator transaction binding the contract method 0x19ab453c. +// +// Solidity: function init(address _addressManager) returns() +func (_ProverPool *ProverPoolTransactor) Init(opts *bind.TransactOpts, _addressManager common.Address) (*types.Transaction, error) { + return _ProverPool.contract.Transact(opts, "init", _addressManager) +} + +// Init is a paid mutator transaction binding the contract method 0x19ab453c. +// +// Solidity: function init(address _addressManager) returns() +func (_ProverPool *ProverPoolSession) Init(_addressManager common.Address) (*types.Transaction, error) { + return _ProverPool.Contract.Init(&_ProverPool.TransactOpts, _addressManager) +} + +// Init is a paid mutator transaction binding the contract method 0x19ab453c. +// +// Solidity: function init(address _addressManager) returns() +func (_ProverPool *ProverPoolTransactorSession) Init(_addressManager common.Address) (*types.Transaction, error) { + return _ProverPool.Contract.Init(&_ProverPool.TransactOpts, _addressManager) +} + +// ReleaseProver is a paid mutator transaction binding the contract method 0xcba0414f. +// +// Solidity: function releaseProver(address addr) returns() +func (_ProverPool *ProverPoolTransactor) ReleaseProver(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { + return _ProverPool.contract.Transact(opts, "releaseProver", addr) +} + +// ReleaseProver is a paid mutator transaction binding the contract method 0xcba0414f. +// +// Solidity: function releaseProver(address addr) returns() +func (_ProverPool *ProverPoolSession) ReleaseProver(addr common.Address) (*types.Transaction, error) { + return _ProverPool.Contract.ReleaseProver(&_ProverPool.TransactOpts, addr) +} + +// ReleaseProver is a paid mutator transaction binding the contract method 0xcba0414f. +// +// Solidity: function releaseProver(address addr) returns() +func (_ProverPool *ProverPoolTransactorSession) ReleaseProver(addr common.Address) (*types.Transaction, error) { + return _ProverPool.Contract.ReleaseProver(&_ProverPool.TransactOpts, addr) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ProverPool *ProverPoolTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ProverPool.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ProverPool *ProverPoolSession) RenounceOwnership() (*types.Transaction, error) { + return _ProverPool.Contract.RenounceOwnership(&_ProverPool.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ProverPool *ProverPoolTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _ProverPool.Contract.RenounceOwnership(&_ProverPool.TransactOpts) +} + +// SetAddressManager is a paid mutator transaction binding the contract method 0x0652b57a. +// +// Solidity: function setAddressManager(address newAddressManager) returns() +func (_ProverPool *ProverPoolTransactor) SetAddressManager(opts *bind.TransactOpts, newAddressManager common.Address) (*types.Transaction, error) { + return _ProverPool.contract.Transact(opts, "setAddressManager", newAddressManager) +} + +// SetAddressManager is a paid mutator transaction binding the contract method 0x0652b57a. +// +// Solidity: function setAddressManager(address newAddressManager) returns() +func (_ProverPool *ProverPoolSession) SetAddressManager(newAddressManager common.Address) (*types.Transaction, error) { + return _ProverPool.Contract.SetAddressManager(&_ProverPool.TransactOpts, newAddressManager) +} + +// SetAddressManager is a paid mutator transaction binding the contract method 0x0652b57a. +// +// Solidity: function setAddressManager(address newAddressManager) returns() +func (_ProverPool *ProverPoolTransactorSession) SetAddressManager(newAddressManager common.Address) (*types.Transaction, error) { + return _ProverPool.Contract.SetAddressManager(&_ProverPool.TransactOpts, newAddressManager) +} + +// SlashProver is a paid mutator transaction binding the contract method 0xcd362a5b. +// +// Solidity: function slashProver(address addr) returns() +func (_ProverPool *ProverPoolTransactor) SlashProver(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { + return _ProverPool.contract.Transact(opts, "slashProver", addr) +} + +// SlashProver is a paid mutator transaction binding the contract method 0xcd362a5b. +// +// Solidity: function slashProver(address addr) returns() +func (_ProverPool *ProverPoolSession) SlashProver(addr common.Address) (*types.Transaction, error) { + return _ProverPool.Contract.SlashProver(&_ProverPool.TransactOpts, addr) +} + +// SlashProver is a paid mutator transaction binding the contract method 0xcd362a5b. +// +// Solidity: function slashProver(address addr) returns() +func (_ProverPool *ProverPoolTransactorSession) SlashProver(addr common.Address) (*types.Transaction, error) { + return _ProverPool.Contract.SlashProver(&_ProverPool.TransactOpts, addr) +} + +// Stake is a paid mutator transaction binding the contract method 0x75244643. +// +// Solidity: function stake(uint64 amount, uint16 rewardPerGas, uint16 maxCapacity) returns() +func (_ProverPool *ProverPoolTransactor) Stake(opts *bind.TransactOpts, amount uint64, rewardPerGas uint16, maxCapacity uint16) (*types.Transaction, error) { + return _ProverPool.contract.Transact(opts, "stake", amount, rewardPerGas, maxCapacity) +} + +// Stake is a paid mutator transaction binding the contract method 0x75244643. +// +// Solidity: function stake(uint64 amount, uint16 rewardPerGas, uint16 maxCapacity) returns() +func (_ProverPool *ProverPoolSession) Stake(amount uint64, rewardPerGas uint16, maxCapacity uint16) (*types.Transaction, error) { + return _ProverPool.Contract.Stake(&_ProverPool.TransactOpts, amount, rewardPerGas, maxCapacity) +} + +// Stake is a paid mutator transaction binding the contract method 0x75244643. +// +// Solidity: function stake(uint64 amount, uint16 rewardPerGas, uint16 maxCapacity) returns() +func (_ProverPool *ProverPoolTransactorSession) Stake(amount uint64, rewardPerGas uint16, maxCapacity uint16) (*types.Transaction, error) { + return _ProverPool.Contract.Stake(&_ProverPool.TransactOpts, amount, rewardPerGas, maxCapacity) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ProverPool *ProverPoolTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _ProverPool.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ProverPool *ProverPoolSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ProverPool.Contract.TransferOwnership(&_ProverPool.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ProverPool *ProverPoolTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ProverPool.Contract.TransferOwnership(&_ProverPool.TransactOpts, newOwner) +} + +// Withdraw is a paid mutator transaction binding the contract method 0x3ccfd60b. +// +// Solidity: function withdraw() returns() +func (_ProverPool *ProverPoolTransactor) Withdraw(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ProverPool.contract.Transact(opts, "withdraw") +} + +// Withdraw is a paid mutator transaction binding the contract method 0x3ccfd60b. +// +// Solidity: function withdraw() returns() +func (_ProverPool *ProverPoolSession) Withdraw() (*types.Transaction, error) { + return _ProverPool.Contract.Withdraw(&_ProverPool.TransactOpts) +} + +// Withdraw is a paid mutator transaction binding the contract method 0x3ccfd60b. +// +// Solidity: function withdraw() returns() +func (_ProverPool *ProverPoolTransactorSession) Withdraw() (*types.Transaction, error) { + return _ProverPool.Contract.Withdraw(&_ProverPool.TransactOpts) +} + +// ProverPoolAddressManagerChangedIterator is returned from FilterAddressManagerChanged and is used to iterate over the raw logs and unpacked data for AddressManagerChanged events raised by the ProverPool contract. +type ProverPoolAddressManagerChangedIterator struct { + Event *ProverPoolAddressManagerChanged // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProverPoolAddressManagerChangedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProverPoolAddressManagerChanged) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProverPoolAddressManagerChanged) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProverPoolAddressManagerChangedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProverPoolAddressManagerChangedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProverPoolAddressManagerChanged represents a AddressManagerChanged event raised by the ProverPool contract. +type ProverPoolAddressManagerChanged struct { + AddressManager common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterAddressManagerChanged is a free log retrieval operation binding the contract event 0x399ded90cb5ed8d89ef7e76ff4af65c373f06d3bf5d7eef55f4228e7b702a18b. +// +// Solidity: event AddressManagerChanged(address addressManager) +func (_ProverPool *ProverPoolFilterer) FilterAddressManagerChanged(opts *bind.FilterOpts) (*ProverPoolAddressManagerChangedIterator, error) { + + logs, sub, err := _ProverPool.contract.FilterLogs(opts, "AddressManagerChanged") + if err != nil { + return nil, err + } + return &ProverPoolAddressManagerChangedIterator{contract: _ProverPool.contract, event: "AddressManagerChanged", logs: logs, sub: sub}, nil +} + +// WatchAddressManagerChanged is a free log subscription operation binding the contract event 0x399ded90cb5ed8d89ef7e76ff4af65c373f06d3bf5d7eef55f4228e7b702a18b. +// +// Solidity: event AddressManagerChanged(address addressManager) +func (_ProverPool *ProverPoolFilterer) WatchAddressManagerChanged(opts *bind.WatchOpts, sink chan<- *ProverPoolAddressManagerChanged) (event.Subscription, error) { + + logs, sub, err := _ProverPool.contract.WatchLogs(opts, "AddressManagerChanged") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProverPoolAddressManagerChanged) + if err := _ProverPool.contract.UnpackLog(event, "AddressManagerChanged", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseAddressManagerChanged is a log parse operation binding the contract event 0x399ded90cb5ed8d89ef7e76ff4af65c373f06d3bf5d7eef55f4228e7b702a18b. +// +// Solidity: event AddressManagerChanged(address addressManager) +func (_ProverPool *ProverPoolFilterer) ParseAddressManagerChanged(log types.Log) (*ProverPoolAddressManagerChanged, error) { + event := new(ProverPoolAddressManagerChanged) + if err := _ProverPool.contract.UnpackLog(event, "AddressManagerChanged", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ProverPoolExitedIterator is returned from FilterExited and is used to iterate over the raw logs and unpacked data for Exited events raised by the ProverPool contract. +type ProverPoolExitedIterator struct { + Event *ProverPoolExited // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProverPoolExitedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProverPoolExited) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProverPoolExited) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProverPoolExitedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProverPoolExitedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProverPoolExited represents a Exited event raised by the ProverPool contract. +type ProverPoolExited struct { + Addr common.Address + Amount uint64 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterExited is a free log retrieval operation binding the contract event 0x7b870040d0137f84191e3e446a10f48b5ac5d26ec96be3f795fcfc4c954410fe. +// +// Solidity: event Exited(address indexed addr, uint64 amount) +func (_ProverPool *ProverPoolFilterer) FilterExited(opts *bind.FilterOpts, addr []common.Address) (*ProverPoolExitedIterator, error) { + + var addrRule []interface{} + for _, addrItem := range addr { + addrRule = append(addrRule, addrItem) + } + + logs, sub, err := _ProverPool.contract.FilterLogs(opts, "Exited", addrRule) + if err != nil { + return nil, err + } + return &ProverPoolExitedIterator{contract: _ProverPool.contract, event: "Exited", logs: logs, sub: sub}, nil +} + +// WatchExited is a free log subscription operation binding the contract event 0x7b870040d0137f84191e3e446a10f48b5ac5d26ec96be3f795fcfc4c954410fe. +// +// Solidity: event Exited(address indexed addr, uint64 amount) +func (_ProverPool *ProverPoolFilterer) WatchExited(opts *bind.WatchOpts, sink chan<- *ProverPoolExited, addr []common.Address) (event.Subscription, error) { + + var addrRule []interface{} + for _, addrItem := range addr { + addrRule = append(addrRule, addrItem) + } + + logs, sub, err := _ProverPool.contract.WatchLogs(opts, "Exited", addrRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProverPoolExited) + if err := _ProverPool.contract.UnpackLog(event, "Exited", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseExited is a log parse operation binding the contract event 0x7b870040d0137f84191e3e446a10f48b5ac5d26ec96be3f795fcfc4c954410fe. +// +// Solidity: event Exited(address indexed addr, uint64 amount) +func (_ProverPool *ProverPoolFilterer) ParseExited(log types.Log) (*ProverPoolExited, error) { + event := new(ProverPoolExited) + if err := _ProverPool.contract.UnpackLog(event, "Exited", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ProverPoolInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the ProverPool contract. +type ProverPoolInitializedIterator struct { + Event *ProverPoolInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProverPoolInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProverPoolInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProverPoolInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProverPoolInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProverPoolInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProverPoolInitialized represents a Initialized event raised by the ProverPool contract. +type ProverPoolInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_ProverPool *ProverPoolFilterer) FilterInitialized(opts *bind.FilterOpts) (*ProverPoolInitializedIterator, error) { + + logs, sub, err := _ProverPool.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &ProverPoolInitializedIterator{contract: _ProverPool.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_ProverPool *ProverPoolFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *ProverPoolInitialized) (event.Subscription, error) { + + logs, sub, err := _ProverPool.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProverPoolInitialized) + if err := _ProverPool.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_ProverPool *ProverPoolFilterer) ParseInitialized(log types.Log) (*ProverPoolInitialized, error) { + event := new(ProverPoolInitialized) + if err := _ProverPool.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ProverPoolOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the ProverPool contract. +type ProverPoolOwnershipTransferredIterator struct { + Event *ProverPoolOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProverPoolOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProverPoolOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProverPoolOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProverPoolOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProverPoolOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProverPoolOwnershipTransferred represents a OwnershipTransferred event raised by the ProverPool contract. +type ProverPoolOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ProverPool *ProverPoolFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ProverPoolOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ProverPool.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &ProverPoolOwnershipTransferredIterator{contract: _ProverPool.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ProverPool *ProverPoolFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ProverPoolOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ProverPool.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProverPoolOwnershipTransferred) + if err := _ProverPool.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ProverPool *ProverPoolFilterer) ParseOwnershipTransferred(log types.Log) (*ProverPoolOwnershipTransferred, error) { + event := new(ProverPoolOwnershipTransferred) + if err := _ProverPool.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ProverPoolSlashedIterator is returned from FilterSlashed and is used to iterate over the raw logs and unpacked data for Slashed events raised by the ProverPool contract. +type ProverPoolSlashedIterator struct { + Event *ProverPoolSlashed // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProverPoolSlashedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProverPoolSlashed) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProverPoolSlashed) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProverPoolSlashedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProverPoolSlashedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProverPoolSlashed represents a Slashed event raised by the ProverPool contract. +type ProverPoolSlashed struct { + Addr common.Address + Amount uint64 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterSlashed is a free log retrieval operation binding the contract event 0xdd80bbe216163c1792fa59b50e56f1a7ac79674c4815b65da0ef875a39655e08. +// +// Solidity: event Slashed(address indexed addr, uint64 amount) +func (_ProverPool *ProverPoolFilterer) FilterSlashed(opts *bind.FilterOpts, addr []common.Address) (*ProverPoolSlashedIterator, error) { + + var addrRule []interface{} + for _, addrItem := range addr { + addrRule = append(addrRule, addrItem) + } + + logs, sub, err := _ProverPool.contract.FilterLogs(opts, "Slashed", addrRule) + if err != nil { + return nil, err + } + return &ProverPoolSlashedIterator{contract: _ProverPool.contract, event: "Slashed", logs: logs, sub: sub}, nil +} + +// WatchSlashed is a free log subscription operation binding the contract event 0xdd80bbe216163c1792fa59b50e56f1a7ac79674c4815b65da0ef875a39655e08. +// +// Solidity: event Slashed(address indexed addr, uint64 amount) +func (_ProverPool *ProverPoolFilterer) WatchSlashed(opts *bind.WatchOpts, sink chan<- *ProverPoolSlashed, addr []common.Address) (event.Subscription, error) { + + var addrRule []interface{} + for _, addrItem := range addr { + addrRule = append(addrRule, addrItem) + } + + logs, sub, err := _ProverPool.contract.WatchLogs(opts, "Slashed", addrRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProverPoolSlashed) + if err := _ProverPool.contract.UnpackLog(event, "Slashed", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseSlashed is a log parse operation binding the contract event 0xdd80bbe216163c1792fa59b50e56f1a7ac79674c4815b65da0ef875a39655e08. +// +// Solidity: event Slashed(address indexed addr, uint64 amount) +func (_ProverPool *ProverPoolFilterer) ParseSlashed(log types.Log) (*ProverPoolSlashed, error) { + event := new(ProverPoolSlashed) + if err := _ProverPool.contract.UnpackLog(event, "Slashed", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ProverPoolStakedIterator is returned from FilterStaked and is used to iterate over the raw logs and unpacked data for Staked events raised by the ProverPool contract. +type ProverPoolStakedIterator struct { + Event *ProverPoolStaked // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProverPoolStakedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProverPoolStaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProverPoolStaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProverPoolStakedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProverPoolStakedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProverPoolStaked represents a Staked event raised by the ProverPool contract. +type ProverPoolStaked struct { + Addr common.Address + Amount uint64 + RewardPerGas uint16 + CurrentCapacity uint16 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterStaked is a free log retrieval operation binding the contract event 0xb071f01ce43c8c0960b11143f30bedc46b345006ee5631abbdfd2a5cb6562774. +// +// Solidity: event Staked(address indexed addr, uint64 amount, uint16 rewardPerGas, uint16 currentCapacity) +func (_ProverPool *ProverPoolFilterer) FilterStaked(opts *bind.FilterOpts, addr []common.Address) (*ProverPoolStakedIterator, error) { + + var addrRule []interface{} + for _, addrItem := range addr { + addrRule = append(addrRule, addrItem) + } + + logs, sub, err := _ProverPool.contract.FilterLogs(opts, "Staked", addrRule) + if err != nil { + return nil, err + } + return &ProverPoolStakedIterator{contract: _ProverPool.contract, event: "Staked", logs: logs, sub: sub}, nil +} + +// WatchStaked is a free log subscription operation binding the contract event 0xb071f01ce43c8c0960b11143f30bedc46b345006ee5631abbdfd2a5cb6562774. +// +// Solidity: event Staked(address indexed addr, uint64 amount, uint16 rewardPerGas, uint16 currentCapacity) +func (_ProverPool *ProverPoolFilterer) WatchStaked(opts *bind.WatchOpts, sink chan<- *ProverPoolStaked, addr []common.Address) (event.Subscription, error) { + + var addrRule []interface{} + for _, addrItem := range addr { + addrRule = append(addrRule, addrItem) + } + + logs, sub, err := _ProverPool.contract.WatchLogs(opts, "Staked", addrRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProverPoolStaked) + if err := _ProverPool.contract.UnpackLog(event, "Staked", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseStaked is a log parse operation binding the contract event 0xb071f01ce43c8c0960b11143f30bedc46b345006ee5631abbdfd2a5cb6562774. +// +// Solidity: event Staked(address indexed addr, uint64 amount, uint16 rewardPerGas, uint16 currentCapacity) +func (_ProverPool *ProverPoolFilterer) ParseStaked(log types.Log) (*ProverPoolStaked, error) { + event := new(ProverPoolStaked) + if err := _ProverPool.contract.UnpackLog(event, "Staked", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ProverPoolWithdrawnIterator is returned from FilterWithdrawn and is used to iterate over the raw logs and unpacked data for Withdrawn events raised by the ProverPool contract. +type ProverPoolWithdrawnIterator struct { + Event *ProverPoolWithdrawn // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProverPoolWithdrawnIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProverPoolWithdrawn) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProverPoolWithdrawn) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProverPoolWithdrawnIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProverPoolWithdrawnIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProverPoolWithdrawn represents a Withdrawn event raised by the ProverPool contract. +type ProverPoolWithdrawn struct { + Addr common.Address + Amount uint64 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterWithdrawn is a free log retrieval operation binding the contract event 0xbae95d59332d6e1e8f1ae78e7bebdaeef072d57b731c8790a636667e3a0a87ee. +// +// Solidity: event Withdrawn(address indexed addr, uint64 amount) +func (_ProverPool *ProverPoolFilterer) FilterWithdrawn(opts *bind.FilterOpts, addr []common.Address) (*ProverPoolWithdrawnIterator, error) { + + var addrRule []interface{} + for _, addrItem := range addr { + addrRule = append(addrRule, addrItem) + } + + logs, sub, err := _ProverPool.contract.FilterLogs(opts, "Withdrawn", addrRule) + if err != nil { + return nil, err + } + return &ProverPoolWithdrawnIterator{contract: _ProverPool.contract, event: "Withdrawn", logs: logs, sub: sub}, nil +} + +// WatchWithdrawn is a free log subscription operation binding the contract event 0xbae95d59332d6e1e8f1ae78e7bebdaeef072d57b731c8790a636667e3a0a87ee. +// +// Solidity: event Withdrawn(address indexed addr, uint64 amount) +func (_ProverPool *ProverPoolFilterer) WatchWithdrawn(opts *bind.WatchOpts, sink chan<- *ProverPoolWithdrawn, addr []common.Address) (event.Subscription, error) { + + var addrRule []interface{} + for _, addrItem := range addr { + addrRule = append(addrRule, addrItem) + } + + logs, sub, err := _ProverPool.contract.WatchLogs(opts, "Withdrawn", addrRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProverPoolWithdrawn) + if err := _ProverPool.contract.UnpackLog(event, "Withdrawn", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseWithdrawn is a log parse operation binding the contract event 0xbae95d59332d6e1e8f1ae78e7bebdaeef072d57b731c8790a636667e3a0a87ee. +// +// Solidity: event Withdrawn(address indexed addr, uint64 amount) +func (_ProverPool *ProverPoolFilterer) ParseWithdrawn(log types.Log) (*ProverPoolWithdrawn, error) { + event := new(ProverPoolWithdrawn) + if err := _ProverPool.contract.UnpackLog(event, "Withdrawn", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/packages/eventindexer/event.go b/packages/eventindexer/event.go index b695fb9359d..a806a31a5ec 100644 --- a/packages/eventindexer/event.go +++ b/packages/eventindexer/event.go @@ -7,6 +7,7 @@ import ( "net/http" "github.com/morkid/paginate" + "github.com/shopspring/decimal" "gorm.io/datatypes" ) @@ -14,19 +15,21 @@ var ( EventNameBlockProven = "BlockProven" EventNameBlockProposed = "BlockProposed" EventNameBlockVerified = "BlockVerified" + EventNameSlashed = "Slashed" ) // Event represents a stored EVM event. The fields will be serialized // into the Data field to be unmarshalled into a concrete struct // dependant on the name of the event type Event struct { - ID int `json:"id"` - Name string `json:"name"` - Data datatypes.JSON `json:"data"` - ChainID int64 `json:"chainID"` - Event string `json:"event"` - Address string `json:"address"` - BlockID sql.NullInt64 `json:"blockID"` + ID int `json:"id"` + Name string `json:"name"` + Data datatypes.JSON `json:"data"` + ChainID int64 `json:"chainID"` + Event string `json:"event"` + Address string `json:"address"` + BlockID sql.NullInt64 `json:"blockID"` + Amount decimal.NullDecimal `json:"amount"` } // SaveEventOpts @@ -37,6 +40,7 @@ type SaveEventOpts struct { Event string Address string BlockID *int64 + Amount *big.Int } type UniqueProversResponse struct { @@ -73,4 +77,5 @@ type EventRepository interface { address string, event string, ) (paginate.Page, error) + GetTotalSlashedTokens(ctx context.Context) (*big.Int, error) } diff --git a/packages/eventindexer/http/cache.go b/packages/eventindexer/http/cache.go new file mode 100644 index 00000000000..e9bbdd41bfc --- /dev/null +++ b/packages/eventindexer/http/cache.go @@ -0,0 +1,9 @@ +package http + +var ( + CacheKeyUniqueProposers = "unique-proposers" + CacheKeyUniqueProvers = "unique-provers" + CacheKeyStats = "stats" + CacheKeyPOSStats = "pos-stats" + CacheKeyCurrentProvers = "current-provers" +) diff --git a/packages/eventindexer/http/get_current_provers.go b/packages/eventindexer/http/get_current_provers.go new file mode 100644 index 00000000000..096ca50d515 --- /dev/null +++ b/packages/eventindexer/http/get_current_provers.go @@ -0,0 +1,60 @@ +package http + +import ( + "context" + "net/http" + + "github.com/cyberhorsey/webutils" + "github.com/labstack/echo/v4" + "github.com/patrickmn/go-cache" +) + +type Prover struct { + CurrentCapacity uint16 `json:"currentCapacity"` + Address string `json:"address"` + AmountStaked uint64 `json:"amountStaked"` +} + +type currentProversResponse struct { + Provers []Prover `json:"provers"` +} + +func (srv *Server) GetCurrentProvers(c echo.Context) error { + cached, found := srv.cache.Get(CacheKeyCurrentProvers) + + var resp *currentProversResponse + + var err error + + if found { + resp = cached.(*currentProversResponse) + } else { + resp, err = srv.getCurrentProvers(c.Request().Context()) + if err != nil { + return webutils.LogAndRenderErrors(c, http.StatusUnprocessableEntity, err) + } + + srv.cache.Set(CacheKeyCurrentProvers, resp, cache.DefaultExpiration) + } + + return c.JSON(http.StatusOK, resp) +} + +func (srv *Server) getCurrentProvers(ctx context.Context) (*currentProversResponse, error) { + provers, err := srv.proverPool.GetProvers(nil) + if err != nil { + return nil, err + } + + resp := ¤tProversResponse{} + + for i, prover := range provers.Provers { + resp.Provers = append(resp.Provers, Prover{ + CurrentCapacity: prover.CurrentCapacity, + AmountStaked: prover.StakedAmount, + Address: provers.Stakers[i].Hex(), + }) + } + + return resp, nil +} diff --git a/packages/eventindexer/http/get_pos_stats.go b/packages/eventindexer/http/get_pos_stats.go new file mode 100644 index 00000000000..a750904fc32 --- /dev/null +++ b/packages/eventindexer/http/get_pos_stats.go @@ -0,0 +1,56 @@ +package http + +import ( + "context" + "net/http" + + "github.com/cyberhorsey/webutils" + "github.com/labstack/echo/v4" + "github.com/patrickmn/go-cache" +) + +type posStatsResponse struct { + TotalSlashedTokens string `json:"totalSlashedTokens"` + CurrentProtocolCapacity string `json:"currentProtocolCapacity"` +} + +func (srv *Server) GetPOSStats(c echo.Context) error { + cached, found := srv.cache.Get(CacheKeyPOSStats) + + var resp *posStatsResponse + + var err error + + if found { + resp = cached.(*posStatsResponse) + } else { + resp, err = srv.getPosStats(c.Request().Context()) + + if err != nil { + return webutils.LogAndRenderErrors(c, http.StatusUnprocessableEntity, err) + } + + srv.cache.Set(CacheKeyPOSStats, resp, cache.DefaultExpiration) + } + + return c.JSON(http.StatusOK, resp) +} + +func (srv *Server) getPosStats(ctx context.Context) (*posStatsResponse, error) { + totalSlashedTokens, err := srv.eventRepo.GetTotalSlashedTokens(ctx) + if err != nil { + return nil, err + } + + capacity, err := srv.proverPool.GetCapacity(nil) + if err != nil { + return nil, err + } + + resp := &posStatsResponse{ + TotalSlashedTokens: totalSlashedTokens.String(), + CurrentProtocolCapacity: capacity.String(), + } + + return resp, nil +} diff --git a/packages/eventindexer/http/get_pos_stats_test.go b/packages/eventindexer/http/get_pos_stats_test.go new file mode 100644 index 00000000000..8917ca62af5 --- /dev/null +++ b/packages/eventindexer/http/get_pos_stats_test.go @@ -0,0 +1,50 @@ +package http + +import ( + "net/http" + "net/http/httptest" + "testing" + "time" + + "github.com/cyberhorsey/webutils/testutils" + "github.com/labstack/echo/v4" +) + +func Test_GetPOSStats(t *testing.T) { + srv := newTestServer("") + + srv.cache.Set(CacheKeyPOSStats, &posStatsResponse{ + TotalSlashedTokens: "1", + CurrentProtocolCapacity: "1", + }, 10*time.Second) + + tests := []struct { + name string + address string + wantStatus int + wantBodyRegexpMatches []string + }{ + { + "success", + "0x123", + http.StatusOK, + []string{`{"totalSlashedTokens":"1","currentProtocolCapacity":"1"}`}, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + req := testutils.NewUnauthenticatedRequest( + echo.GET, + "/posStats", + nil, + ) + + rec := httptest.NewRecorder() + + srv.ServeHTTP(rec, req) + + testutils.AssertStatusAndBody(t, rec, tt.wantStatus, tt.wantBodyRegexpMatches) + }) + } +} diff --git a/packages/eventindexer/http/get_stats.go b/packages/eventindexer/http/get_stats.go index 0fc21c18591..cbb68858c6d 100644 --- a/packages/eventindexer/http/get_stats.go +++ b/packages/eventindexer/http/get_stats.go @@ -5,14 +5,28 @@ import ( "github.com/cyberhorsey/webutils" "github.com/labstack/echo/v4" + "github.com/patrickmn/go-cache" + "github.com/taikoxyz/taiko-mono/packages/eventindexer" ) func (srv *Server) GetStats(c echo.Context) error { - stats, err := srv.statRepo.Find( - c.Request().Context(), - ) - if err != nil { - return webutils.LogAndRenderErrors(c, http.StatusUnprocessableEntity, err) + cached, found := srv.cache.Get(CacheKeyStats) + + var stats *eventindexer.Stat + + var err error + + if found { + stats = cached.(*eventindexer.Stat) + } else { + stats, err = srv.statRepo.Find( + c.Request().Context(), + ) + if err != nil { + return webutils.LogAndRenderErrors(c, http.StatusUnprocessableEntity, err) + } + + srv.cache.Set(CacheKeyStats, stats, cache.DefaultExpiration) } return c.JSON(http.StatusOK, stats) diff --git a/packages/eventindexer/http/get_unique_proposers.go b/packages/eventindexer/http/get_unique_proposers.go index f29f94a466a..cac8bd10ed9 100644 --- a/packages/eventindexer/http/get_unique_proposers.go +++ b/packages/eventindexer/http/get_unique_proposers.go @@ -5,6 +5,7 @@ import ( "github.com/cyberhorsey/webutils" "github.com/labstack/echo/v4" + "github.com/patrickmn/go-cache" "github.com/taikoxyz/taiko-mono/packages/eventindexer" ) @@ -14,11 +15,23 @@ type uniqueProposersResp struct { } func (srv *Server) GetUniqueProposers(c echo.Context) error { - proposers, err := srv.eventRepo.FindUniqueProposers( - c.Request().Context(), - ) - if err != nil { - return webutils.LogAndRenderErrors(c, http.StatusUnprocessableEntity, err) + cached, found := srv.cache.Get(CacheKeyUniqueProposers) + + var proposers []eventindexer.UniqueProposersResponse + + var err error + + if found { + proposers = cached.([]eventindexer.UniqueProposersResponse) + } else { + proposers, err = srv.eventRepo.FindUniqueProposers( + c.Request().Context(), + ) + if err != nil { + return webutils.LogAndRenderErrors(c, http.StatusUnprocessableEntity, err) + } + + srv.cache.Set(CacheKeyUniqueProposers, proposers, cache.DefaultExpiration) } return c.JSON(http.StatusOK, &uniqueProposersResp{ diff --git a/packages/eventindexer/http/get_unique_provers.go b/packages/eventindexer/http/get_unique_provers.go index 649cb1e2bca..02ec73bb40f 100644 --- a/packages/eventindexer/http/get_unique_provers.go +++ b/packages/eventindexer/http/get_unique_provers.go @@ -5,6 +5,7 @@ import ( "github.com/cyberhorsey/webutils" "github.com/labstack/echo/v4" + "github.com/patrickmn/go-cache" "github.com/taikoxyz/taiko-mono/packages/eventindexer" ) @@ -14,11 +15,23 @@ type uniqueProversResp struct { } func (srv *Server) GetUniqueProvers(c echo.Context) error { - provers, err := srv.eventRepo.FindUniqueProvers( - c.Request().Context(), - ) - if err != nil { - return webutils.LogAndRenderErrors(c, http.StatusUnprocessableEntity, err) + cached, found := srv.cache.Get(CacheKeyUniqueProvers) + + var provers []eventindexer.UniqueProversResponse + + var err error + + if found { + provers = cached.([]eventindexer.UniqueProversResponse) + } else { + provers, err = srv.eventRepo.FindUniqueProvers( + c.Request().Context(), + ) + if err != nil { + return webutils.LogAndRenderErrors(c, http.StatusUnprocessableEntity, err) + } + + srv.cache.Set(CacheKeyUniqueProvers, provers, cache.DefaultExpiration) } return c.JSON(http.StatusOK, &uniqueProversResp{ diff --git a/packages/eventindexer/http/routes.go b/packages/eventindexer/http/routes.go index 8c0f1620b54..a9462077972 100644 --- a/packages/eventindexer/http/routes.go +++ b/packages/eventindexer/http/routes.go @@ -9,4 +9,5 @@ func (srv *Server) configureRoutes() { srv.echo.GET("/eventByAddress", srv.GetCountByAddressAndEventName) srv.echo.GET("/events", srv.GetByAddressAndEventName) srv.echo.GET("/stats", srv.GetStats) + srv.echo.GET("/posStats", srv.GetPOSStats) } diff --git a/packages/eventindexer/http/server.go b/packages/eventindexer/http/server.go index 584ddbb32c4..ffa3fcf4cb2 100644 --- a/packages/eventindexer/http/server.go +++ b/packages/eventindexer/http/server.go @@ -5,25 +5,34 @@ import ( "fmt" "net/http" "os" + "time" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethclient" "github.com/labstack/echo/v4/middleware" + "github.com/patrickmn/go-cache" "github.com/taikoxyz/taiko-mono/packages/eventindexer" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/contracts/proverpool" echoprom "github.com/labstack/echo-contrib/prometheus" echo "github.com/labstack/echo/v4" ) type Server struct { - echo *echo.Echo - eventRepo eventindexer.EventRepository - statRepo eventindexer.StatRepository + echo *echo.Echo + eventRepo eventindexer.EventRepository + statRepo eventindexer.StatRepository + cache *cache.Cache + proverPool *proverpool.ProverPool } type NewServerOpts struct { - Echo *echo.Echo - EventRepo eventindexer.EventRepository - StatRepo eventindexer.StatRepository - CorsOrigins []string + Echo *echo.Echo + EventRepo eventindexer.EventRepository + StatRepo eventindexer.StatRepository + ProverPoolAddress common.Address + EthClient *ethclient.Client + CorsOrigins []string } func (opts NewServerOpts) Validate() error { @@ -43,6 +52,8 @@ func (opts NewServerOpts) Validate() error { return eventindexer.ErrNoCORSOrigins } + // proverpooladdress is optional + return nil } @@ -51,10 +62,25 @@ func NewServer(opts NewServerOpts) (*Server, error) { return nil, err } + cache := cache.New(5*time.Minute, 10*time.Minute) + + var proverPool *proverpool.ProverPool + + var err error + + if opts.ProverPoolAddress.Hex() != "" { + proverPool, err = proverpool.NewProverPool(opts.ProverPoolAddress, opts.EthClient) + if err != nil { + return nil, err + } + } + srv := &Server{ - echo: opts.Echo, - eventRepo: opts.EventRepo, - statRepo: opts.StatRepo, + echo: opts.Echo, + eventRepo: opts.EventRepo, + statRepo: opts.StatRepo, + cache: cache, + proverPool: proverPool, } corsOrigins := opts.CorsOrigins diff --git a/packages/eventindexer/http/server_test.go b/packages/eventindexer/http/server_test.go index a732f1a2f89..9395dd2f66f 100644 --- a/packages/eventindexer/http/server_test.go +++ b/packages/eventindexer/http/server_test.go @@ -5,9 +5,11 @@ import ( "net/http" "net/http/httptest" "testing" + "time" "github.com/joho/godotenv" echo "github.com/labstack/echo/v4" + "github.com/patrickmn/go-cache" "github.com/stretchr/testify/assert" "github.com/taikoxyz/taiko-mono/packages/eventindexer" "github.com/taikoxyz/taiko-mono/packages/eventindexer/mock" @@ -18,6 +20,7 @@ func newTestServer(url string) *Server { _ = godotenv.Load("../.test.env") srv := &Server{ + cache: cache.New(5*time.Second, 6*time.Second), echo: echo.New(), eventRepo: mock.NewEventRepository(), statRepo: mock.NewStatRepository(), diff --git a/packages/eventindexer/indexer/filter_then_subscribe.go b/packages/eventindexer/indexer/filter_then_subscribe.go index 4fd227e0e2f..46570ad6ad8 100644 --- a/packages/eventindexer/indexer/filter_then_subscribe.go +++ b/packages/eventindexer/indexer/filter_then_subscribe.go @@ -89,6 +89,16 @@ func (svc *Service) FilterThenSubscribe( return errors.Wrap(err, "svc.saveBlockVerifiedEvents") } + slashedEvents, err := svc.proverPool.FilterSlashed(filterOpts, nil) + if err != nil { + return errors.Wrap(err, "svc.proverPool.FilterSlashed") + } + + err = svc.saveSlashedEvents(ctx, chainID, slashedEvents) + if err != nil { + return errors.Wrap(err, "svc.saveSlashedEvents") + } + header, err := svc.ethClient.HeaderByNumber(ctx, big.NewInt(int64(end))) if err != nil { return errors.Wrap(err, "svc.ethClient.HeaderByNumber") diff --git a/packages/eventindexer/indexer/save_block_proven_event.go b/packages/eventindexer/indexer/save_block_proven_event.go index 8bddbe3586c..bc045a4cd76 100644 --- a/packages/eventindexer/indexer/save_block_proven_event.go +++ b/packages/eventindexer/indexer/save_block_proven_event.go @@ -118,7 +118,13 @@ func (svc *Service) updateAverageProofTime(ctx context.Context, event *taikol1.T new(big.Int).SetUint64(proofTime), ) - log.Infof("avgProofWindow update: id: %v, prover: %v, proposedAt: %v, provenAt: %v, proofTIme: %v, avg: %v, newAvg: %v", + log.Infof(`avgProofWindow update: id: %v, + prover: %v, + proposedAt: %v, + provenAt: %v, + proofTime: %v, + avg: %v, + newAvg: %v`, event.Id.Int64(), event.Prover.Hex(), proposedAt, diff --git a/packages/eventindexer/indexer/save_slashed_event.go b/packages/eventindexer/indexer/save_slashed_event.go new file mode 100644 index 00000000000..7519920f095 --- /dev/null +++ b/packages/eventindexer/indexer/save_slashed_event.go @@ -0,0 +1,65 @@ +package indexer + +import ( + "context" + "encoding/json" + "math/big" + + "github.com/pkg/errors" + log "github.com/sirupsen/logrus" + "github.com/taikoxyz/taiko-mono/packages/eventindexer" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/contracts/proverpool" +) + +func (svc *Service) saveSlashedEvents( + ctx context.Context, + chainID *big.Int, + events *proverpool.ProverPoolSlashedIterator, +) error { + if !events.Next() || events.Event == nil { + log.Infof("no Slashed events") + return nil + } + + for { + event := events.Event + + log.Infof("new slashed event, addr: %v", event.Addr.Hex()) + + if err := svc.saveSlashedEvent(ctx, chainID, event); err != nil { + eventindexer.SlashedEventsProcessedError.Inc() + + return errors.Wrap(err, "svc.saveBlockVerifiedEvent") + } + + if !events.Next() { + return nil + } + } +} + +func (svc *Service) saveSlashedEvent( + ctx context.Context, + chainID *big.Int, + event *proverpool.ProverPoolSlashed, +) error { + marshaled, err := json.Marshal(event) + if err != nil { + return errors.Wrap(err, "json.Marshal(event)") + } + + _, err = svc.eventRepo.Save(ctx, eventindexer.SaveEventOpts{ + Name: eventindexer.EventNameSlashed, + Data: string(marshaled), + ChainID: chainID, + Event: eventindexer.EventNameSlashed, + Address: "", + }) + if err != nil { + return errors.Wrap(err, "svc.eventRepo.Save") + } + + eventindexer.SlashedEventsProcessed.Inc() + + return nil +} diff --git a/packages/eventindexer/indexer/service.go b/packages/eventindexer/indexer/service.go index cbfdfd1197f..f9806ff5f04 100644 --- a/packages/eventindexer/indexer/service.go +++ b/packages/eventindexer/indexer/service.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/rpc" "github.com/taikoxyz/taiko-mono/packages/eventindexer" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/contracts/proverpool" "github.com/taikoxyz/taiko-mono/packages/eventindexer/contracts/taikol1" ) @@ -26,7 +27,8 @@ type Service struct { blockBatchSize uint64 subscriptionBackoff time.Duration - taikol1 *taikol1.TaikoL1 + taikol1 *taikol1.TaikoL1 + proverPool *proverpool.ProverPool } type NewServiceOpts struct { @@ -36,6 +38,7 @@ type NewServiceOpts struct { EthClient *ethclient.Client RPCClient *rpc.Client SrcTaikoAddress common.Address + ProverPoolAddress common.Address BlockBatchSize uint64 SubscriptionBackoff time.Duration } @@ -58,12 +61,21 @@ func NewService(opts NewServiceOpts) (*Service, error) { return nil, errors.Wrap(err, "contracts.NewTaikoL1") } + var proverPool *proverpool.ProverPool + if opts.ProverPoolAddress.Hex() != "" { + proverPool, err = proverpool.NewProverPool(opts.ProverPoolAddress, opts.EthClient) + if err != nil { + return nil, errors.Wrap(err, "proverpool.NewProverPool") + } + } + return &Service{ - eventRepo: opts.EventRepo, - blockRepo: opts.BlockRepo, - statRepo: opts.StatRepo, - ethClient: opts.EthClient, - taikol1: taikoL1, + eventRepo: opts.EventRepo, + blockRepo: opts.BlockRepo, + statRepo: opts.StatRepo, + ethClient: opts.EthClient, + taikol1: taikoL1, + proverPool: proverPool, blockBatchSize: opts.BlockBatchSize, subscriptionBackoff: opts.SubscriptionBackoff, diff --git a/packages/eventindexer/migrations/1666650599_create_events_table.sql b/packages/eventindexer/migrations/1666650599_create_events_table.sql index 99af8917801..a841d50a84c 100644 --- a/packages/eventindexer/migrations/1666650599_create_events_table.sql +++ b/packages/eventindexer/migrations/1666650599_create_events_table.sql @@ -2,12 +2,13 @@ -- +goose StatementBegin CREATE TABLE IF NOT EXISTS events ( id int NOT NULL PRIMARY KEY AUTO_INCREMENT, - name VARCHAR(255) NOT NULL, - event VARCHAR(255) NOT NULL DEFAULT "", + name VARCHAR(20) NOT NULL, + event VARCHAR(20) NOT NULL DEFAULT "", chain_id int NOT NULL, data JSON NOT NULL, - address VARCHAR(255) NOT NULL DEFAULT "", + address VARCHAR(42) NOT NULL DEFAULT "", block_id int DEFAULT NULL, + amount DECIMAL(65, 0) DEFAULT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP , updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ); diff --git a/packages/eventindexer/mock/event_repository.go b/packages/eventindexer/mock/event_repository.go index 9b5e3882130..be48b8c6c18 100644 --- a/packages/eventindexer/mock/event_repository.go +++ b/packages/eventindexer/mock/event_repository.go @@ -2,6 +2,7 @@ package mock import ( "context" + "math/big" "math/rand" "net/http" @@ -105,3 +106,9 @@ func (r *EventRepository) Delete( return nil } + +func (r *EventRepository) GetTotalSlashedTokens( + ctx context.Context, +) (*big.Int, error) { + return big.NewInt(1), nil +} diff --git a/packages/eventindexer/prometheus.go b/packages/eventindexer/prometheus.go index f5b7fc7bf35..aebe7c73164 100644 --- a/packages/eventindexer/prometheus.go +++ b/packages/eventindexer/prometheus.go @@ -30,6 +30,14 @@ var ( Name: "block_verified_events_processed_error_ops_total", Help: "The total number of processed BlockVerified event errors encountered", }) + SlashedEventsProcessed = promauto.NewCounter(prometheus.CounterOpts{ + Name: "slashed_events_processed_ops_total", + Help: "The total number of processed BlockVerified events", + }) + SlashedEventsProcessedError = promauto.NewCounter(prometheus.CounterOpts{ + Name: "slashed_events_processed_error_ops_total", + Help: "The total number of processed BlockVerified event errors encountered", + }) BlocksProcessed = promauto.NewCounter(prometheus.CounterOpts{ Name: "blocks_processed_ops_total", Help: "The total number of processed blocks", diff --git a/packages/eventindexer/repo/containers_test.go b/packages/eventindexer/repo/containers_test.go index 53eff7bcc84..d0d809b7e6a 100644 --- a/packages/eventindexer/repo/containers_test.go +++ b/packages/eventindexer/repo/containers_test.go @@ -23,7 +23,7 @@ var ( func testMysql(t *testing.T) (eventindexer.DB, func(), error) { req := testcontainers.ContainerRequest{ - Image: "mysql:latest", + Image: "mysql:8.0.33", ExposedPorts: []string{"3306/tcp", "33060/tcp"}, Env: map[string]string{ "MYSQL_ROOT_PASSWORD": dbPassword, diff --git a/packages/eventindexer/repo/event.go b/packages/eventindexer/repo/event.go index da647870fbe..a51fad778f9 100644 --- a/packages/eventindexer/repo/event.go +++ b/packages/eventindexer/repo/event.go @@ -2,10 +2,13 @@ package repo import ( "context" + "database/sql" + "math/big" "net/http" "github.com/morkid/paginate" "github.com/pkg/errors" + "github.com/shopspring/decimal" "github.com/taikoxyz/taiko-mono/packages/eventindexer" "gorm.io/datatypes" "gorm.io/gorm" @@ -34,6 +37,25 @@ func (r *EventRepository) Save(ctx context.Context, opts eventindexer.SaveEventO Address: opts.Address, } + if opts.BlockID != nil { + e.BlockID = sql.NullInt64{ + Valid: true, + Int64: *opts.BlockID, + } + } + + if opts.Amount != nil { + amt, err := decimal.NewFromString(opts.Amount.String()) + if err != nil { + return nil, errors.Wrap(err, "decimal.NewFromString") + } + + e.Amount = decimal.NullDecimal{ + Valid: true, + Decimal: amt, + } + } + if err := r.db.GormDB().Create(e).Error; err != nil { return nil, errors.Wrap(err, "r.db.Create") } @@ -134,3 +156,21 @@ func (r *EventRepository) GetByAddressAndEventName( return page, nil } + +func (r *EventRepository) GetTotalSlashedTokens( + ctx context.Context, +) (*big.Int, error) { + var sum decimal.NullDecimal + + if err := r.db.GormDB(). + Raw("SELECT SUM(amount) FROM events WHERE event = ?", eventindexer.EventNameSlashed). + FirstOrInit(&sum).Error; err != nil { + return nil, errors.Wrap(err, "r.db.FirstOrInit") + } + + if !sum.Valid { + return big.NewInt(0), nil + } + + return sum.Decimal.BigInt(), nil +} diff --git a/packages/eventindexer/repo/event_test.go b/packages/eventindexer/repo/event_test.go index 62b69010a94..5d302882c2b 100644 --- a/packages/eventindexer/repo/event_test.go +++ b/packages/eventindexer/repo/event_test.go @@ -257,3 +257,52 @@ func TestIntegration_Event_Delete(t *testing.T) { }) } } + +func TestIntegration_Event_GetTotalSlashedTokens(t *testing.T) { + db, close, err := testMysql(t) + assert.Equal(t, nil, err) + + defer close() + + eventRepo, err := NewEventRepository(db) + assert.Equal(t, nil, err) + + opts := eventindexer.SaveEventOpts{ + Name: eventindexer.EventNameSlashed, + Address: "0x123", + Data: "{\"data\":\"something\"}", + Event: eventindexer.EventNameSlashed, + ChainID: big.NewInt(1), + BlockID: &blockID, + Amount: big.NewInt(1), + } + + for i := 0; i < 5; i++ { + _, err = eventRepo.Save(context.Background(), opts) + + assert.Equal(t, nil, err) + } + + tests := []struct { + name string + wantResp *big.Int + wantErr error + }{ + { + "success", + big.NewInt(5), + nil, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + resp, err := eventRepo.GetTotalSlashedTokens( + context.Background(), + ) + spew.Dump(resp) + assert.Equal(t, tt.wantErr, err) + assert.Equal(t, tt.wantResp, resp) + }) + } +}