From 84695503236df7cb82a686e34b5757add7e48ace Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Wed, 23 Oct 2024 17:26:37 -0400 Subject: [PATCH 01/36] set up log-fetcher: event listener + log parsing + request validation --- services/go-filler/log-fetcher/.gitignore | 1 + services/go-filler/log-fetcher/README.md | 5 + services/go-filler/log-fetcher/cmd/main.go | 16 + services/go-filler/log-fetcher/go.mod | 33 + services/go-filler/log-fetcher/go.sum | 62 ++ .../internal/abis/RIP7755Outbox.json | 618 ++++++++++++++++++ .../log-fetcher/internal/chains/config.go | 119 ++++ .../internal/clients/eth_client.go | 19 + .../log-fetcher/internal/config/config.go | 48 ++ .../log-fetcher/internal/config/provers.go | 19 + .../log-fetcher/internal/handler/handler.go | 30 + .../log-fetcher/internal/listener/listener.go | 74 +++ .../log-fetcher/internal/parser/parser.go | 68 ++ .../internal/validator/validate.go | 67 ++ .../ts-filler/src/handler/handler.service.ts | 5 +- 15 files changed, 1180 insertions(+), 4 deletions(-) create mode 100644 services/go-filler/log-fetcher/.gitignore create mode 100644 services/go-filler/log-fetcher/README.md create mode 100644 services/go-filler/log-fetcher/cmd/main.go create mode 100644 services/go-filler/log-fetcher/go.mod create mode 100644 services/go-filler/log-fetcher/go.sum create mode 100644 services/go-filler/log-fetcher/internal/abis/RIP7755Outbox.json create mode 100644 services/go-filler/log-fetcher/internal/chains/config.go create mode 100644 services/go-filler/log-fetcher/internal/clients/eth_client.go create mode 100644 services/go-filler/log-fetcher/internal/config/config.go create mode 100644 services/go-filler/log-fetcher/internal/config/provers.go create mode 100644 services/go-filler/log-fetcher/internal/handler/handler.go create mode 100644 services/go-filler/log-fetcher/internal/listener/listener.go create mode 100644 services/go-filler/log-fetcher/internal/parser/parser.go create mode 100644 services/go-filler/log-fetcher/internal/validator/validate.go diff --git a/services/go-filler/log-fetcher/.gitignore b/services/go-filler/log-fetcher/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/services/go-filler/log-fetcher/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/services/go-filler/log-fetcher/README.md b/services/go-filler/log-fetcher/README.md new file mode 100644 index 0000000..7ace30e --- /dev/null +++ b/services/go-filler/log-fetcher/README.md @@ -0,0 +1,5 @@ +# Log Fetcher + +## Overview + +The Log Fetcher serves as the first component in our fulfiller architecture. It's main purpose is to monitor events from `RIP7755Outbox` contracts on supported chains. When it ingests an event representing a cross-chain call request, it first parses the log into an ingestible format. It then validates the request by ensuring all routing information matches pre-defined chain configs for the source / destination chains. It then validates that the reward asset / amount represents a reward that would guarantee profit if this request were accepted by the system. If the request passes validation, the log fetcher passes it along to an SQS queue for further processing. diff --git a/services/go-filler/log-fetcher/cmd/main.go b/services/go-filler/log-fetcher/cmd/main.go new file mode 100644 index 0000000..3ba65dd --- /dev/null +++ b/services/go-filler/log-fetcher/cmd/main.go @@ -0,0 +1,16 @@ +package main + +import ( + "math/big" + + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/listener" +) + +func main() { + cfg := config.NewConfig() // Load env vars + srcChain := chains.GetChainConfig(big.NewInt(421614), cfg.RPCs) + + listener.Init(srcChain, cfg) +} diff --git a/services/go-filler/log-fetcher/go.mod b/services/go-filler/log-fetcher/go.mod new file mode 100644 index 0000000..cfbf026 --- /dev/null +++ b/services/go-filler/log-fetcher/go.mod @@ -0,0 +1,33 @@ +module github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher + +go 1.23.2 + +require ( + github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/StackExchange/wmi v1.2.1 // indirect + github.com/bits-and-blooms/bitset v1.13.0 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect + github.com/consensys/bavard v0.1.13 // indirect + github.com/consensys/gnark-crypto v0.12.1 // indirect + github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect + github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect + github.com/deckarep/golang-set/v2 v2.6.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect + github.com/ethereum/c-kzg-4844 v1.0.0 // indirect + github.com/ethereum/go-ethereum v1.14.11 // indirect + github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect + github.com/gorilla/websocket v1.4.2 // indirect + github.com/holiman/uint256 v1.3.1 // indirect + github.com/joho/godotenv v1.5.1 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect + github.com/supranational/blst v0.3.13 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect + golang.org/x/crypto v0.22.0 // indirect + golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.22.0 // indirect + rsc.io/tmplfunc v0.0.3 // indirect +) diff --git a/services/go-filler/log-fetcher/go.sum b/services/go-filler/log-fetcher/go.sum new file mode 100644 index 0000000..d0d9a97 --- /dev/null +++ b/services/go-filler/log-fetcher/go.sum @@ -0,0 +1,62 @@ +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= +github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= +github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= +github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= +github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= +github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= +github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= +github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= +github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= +github.com/ethereum/go-ethereum v1.14.11 h1:8nFDCUUE67rPc6AKxFj7JKaOa2W/W1Rse3oS6LvvxEY= +github.com/ethereum/go-ethereum v1.14.11/go.mod h1:+l/fr42Mma+xBnhefL/+z11/hcmJ2egl+ScIVPjhc7E= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= +github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= +github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= +github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= diff --git a/services/go-filler/log-fetcher/internal/abis/RIP7755Outbox.json b/services/go-filler/log-fetcher/internal/abis/RIP7755Outbox.json new file mode 100644 index 0000000..1b91100 --- /dev/null +++ b/services/go-filler/log-fetcher/internal/abis/RIP7755Outbox.json @@ -0,0 +1,618 @@ +[ + { + "type": "function", + "name": "CANCEL_DELAY_SECONDS", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "cancelRequest", + "inputs": [ + { + "name": "request", + "type": "tuple", + "internalType": "struct CrossChainRequest", + "components": [ + { + "name": "requester", + "type": "address", + "internalType": "address" + }, + { + "name": "calls", + "type": "tuple[]", + "internalType": "struct Call[]", + "components": [ + { "name": "to", "type": "address", "internalType": "address" }, + { "name": "data", "type": "bytes", "internalType": "bytes" }, + { + "name": "value", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "name": "proverContract", + "type": "address", + "internalType": "address" + }, + { + "name": "destinationChainId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "inboxContract", + "type": "address", + "internalType": "address" + }, + { + "name": "l2Oracle", + "type": "address", + "internalType": "address" + }, + { + "name": "l2OracleStorageKey", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "rewardAsset", + "type": "address", + "internalType": "address" + }, + { + "name": "rewardAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "finalityDelaySeconds", + "type": "uint256", + "internalType": "uint256" + }, + { "name": "nonce", "type": "uint256", "internalType": "uint256" }, + { "name": "expiry", "type": "uint256", "internalType": "uint256" }, + { + "name": "precheckContract", + "type": "address", + "internalType": "address" + }, + { "name": "precheckData", "type": "bytes", "internalType": "bytes" } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "claimReward", + "inputs": [ + { + "name": "request", + "type": "tuple", + "internalType": "struct CrossChainRequest", + "components": [ + { + "name": "requester", + "type": "address", + "internalType": "address" + }, + { + "name": "calls", + "type": "tuple[]", + "internalType": "struct Call[]", + "components": [ + { "name": "to", "type": "address", "internalType": "address" }, + { "name": "data", "type": "bytes", "internalType": "bytes" }, + { + "name": "value", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "name": "proverContract", + "type": "address", + "internalType": "address" + }, + { + "name": "destinationChainId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "inboxContract", + "type": "address", + "internalType": "address" + }, + { + "name": "l2Oracle", + "type": "address", + "internalType": "address" + }, + { + "name": "l2OracleStorageKey", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "rewardAsset", + "type": "address", + "internalType": "address" + }, + { + "name": "rewardAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "finalityDelaySeconds", + "type": "uint256", + "internalType": "uint256" + }, + { "name": "nonce", "type": "uint256", "internalType": "uint256" }, + { "name": "expiry", "type": "uint256", "internalType": "uint256" }, + { + "name": "precheckContract", + "type": "address", + "internalType": "address" + }, + { "name": "precheckData", "type": "bytes", "internalType": "bytes" } + ] + }, + { + "name": "fulfillmentInfo", + "type": "tuple", + "internalType": "struct RIP7755Inbox.FulfillmentInfo", + "components": [ + { "name": "timestamp", "type": "uint96", "internalType": "uint96" }, + { "name": "filler", "type": "address", "internalType": "address" } + ] + }, + { "name": "proof", "type": "bytes", "internalType": "bytes" }, + { "name": "payTo", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getRequestStatus", + "inputs": [ + { "name": "requestHash", "type": "bytes32", "internalType": "bytes32" } + ], + "outputs": [ + { + "name": "", + "type": "uint8", + "internalType": "enum RIP7755Outbox.CrossChainCallStatus" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "hashRequest", + "inputs": [ + { + "name": "request", + "type": "tuple", + "internalType": "struct CrossChainRequest", + "components": [ + { + "name": "requester", + "type": "address", + "internalType": "address" + }, + { + "name": "calls", + "type": "tuple[]", + "internalType": "struct Call[]", + "components": [ + { "name": "to", "type": "address", "internalType": "address" }, + { "name": "data", "type": "bytes", "internalType": "bytes" }, + { + "name": "value", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "name": "proverContract", + "type": "address", + "internalType": "address" + }, + { + "name": "destinationChainId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "inboxContract", + "type": "address", + "internalType": "address" + }, + { + "name": "l2Oracle", + "type": "address", + "internalType": "address" + }, + { + "name": "l2OracleStorageKey", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "rewardAsset", + "type": "address", + "internalType": "address" + }, + { + "name": "rewardAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "finalityDelaySeconds", + "type": "uint256", + "internalType": "uint256" + }, + { "name": "nonce", "type": "uint256", "internalType": "uint256" }, + { "name": "expiry", "type": "uint256", "internalType": "uint256" }, + { + "name": "precheckContract", + "type": "address", + "internalType": "address" + }, + { "name": "precheckData", "type": "bytes", "internalType": "bytes" } + ] + } + ], + "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "hashRequestMemory", + "inputs": [ + { + "name": "request", + "type": "tuple", + "internalType": "struct CrossChainRequest", + "components": [ + { + "name": "requester", + "type": "address", + "internalType": "address" + }, + { + "name": "calls", + "type": "tuple[]", + "internalType": "struct Call[]", + "components": [ + { "name": "to", "type": "address", "internalType": "address" }, + { "name": "data", "type": "bytes", "internalType": "bytes" }, + { + "name": "value", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "name": "proverContract", + "type": "address", + "internalType": "address" + }, + { + "name": "destinationChainId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "inboxContract", + "type": "address", + "internalType": "address" + }, + { + "name": "l2Oracle", + "type": "address", + "internalType": "address" + }, + { + "name": "l2OracleStorageKey", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "rewardAsset", + "type": "address", + "internalType": "address" + }, + { + "name": "rewardAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "finalityDelaySeconds", + "type": "uint256", + "internalType": "uint256" + }, + { "name": "nonce", "type": "uint256", "internalType": "uint256" }, + { "name": "expiry", "type": "uint256", "internalType": "uint256" }, + { + "name": "precheckContract", + "type": "address", + "internalType": "address" + }, + { "name": "precheckData", "type": "bytes", "internalType": "bytes" } + ] + } + ], + "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "requestCrossChainCall", + "inputs": [ + { + "name": "request", + "type": "tuple", + "internalType": "struct CrossChainRequest", + "components": [ + { + "name": "requester", + "type": "address", + "internalType": "address" + }, + { + "name": "calls", + "type": "tuple[]", + "internalType": "struct Call[]", + "components": [ + { "name": "to", "type": "address", "internalType": "address" }, + { "name": "data", "type": "bytes", "internalType": "bytes" }, + { + "name": "value", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "name": "proverContract", + "type": "address", + "internalType": "address" + }, + { + "name": "destinationChainId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "inboxContract", + "type": "address", + "internalType": "address" + }, + { + "name": "l2Oracle", + "type": "address", + "internalType": "address" + }, + { + "name": "l2OracleStorageKey", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "rewardAsset", + "type": "address", + "internalType": "address" + }, + { + "name": "rewardAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "finalityDelaySeconds", + "type": "uint256", + "internalType": "uint256" + }, + { "name": "nonce", "type": "uint256", "internalType": "uint256" }, + { "name": "expiry", "type": "uint256", "internalType": "uint256" }, + { + "name": "precheckContract", + "type": "address", + "internalType": "address" + }, + { "name": "precheckData", "type": "bytes", "internalType": "bytes" } + ] + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "event", + "name": "CrossChainCallCanceled", + "inputs": [ + { + "name": "requestHash", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "CrossChainCallRequested", + "inputs": [ + { + "name": "requestHash", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "request", + "type": "tuple", + "indexed": false, + "internalType": "struct CrossChainRequest", + "components": [ + { + "name": "requester", + "type": "address", + "internalType": "address" + }, + { + "name": "calls", + "type": "tuple[]", + "internalType": "struct Call[]", + "components": [ + { "name": "to", "type": "address", "internalType": "address" }, + { "name": "data", "type": "bytes", "internalType": "bytes" }, + { + "name": "value", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "name": "proverContract", + "type": "address", + "internalType": "address" + }, + { + "name": "destinationChainId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "inboxContract", + "type": "address", + "internalType": "address" + }, + { + "name": "l2Oracle", + "type": "address", + "internalType": "address" + }, + { + "name": "l2OracleStorageKey", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "rewardAsset", + "type": "address", + "internalType": "address" + }, + { + "name": "rewardAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "finalityDelaySeconds", + "type": "uint256", + "internalType": "uint256" + }, + { "name": "nonce", "type": "uint256", "internalType": "uint256" }, + { "name": "expiry", "type": "uint256", "internalType": "uint256" }, + { + "name": "precheckContract", + "type": "address", + "internalType": "address" + }, + { "name": "precheckData", "type": "bytes", "internalType": "bytes" } + ] + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "AddressEmptyCode", + "inputs": [ + { "name": "target", "type": "address", "internalType": "address" } + ] + }, + { + "type": "error", + "name": "AddressInsufficientBalance", + "inputs": [ + { "name": "account", "type": "address", "internalType": "address" } + ] + }, + { + "type": "error", + "name": "CannotCancelRequestBeforeExpiry", + "inputs": [ + { + "name": "currentTimestamp", + "type": "uint256", + "internalType": "uint256" + }, + { "name": "expiry", "type": "uint256", "internalType": "uint256" } + ] + }, + { "type": "error", "name": "ExpiryTooSoon", "inputs": [] }, + { "type": "error", "name": "FailedInnerCall", "inputs": [] }, + { + "type": "error", + "name": "InvalidCaller", + "inputs": [ + { "name": "caller", "type": "address", "internalType": "address" }, + { + "name": "expectedCaller", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "InvalidStatus", + "inputs": [ + { + "name": "expected", + "type": "uint8", + "internalType": "enum RIP7755Outbox.CrossChainCallStatus" + }, + { + "name": "actual", + "type": "uint8", + "internalType": "enum RIP7755Outbox.CrossChainCallStatus" + } + ] + }, + { + "type": "error", + "name": "InvalidValue", + "inputs": [ + { "name": "expected", "type": "uint256", "internalType": "uint256" }, + { "name": "received", "type": "uint256", "internalType": "uint256" } + ] + }, + { "type": "error", "name": "ProofValidationFailed", "inputs": [] }, + { + "type": "error", + "name": "SafeERC20FailedOperation", + "inputs": [ + { "name": "token", "type": "address", "internalType": "address" } + ] + } +] diff --git a/services/go-filler/log-fetcher/internal/chains/config.go b/services/go-filler/log-fetcher/internal/chains/config.go new file mode 100644 index 0000000..6d55a9e --- /dev/null +++ b/services/go-filler/log-fetcher/internal/chains/config.go @@ -0,0 +1,119 @@ +package chains + +import ( + "encoding/hex" + "log" + "math/big" + + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/ethereum/go-ethereum/common" +) + +type Contracts struct { + AnchorStateRegistry common.Address + ArbRollup common.Address + L2MessagePasser common.Address + Inbox common.Address + Outbox common.Address +} + +type ChainConfig struct { + ChainId *big.Int + ProverContracts map[string]common.Address + RpcUrl string + L2Oracle common.Address + L2OracleStorageKey [32]byte + Contracts *Contracts + TargetProver config.Prover +} + +func GetChainConfig(chainId *big.Int, rpcConfig *config.RPCs) *ChainConfig { + var chainConfig *ChainConfig + + switch chainId.Int64() { + // Arbitrum Sepolia + case 421614: + provers := map[string]common.Address{ + config.OPStackProver.String(): common.HexToAddress("0x062fBdCfd17A0346D2A9d89FE233bbAdBd1DC14C"), + } + contracts := &Contracts{ + Inbox: common.HexToAddress("0xeE962eD1671F655a806cB22623eEA8A7cCc233bC"), + Outbox: common.HexToAddress("0xBCd5762cF9B07EF5597014c350CE2efB2b0DB2D2"), + } + + chainConfig = &ChainConfig{ + ChainId: chainId, + ProverContracts: provers, + RpcUrl: rpcConfig.ArbitrumSepolia, + L2Oracle: common.HexToAddress("0xd80810638dbDF9081b72C1B33c65375e807281C8"), + L2OracleStorageKey: encodeBytes("0000000000000000000000000000000000000000000000000000000000000076"), + Contracts: contracts, + TargetProver: config.ArbitrumProver, + } + // Base Sepolia + case 84532: + provers := map[string]common.Address{ + config.ArbitrumProver.String(): common.HexToAddress("0x49E2cDC9e81825B6C718ae8244fe0D5b062F4874"), + config.OPStackProver.String(): common.HexToAddress("0x562879614C9Db8Da9379be1D5B52BAEcDD456d78"), + } + contracts := &Contracts{ + Inbox: common.HexToAddress("0xB482b292878FDe64691d028A2237B34e91c7c7ea"), + Outbox: common.HexToAddress("0xD7a5A114A07cC4B5ebd9C5e1cD1136a99fFA3d68"), + } + + chainConfig = &ChainConfig{ + ChainId: chainId, + ProverContracts: provers, + RpcUrl: rpcConfig.BaseSepolia, + L2Oracle: common.HexToAddress("0x4C8BA32A5DAC2A720bb35CeDB51D6B067D104205"), + L2OracleStorageKey: encodeBytes("a6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49"), + Contracts: contracts, + TargetProver: config.OPStackProver, + } + // Optimism Sepolia + case 11155420: + provers := map[string]common.Address{} + contracts := &Contracts{ + L2MessagePasser: common.HexToAddress("0x4200000000000000000000000000000000000016"), + Inbox: common.HexToAddress("0x49E2cDC9e81825B6C718ae8244fe0D5b062F4874"), + } + + chainConfig = &ChainConfig{ + ChainId: chainId, + ProverContracts: provers, + RpcUrl: rpcConfig.OptimismSepolia, + L2Oracle: common.HexToAddress("0x218CD9489199F321E1177b56385d333c5B598629"), + L2OracleStorageKey: encodeBytes("a6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49"), + Contracts: contracts, + TargetProver: config.OPStackProver, + } + // Sepolia + case 11155111: + provers := map[string]common.Address{} + contracts := &Contracts{ + AnchorStateRegistry: common.HexToAddress("0x218CD9489199F321E1177b56385d333c5B598629"), + ArbRollup: common.HexToAddress("0xd80810638dbDF9081b72C1B33c65375e807281C8"), + } + + chainConfig = &ChainConfig{ + ChainId: chainId, + ProverContracts: provers, + RpcUrl: rpcConfig.Sepolia, + Contracts: contracts, + TargetProver: config.NilProver, + } + } + + return chainConfig +} + +func encodeBytes(bytesStr string) [32]byte { + bytes, err := hex.DecodeString(bytesStr) + if err != nil { + log.Fatal(err) + } + + var byteArray [32]byte + copy(byteArray[32-len(bytes):], bytes) + return byteArray +} diff --git a/services/go-filler/log-fetcher/internal/clients/eth_client.go b/services/go-filler/log-fetcher/internal/clients/eth_client.go new file mode 100644 index 0000000..f761424 --- /dev/null +++ b/services/go-filler/log-fetcher/internal/clients/eth_client.go @@ -0,0 +1,19 @@ +package ethclient + +import ( + "fmt" + + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" + "github.com/ethereum/go-ethereum/ethclient" +) + +func GetClient(cfg *chains.ChainConfig) (*ethclient.Client, error) { + client, err := ethclient.Dial(cfg.RpcUrl) + if err != nil { + return nil, err + } + + fmt.Println("Connected to client") + + return client, nil +} diff --git a/services/go-filler/log-fetcher/internal/config/config.go b/services/go-filler/log-fetcher/internal/config/config.go new file mode 100644 index 0000000..10ed3fc --- /dev/null +++ b/services/go-filler/log-fetcher/internal/config/config.go @@ -0,0 +1,48 @@ +package config + +import ( + "log" + "os" + + "github.com/joho/godotenv" +) + +type RPCs struct { + ArbitrumSepolia string + BaseSepolia string + OptimismSepolia string + Sepolia string +} + +type Config struct { + RPCs *RPCs +} + +func NewConfig() *Config { + if err := godotenv.Load(".env"); err != nil { + log.Fatal("config file not found") + } + + config := &Config{ + RPCs: &RPCs{ + ArbitrumSepolia: getEnvStr("ARBITRUM_SEPOLIA_RPC"), + BaseSepolia: getEnvStr("BASE_SEPOLIA_RPC"), + OptimismSepolia: getEnvStr("OPTIMISM_SEPOLIA_RPC"), + Sepolia: getEnvStr("SEPOLIA_RPC"), + }, + } + + return config +} + +// getEnvStr ... Reads env var from process environment, panics if not found +func getEnvStr(key string) string { + envVar, ok := os.LookupEnv(key) + + // Not found + if !ok { + log.Fatalf("could not find env var given key: %s", key) + } + + return envVar +} diff --git a/services/go-filler/log-fetcher/internal/config/provers.go b/services/go-filler/log-fetcher/internal/config/provers.go new file mode 100644 index 0000000..c1fc2ca --- /dev/null +++ b/services/go-filler/log-fetcher/internal/config/provers.go @@ -0,0 +1,19 @@ +package config + +type Prover int + +const ( + NilProver Prover = iota + ArbitrumProver + OPStackProver +) + +var proverName = map[Prover]string{ + NilProver: "None", + ArbitrumProver: "ArbitrumProver", + OPStackProver: "OPStackProver", +} + +func (ss Prover) String() string { + return proverName[ss] +} diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go new file mode 100644 index 0000000..eb1315d --- /dev/null +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -0,0 +1,30 @@ +package handler + +import ( + "fmt" + "log" + + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/validator" + "github.com/ethereum/go-ethereum/core/types" +) + +func HandleLog(vLog types.Log, srcChain *chains.ChainConfig, cfg *config.Config) error { + parsedLog, err := parser.ParseLog(vLog) + if err != nil { + log.Fatal(err) + } + + // validate Log + err = validator.ValidateLog(cfg, srcChain, parsedLog) + if err != nil { + log.Fatal(err) + } + + // send log to queue + fmt.Println("Ready to send to queue") + + return nil +} diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go new file mode 100644 index 0000000..562991c --- /dev/null +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -0,0 +1,74 @@ +package listener + +import ( + "context" + "fmt" + "log" + "math/big" + + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" + ethclient "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/clients" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/handler" + "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" +) + +func Init(srcChain *chains.ChainConfig, cfg *config.Config) { + client, err := ethclient.GetClient(srcChain) + if err != nil { + log.Fatal(err) + } + + contractAddress := srcChain.Contracts.Outbox + if contractAddress == common.HexToAddress("") { + log.Fatalf("Source chain %s missing Outbox contract address", srcChain.ChainId) + } + + crossChainCallRequestedSig := []byte("CrossChainCallRequested(bytes32,(address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes))") + crossChainCallRequestedHash := crypto.Keccak256Hash(crossChainCallRequestedSig) + + query := ethereum.FilterQuery{ + FromBlock: big.NewInt(90542608), + ToBlock: big.NewInt(90542608), + Addresses: []common.Address{contractAddress}, + Topics: [][]common.Hash{{crossChainCallRequestedHash}}, + } + + logs, err := client.FilterLogs(context.Background(), query) + if err != nil { + log.Fatal(err) + } + + for _, vLog := range logs { + fmt.Println("Log received!") + fmt.Printf("Log Block Number: %d\n", vLog.BlockNumber) + fmt.Printf("Log Index: %d\n", vLog.Index) + + err := handler.HandleLog(vLog, srcChain, cfg) + if err != nil { + log.Fatal(err) + } + } + + // query := ethereum.FilterQuery{ + // Addresses: []common.Address{contractAddress}, + // } + + // logs := make(chan types.Log) + + // sub, err := client.SubscribeFilterLogs(context.Background(), query, logs) + // if err != nil { + // log.Fatal(err) + // } + + // for { + // select { + // case err := <-sub.Err(): + // log.Fatal(err) + // case vLog := <- logs: + // fmt.Println(vLog) // pointer to event log + // } + // } +} diff --git a/services/go-filler/log-fetcher/internal/parser/parser.go b/services/go-filler/log-fetcher/internal/parser/parser.go new file mode 100644 index 0000000..ecdbadb --- /dev/null +++ b/services/go-filler/log-fetcher/internal/parser/parser.go @@ -0,0 +1,68 @@ +package parser + +import ( + "math/big" + "os" + "path/filepath" + "strings" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" +) + +type Call struct { + To common.Address + Data []byte + Value *big.Int +} + +type CrossChainRequest struct { + Requester common.Address + Calls []Call + ProverContract common.Address + DestinationChainId *big.Int + InboxContract common.Address + L2Oracle common.Address + L2OracleStorageKey [32]byte + RewardAsset common.Address + RewardAmount *big.Int + FinalityDelaySeconds *big.Int + Nonce *big.Int + Expiry *big.Int + PrecheckContract common.Address + PrecheckData []byte +} + +type LogCrossChainCallRequested struct { + RequestHash [32]byte + Request CrossChainRequest +} + +func ParseLog(vLog types.Log) (LogCrossChainCallRequested, error) { + absPath, err := filepath.Abs("internal/abis/RIP7755Outbox.json") + if err != nil { + return LogCrossChainCallRequested{}, err + } + + outboxAbi, err := os.ReadFile(absPath) + if err != nil { + return LogCrossChainCallRequested{}, err + } + + contractAbi, err := abi.JSON(strings.NewReader(string(outboxAbi))) + if err != nil { + return LogCrossChainCallRequested{}, err + } + + var event LogCrossChainCallRequested + + err = contractAbi.UnpackIntoInterface(&event, "CrossChainCallRequested", vLog.Data) + if err != nil { + return LogCrossChainCallRequested{}, err + } + + event.RequestHash = vLog.Topics[1] + + return event, nil +} diff --git a/services/go-filler/log-fetcher/internal/validator/validate.go b/services/go-filler/log-fetcher/internal/validator/validate.go new file mode 100644 index 0000000..f328eac --- /dev/null +++ b/services/go-filler/log-fetcher/internal/validator/validate.go @@ -0,0 +1,67 @@ +package validator + +import ( + "errors" + "math/big" + + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" + "github.com/ethereum/go-ethereum/common" +) + +func ValidateLog(cfg *config.Config, srcChain *chains.ChainConfig, parsedLog parser.LogCrossChainCallRequested) error { + // - Confirm valid proverContract address on source chain + dstChain := chains.GetChainConfig(parsedLog.Request.DestinationChainId, cfg.RPCs) + if dstChain.ChainId == big.NewInt(0) { + return errors.New("unknown destination chain") + } + + proverName := dstChain.TargetProver.String() + if proverName == "" { + return errors.New("destination chain missing Prover name") + } + + expectedProverAddr := srcChain.ProverContracts[proverName] + if expectedProverAddr == common.HexToAddress("") { + return errors.New("expected prover address not found for source chain") + } + + if parsedLog.Request.ProverContract != expectedProverAddr { + return errors.New("unknown Prover contract") + } + + // - Make sure inboxContract matches the trusted inbox for dst chain Id + if parsedLog.Request.InboxContract != dstChain.Contracts.Inbox { + return errors.New("unknown Inbox contract on destination chain") + } + + // - Confirm l2Oracle and l2OracleStorageKey are valid for dst chain + if parsedLog.Request.L2Oracle != dstChain.L2Oracle { + return errors.New("unknown Oracle contract for destination chain") + } + if parsedLog.Request.L2OracleStorageKey != dstChain.L2OracleStorageKey { + return errors.New("unknown storage key for dst L2Oracle") + } + + // - Add up total value needed + valueNeeded := big.NewInt(0) + + for i := 0; i < len(parsedLog.Request.Calls); i++ { + valueNeeded.Add(valueNeeded, parsedLog.Request.Calls[i].Value) + } + + // - rewardAsset + rewardAmount should make sense given requested calls + if !isValidReward(parsedLog.Request, valueNeeded) { + return errors.New("undesirable reward") + } + + return nil +} + +func isValidReward(request parser.CrossChainRequest, valueNeeded *big.Int) bool { + nativeAssetAddr := common.HexToAddress("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE") + isGreaterThan := request.RewardAmount.Cmp(valueNeeded) == 1 + + return request.RewardAsset == nativeAssetAddr && isGreaterThan +} diff --git a/services/ts-filler/src/handler/handler.service.ts b/services/ts-filler/src/handler/handler.service.ts index d55ebac..47964c3 100644 --- a/services/ts-filler/src/handler/handler.service.ts +++ b/services/ts-filler/src/handler/handler.service.ts @@ -22,10 +22,7 @@ export default class HandlerService { const expectedProverAddr = this.activeChains.src.proverContracts[proverName].toLowerCase(); - if ( - this.activeChains.src.proverContracts[proverName].toLowerCase() !== - expectedProverAddr - ) { + if (request.proverContract.toLowerCase() !== expectedProverAddr) { throw new Error("Unknown Prover contract"); } From 3c91cb9fcbfb2cf60e61673b35afb5e732d2c55a Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Wed, 23 Oct 2024 20:01:43 -0400 Subject: [PATCH 02/36] add sqs client wrapper and some unit tests for chains config --- services/go-filler/log-fetcher/go.mod | 19 +++ services/go-filler/log-fetcher/go.sum | 43 +++++ .../internal/chains/config_test.go | 156 ++++++++++++++++++ .../log-fetcher/internal/config/config.go | 4 +- .../log-fetcher/internal/handler/handler.go | 7 +- .../log-fetcher/internal/parser/parser.go | 3 + .../log-fetcher/internal/queue/queue.go | 44 +++++ .../internal/validator/validate.go | 3 + 8 files changed, 276 insertions(+), 3 deletions(-) create mode 100644 services/go-filler/log-fetcher/internal/chains/config_test.go create mode 100644 services/go-filler/log-fetcher/internal/queue/queue.go diff --git a/services/go-filler/log-fetcher/go.mod b/services/go-filler/log-fetcher/go.mod index cfbf026..a80e971 100644 --- a/services/go-filler/log-fetcher/go.mod +++ b/services/go-filler/log-fetcher/go.mod @@ -5,12 +5,27 @@ go 1.23.2 require ( github.com/Microsoft/go-winio v0.6.2 // indirect github.com/StackExchange/wmi v1.2.1 // indirect + github.com/aws/aws-sdk-go-v2 v1.32.2 // indirect + github.com/aws/aws-sdk-go-v2/config v1.28.0 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.17.41 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.17 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.21 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.2 // indirect + github.com/aws/aws-sdk-go-v2/service/sqs v1.36.2 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.24.2 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.2 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.32.2 // indirect + github.com/aws/smithy-go v1.22.0 // indirect github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.6.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/ethereum/c-kzg-4844 v1.0.0 // indirect @@ -19,9 +34,12 @@ require ( github.com/go-ole/go-ole v1.3.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/holiman/uint256 v1.3.1 // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/joho/godotenv v1.5.1 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect + github.com/stretchr/testify v1.9.0 // indirect github.com/supranational/blst v0.3.13 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect @@ -29,5 +47,6 @@ require ( golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.22.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) diff --git a/services/go-filler/log-fetcher/go.sum b/services/go-filler/log-fetcher/go.sum index d0d9a97..9a9dac4 100644 --- a/services/go-filler/log-fetcher/go.sum +++ b/services/go-filler/log-fetcher/go.sum @@ -2,6 +2,34 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/aws/aws-sdk-go-v2 v1.32.2 h1:AkNLZEyYMLnx/Q/mSKkcMqwNFXMAvFto9bNsHqcTduI= +github.com/aws/aws-sdk-go-v2 v1.32.2/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo= +github.com/aws/aws-sdk-go-v2/config v1.28.0 h1:FosVYWcqEtWNxHn8gB/Vs6jOlNwSoyOCA/g/sxyySOQ= +github.com/aws/aws-sdk-go-v2/config v1.28.0/go.mod h1:pYhbtvg1siOOg8h5an77rXle9tVG8T+BWLWAo7cOukc= +github.com/aws/aws-sdk-go-v2/credentials v1.17.41 h1:7gXo+Axmp+R4Z+AK8YFQO0ZV3L0gizGINCOWxSLY9W8= +github.com/aws/aws-sdk-go-v2/credentials v1.17.41/go.mod h1:u4Eb8d3394YLubphT4jLEwN1rLNq2wFOlT6OuxFwPzU= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.17 h1:TMH3f/SCAWdNtXXVPPu5D6wrr4G5hI1rAxbcocKfC7Q= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.17/go.mod h1:1ZRXLdTpzdJb9fwTMXiLipENRxkGMTn1sfKexGllQCw= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21 h1:UAsR3xA31QGf79WzpG/ixT9FZvQlh5HY1NRqSHBNOCk= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21/go.mod h1:JNr43NFf5L9YaG3eKTm7HQzls9J+A9YYcGI5Quh1r2Y= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.21 h1:6jZVETqmYCadGFvrYEQfC5fAQmlo80CeL5psbno6r0s= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.21/go.mod h1:1SR0GbLlnN3QUmYaflZNiH1ql+1qrSiB2vwcJ+4UM60= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 h1:TToQNkvGguu209puTojY/ozlqy2d/SFNcoLIqTFi42g= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0/go.mod h1:0jp+ltwkf+SwG2fm/PKo8t4y8pJSgOCO4D8Lz3k0aHQ= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.2 h1:s7NA1SOw8q/5c0wr8477yOPp0z+uBaXBnLE0XYb0POA= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.2/go.mod h1:fnjjWyAW/Pj5HYOxl9LJqWtEwS7W2qgcRLWP+uWbss0= +github.com/aws/aws-sdk-go-v2/service/sqs v1.36.2 h1:kmbcoWgbzfh5a6rvfjOnfHSGEqD13qu1GfTPRZqg0FI= +github.com/aws/aws-sdk-go-v2/service/sqs v1.36.2/go.mod h1:/UPx74a3M0WYeT2yLQYG/qHhkPlPXd6TsppfGgy2COk= +github.com/aws/aws-sdk-go-v2/service/sso v1.24.2 h1:bSYXVyUzoTHoKalBmwaZxs97HU9DWWI3ehHSAMa7xOk= +github.com/aws/aws-sdk-go-v2/service/sso v1.24.2/go.mod h1:skMqY7JElusiOUjMJMOv1jJsP7YUg7DrhgqZZWuzu1U= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.2 h1:AhmO1fHINP9vFYUE0LHzCWg/LfUWUF+zFPEcY9QXb7o= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.2/go.mod h1:o8aQygT2+MVP0NaV6kbdE1YnnIM8RRVQzoeUH45GOdI= +github.com/aws/aws-sdk-go-v2/service/sts v1.32.2 h1:CiS7i0+FUe+/YY1GvIBLLrR/XNGZ4CtM1Ll0XavNuVo= +github.com/aws/aws-sdk-go-v2/service/sts v1.32.2/go.mod h1:HtaiBI8CjYoNVde8arShXb94UbQQi9L4EMr6D+xGBwo= +github.com/aws/smithy-go v1.22.0 h1:uunKnWlcoL3zO7q+gG2Pk53joueEOsnNB28QdMsmiMM= +github.com/aws/smithy-go v1.22.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= @@ -14,6 +42,9 @@ github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLR github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= @@ -33,13 +64,21 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0U github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= @@ -58,5 +97,9 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= diff --git a/services/go-filler/log-fetcher/internal/chains/config_test.go b/services/go-filler/log-fetcher/internal/chains/config_test.go new file mode 100644 index 0000000..089e60c --- /dev/null +++ b/services/go-filler/log-fetcher/internal/chains/config_test.go @@ -0,0 +1,156 @@ +package chains + +import ( + "math/big" + "reflect" + "testing" + + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/ethereum/go-ethereum/common" +) + +func TestGetChainConfig(t *testing.T) { + testCases := []struct { + name string + chainID int64 + rpcConfig *config.RPCs + expected *ChainConfig + }{ + { + name: "Arbitrum Sepolia", + chainID: 421614, + rpcConfig: &config.RPCs{ + ArbitrumSepolia: "https://arb-sepolia.example.com", + }, + expected: &ChainConfig{ + ChainId: big.NewInt(421614), + ProverContracts: map[string]common.Address{ + config.OPStackProver.String(): common.HexToAddress("0x062fBdCfd17A0346D2A9d89FE233bbAdBd1DC14C"), + }, + RpcUrl: "https://arb-sepolia.example.com", + L2Oracle: common.HexToAddress("0xd80810638dbDF9081b72C1B33c65375e807281C8"), + L2OracleStorageKey: encodeBytes("0000000000000000000000000000000000000000000000000000000000000076"), + Contracts: &Contracts{ + Inbox: common.HexToAddress("0xeE962eD1671F655a806cB22623eEA8A7cCc233bC"), + Outbox: common.HexToAddress("0xBCd5762cF9B07EF5597014c350CE2efB2b0DB2D2"), + }, + TargetProver: config.ArbitrumProver, + }, + }, + { + name: "Base Sepolia", + chainID: 84532, + rpcConfig: &config.RPCs{ + BaseSepolia: "https://base-sepolia.example.com", + }, + expected: &ChainConfig{ + ChainId: big.NewInt(84532), + ProverContracts: map[string]common.Address{ + config.ArbitrumProver.String(): common.HexToAddress("0x49E2cDC9e81825B6C718ae8244fe0D5b062F4874"), + config.OPStackProver.String(): common.HexToAddress("0x562879614C9Db8Da9379be1D5B52BAEcDD456d78"), + }, + RpcUrl: "https://base-sepolia.example.com", + L2Oracle: common.HexToAddress("0x4C8BA32A5DAC2A720bb35CeDB51D6B067D104205"), + L2OracleStorageKey: encodeBytes("a6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49"), + Contracts: &Contracts{ + Inbox: common.HexToAddress("0xB482b292878FDe64691d028A2237B34e91c7c7ea"), + Outbox: common.HexToAddress("0xD7a5A114A07cC4B5ebd9C5e1cD1136a99fFA3d68"), + }, + TargetProver: config.OPStackProver, + }, + }, + { + name: "Optimism Sepolia", + chainID: 11155420, + rpcConfig: &config.RPCs{ + OptimismSepolia: "https://opt-sepolia.example.com", + }, + expected: &ChainConfig{ + ChainId: big.NewInt(11155420), + ProverContracts: map[string]common.Address{}, + RpcUrl: "https://opt-sepolia.example.com", + L2Oracle: common.HexToAddress("0x218CD9489199F321E1177b56385d333c5B598629"), + L2OracleStorageKey: encodeBytes("a6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49"), + Contracts: &Contracts{ + L2MessagePasser: common.HexToAddress("0x4200000000000000000000000000000000000016"), + Inbox: common.HexToAddress("0x49E2cDC9e81825B6C718ae8244fe0D5b062F4874"), + }, + TargetProver: config.OPStackProver, + }, + }, + { + name: "Sepolia", + chainID: 11155111, + rpcConfig: &config.RPCs{ + Sepolia: "https://sepolia.example.com", + }, + expected: &ChainConfig{ + ChainId: big.NewInt(11155111), + ProverContracts: map[string]common.Address{}, + RpcUrl: "https://sepolia.example.com", + Contracts: &Contracts{ + AnchorStateRegistry: common.HexToAddress("0x218CD9489199F321E1177b56385d333c5B598629"), + ArbRollup: common.HexToAddress("0xd80810638dbDF9081b72C1B33c65375e807281C8"), + }, + TargetProver: config.NilProver, + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + result := GetChainConfig(big.NewInt(tc.chainID), tc.rpcConfig) + if !reflect.DeepEqual(result, tc.expected) { + t.Errorf("GetChainConfig(%d) = %+v, want %+v", tc.chainID, result, tc.expected) + } + }) + } +} + +func TestGetChainConfig_UnknownChain(t *testing.T) { + unknownChainID := big.NewInt(999999) + result := GetChainConfig(unknownChainID, &config.RPCs{}) + if result != nil { + + t.Errorf("GetChainConfig(%d) = %+v, want nil", unknownChainID, result) + } +} + +func TestEncodeBytes(t *testing.T) { + testCases := []struct { + name string + input string + expected [32]byte + }{ + { + name: "Empty string", + input: "", + expected: [32]byte{}, + }, + { + name: "Short string", + input: "0102030405", + expected: [32]byte{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, + }, + }, + { + name: "Full 32-byte string", + input: "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20", + expected: [32]byte{ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + result := encodeBytes(tc.input) + if !reflect.DeepEqual(result, tc.expected) { + t.Errorf("encodeBytes(%s) = %v, want %v", tc.input, result, tc.expected) + } + }) + } +} diff --git a/services/go-filler/log-fetcher/internal/config/config.go b/services/go-filler/log-fetcher/internal/config/config.go index 10ed3fc..34594db 100644 --- a/services/go-filler/log-fetcher/internal/config/config.go +++ b/services/go-filler/log-fetcher/internal/config/config.go @@ -15,7 +15,8 @@ type RPCs struct { } type Config struct { - RPCs *RPCs + RPCs *RPCs + QueueUrl string } func NewConfig() *Config { @@ -30,6 +31,7 @@ func NewConfig() *Config { OptimismSepolia: getEnvStr("OPTIMISM_SEPOLIA_RPC"), Sepolia: getEnvStr("SEPOLIA_RPC"), }, + QueueUrl: getEnvStr("AWS_QUEUE_URL"), } return config diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go index eb1315d..b409181 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler.go +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -1,12 +1,12 @@ package handler import ( - "fmt" "log" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/queue" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/validator" "github.com/ethereum/go-ethereum/core/types" ) @@ -24,7 +24,10 @@ func HandleLog(vLog types.Log, srcChain *chains.ChainConfig, cfg *config.Config) } // send log to queue - fmt.Println("Ready to send to queue") + err = queue.SendMessage(parsedLog, cfg) + if err != nil { + log.Fatal(err) + } return nil } diff --git a/services/go-filler/log-fetcher/internal/parser/parser.go b/services/go-filler/log-fetcher/internal/parser/parser.go index ecdbadb..60addb6 100644 --- a/services/go-filler/log-fetcher/internal/parser/parser.go +++ b/services/go-filler/log-fetcher/internal/parser/parser.go @@ -1,6 +1,7 @@ package parser import ( + "fmt" "math/big" "os" "path/filepath" @@ -40,6 +41,8 @@ type LogCrossChainCallRequested struct { } func ParseLog(vLog types.Log) (LogCrossChainCallRequested, error) { + fmt.Println("Parsing log") + absPath, err := filepath.Abs("internal/abis/RIP7755Outbox.json") if err != nil { return LogCrossChainCallRequested{}, err diff --git a/services/go-filler/log-fetcher/internal/queue/queue.go b/services/go-filler/log-fetcher/internal/queue/queue.go new file mode 100644 index 0000000..167ba79 --- /dev/null +++ b/services/go-filler/log-fetcher/internal/queue/queue.go @@ -0,0 +1,44 @@ +package queue + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/aws/aws-sdk-go-v2/config" + "github.com/aws/aws-sdk-go-v2/service/sqs" + internalConfig "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" +) + +func SendMessage(parsedLog parser.LogCrossChainCallRequested, cfg *internalConfig.Config) error { + fmt.Println("Sending job to queue") + + sdkConfig, err := config.LoadDefaultConfig(context.Background()) + if err != nil { + return err + } + + sqsClient := sqs.NewFromConfig(sdkConfig) + + job, err := json.Marshal(parsedLog) + if err != nil { + return err + } + + jobStr := string(job) + + params := sqs.SendMessageInput{ + MessageBody: &jobStr, + QueueUrl: &cfg.QueueUrl, + } + + queueRes, err := sqsClient.SendMessage(context.TODO(), ¶ms) + if err != nil { + return err + } + + fmt.Println(queueRes) + + return nil +} diff --git a/services/go-filler/log-fetcher/internal/validator/validate.go b/services/go-filler/log-fetcher/internal/validator/validate.go index f328eac..031a06d 100644 --- a/services/go-filler/log-fetcher/internal/validator/validate.go +++ b/services/go-filler/log-fetcher/internal/validator/validate.go @@ -2,6 +2,7 @@ package validator import ( "errors" + "fmt" "math/big" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" @@ -11,6 +12,8 @@ import ( ) func ValidateLog(cfg *config.Config, srcChain *chains.ChainConfig, parsedLog parser.LogCrossChainCallRequested) error { + fmt.Println("Validating log") + // - Confirm valid proverContract address on source chain dstChain := chains.GetChainConfig(parsedLog.Request.DestinationChainId, cfg.RPCs) if dstChain.ChainId == big.NewInt(0) { From 91ddeef9758e67215b79b75b6d8d70dca5cd4363 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Thu, 24 Oct 2024 14:42:33 -0400 Subject: [PATCH 03/36] add unit testing for ethclient and config --- services/go-filler/log-fetcher/cmd/main.go | 12 ++++- services/go-filler/log-fetcher/go.mod | 1 + services/go-filler/log-fetcher/go.sum | 25 +++++++++ .../internal/clients/eth_client_test.go | 46 ++++++++++++++++ .../log-fetcher/internal/config/config.go | 6 +-- .../internal/config/config_test.go | 53 +++++++++++++++++++ .../log-fetcher/internal/handler/handler.go | 8 ++- .../log-fetcher/internal/listener/listener.go | 13 ++--- services/ts-filler/scripts/generateProof.ts | 2 +- .../ts-filler/src/prover/prover.service.ts | 1 + 10 files changed, 150 insertions(+), 17 deletions(-) create mode 100644 services/go-filler/log-fetcher/internal/clients/eth_client_test.go create mode 100644 services/go-filler/log-fetcher/internal/config/config_test.go diff --git a/services/go-filler/log-fetcher/cmd/main.go b/services/go-filler/log-fetcher/cmd/main.go index 3ba65dd..2efbcb3 100644 --- a/services/go-filler/log-fetcher/cmd/main.go +++ b/services/go-filler/log-fetcher/cmd/main.go @@ -1,6 +1,7 @@ package main import ( + "log" "math/big" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" @@ -9,8 +10,15 @@ import ( ) func main() { - cfg := config.NewConfig() // Load env vars + cfg, err := config.NewConfig() // Load env vars + if err != nil { + log.Fatal(err) + } + srcChain := chains.GetChainConfig(big.NewInt(421614), cfg.RPCs) - listener.Init(srcChain, cfg) + err = listener.Init(srcChain, cfg) + if err != nil { + log.Fatal(err) + } } diff --git a/services/go-filler/log-fetcher/go.mod b/services/go-filler/log-fetcher/go.mod index a80e971..e667efd 100644 --- a/services/go-filler/log-fetcher/go.mod +++ b/services/go-filler/log-fetcher/go.mod @@ -32,6 +32,7 @@ require ( github.com/ethereum/go-ethereum v1.14.11 // indirect github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect github.com/go-ole/go-ole v1.3.0 // indirect + github.com/golang/mock v1.6.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/holiman/uint256 v1.3.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect diff --git a/services/go-filler/log-fetcher/go.sum b/services/go-filler/log-fetcher/go.sum index 9a9dac4..72a4ac3 100644 --- a/services/go-filler/log-fetcher/go.sum +++ b/services/go-filler/log-fetcher/go.sum @@ -59,6 +59,8 @@ github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= @@ -85,18 +87,41 @@ github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFA github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/services/go-filler/log-fetcher/internal/clients/eth_client_test.go b/services/go-filler/log-fetcher/internal/clients/eth_client_test.go new file mode 100644 index 0000000..012d83b --- /dev/null +++ b/services/go-filler/log-fetcher/internal/clients/eth_client_test.go @@ -0,0 +1,46 @@ +package ethclient + +import ( + "net/http" + "net/http/httptest" + "testing" + + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" + "github.com/stretchr/testify/assert" +) + +func TestGetClient(t *testing.T) { + t.Run("successful connection", func(t *testing.T) { + // Create a mock HTTP server + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + })) + defer server.Close() + + // Create a chain config with the mock server URL + cfg := &chains.ChainConfig{ + RpcUrl: server.URL, + } + + // Call GetClient + client, err := GetClient(cfg) + + // Assert + assert.NoError(t, err) + assert.NotNil(t, client) + }) + + t.Run("failed connection", func(t *testing.T) { + // Create a chain config with an invalid URL + cfg := &chains.ChainConfig{ + RpcUrl: "invalid-url", + } + + // Call GetClient + client, err := GetClient(cfg) + + // Assert + assert.Error(t, err) + assert.Nil(t, client) + }) +} diff --git a/services/go-filler/log-fetcher/internal/config/config.go b/services/go-filler/log-fetcher/internal/config/config.go index 34594db..f6a46db 100644 --- a/services/go-filler/log-fetcher/internal/config/config.go +++ b/services/go-filler/log-fetcher/internal/config/config.go @@ -19,9 +19,9 @@ type Config struct { QueueUrl string } -func NewConfig() *Config { +func NewConfig() (*Config, error) { if err := godotenv.Load(".env"); err != nil { - log.Fatal("config file not found") + return nil, err } config := &Config{ @@ -34,7 +34,7 @@ func NewConfig() *Config { QueueUrl: getEnvStr("AWS_QUEUE_URL"), } - return config + return config, nil } // getEnvStr ... Reads env var from process environment, panics if not found diff --git a/services/go-filler/log-fetcher/internal/config/config_test.go b/services/go-filler/log-fetcher/internal/config/config_test.go new file mode 100644 index 0000000..439a20f --- /dev/null +++ b/services/go-filler/log-fetcher/internal/config/config_test.go @@ -0,0 +1,53 @@ +// config_test.go +package config + +import ( + "os" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestNewConfig(t *testing.T) { + // Setup test environment variables + os.Setenv("ARBITRUM_SEPOLIA_RPC", "https://arbitrum-sepolia.example.com") + os.Setenv("BASE_SEPOLIA_RPC", "https://base-sepolia.example.com") + os.Setenv("OPTIMISM_SEPOLIA_RPC", "https://optimism-sepolia.example.com") + os.Setenv("SEPOLIA_RPC", "https://sepolia.example.com") + os.Setenv("AWS_QUEUE_URL", "https://sqs.example.com/queue") + + // Create a temporary .env file + envContent := ` +ARBITRUM_SEPOLIA_RPC=https://arbitrum-sepolia.example.com +BASE_SEPOLIA_RPC=https://base-sepolia.example.com +OPTIMISM_SEPOLIA_RPC=https://optimism-sepolia.example.com +SEPOLIA_RPC=https://sepolia.example.com +AWS_QUEUE_URL=https://sqs.example.com/queue +` + err := os.WriteFile(".env", []byte(envContent), 0644) + assert.NoError(t, err) + defer os.Remove(".env") + + // Test NewConfig + config, err := NewConfig() + + assert.NoError(t, err) + + assert.NotNil(t, config) + assert.NotNil(t, config.RPCs) + assert.Equal(t, "https://arbitrum-sepolia.example.com", config.RPCs.ArbitrumSepolia) + assert.Equal(t, "https://base-sepolia.example.com", config.RPCs.BaseSepolia) + assert.Equal(t, "https://optimism-sepolia.example.com", config.RPCs.OptimismSepolia) + assert.Equal(t, "https://sepolia.example.com", config.RPCs.Sepolia) + assert.Equal(t, "https://sqs.example.com/queue", config.QueueUrl) +} + +func TestNewConfigMissingEnvVar(t *testing.T) { + // Ensure no environment variables are set + os.Clearenv() + + _, err := NewConfig() + if err == nil { + t.Fatal("expected an error due to missing environment variables, got none") + } +} diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go index b409181..6127377 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler.go +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -1,8 +1,6 @@ package handler import ( - "log" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" @@ -14,19 +12,19 @@ import ( func HandleLog(vLog types.Log, srcChain *chains.ChainConfig, cfg *config.Config) error { parsedLog, err := parser.ParseLog(vLog) if err != nil { - log.Fatal(err) + return err } // validate Log err = validator.ValidateLog(cfg, srcChain, parsedLog) if err != nil { - log.Fatal(err) + return err } // send log to queue err = queue.SendMessage(parsedLog, cfg) if err != nil { - log.Fatal(err) + return err } return nil diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index 562991c..f7f40f0 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -3,7 +3,6 @@ package listener import ( "context" "fmt" - "log" "math/big" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" @@ -15,15 +14,15 @@ import ( "github.com/ethereum/go-ethereum/crypto" ) -func Init(srcChain *chains.ChainConfig, cfg *config.Config) { +func Init(srcChain *chains.ChainConfig, cfg *config.Config) error { client, err := ethclient.GetClient(srcChain) if err != nil { - log.Fatal(err) + return err } contractAddress := srcChain.Contracts.Outbox if contractAddress == common.HexToAddress("") { - log.Fatalf("Source chain %s missing Outbox contract address", srcChain.ChainId) + return fmt.Errorf("source chain %s missing Outbox contract address", srcChain.ChainId) } crossChainCallRequestedSig := []byte("CrossChainCallRequested(bytes32,(address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes))") @@ -38,7 +37,7 @@ func Init(srcChain *chains.ChainConfig, cfg *config.Config) { logs, err := client.FilterLogs(context.Background(), query) if err != nil { - log.Fatal(err) + return err } for _, vLog := range logs { @@ -48,7 +47,7 @@ func Init(srcChain *chains.ChainConfig, cfg *config.Config) { err := handler.HandleLog(vLog, srcChain, cfg) if err != nil { - log.Fatal(err) + return err } } @@ -71,4 +70,6 @@ func Init(srcChain *chains.ChainConfig, cfg *config.Config) { // fmt.Println(vLog) // pointer to event log // } // } + + return nil } diff --git a/services/ts-filler/scripts/generateProof.ts b/services/ts-filler/scripts/generateProof.ts index 254192b..7b04bd8 100644 --- a/services/ts-filler/scripts/generateProof.ts +++ b/services/ts-filler/scripts/generateProof.ts @@ -26,7 +26,7 @@ async function main() { const configService = new ConfigService(); const chainService = new ChainService(activeChains, configService); const prover = new Prover(activeChains, chainService); - const proof = await prover.generateProof(); + const proof = await prover.generateProof(config.requestHash); await Bun.write("./Proof.json", JSON.stringify(proof)); } diff --git a/services/ts-filler/src/prover/prover.service.ts b/services/ts-filler/src/prover/prover.service.ts index 18182a0..30e4816 100644 --- a/services/ts-filler/src/prover/prover.service.ts +++ b/services/ts-filler/src/prover/prover.service.ts @@ -40,6 +40,7 @@ export default class ProverService { requestHash: Address ): Promise { const beaconData = await this.chainService.getBeaconRootAndL2Timestamp(); + console.log(beaconData); const beaconBlock = await this.chainService.getBeaconBlock( beaconData.beaconRoot ); From 086e090e1faf71d4dbbe2a6abbf9aa936c24bb10 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Thu, 24 Oct 2024 15:21:00 -0400 Subject: [PATCH 04/36] add docker-compose with redis, update queue client --- services/go-filler/docker-compose.yml | 13 +++++ services/go-filler/log-fetcher/go.mod | 11 +++++ services/go-filler/log-fetcher/go.sum | 48 +++++++++++++++++++ .../internal/clients/eth_client.go | 4 +- .../internal/clients/eth_client_test.go | 6 +-- .../internal/clients/queue_client.go | 40 ++++++++++++++++ .../log-fetcher/internal/config/config.go | 8 ++-- .../log-fetcher/internal/handler/handler.go | 4 +- .../log-fetcher/internal/listener/listener.go | 4 +- .../log-fetcher/internal/queue/queue.go | 44 ----------------- 10 files changed, 126 insertions(+), 56 deletions(-) create mode 100644 services/go-filler/docker-compose.yml create mode 100644 services/go-filler/log-fetcher/internal/clients/queue_client.go delete mode 100644 services/go-filler/log-fetcher/internal/queue/queue.go diff --git a/services/go-filler/docker-compose.yml b/services/go-filler/docker-compose.yml new file mode 100644 index 0000000..3536614 --- /dev/null +++ b/services/go-filler/docker-compose.yml @@ -0,0 +1,13 @@ +version: "3.8" +services: + cache: + image: redis:6.2-alpine + restart: always + ports: + - "6379:6379" + command: redis-server --save 20 1 --loglevel warning --requirepass eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81 + volumes: + - cache:/data +volumes: + cache: + driver: local diff --git a/services/go-filler/log-fetcher/go.mod b/services/go-filler/log-fetcher/go.mod index e667efd..2800592 100644 --- a/services/go-filler/log-fetcher/go.mod +++ b/services/go-filler/log-fetcher/go.mod @@ -21,6 +21,7 @@ require ( github.com/aws/smithy-go v1.22.0 // indirect github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect @@ -28,18 +29,26 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.6.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect + github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/ethereum/c-kzg-4844 v1.0.0 // indirect github.com/ethereum/go-ethereum v1.14.11 // indirect github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/golang/mock v1.6.0 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect + github.com/hibiken/asynq v0.24.1 // indirect github.com/holiman/uint256 v1.3.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/joho/godotenv v1.5.1 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/redis/go-redis/v9 v9.0.3 // indirect + github.com/robfig/cron/v3 v3.0.1 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect + github.com/spf13/cast v1.3.1 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/stretchr/testify v1.9.0 // indirect github.com/supranational/blst v0.3.13 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect @@ -48,6 +57,8 @@ require ( golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.22.0 // indirect + golang.org/x/time v0.5.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) diff --git a/services/go-filler/log-fetcher/go.sum b/services/go-filler/log-fetcher/go.sum index 72a4ac3..f237792 100644 --- a/services/go-filler/log-fetcher/go.sum +++ b/services/go-filler/log-fetcher/go.sum @@ -32,8 +32,13 @@ github.com/aws/smithy-go v1.22.0 h1:uunKnWlcoL3zO7q+gG2Pk53joueEOsnNB28QdMsmiMM= github.com/aws/smithy-go v1.22.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bsm/ginkgo/v2 v2.7.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w= +github.com/bsm/gomega v1.26.0/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= @@ -50,6 +55,8 @@ github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpO github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/ethereum/go-ethereum v1.14.11 h1:8nFDCUUE67rPc6AKxFj7JKaOa2W/W1Rse3oS6LvvxEY= @@ -61,9 +68,20 @@ github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hibiken/asynq v0.24.1 h1:+5iIEAyA9K/lcSPvx3qoPtsKJeKI5u9aOIvUmSsazEw= +github.com/hibiken/asynq v0.24.1/go.mod h1:u5qVeSbrnfT+vtG5Mq8ZPzQu/BmCKMHvTGb91uy9Tts= github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= @@ -71,14 +89,27 @@ github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHW github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/redis/go-redis/v9 v9.0.3 h1:+7mmR26M0IvyLxGZUHxu4GiBkJkVDid0Un+j4ScYu4k= +github.com/redis/go-redis/v9 v9.0.3/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk= +github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= +github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= @@ -88,13 +119,16 @@ github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0h github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= @@ -108,6 +142,7 @@ golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -116,14 +151,27 @@ golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= diff --git a/services/go-filler/log-fetcher/internal/clients/eth_client.go b/services/go-filler/log-fetcher/internal/clients/eth_client.go index f761424..3af9ea8 100644 --- a/services/go-filler/log-fetcher/internal/clients/eth_client.go +++ b/services/go-filler/log-fetcher/internal/clients/eth_client.go @@ -1,4 +1,4 @@ -package ethclient +package clients import ( "fmt" @@ -7,7 +7,7 @@ import ( "github.com/ethereum/go-ethereum/ethclient" ) -func GetClient(cfg *chains.ChainConfig) (*ethclient.Client, error) { +func GetEthClient(cfg *chains.ChainConfig) (*ethclient.Client, error) { client, err := ethclient.Dial(cfg.RpcUrl) if err != nil { return nil, err diff --git a/services/go-filler/log-fetcher/internal/clients/eth_client_test.go b/services/go-filler/log-fetcher/internal/clients/eth_client_test.go index 012d83b..b556270 100644 --- a/services/go-filler/log-fetcher/internal/clients/eth_client_test.go +++ b/services/go-filler/log-fetcher/internal/clients/eth_client_test.go @@ -1,4 +1,4 @@ -package ethclient +package clients import ( "net/http" @@ -23,7 +23,7 @@ func TestGetClient(t *testing.T) { } // Call GetClient - client, err := GetClient(cfg) + client, err := GetEthClient(cfg) // Assert assert.NoError(t, err) @@ -37,7 +37,7 @@ func TestGetClient(t *testing.T) { } // Call GetClient - client, err := GetClient(cfg) + client, err := GetEthClient(cfg) // Assert assert.Error(t, err) diff --git a/services/go-filler/log-fetcher/internal/clients/queue_client.go b/services/go-filler/log-fetcher/internal/clients/queue_client.go new file mode 100644 index 0000000..5a8dacf --- /dev/null +++ b/services/go-filler/log-fetcher/internal/clients/queue_client.go @@ -0,0 +1,40 @@ +package clients + +import ( + "encoding/json" + "fmt" + + internalConfig "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" + "github.com/hibiken/asynq" +) + +func SendMessageToQueue(parsedLog parser.LogCrossChainCallRequested, cfg *internalConfig.Config) error { + fmt.Println("Sending job to queue") + + redisConnOpt := asynq.RedisClientOpt{ + Addr: cfg.RedisQueueUrl, + Password: cfg.RedisPassword, + DB: 2, + } + + client := asynq.NewClient(redisConnOpt) + + // Task is created with two parameters: its type and payload. + // Payload data is simply an array of bytes. It can be encoded in JSON, Protocol Buffer, Gob, etc. + b, err := json.Marshal(parsedLog) + if err != nil { + return err + } + + task := asynq.NewTask("example", b) + + // Enqueue the task to be processed immediately. + info, err := client.Enqueue(task) + if err != nil { + return err + } + + fmt.Println(info) + return nil +} diff --git a/services/go-filler/log-fetcher/internal/config/config.go b/services/go-filler/log-fetcher/internal/config/config.go index f6a46db..acaac82 100644 --- a/services/go-filler/log-fetcher/internal/config/config.go +++ b/services/go-filler/log-fetcher/internal/config/config.go @@ -15,8 +15,9 @@ type RPCs struct { } type Config struct { - RPCs *RPCs - QueueUrl string + RPCs *RPCs + RedisQueueUrl string + RedisPassword string } func NewConfig() (*Config, error) { @@ -31,7 +32,8 @@ func NewConfig() (*Config, error) { OptimismSepolia: getEnvStr("OPTIMISM_SEPOLIA_RPC"), Sepolia: getEnvStr("SEPOLIA_RPC"), }, - QueueUrl: getEnvStr("AWS_QUEUE_URL"), + RedisQueueUrl: getEnvStr("REDIS_QUEUE_URL"), + RedisPassword: getEnvStr("REDIS_PASSWORD"), } return config, nil diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go index 6127377..d3d5516 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler.go +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -2,9 +2,9 @@ package handler import ( "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/clients" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/queue" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/validator" "github.com/ethereum/go-ethereum/core/types" ) @@ -22,7 +22,7 @@ func HandleLog(vLog types.Log, srcChain *chains.ChainConfig, cfg *config.Config) } // send log to queue - err = queue.SendMessage(parsedLog, cfg) + err = clients.SendMessageToQueue(parsedLog, cfg) if err != nil { return err } diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index f7f40f0..0828c1b 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -6,7 +6,7 @@ import ( "math/big" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" - ethclient "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/clients" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/clients" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/handler" "github.com/ethereum/go-ethereum" @@ -15,7 +15,7 @@ import ( ) func Init(srcChain *chains.ChainConfig, cfg *config.Config) error { - client, err := ethclient.GetClient(srcChain) + client, err := clients.GetEthClient(srcChain) if err != nil { return err } diff --git a/services/go-filler/log-fetcher/internal/queue/queue.go b/services/go-filler/log-fetcher/internal/queue/queue.go deleted file mode 100644 index 167ba79..0000000 --- a/services/go-filler/log-fetcher/internal/queue/queue.go +++ /dev/null @@ -1,44 +0,0 @@ -package queue - -import ( - "context" - "encoding/json" - "fmt" - - "github.com/aws/aws-sdk-go-v2/config" - "github.com/aws/aws-sdk-go-v2/service/sqs" - internalConfig "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" -) - -func SendMessage(parsedLog parser.LogCrossChainCallRequested, cfg *internalConfig.Config) error { - fmt.Println("Sending job to queue") - - sdkConfig, err := config.LoadDefaultConfig(context.Background()) - if err != nil { - return err - } - - sqsClient := sqs.NewFromConfig(sdkConfig) - - job, err := json.Marshal(parsedLog) - if err != nil { - return err - } - - jobStr := string(job) - - params := sqs.SendMessageInput{ - MessageBody: &jobStr, - QueueUrl: &cfg.QueueUrl, - } - - queueRes, err := sqsClient.SendMessage(context.TODO(), ¶ms) - if err != nil { - return err - } - - fmt.Println(queueRes) - - return nil -} From 6575ace551d23c19d7103939f5f3afa64d7fa991 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Thu, 24 Oct 2024 15:59:41 -0400 Subject: [PATCH 05/36] fix config unit tests --- .../go-filler/log-fetcher/internal/config/config_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/go-filler/log-fetcher/internal/config/config_test.go b/services/go-filler/log-fetcher/internal/config/config_test.go index 439a20f..2c7c5db 100644 --- a/services/go-filler/log-fetcher/internal/config/config_test.go +++ b/services/go-filler/log-fetcher/internal/config/config_test.go @@ -14,7 +14,8 @@ func TestNewConfig(t *testing.T) { os.Setenv("BASE_SEPOLIA_RPC", "https://base-sepolia.example.com") os.Setenv("OPTIMISM_SEPOLIA_RPC", "https://optimism-sepolia.example.com") os.Setenv("SEPOLIA_RPC", "https://sepolia.example.com") - os.Setenv("AWS_QUEUE_URL", "https://sqs.example.com/queue") + os.Setenv("REDIS_QUEUE_URL", "https://sqs.example.com/queue") + os.Setenv("REDIS_PASSWORD", "redis-password") // Create a temporary .env file envContent := ` @@ -22,7 +23,8 @@ ARBITRUM_SEPOLIA_RPC=https://arbitrum-sepolia.example.com BASE_SEPOLIA_RPC=https://base-sepolia.example.com OPTIMISM_SEPOLIA_RPC=https://optimism-sepolia.example.com SEPOLIA_RPC=https://sepolia.example.com -AWS_QUEUE_URL=https://sqs.example.com/queue +REDIS_QUEUE_URL=https://sqs.example.com/queue +REDIS_PASSWORD=redis-password ` err := os.WriteFile(".env", []byte(envContent), 0644) assert.NoError(t, err) @@ -39,7 +41,8 @@ AWS_QUEUE_URL=https://sqs.example.com/queue assert.Equal(t, "https://base-sepolia.example.com", config.RPCs.BaseSepolia) assert.Equal(t, "https://optimism-sepolia.example.com", config.RPCs.OptimismSepolia) assert.Equal(t, "https://sepolia.example.com", config.RPCs.Sepolia) - assert.Equal(t, "https://sqs.example.com/queue", config.QueueUrl) + assert.Equal(t, "https://sqs.example.com/queue", config.RedisQueueUrl) + assert.Equal(t, "redis-password", config.RedisPassword) } func TestNewConfigMissingEnvVar(t *testing.T) { From 7d05bc1b5931cc76d24fe5a9044f7ca07e5a94f7 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Thu, 24 Oct 2024 16:59:24 -0400 Subject: [PATCH 06/36] update listener to be realtime --- .../internal/clients/queue_client.go | 16 +++--- .../internal/clients/queue_client_test.go | 32 ++++++++++++ .../internal/config/config_test.go | 1 - .../log-fetcher/internal/handler/handler.go | 3 +- .../log-fetcher/internal/listener/listener.go | 51 +++++++------------ 5 files changed, 62 insertions(+), 41 deletions(-) create mode 100644 services/go-filler/log-fetcher/internal/clients/queue_client_test.go diff --git a/services/go-filler/log-fetcher/internal/clients/queue_client.go b/services/go-filler/log-fetcher/internal/clients/queue_client.go index 5a8dacf..0251d41 100644 --- a/services/go-filler/log-fetcher/internal/clients/queue_client.go +++ b/services/go-filler/log-fetcher/internal/clients/queue_client.go @@ -9,16 +9,17 @@ import ( "github.com/hibiken/asynq" ) -func SendMessageToQueue(parsedLog parser.LogCrossChainCallRequested, cfg *internalConfig.Config) error { - fmt.Println("Sending job to queue") - +func GetQueueClient(cfg *internalConfig.Config) *asynq.Client { redisConnOpt := asynq.RedisClientOpt{ Addr: cfg.RedisQueueUrl, Password: cfg.RedisPassword, DB: 2, } + return asynq.NewClient(redisConnOpt) +} - client := asynq.NewClient(redisConnOpt) +func SendMessageToQueue(parsedLog parser.LogCrossChainCallRequested, cfg *internalConfig.Config, client *asynq.Client) error { + fmt.Println("Sending job to queue") // Task is created with two parameters: its type and payload. // Payload data is simply an array of bytes. It can be encoded in JSON, Protocol Buffer, Gob, etc. @@ -27,14 +28,15 @@ func SendMessageToQueue(parsedLog parser.LogCrossChainCallRequested, cfg *intern return err } - task := asynq.NewTask("example", b) + task := asynq.NewTask("call-requested", b) // Enqueue the task to be processed immediately. - info, err := client.Enqueue(task) + _, err = client.Enqueue(task) if err != nil { return err } - fmt.Println(info) + fmt.Println("Job sent to queue") + return nil } diff --git a/services/go-filler/log-fetcher/internal/clients/queue_client_test.go b/services/go-filler/log-fetcher/internal/clients/queue_client_test.go new file mode 100644 index 0000000..a36df30 --- /dev/null +++ b/services/go-filler/log-fetcher/internal/clients/queue_client_test.go @@ -0,0 +1,32 @@ +package clients + +import ( + "testing" + + internalConfig "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/stretchr/testify/assert" +) + +func TestGetQueueClient(t *testing.T) { + cfg := &internalConfig.Config{ + RedisQueueUrl: "localhost:6379", + RedisPassword: "", + } + + client := GetQueueClient(cfg) + assert.NotNil(t, client, "Expected non-nil client") +} + +// func TestSendMessageToQueue(t *testing.T) { +// cfg := &internalConfig.Config{ +// RedisQueueUrl: "localhost:6379", +// RedisPassword: "", +// } +// // How do I properly mock the client? +// client := GetQueueClient(cfg) +// parsedLog := parser.LogCrossChainCallRequested{} + +// err := SendMessageToQueue(parsedLog, cfg, client) + +// assert.NoError(t, err, "Expected no error") +// } diff --git a/services/go-filler/log-fetcher/internal/config/config_test.go b/services/go-filler/log-fetcher/internal/config/config_test.go index 2c7c5db..6b81b10 100644 --- a/services/go-filler/log-fetcher/internal/config/config_test.go +++ b/services/go-filler/log-fetcher/internal/config/config_test.go @@ -1,4 +1,3 @@ -// config_test.go package config import ( diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go index d3d5516..8d32ec6 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler.go +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -22,7 +22,8 @@ func HandleLog(vLog types.Log, srcChain *chains.ChainConfig, cfg *config.Config) } // send log to queue - err = clients.SendMessageToQueue(parsedLog, cfg) + queueClient := clients.GetQueueClient(cfg) + err = clients.SendMessageToQueue(parsedLog, cfg, queueClient) if err != nil { return err } diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index 0828c1b..80d0429 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -3,7 +3,6 @@ package listener import ( "context" "fmt" - "math/big" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/clients" @@ -11,6 +10,7 @@ import ( "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/handler" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" ) @@ -29,47 +29,34 @@ func Init(srcChain *chains.ChainConfig, cfg *config.Config) error { crossChainCallRequestedHash := crypto.Keccak256Hash(crossChainCallRequestedSig) query := ethereum.FilterQuery{ - FromBlock: big.NewInt(90542608), - ToBlock: big.NewInt(90542608), Addresses: []common.Address{contractAddress}, Topics: [][]common.Hash{{crossChainCallRequestedHash}}, } - logs, err := client.FilterLogs(context.Background(), query) + logs := make(chan types.Log) + + sub, err := client.SubscribeFilterLogs(context.Background(), query, logs) if err != nil { return err } - for _, vLog := range logs { - fmt.Println("Log received!") - fmt.Printf("Log Block Number: %d\n", vLog.BlockNumber) - fmt.Printf("Log Index: %d\n", vLog.Index) + defer sub.Unsubscribe() + + fmt.Println("Subscribed to logs") - err := handler.HandleLog(vLog, srcChain, cfg) - if err != nil { + for { + select { + case err := <-sub.Err(): return err + case vLog := <-logs: + fmt.Println("Log received!") + fmt.Printf("Log Block Number: %d\n", vLog.BlockNumber) + fmt.Printf("Log Index: %d\n", vLog.Index) + + err := handler.HandleLog(vLog, srcChain, cfg) + if err != nil { + return err + } } } - - // query := ethereum.FilterQuery{ - // Addresses: []common.Address{contractAddress}, - // } - - // logs := make(chan types.Log) - - // sub, err := client.SubscribeFilterLogs(context.Background(), query, logs) - // if err != nil { - // log.Fatal(err) - // } - - // for { - // select { - // case err := <-sub.Err(): - // log.Fatal(err) - // case vLog := <- logs: - // fmt.Println(vLog) // pointer to event log - // } - // } - - return nil } From bcdffbcfb8b5185e1cdd76109e727eecc536dff1 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Thu, 24 Oct 2024 17:13:59 -0400 Subject: [PATCH 07/36] tidy dependencies and update readme --- services/go-filler/log-fetcher/README.md | 39 +++++- services/go-filler/log-fetcher/go.mod | 28 ++--- services/go-filler/log-fetcher/go.sum | 151 +++++++++++++++++------ 3 files changed, 159 insertions(+), 59 deletions(-) diff --git a/services/go-filler/log-fetcher/README.md b/services/go-filler/log-fetcher/README.md index 7ace30e..ff44bfe 100644 --- a/services/go-filler/log-fetcher/README.md +++ b/services/go-filler/log-fetcher/README.md @@ -2,4 +2,41 @@ ## Overview -The Log Fetcher serves as the first component in our fulfiller architecture. It's main purpose is to monitor events from `RIP7755Outbox` contracts on supported chains. When it ingests an event representing a cross-chain call request, it first parses the log into an ingestible format. It then validates the request by ensuring all routing information matches pre-defined chain configs for the source / destination chains. It then validates that the reward asset / amount represents a reward that would guarantee profit if this request were accepted by the system. If the request passes validation, the log fetcher passes it along to an SQS queue for further processing. +The Log Fetcher serves as the first component in the RIP-7755 Fulfiller architecture. Its main purpose is to monitor events from `RIP7755Outbox` contracts on supported chains. When it ingests an event representing a cross-chain call request, it first parses the log into an ingestible format. It then validates the request by ensuring all routing information matches pre-defined chain configs for the source / destination chains. It then validates that the reward asset / amount represents a reward that would guarantee profit if this request were accepted by the system. If the request passes validation, the log fetcher passes it along to an SQS queue for further processing. + +## Getting Started + +Navigate to the `log-fetcher` directory: + +```bash +cd services/go-filler/log-fetcher +``` + +Install dependencies: + +```bash +go mod tidy +``` + +Spin up the docker containers: + +```bash +docker-compose up -d +``` + +Create a `.env` file (the rpc urls must be websocket): + +```txt +ARBITRUM_SEPOLIA_RPC= +BASE_SEPOLIA_RPC= +OPTIMISM_SEPOLIA_RPC= +SEPOLIA_RPC= +REDIS_QUEUE_URL= +REDIS_PASSWORD= +``` + +Run the application: + +```bash +go run ./cmd +``` diff --git a/services/go-filler/log-fetcher/go.mod b/services/go-filler/log-fetcher/go.mod index 2800592..cbda689 100644 --- a/services/go-filler/log-fetcher/go.mod +++ b/services/go-filler/log-fetcher/go.mod @@ -2,23 +2,16 @@ module github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher go 1.23.2 +require ( + github.com/ethereum/go-ethereum v1.14.11 + github.com/hibiken/asynq v0.24.1 + github.com/joho/godotenv v1.5.1 + github.com/stretchr/testify v1.9.0 +) + require ( github.com/Microsoft/go-winio v0.6.2 // indirect github.com/StackExchange/wmi v1.2.1 // indirect - github.com/aws/aws-sdk-go-v2 v1.32.2 // indirect - github.com/aws/aws-sdk-go-v2/config v1.28.0 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.17.41 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.17 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.21 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.2 // indirect - github.com/aws/aws-sdk-go-v2/service/sqs v1.36.2 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.24.2 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.2 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.32.2 // indirect - github.com/aws/smithy-go v1.22.0 // indirect github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect @@ -31,25 +24,18 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/ethereum/c-kzg-4844 v1.0.0 // indirect - github.com/ethereum/go-ethereum v1.14.11 // indirect github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect github.com/go-ole/go-ole v1.3.0 // indirect - github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/uuid v1.3.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect - github.com/hibiken/asynq v0.24.1 // indirect github.com/holiman/uint256 v1.3.1 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/joho/godotenv v1.5.1 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/redis/go-redis/v9 v9.0.3 // indirect github.com/robfig/cron/v3 v3.0.1 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/spf13/cast v1.3.1 // indirect - github.com/stretchr/objx v0.5.2 // indirect - github.com/stretchr/testify v1.9.0 // indirect github.com/supranational/blst v0.3.13 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect diff --git a/services/go-filler/log-fetcher/go.sum b/services/go-filler/log-fetcher/go.sum index f237792..1a395ad 100644 --- a/services/go-filler/log-fetcher/go.sum +++ b/services/go-filler/log-fetcher/go.sum @@ -1,48 +1,44 @@ +github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= +github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= -github.com/aws/aws-sdk-go-v2 v1.32.2 h1:AkNLZEyYMLnx/Q/mSKkcMqwNFXMAvFto9bNsHqcTduI= -github.com/aws/aws-sdk-go-v2 v1.32.2/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo= -github.com/aws/aws-sdk-go-v2/config v1.28.0 h1:FosVYWcqEtWNxHn8gB/Vs6jOlNwSoyOCA/g/sxyySOQ= -github.com/aws/aws-sdk-go-v2/config v1.28.0/go.mod h1:pYhbtvg1siOOg8h5an77rXle9tVG8T+BWLWAo7cOukc= -github.com/aws/aws-sdk-go-v2/credentials v1.17.41 h1:7gXo+Axmp+R4Z+AK8YFQO0ZV3L0gizGINCOWxSLY9W8= -github.com/aws/aws-sdk-go-v2/credentials v1.17.41/go.mod h1:u4Eb8d3394YLubphT4jLEwN1rLNq2wFOlT6OuxFwPzU= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.17 h1:TMH3f/SCAWdNtXXVPPu5D6wrr4G5hI1rAxbcocKfC7Q= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.17/go.mod h1:1ZRXLdTpzdJb9fwTMXiLipENRxkGMTn1sfKexGllQCw= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21 h1:UAsR3xA31QGf79WzpG/ixT9FZvQlh5HY1NRqSHBNOCk= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21/go.mod h1:JNr43NFf5L9YaG3eKTm7HQzls9J+A9YYcGI5Quh1r2Y= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.21 h1:6jZVETqmYCadGFvrYEQfC5fAQmlo80CeL5psbno6r0s= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.21/go.mod h1:1SR0GbLlnN3QUmYaflZNiH1ql+1qrSiB2vwcJ+4UM60= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 h1:TToQNkvGguu209puTojY/ozlqy2d/SFNcoLIqTFi42g= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0/go.mod h1:0jp+ltwkf+SwG2fm/PKo8t4y8pJSgOCO4D8Lz3k0aHQ= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.2 h1:s7NA1SOw8q/5c0wr8477yOPp0z+uBaXBnLE0XYb0POA= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.2/go.mod h1:fnjjWyAW/Pj5HYOxl9LJqWtEwS7W2qgcRLWP+uWbss0= -github.com/aws/aws-sdk-go-v2/service/sqs v1.36.2 h1:kmbcoWgbzfh5a6rvfjOnfHSGEqD13qu1GfTPRZqg0FI= -github.com/aws/aws-sdk-go-v2/service/sqs v1.36.2/go.mod h1:/UPx74a3M0WYeT2yLQYG/qHhkPlPXd6TsppfGgy2COk= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.2 h1:bSYXVyUzoTHoKalBmwaZxs97HU9DWWI3ehHSAMa7xOk= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.2/go.mod h1:skMqY7JElusiOUjMJMOv1jJsP7YUg7DrhgqZZWuzu1U= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.2 h1:AhmO1fHINP9vFYUE0LHzCWg/LfUWUF+zFPEcY9QXb7o= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.2/go.mod h1:o8aQygT2+MVP0NaV6kbdE1YnnIM8RRVQzoeUH45GOdI= -github.com/aws/aws-sdk-go-v2/service/sts v1.32.2 h1:CiS7i0+FUe+/YY1GvIBLLrR/XNGZ4CtM1Ll0XavNuVo= -github.com/aws/aws-sdk-go-v2/service/sts v1.32.2/go.mod h1:HtaiBI8CjYoNVde8arShXb94UbQQi9L4EMr6D+xGBwo= -github.com/aws/smithy-go v1.22.0 h1:uunKnWlcoL3zO7q+gG2Pk53joueEOsnNB28QdMsmiMM= -github.com/aws/smithy-go v1.22.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= +github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= +github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao= github.com/bsm/ginkgo/v2 v2.7.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w= +github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y= github.com/bsm/gomega v1.26.0/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= +github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v1.1.2 h1:CUh2IPtR4swHlEj48Rhfzw6l/d0qA31fItcIszQVIsA= +github.com/cockroachdb/pebble v1.1.2/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= @@ -52,6 +48,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= @@ -63,62 +60,136 @@ github.com/ethereum/go-ethereum v1.14.11 h1:8nFDCUUE67rPc6AKxFj7JKaOa2W/W1Rse3oS github.com/ethereum/go-ethereum v1.14.11/go.mod h1:+l/fr42Mma+xBnhefL/+z11/hcmJ2egl+ScIVPjhc7E= github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= +github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= +github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= +github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hibiken/asynq v0.24.1 h1:+5iIEAyA9K/lcSPvx3qoPtsKJeKI5u9aOIvUmSsazEw= github.com/hibiken/asynq v0.24.1/go.mod h1:u5qVeSbrnfT+vtG5Mq8ZPzQu/BmCKMHvTGb91uy9Tts= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= +github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= +github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= +github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= +github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= +github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= +github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v1.12.0 h1:C+UIj/QWtmqY13Arb8kwMt5j34/0Z2iKamrJ+ryC0Gg= +github.com/prometheus/client_golang v1.12.0/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a h1:CmF68hwI0XsOQ5UwlBopMi2Ow4Pbg32akc4KIVCOm+Y= +github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/redis/go-redis/v9 v9.0.3 h1:+7mmR26M0IvyLxGZUHxu4GiBkJkVDid0Un+j4ScYu4k= github.com/redis/go-redis/v9 v9.0.3/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= +github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= +github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= +github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= +github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= +github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -151,13 +222,14 @@ golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -170,7 +242,12 @@ google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWn gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 58502465d36b73977183f81459d9a3021621d967 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Thu, 24 Oct 2024 19:32:59 -0400 Subject: [PATCH 08/36] progress on setting up queue client testing --- services/go-filler/log-fetcher/README.md | 2 +- services/go-filler/log-fetcher/go.mod | 1 + services/go-filler/log-fetcher/go.sum | 2 + .../internal/clients/queue_client.go | 19 ++++++++-- .../internal/clients/queue_client_test.go | 37 +++++++++---------- .../log-fetcher/internal/handler/handler.go | 2 +- 6 files changed, 38 insertions(+), 25 deletions(-) diff --git a/services/go-filler/log-fetcher/README.md b/services/go-filler/log-fetcher/README.md index ff44bfe..9b1ce19 100644 --- a/services/go-filler/log-fetcher/README.md +++ b/services/go-filler/log-fetcher/README.md @@ -2,7 +2,7 @@ ## Overview -The Log Fetcher serves as the first component in the RIP-7755 Fulfiller architecture. Its main purpose is to monitor events from `RIP7755Outbox` contracts on supported chains. When it ingests an event representing a cross-chain call request, it first parses the log into an ingestible format. It then validates the request by ensuring all routing information matches pre-defined chain configs for the source / destination chains. It then validates that the reward asset / amount represents a reward that would guarantee profit if this request were accepted by the system. If the request passes validation, the log fetcher passes it along to an SQS queue for further processing. +The Log Fetcher serves as the first component in the RIP-7755 Fulfiller architecture. Its main purpose is to monitor events from `RIP7755Outbox` contracts on supported chains. When it ingests an event representing a cross-chain call request, it first parses the log into an ingestible format. It then validates the request by ensuring all routing information matches pre-defined chain configs for the source / destination chains. It then validates that the reward asset / amount represents a reward that would guarantee profit if this request were accepted by the system. If the request passes validation, the log fetcher passes it along to a Redis queue for further processing. ## Getting Started diff --git a/services/go-filler/log-fetcher/go.mod b/services/go-filler/log-fetcher/go.mod index cbda689..e8cdc36 100644 --- a/services/go-filler/log-fetcher/go.mod +++ b/services/go-filler/log-fetcher/go.mod @@ -36,6 +36,7 @@ require ( github.com/robfig/cron/v3 v3.0.1 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/spf13/cast v1.3.1 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/supranational/blst v0.3.13 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect diff --git a/services/go-filler/log-fetcher/go.sum b/services/go-filler/log-fetcher/go.sum index 1a395ad..717a683 100644 --- a/services/go-filler/log-fetcher/go.sum +++ b/services/go-filler/log-fetcher/go.sum @@ -170,6 +170,8 @@ github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= diff --git a/services/go-filler/log-fetcher/internal/clients/queue_client.go b/services/go-filler/log-fetcher/internal/clients/queue_client.go index 0251d41..fd021ab 100644 --- a/services/go-filler/log-fetcher/internal/clients/queue_client.go +++ b/services/go-filler/log-fetcher/internal/clients/queue_client.go @@ -9,16 +9,27 @@ import ( "github.com/hibiken/asynq" ) -func GetQueueClient(cfg *internalConfig.Config) *asynq.Client { +type QueueClient interface { + SendMessageToQueue(parsedLog parser.LogCrossChainCallRequested, cfg *internalConfig.Config) error +} +type AsynqClient interface { + Enqueue(task *asynq.Task, opts ...asynq.Option) (*asynq.TaskInfo, error) +} + +type queueClient struct { + client AsynqClient +} + +func GetQueueClient(cfg *internalConfig.Config) QueueClient { redisConnOpt := asynq.RedisClientOpt{ Addr: cfg.RedisQueueUrl, Password: cfg.RedisPassword, DB: 2, } - return asynq.NewClient(redisConnOpt) + return &queueClient{client: asynq.NewClient(redisConnOpt)} } -func SendMessageToQueue(parsedLog parser.LogCrossChainCallRequested, cfg *internalConfig.Config, client *asynq.Client) error { +func (c *queueClient) SendMessageToQueue(parsedLog parser.LogCrossChainCallRequested, cfg *internalConfig.Config) error { fmt.Println("Sending job to queue") // Task is created with two parameters: its type and payload. @@ -31,7 +42,7 @@ func SendMessageToQueue(parsedLog parser.LogCrossChainCallRequested, cfg *intern task := asynq.NewTask("call-requested", b) // Enqueue the task to be processed immediately. - _, err = client.Enqueue(task) + _, err = c.client.Enqueue(task) if err != nil { return err } diff --git a/services/go-filler/log-fetcher/internal/clients/queue_client_test.go b/services/go-filler/log-fetcher/internal/clients/queue_client_test.go index a36df30..92a918c 100644 --- a/services/go-filler/log-fetcher/internal/clients/queue_client_test.go +++ b/services/go-filler/log-fetcher/internal/clients/queue_client_test.go @@ -3,30 +3,29 @@ package clients import ( "testing" - internalConfig "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" + "github.com/hibiken/asynq" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" ) -func TestGetQueueClient(t *testing.T) { - cfg := &internalConfig.Config{ - RedisQueueUrl: "localhost:6379", - RedisPassword: "", - } +type AsynqClientMock struct { + mock.Mock +} - client := GetQueueClient(cfg) - assert.NotNil(t, client, "Expected non-nil client") +func (m *AsynqClientMock) Enqueue(task *asynq.Task, opts ...asynq.Option) (*asynq.TaskInfo, error) { + args := m.Called(task, opts) + return args.Get(0).(*asynq.TaskInfo), args.Error(1) } -// func TestSendMessageToQueue(t *testing.T) { -// cfg := &internalConfig.Config{ -// RedisQueueUrl: "localhost:6379", -// RedisPassword: "", -// } -// // How do I properly mock the client? -// client := GetQueueClient(cfg) -// parsedLog := parser.LogCrossChainCallRequested{} +func TestSendMessageToQueue(t *testing.T) { + mockClient := new(AsynqClientMock) + queueClient := &queueClient{client: mockClient} + + mockClient.On("Enqueue", mock.Anything, mock.Anything).Return(&asynq.TaskInfo{}, nil) -// err := SendMessageToQueue(parsedLog, cfg, client) + err := queueClient.SendMessageToQueue(parser.LogCrossChainCallRequested{}, &config.Config{}) -// assert.NoError(t, err, "Expected no error") -// } + assert.NoError(t, err) +} diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go index 8d32ec6..e8e2d45 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler.go +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -23,7 +23,7 @@ func HandleLog(vLog types.Log, srcChain *chains.ChainConfig, cfg *config.Config) // send log to queue queueClient := clients.GetQueueClient(cfg) - err = clients.SendMessageToQueue(parsedLog, cfg, queueClient) + err = queueClient.SendMessageToQueue(parsedLog, cfg) if err != nil { return err } From 2ae460d755fdeed03d0ed2aa9b4e7321bf33ca11 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Fri, 25 Oct 2024 18:13:56 -0400 Subject: [PATCH 09/36] add mongo integration with unit tests --- services/go-filler/log-fetcher/cmd/main.go | 9 +- services/go-filler/log-fetcher/go.mod | 25 +++-- services/go-filler/log-fetcher/go.sum | 97 +++++++------------ .../internal/clients/queue_client.go | 53 ---------- .../internal/clients/queue_client_test.go | 31 ------ .../log-fetcher/internal/config/config.go | 2 + .../internal/config/config_test.go | 3 + .../log-fetcher/internal/handler/handler.go | 8 +- .../log-fetcher/internal/listener/listener.go | 5 +- .../internal/store/mongo_client.go | 69 +++++++++++++ .../internal/store/mongo_client_test.go | 94 ++++++++++++++++++ 11 files changed, 230 insertions(+), 166 deletions(-) delete mode 100644 services/go-filler/log-fetcher/internal/clients/queue_client.go delete mode 100644 services/go-filler/log-fetcher/internal/clients/queue_client_test.go create mode 100644 services/go-filler/log-fetcher/internal/store/mongo_client.go create mode 100644 services/go-filler/log-fetcher/internal/store/mongo_client_test.go diff --git a/services/go-filler/log-fetcher/cmd/main.go b/services/go-filler/log-fetcher/cmd/main.go index 2efbcb3..55d5054 100644 --- a/services/go-filler/log-fetcher/cmd/main.go +++ b/services/go-filler/log-fetcher/cmd/main.go @@ -7,6 +7,7 @@ import ( "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/listener" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" ) func main() { @@ -15,9 +16,15 @@ func main() { log.Fatal(err) } + mongoClient, err := store.NewMongoClient(cfg) + if err != nil { + log.Fatal(err) + } + defer mongoClient.Close() + srcChain := chains.GetChainConfig(big.NewInt(421614), cfg.RPCs) - err = listener.Init(srcChain, cfg) + err = listener.Init(srcChain, cfg, mongoClient) if err != nil { log.Fatal(err) } diff --git a/services/go-filler/log-fetcher/go.mod b/services/go-filler/log-fetcher/go.mod index e8cdc36..65dc42d 100644 --- a/services/go-filler/log-fetcher/go.mod +++ b/services/go-filler/log-fetcher/go.mod @@ -4,9 +4,9 @@ go 1.23.2 require ( github.com/ethereum/go-ethereum v1.14.11 - github.com/hibiken/asynq v0.24.1 github.com/joho/godotenv v1.5.1 github.com/stretchr/testify v1.9.0 + go.mongodb.org/mongo-driver v1.17.1 ) require ( @@ -14,7 +14,6 @@ require ( github.com/StackExchange/wmi v1.2.1 // indirect github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect @@ -22,30 +21,30 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.6.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect - github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/ethereum/c-kzg-4844 v1.0.0 // indirect github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect github.com/go-ole/go-ole v1.3.0 // indirect - github.com/golang/protobuf v1.5.4 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/holiman/uint256 v1.3.1 // indirect + github.com/klauspost/compress v1.16.0 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect + github.com/montanaflynn/stats v0.7.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/redis/go-redis/v9 v9.0.3 // indirect - github.com/robfig/cron/v3 v3.0.1 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect - github.com/spf13/cast v1.3.1 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/supranational/blst v0.3.13 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect - golang.org/x/crypto v0.22.0 // indirect + github.com/xdg-go/pbkdf2 v1.0.0 // indirect + github.com/xdg-go/scram v1.1.2 // indirect + github.com/xdg-go/stringprep v1.0.4 // indirect + github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect + golang.org/x/crypto v0.26.0 // indirect golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/time v0.5.0 // indirect - google.golang.org/protobuf v1.34.2 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.23.0 // indirect + golang.org/x/text v0.17.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) diff --git a/services/go-filler/log-fetcher/go.sum b/services/go-filler/log-fetcher/go.sum index 717a683..74932a3 100644 --- a/services/go-filler/log-fetcher/go.sum +++ b/services/go-filler/log-fetcher/go.sum @@ -10,15 +10,10 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= -github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao= -github.com/bsm/ginkgo/v2 v2.7.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w= -github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y= -github.com/bsm/gomega v1.26.0/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= @@ -43,7 +38,6 @@ github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLR github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= @@ -52,8 +46,6 @@ github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/ethereum/go-ethereum v1.14.11 h1:8nFDCUUE67rPc6AKxFj7JKaOa2W/W1Rse3oS6LvvxEY= @@ -75,28 +67,21 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= -github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= -github.com/hibiken/asynq v0.24.1 h1:+5iIEAyA9K/lcSPvx3qoPtsKJeKI5u9aOIvUmSsazEw= -github.com/hibiken/asynq v0.24.1/go.mod h1:u5qVeSbrnfT+vtG5Mq8ZPzQu/BmCKMHvTGb91uy9Tts= github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= @@ -111,11 +96,8 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= @@ -137,6 +119,8 @@ github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8oh github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= +github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= +github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -151,12 +135,8 @@ github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuI github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/redis/go-redis/v9 v9.0.3 h1:+7mmR26M0IvyLxGZUHxu4GiBkJkVDid0Un+j4ScYu4k= -github.com/redis/go-redis/v9 v9.0.3/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= -github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= @@ -165,15 +145,10 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= @@ -188,69 +163,67 @@ github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2n github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= +github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= +github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= +github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= +github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= -go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= +github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.mongodb.org/mongo-driver v1.17.1 h1:Wic5cJIwJgSpBhe3lx3+/RybR5PiYRMpVFgO7cOHyIM= +go.mongodb.org/mongo-driver v1.17.1/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= diff --git a/services/go-filler/log-fetcher/internal/clients/queue_client.go b/services/go-filler/log-fetcher/internal/clients/queue_client.go deleted file mode 100644 index fd021ab..0000000 --- a/services/go-filler/log-fetcher/internal/clients/queue_client.go +++ /dev/null @@ -1,53 +0,0 @@ -package clients - -import ( - "encoding/json" - "fmt" - - internalConfig "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" - "github.com/hibiken/asynq" -) - -type QueueClient interface { - SendMessageToQueue(parsedLog parser.LogCrossChainCallRequested, cfg *internalConfig.Config) error -} -type AsynqClient interface { - Enqueue(task *asynq.Task, opts ...asynq.Option) (*asynq.TaskInfo, error) -} - -type queueClient struct { - client AsynqClient -} - -func GetQueueClient(cfg *internalConfig.Config) QueueClient { - redisConnOpt := asynq.RedisClientOpt{ - Addr: cfg.RedisQueueUrl, - Password: cfg.RedisPassword, - DB: 2, - } - return &queueClient{client: asynq.NewClient(redisConnOpt)} -} - -func (c *queueClient) SendMessageToQueue(parsedLog parser.LogCrossChainCallRequested, cfg *internalConfig.Config) error { - fmt.Println("Sending job to queue") - - // Task is created with two parameters: its type and payload. - // Payload data is simply an array of bytes. It can be encoded in JSON, Protocol Buffer, Gob, etc. - b, err := json.Marshal(parsedLog) - if err != nil { - return err - } - - task := asynq.NewTask("call-requested", b) - - // Enqueue the task to be processed immediately. - _, err = c.client.Enqueue(task) - if err != nil { - return err - } - - fmt.Println("Job sent to queue") - - return nil -} diff --git a/services/go-filler/log-fetcher/internal/clients/queue_client_test.go b/services/go-filler/log-fetcher/internal/clients/queue_client_test.go deleted file mode 100644 index 92a918c..0000000 --- a/services/go-filler/log-fetcher/internal/clients/queue_client_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package clients - -import ( - "testing" - - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" - "github.com/hibiken/asynq" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" -) - -type AsynqClientMock struct { - mock.Mock -} - -func (m *AsynqClientMock) Enqueue(task *asynq.Task, opts ...asynq.Option) (*asynq.TaskInfo, error) { - args := m.Called(task, opts) - return args.Get(0).(*asynq.TaskInfo), args.Error(1) -} - -func TestSendMessageToQueue(t *testing.T) { - mockClient := new(AsynqClientMock) - queueClient := &queueClient{client: mockClient} - - mockClient.On("Enqueue", mock.Anything, mock.Anything).Return(&asynq.TaskInfo{}, nil) - - err := queueClient.SendMessageToQueue(parser.LogCrossChainCallRequested{}, &config.Config{}) - - assert.NoError(t, err) -} diff --git a/services/go-filler/log-fetcher/internal/config/config.go b/services/go-filler/log-fetcher/internal/config/config.go index acaac82..73eeebc 100644 --- a/services/go-filler/log-fetcher/internal/config/config.go +++ b/services/go-filler/log-fetcher/internal/config/config.go @@ -18,6 +18,7 @@ type Config struct { RPCs *RPCs RedisQueueUrl string RedisPassword string + MongoUri string } func NewConfig() (*Config, error) { @@ -34,6 +35,7 @@ func NewConfig() (*Config, error) { }, RedisQueueUrl: getEnvStr("REDIS_QUEUE_URL"), RedisPassword: getEnvStr("REDIS_PASSWORD"), + MongoUri: getEnvStr("MONGO_URI"), } return config, nil diff --git a/services/go-filler/log-fetcher/internal/config/config_test.go b/services/go-filler/log-fetcher/internal/config/config_test.go index 6b81b10..9e8af62 100644 --- a/services/go-filler/log-fetcher/internal/config/config_test.go +++ b/services/go-filler/log-fetcher/internal/config/config_test.go @@ -15,6 +15,7 @@ func TestNewConfig(t *testing.T) { os.Setenv("SEPOLIA_RPC", "https://sepolia.example.com") os.Setenv("REDIS_QUEUE_URL", "https://sqs.example.com/queue") os.Setenv("REDIS_PASSWORD", "redis-password") + os.Setenv("MONGO_URI", "mongodb://localhost:27017/db") // Create a temporary .env file envContent := ` @@ -24,6 +25,7 @@ OPTIMISM_SEPOLIA_RPC=https://optimism-sepolia.example.com SEPOLIA_RPC=https://sepolia.example.com REDIS_QUEUE_URL=https://sqs.example.com/queue REDIS_PASSWORD=redis-password +MONGO_URI=mongodb://localhost:27017/db ` err := os.WriteFile(".env", []byte(envContent), 0644) assert.NoError(t, err) @@ -42,6 +44,7 @@ REDIS_PASSWORD=redis-password assert.Equal(t, "https://sepolia.example.com", config.RPCs.Sepolia) assert.Equal(t, "https://sqs.example.com/queue", config.RedisQueueUrl) assert.Equal(t, "redis-password", config.RedisPassword) + assert.Equal(t, "mongodb://localhost:27017/db", config.MongoUri) } func TestNewConfigMissingEnvVar(t *testing.T) { diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go index e8e2d45..9b39d19 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler.go +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -2,14 +2,14 @@ package handler import ( "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/clients" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/validator" "github.com/ethereum/go-ethereum/core/types" ) -func HandleLog(vLog types.Log, srcChain *chains.ChainConfig, cfg *config.Config) error { +func HandleLog(vLog types.Log, srcChain *chains.ChainConfig, cfg *config.Config, mongoClient store.MongoClient) error { parsedLog, err := parser.ParseLog(vLog) if err != nil { return err @@ -22,8 +22,8 @@ func HandleLog(vLog types.Log, srcChain *chains.ChainConfig, cfg *config.Config) } // send log to queue - queueClient := clients.GetQueueClient(cfg) - err = queueClient.SendMessageToQueue(parsedLog, cfg) + collection := mongoClient.Collection("requests") + err = collection.Enqueue(parsedLog, cfg) if err != nil { return err } diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index 80d0429..05802ce 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -8,13 +8,14 @@ import ( "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/clients" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/handler" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" ) -func Init(srcChain *chains.ChainConfig, cfg *config.Config) error { +func Init(srcChain *chains.ChainConfig, cfg *config.Config, mongoClient store.MongoClient) error { client, err := clients.GetEthClient(srcChain) if err != nil { return err @@ -53,7 +54,7 @@ func Init(srcChain *chains.ChainConfig, cfg *config.Config) error { fmt.Printf("Log Block Number: %d\n", vLog.BlockNumber) fmt.Printf("Log Index: %d\n", vLog.Index) - err := handler.HandleLog(vLog, srcChain, cfg) + err := handler.HandleLog(vLog, srcChain, cfg, mongoClient) if err != nil { return err } diff --git a/services/go-filler/log-fetcher/internal/store/mongo_client.go b/services/go-filler/log-fetcher/internal/store/mongo_client.go new file mode 100644 index 0000000..5dd7a13 --- /dev/null +++ b/services/go-filler/log-fetcher/internal/store/mongo_client.go @@ -0,0 +1,69 @@ +package store + +import ( + "context" + "fmt" + + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" +) + +type MongoClient interface { + Close() error + Collection(name string) MongoConnection +} + +type MongoConnection interface { + Enqueue(parsedLog parser.LogCrossChainCallRequested, cfg *config.Config) error +} + +type MongoCollection interface { + InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error) +} + +type MongoDriverClient interface { + Database(name string, opts ...*options.DatabaseOptions) *mongo.Database + Disconnect(context.Context) error +} + +type mongoClient struct { + client MongoDriverClient +} +type mongoConnection struct { + collection MongoCollection +} + +func NewMongoClient(cfg *config.Config) (MongoClient, error) { + fmt.Println("Connecting to MongoDB") + client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(cfg.MongoUri)) + if err != nil { + return nil, err + } + + fmt.Println("Connected to MongoDB") + + return &mongoClient{client: client}, nil +} + +func (c *mongoClient) Collection(name string) MongoConnection { + return &mongoConnection{collection: c.client.Database("calls").Collection(name)} +} + +func (c *mongoConnection) Enqueue(parsedLog parser.LogCrossChainCallRequested, cfg *config.Config) error { + fmt.Println("Sending job to queue") + + _, err := c.collection.InsertOne(context.TODO(), parsedLog) + if err != nil { + return err + } + + fmt.Println("Job sent to queue") + + return nil +} + +func (c *mongoClient) Close() error { + return c.client.Disconnect(context.TODO()) +} diff --git a/services/go-filler/log-fetcher/internal/store/mongo_client_test.go b/services/go-filler/log-fetcher/internal/store/mongo_client_test.go new file mode 100644 index 0000000..f7b0c17 --- /dev/null +++ b/services/go-filler/log-fetcher/internal/store/mongo_client_test.go @@ -0,0 +1,94 @@ +package store + +import ( + "context" + "errors" + "testing" + + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" +) + +type MongoClientMock struct { + mock.Mock +} + +type MongoConnectionMock struct { + mock.Mock +} + +func (c *MongoConnectionMock) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error) { + args := c.Called(ctx, document, opts) + return args.Get(0).(*mongo.InsertOneResult), args.Error(1) +} + +func (m *MongoClientMock) Database(name string, opts ...*options.DatabaseOptions) *mongo.Database { + args := m.Called(name, opts) + return args.Get(0).(*mongo.Database) +} + +func (m *MongoClientMock) Disconnect(ctx context.Context) error { + args := m.Called(ctx) + return args.Error(0) +} + +func TestEnqueue(t *testing.T) { + mockConnection := new(MongoConnectionMock) + mongoConnection := &mongoConnection{collection: mockConnection} + + mockConnection.On("InsertOne", mock.Anything, mock.Anything, mock.Anything).Return(&mongo.InsertOneResult{}, nil) + + err := mongoConnection.Enqueue(parser.LogCrossChainCallRequested{}, &config.Config{}) + + assert.NoError(t, err) +} + +func TestEnqueuePassesParsedLogToInsertOne(t *testing.T) { + mockConnection := new(MongoConnectionMock) + mongoConnection := &mongoConnection{collection: mockConnection} + parsedLog := parser.LogCrossChainCallRequested{} + + mockConnection.On("InsertOne", context.TODO(), parsedLog, mock.Anything).Return(&mongo.InsertOneResult{}, nil) + + err := mongoConnection.Enqueue(parsedLog, &config.Config{}) + + assert.NoError(t, err) + mockConnection.AssertExpectations(t) +} + +func TestEnqueueError(t *testing.T) { + mockConnection := new(MongoConnectionMock) + mongoConnection := &mongoConnection{collection: mockConnection} + + mockConnection.On("InsertOne", mock.Anything, mock.Anything, mock.Anything).Return(&mongo.InsertOneResult{}, errors.New("error")) + + err := mongoConnection.Enqueue(parser.LogCrossChainCallRequested{}, &config.Config{}) + + assert.Error(t, err) +} + +func TestClose(t *testing.T) { + mockClient := new(MongoClientMock) + mongoClient := &mongoClient{client: mockClient} + + mockClient.On("Disconnect", context.TODO()).Return(nil) + + err := mongoClient.Close() + + assert.NoError(t, err) +} + +func TestCloseError(t *testing.T) { + mockClient := new(MongoClientMock) + mongoClient := &mongoClient{client: mockClient} + + mockClient.On("Disconnect", context.TODO()).Return(errors.New("error")) + + err := mongoClient.Close() + + assert.Error(t, err) +} From 1fd6c2776a42102ad5e415fec0b09c5560f263f3 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Fri, 25 Oct 2024 18:52:47 -0400 Subject: [PATCH 10/36] add unit tests for validator package --- services/go-filler/log-fetcher/cmd/main.go | 5 +- .../log-fetcher/internal/chains/config.go | 7 +- .../internal/chains/config_test.go | 13 +- .../log-fetcher/internal/handler/handler.go | 7 +- .../validator/{validate.go => validator.go} | 18 +- .../internal/validator/validator_test.go | 160 ++++++++++++++++++ 6 files changed, 195 insertions(+), 15 deletions(-) rename services/go-filler/log-fetcher/internal/validator/{validate.go => validator.go} (81%) create mode 100644 services/go-filler/log-fetcher/internal/validator/validator_test.go diff --git a/services/go-filler/log-fetcher/cmd/main.go b/services/go-filler/log-fetcher/cmd/main.go index 55d5054..e95144f 100644 --- a/services/go-filler/log-fetcher/cmd/main.go +++ b/services/go-filler/log-fetcher/cmd/main.go @@ -22,7 +22,10 @@ func main() { } defer mongoClient.Close() - srcChain := chains.GetChainConfig(big.NewInt(421614), cfg.RPCs) + srcChain, err := chains.GetChainConfig(big.NewInt(421614), cfg.RPCs) + if err != nil { + log.Fatal(err) + } err = listener.Init(srcChain, cfg, mongoClient) if err != nil { diff --git a/services/go-filler/log-fetcher/internal/chains/config.go b/services/go-filler/log-fetcher/internal/chains/config.go index 6d55a9e..067eae7 100644 --- a/services/go-filler/log-fetcher/internal/chains/config.go +++ b/services/go-filler/log-fetcher/internal/chains/config.go @@ -2,6 +2,7 @@ package chains import ( "encoding/hex" + "fmt" "log" "math/big" @@ -27,7 +28,7 @@ type ChainConfig struct { TargetProver config.Prover } -func GetChainConfig(chainId *big.Int, rpcConfig *config.RPCs) *ChainConfig { +func GetChainConfig(chainId *big.Int, rpcConfig *config.RPCs) (*ChainConfig, error) { var chainConfig *ChainConfig switch chainId.Int64() { @@ -102,9 +103,11 @@ func GetChainConfig(chainId *big.Int, rpcConfig *config.RPCs) *ChainConfig { Contracts: contracts, TargetProver: config.NilProver, } + default: + return nil, fmt.Errorf("unknown chainId: %d", chainId.Int64()) } - return chainConfig + return chainConfig, nil } func encodeBytes(bytesStr string) [32]byte { diff --git a/services/go-filler/log-fetcher/internal/chains/config_test.go b/services/go-filler/log-fetcher/internal/chains/config_test.go index 089e60c..78ef1da 100644 --- a/services/go-filler/log-fetcher/internal/chains/config_test.go +++ b/services/go-filler/log-fetcher/internal/chains/config_test.go @@ -99,7 +99,11 @@ func TestGetChainConfig(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - result := GetChainConfig(big.NewInt(tc.chainID), tc.rpcConfig) + result, err := GetChainConfig(big.NewInt(tc.chainID), tc.rpcConfig) + if err != nil { + t.Errorf("GetChainConfig(%d) returned error: %v", tc.chainID, err) + } + if !reflect.DeepEqual(result, tc.expected) { t.Errorf("GetChainConfig(%d) = %+v, want %+v", tc.chainID, result, tc.expected) } @@ -109,10 +113,9 @@ func TestGetChainConfig(t *testing.T) { func TestGetChainConfig_UnknownChain(t *testing.T) { unknownChainID := big.NewInt(999999) - result := GetChainConfig(unknownChainID, &config.RPCs{}) - if result != nil { - - t.Errorf("GetChainConfig(%d) = %+v, want nil", unknownChainID, result) + result, err := GetChainConfig(unknownChainID, &config.RPCs{}) + if err == nil { + t.Errorf("GetChainConfig(%d) = %+v, want error", unknownChainID, result) } } diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go index 9b39d19..72d757d 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler.go +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -16,14 +16,15 @@ func HandleLog(vLog types.Log, srcChain *chains.ChainConfig, cfg *config.Config, } // validate Log - err = validator.ValidateLog(cfg, srcChain, parsedLog) + v := validator.NewValidator() + err = v.ValidateLog(cfg, srcChain, parsedLog) if err != nil { return err } // send log to queue - collection := mongoClient.Collection("requests") - err = collection.Enqueue(parsedLog, cfg) + c := mongoClient.Collection("requests") + err = c.Enqueue(parsedLog, cfg) if err != nil { return err } diff --git a/services/go-filler/log-fetcher/internal/validator/validate.go b/services/go-filler/log-fetcher/internal/validator/validator.go similarity index 81% rename from services/go-filler/log-fetcher/internal/validator/validate.go rename to services/go-filler/log-fetcher/internal/validator/validator.go index 031a06d..7add122 100644 --- a/services/go-filler/log-fetcher/internal/validator/validate.go +++ b/services/go-filler/log-fetcher/internal/validator/validator.go @@ -11,13 +11,23 @@ import ( "github.com/ethereum/go-ethereum/common" ) -func ValidateLog(cfg *config.Config, srcChain *chains.ChainConfig, parsedLog parser.LogCrossChainCallRequested) error { +type Validator interface { + ValidateLog(cfg *config.Config, srcChain *chains.ChainConfig, parsedLog parser.LogCrossChainCallRequested) error +} + +type validator struct{} + +func NewValidator() Validator { + return &validator{} +} + +func (v *validator) ValidateLog(cfg *config.Config, srcChain *chains.ChainConfig, parsedLog parser.LogCrossChainCallRequested) error { fmt.Println("Validating log") // - Confirm valid proverContract address on source chain - dstChain := chains.GetChainConfig(parsedLog.Request.DestinationChainId, cfg.RPCs) - if dstChain.ChainId == big.NewInt(0) { - return errors.New("unknown destination chain") + dstChain, err := chains.GetChainConfig(parsedLog.Request.DestinationChainId, cfg.RPCs) + if err != nil { + return err } proverName := dstChain.TargetProver.String() diff --git a/services/go-filler/log-fetcher/internal/validator/validator_test.go b/services/go-filler/log-fetcher/internal/validator/validator_test.go new file mode 100644 index 0000000..5651bc2 --- /dev/null +++ b/services/go-filler/log-fetcher/internal/validator/validator_test.go @@ -0,0 +1,160 @@ +package validator + +import ( + "encoding/hex" + "log" + "math/big" + "testing" + + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" + "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/assert" +) + +var cfg = &config.Config{ + RPCs: &config.RPCs{ + ArbitrumSepolia: "https://arbitrum-sepolia.llamarpc.com", + }, +} + +var srcChain = &chains.ChainConfig{ + ChainId: big.NewInt(42161), + ProverContracts: map[string]common.Address{ + "OPStackProver": common.HexToAddress("0x1234567890123456789012345678901234567890"), + }, +} + +var parsedLog = parser.LogCrossChainCallRequested{ + Request: parser.CrossChainRequest{ + Calls: []parser.Call{ + { + To: common.HexToAddress("0x1234567890123456789012345678901234567890"), + Value: big.NewInt(1000000000000000000), + }, + }, + DestinationChainId: big.NewInt(84532), + InboxContract: common.HexToAddress("0xB482b292878FDe64691d028A2237B34e91c7c7ea"), + L2Oracle: common.HexToAddress("0x4C8BA32A5DAC2A720bb35CeDB51D6B067D104205"), + L2OracleStorageKey: encodeBytes("a6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49"), + ProverContract: common.HexToAddress("0x1234567890123456789012345678901234567890"), + RewardAsset: common.HexToAddress("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"), + RewardAmount: big.NewInt(2000000000000000000), + }, +} + +func TestValidateLog(t *testing.T) { + validator := NewValidator() + + err := validator.ValidateLog(cfg, srcChain, parsedLog) + + assert.NoError(t, err) +} + +func TestValidateLog_UnknownDestinationChain(t *testing.T) { + validator := NewValidator() + + prevDstChainId := parsedLog.Request.DestinationChainId + parsedLog.Request.DestinationChainId = big.NewInt(11155112) + defer func() { parsedLog.Request.DestinationChainId = prevDstChainId }() + + err := validator.ValidateLog(cfg, srcChain, parsedLog) + + assert.Error(t, err) +} + +func TestValidateLog_UnknownProverName(t *testing.T) { + validator := NewValidator() + + prevDstChainId := parsedLog.Request.DestinationChainId + parsedLog.Request.DestinationChainId = big.NewInt(11155111) + defer func() { parsedLog.Request.DestinationChainId = prevDstChainId }() + + err := validator.ValidateLog(cfg, srcChain, parsedLog) + + assert.Error(t, err) +} + +func TestValidateLog_UnknownProverContract(t *testing.T) { + validator := NewValidator() + + prevProverContract := parsedLog.Request.ProverContract + parsedLog.Request.ProverContract = common.HexToAddress("0x1234567890123456789012345678901234567891") + defer func() { parsedLog.Request.ProverContract = prevProverContract }() + + err := validator.ValidateLog(cfg, srcChain, parsedLog) + + assert.Error(t, err) +} + +func TestValidateLog_UnknownInboxContract(t *testing.T) { + validator := NewValidator() + + prevInboxContract := parsedLog.Request.InboxContract + parsedLog.Request.InboxContract = common.HexToAddress("0x1234567890123456789012345678901234567891") + defer func() { parsedLog.Request.InboxContract = prevInboxContract }() + + err := validator.ValidateLog(cfg, srcChain, parsedLog) + + assert.Error(t, err) +} + +func TestValidateLog_UnknownL2Oracle(t *testing.T) { + validator := NewValidator() + + prevL2Oracle := parsedLog.Request.L2Oracle + parsedLog.Request.L2Oracle = common.HexToAddress("0x1234567890123456789012345678901234567891") + defer func() { parsedLog.Request.L2Oracle = prevL2Oracle }() + + err := validator.ValidateLog(cfg, srcChain, parsedLog) + + assert.Error(t, err) +} + +func TestValidateLog_UnknownL2OracleStorageKey(t *testing.T) { + validator := NewValidator() + + prevL2OracleStorageKey := parsedLog.Request.L2OracleStorageKey + parsedLog.Request.L2OracleStorageKey = encodeBytes("1234567890123456789012345678901234567891") + defer func() { parsedLog.Request.L2OracleStorageKey = prevL2OracleStorageKey }() + + err := validator.ValidateLog(cfg, srcChain, parsedLog) + + assert.Error(t, err) +} + +func TestValidateLog_InvalidReward_NotNativeAsset(t *testing.T) { + validator := NewValidator() + + prevRewardAsset := parsedLog.Request.RewardAsset + parsedLog.Request.RewardAsset = common.HexToAddress("0x1234567890123456789012345678901234567891") + defer func() { parsedLog.Request.RewardAsset = prevRewardAsset }() + + err := validator.ValidateLog(cfg, srcChain, parsedLog) + + assert.Error(t, err) +} + +func TestValidateLog_InvalidReward_NotGreaterThanValueNeeded(t *testing.T) { + validator := NewValidator() + + prevRewardAmount := parsedLog.Request.RewardAmount + parsedLog.Request.RewardAmount = big.NewInt(1000000000000000000) + defer func() { parsedLog.Request.RewardAmount = prevRewardAmount }() + + err := validator.ValidateLog(cfg, srcChain, parsedLog) + + assert.Error(t, err) +} + +func encodeBytes(bytesStr string) [32]byte { + bytes, err := hex.DecodeString(bytesStr) + if err != nil { + log.Fatal(err) + } + + var byteArray [32]byte + copy(byteArray[32-len(bytes):], bytes) + return byteArray +} From beed9c8e1d4909c551c907105b2d6a4613cd2fc7 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Sat, 26 Oct 2024 14:40:06 -0400 Subject: [PATCH 11/36] refactor handler and parser --- services/go-filler/log-fetcher/README.md | 6 ++++ .../log-fetcher/internal/handler/handler.go | 28 +++++++++++++------ .../log-fetcher/internal/listener/listener.go | 4 ++- .../log-fetcher/internal/parser/parser.go | 12 +++++++- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/services/go-filler/log-fetcher/README.md b/services/go-filler/log-fetcher/README.md index 9b1ce19..6a98e39 100644 --- a/services/go-filler/log-fetcher/README.md +++ b/services/go-filler/log-fetcher/README.md @@ -40,3 +40,9 @@ Run the application: ```bash go run ./cmd ``` + +Run unit tests: + +```bash +go test ./internal/... +``` diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go index 72d757d..53dc413 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler.go +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -9,22 +9,34 @@ import ( "github.com/ethereum/go-ethereum/core/types" ) -func HandleLog(vLog types.Log, srcChain *chains.ChainConfig, cfg *config.Config, mongoClient store.MongoClient) error { - parsedLog, err := parser.ParseLog(vLog) +type Handler interface { + HandleLog(vLog types.Log) error +} + +type handler struct { + cfg *config.Config + srcChain *chains.ChainConfig + parser parser.Parser + validator validator.Validator + queue store.MongoConnection +} + +func NewHandler(cfg *config.Config, srcChain *chains.ChainConfig, queue store.MongoConnection) Handler { + return &handler{cfg: cfg, srcChain: srcChain, parser: parser.NewParser(), validator: validator.NewValidator(), queue: queue} +} + +func (h *handler) HandleLog(vLog types.Log) error { + parsedLog, err := h.parser.ParseLog(vLog) if err != nil { return err } - // validate Log - v := validator.NewValidator() - err = v.ValidateLog(cfg, srcChain, parsedLog) + err = h.validator.ValidateLog(h.cfg, h.srcChain, parsedLog) if err != nil { return err } - // send log to queue - c := mongoClient.Collection("requests") - err = c.Enqueue(parsedLog, cfg) + err = h.queue.Enqueue(parsedLog, h.cfg) if err != nil { return err } diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index 05802ce..0fcbcbd 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -16,6 +16,8 @@ import ( ) func Init(srcChain *chains.ChainConfig, cfg *config.Config, mongoClient store.MongoClient) error { + h := handler.NewHandler(cfg, srcChain, mongoClient.Collection("requests")) + client, err := clients.GetEthClient(srcChain) if err != nil { return err @@ -54,7 +56,7 @@ func Init(srcChain *chains.ChainConfig, cfg *config.Config, mongoClient store.Mo fmt.Printf("Log Block Number: %d\n", vLog.BlockNumber) fmt.Printf("Log Index: %d\n", vLog.Index) - err := handler.HandleLog(vLog, srcChain, cfg, mongoClient) + err := h.HandleLog(vLog) if err != nil { return err } diff --git a/services/go-filler/log-fetcher/internal/parser/parser.go b/services/go-filler/log-fetcher/internal/parser/parser.go index 60addb6..83bdedd 100644 --- a/services/go-filler/log-fetcher/internal/parser/parser.go +++ b/services/go-filler/log-fetcher/internal/parser/parser.go @@ -12,6 +12,16 @@ import ( "github.com/ethereum/go-ethereum/core/types" ) +type Parser interface { + ParseLog(vLog types.Log) (LogCrossChainCallRequested, error) +} + +type parser struct{} + +func NewParser() Parser { + return &parser{} +} + type Call struct { To common.Address Data []byte @@ -40,7 +50,7 @@ type LogCrossChainCallRequested struct { Request CrossChainRequest } -func ParseLog(vLog types.Log) (LogCrossChainCallRequested, error) { +func (p *parser) ParseLog(vLog types.Log) (LogCrossChainCallRequested, error) { fmt.Println("Parsing log") absPath, err := filepath.Abs("internal/abis/RIP7755Outbox.json") From 412f74962541104d1a2416eff7a83f64ac4a4fe8 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Sat, 26 Oct 2024 15:02:00 -0400 Subject: [PATCH 12/36] refactor queue and validator --- services/go-filler/log-fetcher/cmd/main.go | 6 +-- .../log-fetcher/internal/handler/handler.go | 10 ++-- .../log-fetcher/internal/listener/listener.go | 4 +- .../internal/store/mongo_client.go | 47 +++++++++---------- .../internal/store/mongo_client_test.go | 21 ++++----- .../internal/validator/validator.go | 17 ++++--- .../internal/validator/validator_test.go | 36 +++++++------- 7 files changed, 71 insertions(+), 70 deletions(-) diff --git a/services/go-filler/log-fetcher/cmd/main.go b/services/go-filler/log-fetcher/cmd/main.go index e95144f..ba1004b 100644 --- a/services/go-filler/log-fetcher/cmd/main.go +++ b/services/go-filler/log-fetcher/cmd/main.go @@ -16,18 +16,18 @@ func main() { log.Fatal(err) } - mongoClient, err := store.NewMongoClient(cfg) + queue, err := store.NewQueue(cfg) if err != nil { log.Fatal(err) } - defer mongoClient.Close() + defer queue.Close() srcChain, err := chains.GetChainConfig(big.NewInt(421614), cfg.RPCs) if err != nil { log.Fatal(err) } - err = listener.Init(srcChain, cfg, mongoClient) + err = listener.Init(srcChain, cfg, queue) if err != nil { log.Fatal(err) } diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go index 53dc413..9f26d02 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler.go +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -18,11 +18,11 @@ type handler struct { srcChain *chains.ChainConfig parser parser.Parser validator validator.Validator - queue store.MongoConnection + queue store.Queue } -func NewHandler(cfg *config.Config, srcChain *chains.ChainConfig, queue store.MongoConnection) Handler { - return &handler{cfg: cfg, srcChain: srcChain, parser: parser.NewParser(), validator: validator.NewValidator(), queue: queue} +func NewHandler(cfg *config.Config, srcChain *chains.ChainConfig, queue store.Queue) Handler { + return &handler{cfg: cfg, srcChain: srcChain, parser: parser.NewParser(), validator: validator.NewValidator(cfg, srcChain), queue: queue} } func (h *handler) HandleLog(vLog types.Log) error { @@ -31,12 +31,12 @@ func (h *handler) HandleLog(vLog types.Log) error { return err } - err = h.validator.ValidateLog(h.cfg, h.srcChain, parsedLog) + err = h.validator.ValidateLog(parsedLog) if err != nil { return err } - err = h.queue.Enqueue(parsedLog, h.cfg) + err = h.queue.Enqueue(parsedLog) if err != nil { return err } diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index 0fcbcbd..3072b69 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -15,8 +15,8 @@ import ( "github.com/ethereum/go-ethereum/crypto" ) -func Init(srcChain *chains.ChainConfig, cfg *config.Config, mongoClient store.MongoClient) error { - h := handler.NewHandler(cfg, srcChain, mongoClient.Collection("requests")) +func Init(srcChain *chains.ChainConfig, cfg *config.Config, queue store.Queue) error { + h := handler.NewHandler(cfg, srcChain, queue) client, err := clients.GetEthClient(srcChain) if err != nil { diff --git a/services/go-filler/log-fetcher/internal/store/mongo_client.go b/services/go-filler/log-fetcher/internal/store/mongo_client.go index 5dd7a13..cbfe16a 100644 --- a/services/go-filler/log-fetcher/internal/store/mongo_client.go +++ b/services/go-filler/log-fetcher/internal/store/mongo_client.go @@ -10,13 +10,9 @@ import ( "go.mongodb.org/mongo-driver/mongo/options" ) -type MongoClient interface { +type Queue interface { + Enqueue(parsedLog parser.LogCrossChainCallRequested) error Close() error - Collection(name string) MongoConnection -} - -type MongoConnection interface { - Enqueue(parsedLog parser.LogCrossChainCallRequested, cfg *config.Config) error } type MongoCollection interface { @@ -28,33 +24,24 @@ type MongoDriverClient interface { Disconnect(context.Context) error } -type mongoClient struct { - client MongoDriverClient -} -type mongoConnection struct { +type queue struct { + client MongoDriverClient collection MongoCollection } -func NewMongoClient(cfg *config.Config) (MongoClient, error) { - fmt.Println("Connecting to MongoDB") - client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(cfg.MongoUri)) +func NewQueue(cfg *config.Config) (Queue, error) { + client, err := connect(cfg) if err != nil { return nil, err } - fmt.Println("Connected to MongoDB") - - return &mongoClient{client: client}, nil + return &queue{client: client, collection: client.Database("calls").Collection("requests")}, nil } -func (c *mongoClient) Collection(name string) MongoConnection { - return &mongoConnection{collection: c.client.Database("calls").Collection(name)} -} - -func (c *mongoConnection) Enqueue(parsedLog parser.LogCrossChainCallRequested, cfg *config.Config) error { +func (q *queue) Enqueue(parsedLog parser.LogCrossChainCallRequested) error { fmt.Println("Sending job to queue") - _, err := c.collection.InsertOne(context.TODO(), parsedLog) + _, err := q.collection.InsertOne(context.TODO(), parsedLog) if err != nil { return err } @@ -64,6 +51,18 @@ func (c *mongoConnection) Enqueue(parsedLog parser.LogCrossChainCallRequested, c return nil } -func (c *mongoClient) Close() error { - return c.client.Disconnect(context.TODO()) +func (q *queue) Close() error { + return q.client.Disconnect(context.TODO()) +} + +func connect(cfg *config.Config) (MongoDriverClient, error) { + fmt.Println("Connecting to MongoDB") + client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(cfg.MongoUri)) + if err != nil { + return nil, err + } + + fmt.Println("Connected to MongoDB") + + return client, nil } diff --git a/services/go-filler/log-fetcher/internal/store/mongo_client_test.go b/services/go-filler/log-fetcher/internal/store/mongo_client_test.go index f7b0c17..526314f 100644 --- a/services/go-filler/log-fetcher/internal/store/mongo_client_test.go +++ b/services/go-filler/log-fetcher/internal/store/mongo_client_test.go @@ -5,7 +5,6 @@ import ( "errors" "testing" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -38,23 +37,23 @@ func (m *MongoClientMock) Disconnect(ctx context.Context) error { func TestEnqueue(t *testing.T) { mockConnection := new(MongoConnectionMock) - mongoConnection := &mongoConnection{collection: mockConnection} + queue := &queue{collection: mockConnection} mockConnection.On("InsertOne", mock.Anything, mock.Anything, mock.Anything).Return(&mongo.InsertOneResult{}, nil) - err := mongoConnection.Enqueue(parser.LogCrossChainCallRequested{}, &config.Config{}) + err := queue.Enqueue(parser.LogCrossChainCallRequested{}) assert.NoError(t, err) } func TestEnqueuePassesParsedLogToInsertOne(t *testing.T) { mockConnection := new(MongoConnectionMock) - mongoConnection := &mongoConnection{collection: mockConnection} + queue := &queue{collection: mockConnection} parsedLog := parser.LogCrossChainCallRequested{} mockConnection.On("InsertOne", context.TODO(), parsedLog, mock.Anything).Return(&mongo.InsertOneResult{}, nil) - err := mongoConnection.Enqueue(parsedLog, &config.Config{}) + err := queue.Enqueue(parsedLog) assert.NoError(t, err) mockConnection.AssertExpectations(t) @@ -62,33 +61,33 @@ func TestEnqueuePassesParsedLogToInsertOne(t *testing.T) { func TestEnqueueError(t *testing.T) { mockConnection := new(MongoConnectionMock) - mongoConnection := &mongoConnection{collection: mockConnection} + queue := &queue{collection: mockConnection} mockConnection.On("InsertOne", mock.Anything, mock.Anything, mock.Anything).Return(&mongo.InsertOneResult{}, errors.New("error")) - err := mongoConnection.Enqueue(parser.LogCrossChainCallRequested{}, &config.Config{}) + err := queue.Enqueue(parser.LogCrossChainCallRequested{}) assert.Error(t, err) } func TestClose(t *testing.T) { mockClient := new(MongoClientMock) - mongoClient := &mongoClient{client: mockClient} + queue := &queue{client: mockClient} mockClient.On("Disconnect", context.TODO()).Return(nil) - err := mongoClient.Close() + err := queue.Close() assert.NoError(t, err) } func TestCloseError(t *testing.T) { mockClient := new(MongoClientMock) - mongoClient := &mongoClient{client: mockClient} + queue := &queue{client: mockClient} mockClient.On("Disconnect", context.TODO()).Return(errors.New("error")) - err := mongoClient.Close() + err := queue.Close() assert.Error(t, err) } diff --git a/services/go-filler/log-fetcher/internal/validator/validator.go b/services/go-filler/log-fetcher/internal/validator/validator.go index 7add122..218fe4d 100644 --- a/services/go-filler/log-fetcher/internal/validator/validator.go +++ b/services/go-filler/log-fetcher/internal/validator/validator.go @@ -12,20 +12,23 @@ import ( ) type Validator interface { - ValidateLog(cfg *config.Config, srcChain *chains.ChainConfig, parsedLog parser.LogCrossChainCallRequested) error + ValidateLog(parsedLog parser.LogCrossChainCallRequested) error } -type validator struct{} +type validator struct { + cfg *config.Config + srcChain *chains.ChainConfig +} -func NewValidator() Validator { - return &validator{} +func NewValidator(cfg *config.Config, srcChain *chains.ChainConfig) Validator { + return &validator{cfg: cfg, srcChain: srcChain} } -func (v *validator) ValidateLog(cfg *config.Config, srcChain *chains.ChainConfig, parsedLog parser.LogCrossChainCallRequested) error { +func (v *validator) ValidateLog(parsedLog parser.LogCrossChainCallRequested) error { fmt.Println("Validating log") // - Confirm valid proverContract address on source chain - dstChain, err := chains.GetChainConfig(parsedLog.Request.DestinationChainId, cfg.RPCs) + dstChain, err := chains.GetChainConfig(parsedLog.Request.DestinationChainId, v.cfg.RPCs) if err != nil { return err } @@ -35,7 +38,7 @@ func (v *validator) ValidateLog(cfg *config.Config, srcChain *chains.ChainConfig return errors.New("destination chain missing Prover name") } - expectedProverAddr := srcChain.ProverContracts[proverName] + expectedProverAddr := v.srcChain.ProverContracts[proverName] if expectedProverAddr == common.HexToAddress("") { return errors.New("expected prover address not found for source chain") } diff --git a/services/go-filler/log-fetcher/internal/validator/validator_test.go b/services/go-filler/log-fetcher/internal/validator/validator_test.go index 5651bc2..43389c1 100644 --- a/services/go-filler/log-fetcher/internal/validator/validator_test.go +++ b/services/go-filler/log-fetcher/internal/validator/validator_test.go @@ -45,105 +45,105 @@ var parsedLog = parser.LogCrossChainCallRequested{ } func TestValidateLog(t *testing.T) { - validator := NewValidator() + validator := NewValidator(cfg, srcChain) - err := validator.ValidateLog(cfg, srcChain, parsedLog) + err := validator.ValidateLog(parsedLog) assert.NoError(t, err) } func TestValidateLog_UnknownDestinationChain(t *testing.T) { - validator := NewValidator() + validator := NewValidator(cfg, srcChain) prevDstChainId := parsedLog.Request.DestinationChainId parsedLog.Request.DestinationChainId = big.NewInt(11155112) defer func() { parsedLog.Request.DestinationChainId = prevDstChainId }() - err := validator.ValidateLog(cfg, srcChain, parsedLog) + err := validator.ValidateLog(parsedLog) assert.Error(t, err) } func TestValidateLog_UnknownProverName(t *testing.T) { - validator := NewValidator() + validator := NewValidator(cfg, srcChain) prevDstChainId := parsedLog.Request.DestinationChainId parsedLog.Request.DestinationChainId = big.NewInt(11155111) defer func() { parsedLog.Request.DestinationChainId = prevDstChainId }() - err := validator.ValidateLog(cfg, srcChain, parsedLog) + err := validator.ValidateLog(parsedLog) assert.Error(t, err) } func TestValidateLog_UnknownProverContract(t *testing.T) { - validator := NewValidator() + validator := NewValidator(cfg, srcChain) prevProverContract := parsedLog.Request.ProverContract parsedLog.Request.ProverContract = common.HexToAddress("0x1234567890123456789012345678901234567891") defer func() { parsedLog.Request.ProverContract = prevProverContract }() - err := validator.ValidateLog(cfg, srcChain, parsedLog) + err := validator.ValidateLog(parsedLog) assert.Error(t, err) } func TestValidateLog_UnknownInboxContract(t *testing.T) { - validator := NewValidator() + validator := NewValidator(cfg, srcChain) prevInboxContract := parsedLog.Request.InboxContract parsedLog.Request.InboxContract = common.HexToAddress("0x1234567890123456789012345678901234567891") defer func() { parsedLog.Request.InboxContract = prevInboxContract }() - err := validator.ValidateLog(cfg, srcChain, parsedLog) + err := validator.ValidateLog(parsedLog) assert.Error(t, err) } func TestValidateLog_UnknownL2Oracle(t *testing.T) { - validator := NewValidator() + validator := NewValidator(cfg, srcChain) prevL2Oracle := parsedLog.Request.L2Oracle parsedLog.Request.L2Oracle = common.HexToAddress("0x1234567890123456789012345678901234567891") defer func() { parsedLog.Request.L2Oracle = prevL2Oracle }() - err := validator.ValidateLog(cfg, srcChain, parsedLog) + err := validator.ValidateLog(parsedLog) assert.Error(t, err) } func TestValidateLog_UnknownL2OracleStorageKey(t *testing.T) { - validator := NewValidator() + validator := NewValidator(cfg, srcChain) prevL2OracleStorageKey := parsedLog.Request.L2OracleStorageKey parsedLog.Request.L2OracleStorageKey = encodeBytes("1234567890123456789012345678901234567891") defer func() { parsedLog.Request.L2OracleStorageKey = prevL2OracleStorageKey }() - err := validator.ValidateLog(cfg, srcChain, parsedLog) + err := validator.ValidateLog(parsedLog) assert.Error(t, err) } func TestValidateLog_InvalidReward_NotNativeAsset(t *testing.T) { - validator := NewValidator() + validator := NewValidator(cfg, srcChain) prevRewardAsset := parsedLog.Request.RewardAsset parsedLog.Request.RewardAsset = common.HexToAddress("0x1234567890123456789012345678901234567891") defer func() { parsedLog.Request.RewardAsset = prevRewardAsset }() - err := validator.ValidateLog(cfg, srcChain, parsedLog) + err := validator.ValidateLog(parsedLog) assert.Error(t, err) } func TestValidateLog_InvalidReward_NotGreaterThanValueNeeded(t *testing.T) { - validator := NewValidator() + validator := NewValidator(cfg, srcChain) prevRewardAmount := parsedLog.Request.RewardAmount parsedLog.Request.RewardAmount = big.NewInt(1000000000000000000) defer func() { parsedLog.Request.RewardAmount = prevRewardAmount }() - err := validator.ValidateLog(cfg, srcChain, parsedLog) + err := validator.ValidateLog(parsedLog) assert.Error(t, err) } From 0bf35437382cabfb75ae542891b8d113181a98a6 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Sat, 26 Oct 2024 15:12:56 -0400 Subject: [PATCH 13/36] write unit testing for handler --- .../log-fetcher/internal/handler/handler.go | 4 +- .../internal/handler/handler_test.go | 119 ++++++++++++++++++ 2 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 services/go-filler/log-fetcher/internal/handler/handler_test.go diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go index 9f26d02..776a0e3 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler.go +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -14,15 +14,13 @@ type Handler interface { } type handler struct { - cfg *config.Config - srcChain *chains.ChainConfig parser parser.Parser validator validator.Validator queue store.Queue } func NewHandler(cfg *config.Config, srcChain *chains.ChainConfig, queue store.Queue) Handler { - return &handler{cfg: cfg, srcChain: srcChain, parser: parser.NewParser(), validator: validator.NewValidator(cfg, srcChain), queue: queue} + return &handler{parser: parser.NewParser(), validator: validator.NewValidator(cfg, srcChain), queue: queue} } func (h *handler) HandleLog(vLog types.Log) error { diff --git a/services/go-filler/log-fetcher/internal/handler/handler_test.go b/services/go-filler/log-fetcher/internal/handler/handler_test.go new file mode 100644 index 0000000..844fa4b --- /dev/null +++ b/services/go-filler/log-fetcher/internal/handler/handler_test.go @@ -0,0 +1,119 @@ +package handler + +import ( + "errors" + "testing" + + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" + "github.com/ethereum/go-ethereum/core/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" +) + +type ParserMock struct { + mock.Mock +} + +type ValidatorMock struct { + mock.Mock +} + +type QueueMock struct { + mock.Mock +} + +func (p *ParserMock) ParseLog(vLog types.Log) (parser.LogCrossChainCallRequested, error) { + args := p.Called(vLog) + return args.Get(0).(parser.LogCrossChainCallRequested), args.Error(1) +} + +func (v *ValidatorMock) ValidateLog(parsedLog parser.LogCrossChainCallRequested) error { + args := v.Called(parsedLog) + return args.Error(0) +} + +func (q *QueueMock) Enqueue(parsedLog parser.LogCrossChainCallRequested) error { + args := q.Called(parsedLog) + return args.Error(0) +} + +func (q *QueueMock) Close() error { + args := q.Called() + return args.Error(0) +} + +func TestHandler(t *testing.T) { + parserMock := new(ParserMock) + validatorMock := new(ValidatorMock) + queueMock := new(QueueMock) + + vLog := types.Log{} + parsedLog := parser.LogCrossChainCallRequested{} + + parserMock.On("ParseLog", vLog).Return(parsedLog, nil) + validatorMock.On("ValidateLog", parsedLog).Return(nil) + queueMock.On("Enqueue", parsedLog).Return(nil) + + handler := &handler{parser: parserMock, validator: validatorMock, queue: queueMock} + + err := handler.HandleLog(vLog) + + assert.NoError(t, err) + + parserMock.AssertExpectations(t) + validatorMock.AssertExpectations(t) + queueMock.AssertExpectations(t) +} + +func TestHandlerReturnsErrorFromParser(t *testing.T) { + parserMock := new(ParserMock) + validatorMock := new(ValidatorMock) + queueMock := new(QueueMock) + + vLog := types.Log{} + + parserMock.On("ParseLog", vLog).Return(parser.LogCrossChainCallRequested{}, errors.New("test error")) + + handler := &handler{parser: parserMock, validator: validatorMock, queue: queueMock} + + err := handler.HandleLog(vLog) + + assert.Error(t, err) +} + +func TestHandlerReturnsErrorFromValidator(t *testing.T) { + parserMock := new(ParserMock) + validatorMock := new(ValidatorMock) + queueMock := new(QueueMock) + + vLog := types.Log{} + parsedLog := parser.LogCrossChainCallRequested{} + + parserMock.On("ParseLog", vLog).Return(parsedLog, nil) + validatorMock.On("ValidateLog", parsedLog).Return(errors.New("test error")) + + handler := &handler{parser: parserMock, validator: validatorMock, queue: queueMock} + + err := handler.HandleLog(vLog) + + assert.Error(t, err) +} + +func TestHandlerReturnsErrorFromQueue(t *testing.T) { + parserMock := new(ParserMock) + validatorMock := new(ValidatorMock) + queueMock := new(QueueMock) + + vLog := types.Log{} + parsedLog := parser.LogCrossChainCallRequested{} + + parserMock.On("ParseLog", vLog).Return(parsedLog, nil) + validatorMock.On("ValidateLog", parsedLog).Return(nil) + queueMock.On("Enqueue", parsedLog).Return(errors.New("test error")) + + handler := &handler{parser: parserMock, validator: validatorMock, queue: queueMock} + + err := handler.HandleLog(vLog) + + assert.Error(t, err) +} From 9ce82400b38da10e97234d48502fa42fe97c1c7b Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Sat, 26 Oct 2024 15:45:31 -0400 Subject: [PATCH 14/36] add unit testing for parser --- .../{RIP7755Outbox.json => RIP7755Outbox.go} | 6 +- .../log-fetcher/internal/handler/handler.go | 9 ++- .../log-fetcher/internal/listener/listener.go | 5 +- .../log-fetcher/internal/parser/parser.go | 33 ++++------- .../internal/parser/parser_test.go | 58 +++++++++++++++++++ 5 files changed, 85 insertions(+), 26 deletions(-) rename services/go-filler/log-fetcher/internal/abis/{RIP7755Outbox.json => RIP7755Outbox.go} (99%) create mode 100644 services/go-filler/log-fetcher/internal/parser/parser_test.go diff --git a/services/go-filler/log-fetcher/internal/abis/RIP7755Outbox.json b/services/go-filler/log-fetcher/internal/abis/RIP7755Outbox.go similarity index 99% rename from services/go-filler/log-fetcher/internal/abis/RIP7755Outbox.json rename to services/go-filler/log-fetcher/internal/abis/RIP7755Outbox.go index 1b91100..cb98e86 100644 --- a/services/go-filler/log-fetcher/internal/abis/RIP7755Outbox.json +++ b/services/go-filler/log-fetcher/internal/abis/RIP7755Outbox.go @@ -1,4 +1,6 @@ -[ +package abis + +const RIP7755OutboxAbi = `[ { "type": "function", "name": "CANCEL_DELAY_SECONDS", @@ -615,4 +617,4 @@ { "name": "token", "type": "address", "internalType": "address" } ] } -] +]` diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go index 776a0e3..046bfa2 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler.go +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -19,8 +19,13 @@ type handler struct { queue store.Queue } -func NewHandler(cfg *config.Config, srcChain *chains.ChainConfig, queue store.Queue) Handler { - return &handler{parser: parser.NewParser(), validator: validator.NewValidator(cfg, srcChain), queue: queue} +func NewHandler(cfg *config.Config, srcChain *chains.ChainConfig, queue store.Queue) (Handler, error) { + parser, err := parser.NewParser() + if err != nil { + return nil, err + } + + return &handler{parser: parser, validator: validator.NewValidator(cfg, srcChain), queue: queue}, nil } func (h *handler) HandleLog(vLog types.Log) error { diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index 3072b69..f31ad90 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -16,7 +16,10 @@ import ( ) func Init(srcChain *chains.ChainConfig, cfg *config.Config, queue store.Queue) error { - h := handler.NewHandler(cfg, srcChain, queue) + h, err := handler.NewHandler(cfg, srcChain, queue) + if err != nil { + return err + } client, err := clients.GetEthClient(srcChain) if err != nil { diff --git a/services/go-filler/log-fetcher/internal/parser/parser.go b/services/go-filler/log-fetcher/internal/parser/parser.go index 83bdedd..4e80baf 100644 --- a/services/go-filler/log-fetcher/internal/parser/parser.go +++ b/services/go-filler/log-fetcher/internal/parser/parser.go @@ -3,10 +3,9 @@ package parser import ( "fmt" "math/big" - "os" - "path/filepath" "strings" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/abis" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -16,10 +15,17 @@ type Parser interface { ParseLog(vLog types.Log) (LogCrossChainCallRequested, error) } -type parser struct{} +type parser struct { + outboxAbi abi.ABI +} + +func NewParser() (Parser, error) { + contractAbi, err := abi.JSON(strings.NewReader(abis.RIP7755OutboxAbi)) + if err != nil { + return nil, err + } -func NewParser() Parser { - return &parser{} + return &parser{outboxAbi: contractAbi}, nil } type Call struct { @@ -53,24 +59,9 @@ type LogCrossChainCallRequested struct { func (p *parser) ParseLog(vLog types.Log) (LogCrossChainCallRequested, error) { fmt.Println("Parsing log") - absPath, err := filepath.Abs("internal/abis/RIP7755Outbox.json") - if err != nil { - return LogCrossChainCallRequested{}, err - } - - outboxAbi, err := os.ReadFile(absPath) - if err != nil { - return LogCrossChainCallRequested{}, err - } - - contractAbi, err := abi.JSON(strings.NewReader(string(outboxAbi))) - if err != nil { - return LogCrossChainCallRequested{}, err - } - var event LogCrossChainCallRequested - err = contractAbi.UnpackIntoInterface(&event, "CrossChainCallRequested", vLog.Data) + err := p.outboxAbi.UnpackIntoInterface(&event, "CrossChainCallRequested", vLog.Data) if err != nil { return LogCrossChainCallRequested{}, err } diff --git a/services/go-filler/log-fetcher/internal/parser/parser_test.go b/services/go-filler/log-fetcher/internal/parser/parser_test.go new file mode 100644 index 0000000..d5fa0c3 --- /dev/null +++ b/services/go-filler/log-fetcher/internal/parser/parser_test.go @@ -0,0 +1,58 @@ +package parser + +import ( + "math/big" + "testing" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/stretchr/testify/assert" +) + +var vLog = types.Log{ + Topics: []common.Hash{ + common.HexToHash("0x123456789abcdef"), + common.HexToHash("0xabcdef123456789"), + }, + Data: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 140, 26, 97, 123, 219, 71, 52, 47, 156, 23, 172, 135, 80, 224, 176, 112, 195, 114, 199, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 47, 189, 207, 209, 122, 3, 70, 210, 169, 216, 159, 226, 51, 187, 173, 189, 29, 193, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 74, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, 130, 178, 146, 135, 143, 222, 100, 105, 29, 2, 138, 34, 55, 179, 78, 145, 199, 199, 234, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76, 139, 163, 42, 93, 172, 42, 114, 11, 179, 92, 237, 181, 29, 107, 6, 125, 16, 66, 5, 166, 238, 247, 227, 90, 190, 112, 38, 114, 150, 65, 20, 127, 121, 21, 87, 60, 126, 151, 180, 126, 250, 84, 111, 95, 110, 50, 48, 38, 59, 203, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 58, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 103, 47, 182, 210, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 140, 26, 97, 123, 219, 71, 52, 47, 156, 23, 172, 135, 80, 224, 176, 112, 195, 114, 199, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +} + +func TestParseLog(t *testing.T) { + parser, err := NewParser() + if err != nil { + t.Fatalf("Failed to create parser: %v", err) + } + + parsedLog, err := parser.ParseLog(vLog) + + var expectedRequestHash [32]byte = vLog.Topics[1] + + assert.NoError(t, err) + assert.Equal(t, parsedLog.RequestHash, expectedRequestHash) + assert.Equal(t, parsedLog.Request.Requester, common.HexToAddress("0x8C1a617BdB47342F9C17Ac8750E0b070c372C721")) + assert.Equal(t, parsedLog.Request.Calls[0].To, common.HexToAddress("0x8C1a617BdB47342F9C17Ac8750E0b070c372C721")) + assert.Equal(t, parsedLog.Request.Calls[0].Data, []byte{}) + assert.Equal(t, parsedLog.Request.Calls[0].Value, big.NewInt(1)) + assert.Equal(t, parsedLog.Request.ProverContract, common.HexToAddress("0x062fBdCfd17A0346D2A9d89FE233bbAdBd1DC14C")) + assert.Equal(t, parsedLog.Request.DestinationChainId, big.NewInt(84532)) + assert.Equal(t, parsedLog.Request.InboxContract, common.HexToAddress("0xB482b292878FDe64691d028A2237B34e91c7c7ea")) + assert.Equal(t, parsedLog.Request.L2Oracle, common.HexToAddress("0x4C8BA32A5DAC2A720bb35CeDB51D6B067D104205")) + assert.Equal(t, parsedLog.Request.L2OracleStorageKey, [32]byte{0xa6, 0xee, 0xf7, 0xe3, 0x5a, 0xbe, 0x70, 0x26, 0x72, 0x96, 0x41, 0x14, 0x7f, 0x79, 0x15, 0x57, 0x3c, 0x7e, 0x97, 0xb4, 0x7e, 0xfa, 0x54, 0x6f, 0x5f, 0x6e, 0x32, 0x30, 0x26, 0x3b, 0xcb, 0x49}) + assert.Equal(t, parsedLog.Request.RewardAsset, common.HexToAddress("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE")) + assert.Equal(t, parsedLog.Request.RewardAmount, big.NewInt(2)) + assert.Equal(t, parsedLog.Request.FinalityDelaySeconds, big.NewInt(604800)) + assert.Equal(t, parsedLog.Request.Nonce, big.NewInt(18)) + assert.Equal(t, parsedLog.Request.Expiry, big.NewInt(1731180242)) + assert.Equal(t, parsedLog.Request.PrecheckContract, common.HexToAddress("0x0000000000000000000000000000000000000000")) + assert.Equal(t, parsedLog.Request.PrecheckData, []byte{}) +} + +func TestParseLog_InvalidLog(t *testing.T) { + parser, err := NewParser() + if err != nil { + t.Fatalf("Failed to create parser: %v", err) + } + + _, err = parser.ParseLog(types.Log{}) + assert.Error(t, err) +} From cef1dac8c9c075e0abeb1a5f65c58c2d21092916 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Sat, 26 Oct 2024 16:07:10 -0400 Subject: [PATCH 15/36] refactor listener and add unit tests --- services/go-filler/log-fetcher/cmd/main.go | 7 +++- .../log-fetcher/internal/listener/listener.go | 34 +++++++++++++------ .../internal/listener/listener_test.go | 32 +++++++++++++++++ 3 files changed, 62 insertions(+), 11 deletions(-) create mode 100644 services/go-filler/log-fetcher/internal/listener/listener_test.go diff --git a/services/go-filler/log-fetcher/cmd/main.go b/services/go-filler/log-fetcher/cmd/main.go index ba1004b..7c6d4ec 100644 --- a/services/go-filler/log-fetcher/cmd/main.go +++ b/services/go-filler/log-fetcher/cmd/main.go @@ -27,7 +27,12 @@ func main() { log.Fatal(err) } - err = listener.Init(srcChain, cfg, queue) + l, err := listener.NewListener(srcChain, cfg, queue) + if err != nil { + log.Fatal(err) + } + + err = l.Init() if err != nil { log.Fatal(err) } diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index f31ad90..8c7a916 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -15,20 +15,25 @@ import ( "github.com/ethereum/go-ethereum/crypto" ) -func Init(srcChain *chains.ChainConfig, cfg *config.Config, queue store.Queue) error { +type Listener interface { + Init() error +} + +type listener struct { + srcChain *chains.ChainConfig + handler handler.Handler + query ethereum.FilterQuery +} + +func NewListener(srcChain *chains.ChainConfig, cfg *config.Config, queue store.Queue) (Listener, error) { h, err := handler.NewHandler(cfg, srcChain, queue) if err != nil { - return err - } - - client, err := clients.GetEthClient(srcChain) - if err != nil { - return err + return nil, err } contractAddress := srcChain.Contracts.Outbox if contractAddress == common.HexToAddress("") { - return fmt.Errorf("source chain %s missing Outbox contract address", srcChain.ChainId) + return nil, fmt.Errorf("source chain %s missing Outbox contract address", srcChain.ChainId) } crossChainCallRequestedSig := []byte("CrossChainCallRequested(bytes32,(address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes))") @@ -39,9 +44,18 @@ func Init(srcChain *chains.ChainConfig, cfg *config.Config, queue store.Queue) e Topics: [][]common.Hash{{crossChainCallRequestedHash}}, } + return &listener{srcChain: srcChain, handler: h, query: query}, nil +} + +func (l *listener) Init() error { + client, err := clients.GetEthClient(l.srcChain) + if err != nil { + return err + } + logs := make(chan types.Log) - sub, err := client.SubscribeFilterLogs(context.Background(), query, logs) + sub, err := client.SubscribeFilterLogs(context.Background(), l.query, logs) if err != nil { return err } @@ -59,7 +73,7 @@ func Init(srcChain *chains.ChainConfig, cfg *config.Config, queue store.Queue) e fmt.Printf("Log Block Number: %d\n", vLog.BlockNumber) fmt.Printf("Log Index: %d\n", vLog.Index) - err := h.HandleLog(vLog) + err := l.handler.HandleLog(vLog) if err != nil { return err } diff --git a/services/go-filler/log-fetcher/internal/listener/listener_test.go b/services/go-filler/log-fetcher/internal/listener/listener_test.go new file mode 100644 index 0000000..f03f2d7 --- /dev/null +++ b/services/go-filler/log-fetcher/internal/listener/listener_test.go @@ -0,0 +1,32 @@ +package listener + +import ( + "math/big" + "testing" + + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" + "github.com/stretchr/testify/assert" +) + +var cfg *config.Config = &config.Config{ + RPCs: &config.RPCs{ + ArbitrumSepolia: "https://arbitrum-sepolia.com", + }, +} +var queue store.Queue + +func TestNewListener(t *testing.T) { + srcChain, err := chains.GetChainConfig(big.NewInt(421614), cfg.RPCs) + if err != nil { + t.Fatalf("Failed to create source chain: %v", err) + } + + l, err := NewListener(srcChain, cfg, queue) + if err != nil { + t.Fatalf("Failed to create listener: %v", err) + } + + assert.NotNil(t, l) +} From ef88684dbe69eba6abf449d9d6bac70220fd2f36 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Sat, 26 Oct 2024 16:25:55 -0400 Subject: [PATCH 16/36] add support for multiple source chains --- services/go-filler/log-fetcher/cmd/main.go | 24 +++++++++---------- .../log-fetcher/internal/listener/listener.go | 18 +++++++++----- .../internal/listener/listener_test.go | 8 +------ 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/services/go-filler/log-fetcher/cmd/main.go b/services/go-filler/log-fetcher/cmd/main.go index 7c6d4ec..0a8aa55 100644 --- a/services/go-filler/log-fetcher/cmd/main.go +++ b/services/go-filler/log-fetcher/cmd/main.go @@ -4,12 +4,13 @@ import ( "log" "math/big" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/listener" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" ) +var supportedChains = []*big.Int{big.NewInt(421614)} + func main() { cfg, err := config.NewConfig() // Load env vars if err != nil { @@ -22,18 +23,15 @@ func main() { } defer queue.Close() - srcChain, err := chains.GetChainConfig(big.NewInt(421614), cfg.RPCs) - if err != nil { - log.Fatal(err) - } - - l, err := listener.NewListener(srcChain, cfg, queue) - if err != nil { - log.Fatal(err) - } + for _, chainId := range supportedChains { + l, err := listener.NewListener(chainId, cfg, queue) + if err != nil { + log.Fatal(err) + } - err = l.Init() - if err != nil { - log.Fatal(err) + err = l.Init() + if err != nil { + log.Fatal(err) + } } } diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index 8c7a916..aa5e0c3 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -3,6 +3,8 @@ package listener import ( "context" "fmt" + "log" + "math/big" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/clients" @@ -23,9 +25,15 @@ type listener struct { srcChain *chains.ChainConfig handler handler.Handler query ethereum.FilterQuery + logs chan types.Log } -func NewListener(srcChain *chains.ChainConfig, cfg *config.Config, queue store.Queue) (Listener, error) { +func NewListener(srcChainId *big.Int, cfg *config.Config, queue store.Queue) (Listener, error) { + srcChain, err := chains.GetChainConfig(srcChainId, cfg.RPCs) + if err != nil { + log.Fatal(err) + } + h, err := handler.NewHandler(cfg, srcChain, queue) if err != nil { return nil, err @@ -44,7 +52,7 @@ func NewListener(srcChain *chains.ChainConfig, cfg *config.Config, queue store.Q Topics: [][]common.Hash{{crossChainCallRequestedHash}}, } - return &listener{srcChain: srcChain, handler: h, query: query}, nil + return &listener{srcChain: srcChain, handler: h, query: query, logs: make(chan types.Log)}, nil } func (l *listener) Init() error { @@ -53,9 +61,7 @@ func (l *listener) Init() error { return err } - logs := make(chan types.Log) - - sub, err := client.SubscribeFilterLogs(context.Background(), l.query, logs) + sub, err := client.SubscribeFilterLogs(context.Background(), l.query, l.logs) if err != nil { return err } @@ -68,7 +74,7 @@ func (l *listener) Init() error { select { case err := <-sub.Err(): return err - case vLog := <-logs: + case vLog := <-l.logs: fmt.Println("Log received!") fmt.Printf("Log Block Number: %d\n", vLog.BlockNumber) fmt.Printf("Log Index: %d\n", vLog.Index) diff --git a/services/go-filler/log-fetcher/internal/listener/listener_test.go b/services/go-filler/log-fetcher/internal/listener/listener_test.go index f03f2d7..4bc1529 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener_test.go +++ b/services/go-filler/log-fetcher/internal/listener/listener_test.go @@ -4,7 +4,6 @@ import ( "math/big" "testing" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" "github.com/stretchr/testify/assert" @@ -18,12 +17,7 @@ var cfg *config.Config = &config.Config{ var queue store.Queue func TestNewListener(t *testing.T) { - srcChain, err := chains.GetChainConfig(big.NewInt(421614), cfg.RPCs) - if err != nil { - t.Fatalf("Failed to create source chain: %v", err) - } - - l, err := NewListener(srcChain, cfg, queue) + l, err := NewListener(big.NewInt(421614), cfg, queue) if err != nil { t.Fatalf("Failed to create listener: %v", err) } From 521c3ea1c56c096ca6b9f575af5785c0f1632d83 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Sat, 26 Oct 2024 16:32:22 -0400 Subject: [PATCH 17/36] use mongo in docker compose file instead of redis --- services/go-filler/docker-compose.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/services/go-filler/docker-compose.yml b/services/go-filler/docker-compose.yml index 3536614..5298cf6 100644 --- a/services/go-filler/docker-compose.yml +++ b/services/go-filler/docker-compose.yml @@ -1,13 +1,10 @@ version: "3.8" services: - cache: - image: redis:6.2-alpine + database: + image: mongo + container_name: mongodb restart: always ports: - - "6379:6379" - command: redis-server --save 20 1 --loglevel warning --requirepass eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81 - volumes: - - cache:/data -volumes: - cache: - driver: local + - 27017:27017 + environment: + - MONGODB_DATABASE="calls" From 90cc5b3a69a2f21481073dcc426a7d61b9cc1e2a Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Sat, 26 Oct 2024 16:33:54 -0400 Subject: [PATCH 18/36] update env vars in log fetcher readme --- services/go-filler/log-fetcher/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/go-filler/log-fetcher/README.md b/services/go-filler/log-fetcher/README.md index 6a98e39..e6eddd3 100644 --- a/services/go-filler/log-fetcher/README.md +++ b/services/go-filler/log-fetcher/README.md @@ -31,8 +31,7 @@ ARBITRUM_SEPOLIA_RPC= BASE_SEPOLIA_RPC= OPTIMISM_SEPOLIA_RPC= SEPOLIA_RPC= -REDIS_QUEUE_URL= -REDIS_PASSWORD= +MONGO_URI= ``` Run the application: From 60624fbc276086974d416e4d5434f5c248b29939 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Sat, 26 Oct 2024 16:35:38 -0400 Subject: [PATCH 19/36] remove redis vars from config --- .../go-filler/log-fetcher/internal/config/config.go | 10 +++------- .../log-fetcher/internal/config/config_test.go | 6 ------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/services/go-filler/log-fetcher/internal/config/config.go b/services/go-filler/log-fetcher/internal/config/config.go index 73eeebc..088a12f 100644 --- a/services/go-filler/log-fetcher/internal/config/config.go +++ b/services/go-filler/log-fetcher/internal/config/config.go @@ -15,10 +15,8 @@ type RPCs struct { } type Config struct { - RPCs *RPCs - RedisQueueUrl string - RedisPassword string - MongoUri string + RPCs *RPCs + MongoUri string } func NewConfig() (*Config, error) { @@ -33,9 +31,7 @@ func NewConfig() (*Config, error) { OptimismSepolia: getEnvStr("OPTIMISM_SEPOLIA_RPC"), Sepolia: getEnvStr("SEPOLIA_RPC"), }, - RedisQueueUrl: getEnvStr("REDIS_QUEUE_URL"), - RedisPassword: getEnvStr("REDIS_PASSWORD"), - MongoUri: getEnvStr("MONGO_URI"), + MongoUri: getEnvStr("MONGO_URI"), } return config, nil diff --git a/services/go-filler/log-fetcher/internal/config/config_test.go b/services/go-filler/log-fetcher/internal/config/config_test.go index 9e8af62..b7541ee 100644 --- a/services/go-filler/log-fetcher/internal/config/config_test.go +++ b/services/go-filler/log-fetcher/internal/config/config_test.go @@ -13,8 +13,6 @@ func TestNewConfig(t *testing.T) { os.Setenv("BASE_SEPOLIA_RPC", "https://base-sepolia.example.com") os.Setenv("OPTIMISM_SEPOLIA_RPC", "https://optimism-sepolia.example.com") os.Setenv("SEPOLIA_RPC", "https://sepolia.example.com") - os.Setenv("REDIS_QUEUE_URL", "https://sqs.example.com/queue") - os.Setenv("REDIS_PASSWORD", "redis-password") os.Setenv("MONGO_URI", "mongodb://localhost:27017/db") // Create a temporary .env file @@ -23,8 +21,6 @@ ARBITRUM_SEPOLIA_RPC=https://arbitrum-sepolia.example.com BASE_SEPOLIA_RPC=https://base-sepolia.example.com OPTIMISM_SEPOLIA_RPC=https://optimism-sepolia.example.com SEPOLIA_RPC=https://sepolia.example.com -REDIS_QUEUE_URL=https://sqs.example.com/queue -REDIS_PASSWORD=redis-password MONGO_URI=mongodb://localhost:27017/db ` err := os.WriteFile(".env", []byte(envContent), 0644) @@ -42,8 +38,6 @@ MONGO_URI=mongodb://localhost:27017/db assert.Equal(t, "https://base-sepolia.example.com", config.RPCs.BaseSepolia) assert.Equal(t, "https://optimism-sepolia.example.com", config.RPCs.OptimismSepolia) assert.Equal(t, "https://sepolia.example.com", config.RPCs.Sepolia) - assert.Equal(t, "https://sqs.example.com/queue", config.RedisQueueUrl) - assert.Equal(t, "redis-password", config.RedisPassword) assert.Equal(t, "mongodb://localhost:27017/db", config.MongoUri) } From 65abef7d025afa95e39eb7069c7179d4b9f67716 Mon Sep 17 00:00:00 2001 From: Michael de Hoog Date: Mon, 28 Oct 2024 13:11:30 -1000 Subject: [PATCH 20/36] Move go.mod to go-filler root --- services/go-filler/{log-fetcher => }/go.mod | 2 +- services/go-filler/go.sum | 74 +++++++ services/go-filler/log-fetcher/go.sum | 230 -------------------- 3 files changed, 75 insertions(+), 231 deletions(-) rename services/go-filler/{log-fetcher => }/go.mod (96%) create mode 100644 services/go-filler/go.sum delete mode 100644 services/go-filler/log-fetcher/go.sum diff --git a/services/go-filler/log-fetcher/go.mod b/services/go-filler/go.mod similarity index 96% rename from services/go-filler/log-fetcher/go.mod rename to services/go-filler/go.mod index 65dc42d..03ded6d 100644 --- a/services/go-filler/log-fetcher/go.mod +++ b/services/go-filler/go.mod @@ -1,4 +1,4 @@ -module github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher +module github.com/base-org/RIP-7755-poc/services/go-filler go 1.23.2 diff --git a/services/go-filler/go.sum b/services/go-filler/go.sum new file mode 100644 index 0000000..2bc66db --- /dev/null +++ b/services/go-filler/go.sum @@ -0,0 +1,74 @@ +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= +github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= +github.com/ethereum/go-ethereum v1.14.11/go.mod h1:+l/fr42Mma+xBnhefL/+z11/hcmJ2egl+ScIVPjhc7E= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= +github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= +github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= +github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= +github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.mongodb.org/mongo-driver v1.17.1/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= diff --git a/services/go-filler/log-fetcher/go.sum b/services/go-filler/log-fetcher/go.sum deleted file mode 100644 index 74932a3..0000000 --- a/services/go-filler/log-fetcher/go.sum +++ /dev/null @@ -1,230 +0,0 @@ -github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= -github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= -github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= -github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= -github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= -github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= -github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= -github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= -github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= -github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= -github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= -github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= -github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v1.1.2 h1:CUh2IPtR4swHlEj48Rhfzw6l/d0qA31fItcIszQVIsA= -github.com/cockroachdb/pebble v1.1.2/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= -github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= -github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= -github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= -github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= -github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= -github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= -github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= -github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= -github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= -github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= -github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= -github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= -github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= -github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= -github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= -github.com/ethereum/go-ethereum v1.14.11 h1:8nFDCUUE67rPc6AKxFj7JKaOa2W/W1Rse3oS6LvvxEY= -github.com/ethereum/go-ethereum v1.14.11/go.mod h1:+l/fr42Mma+xBnhefL/+z11/hcmJ2egl+ScIVPjhc7E= -github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= -github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= -github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= -github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= -github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= -github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= -github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= -github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= -github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= -github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= -github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= -github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= -github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= -github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= -github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= -github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= -github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= -github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= -github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= -github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= -github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= -github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= -github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= -github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= -github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= -github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= -github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= -github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= -github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= -github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= -github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= -github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= -github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= -github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= -github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.12.0 h1:C+UIj/QWtmqY13Arb8kwMt5j34/0Z2iKamrJ+ryC0Gg= -github.com/prometheus/client_golang v1.12.0/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a h1:CmF68hwI0XsOQ5UwlBopMi2Ow4Pbg32akc4KIVCOm+Y= -github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= -github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= -github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= -github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= -github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= -github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= -github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= -github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= -github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= -github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= -github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= -github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= -github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= -github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= -github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= -github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= -github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= -github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.mongodb.org/mongo-driver v1.17.1 h1:Wic5cJIwJgSpBhe3lx3+/RybR5PiYRMpVFgO7cOHyIM= -go.mongodb.org/mongo-driver v1.17.1/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= -golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= -golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= -golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= -gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= -rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= From cb7d33da84568105ee397ec1093d55211dc9f960 Mon Sep 17 00:00:00 2001 From: Michael de Hoog Date: Mon, 28 Oct 2024 13:35:27 -1000 Subject: [PATCH 21/36] Add signal handling and clean shutdown --- services/go-filler/log-fetcher/cmd/main.go | 30 ++++++++++++++- .../log-fetcher/internal/listener/listener.go | 37 ++++++++++++++++--- 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/services/go-filler/log-fetcher/cmd/main.go b/services/go-filler/log-fetcher/cmd/main.go index 0a8aa55..69665f3 100644 --- a/services/go-filler/log-fetcher/cmd/main.go +++ b/services/go-filler/log-fetcher/cmd/main.go @@ -1,8 +1,15 @@ package main import ( + "context" + "fmt" "log" "math/big" + "os" + "os/signal" + "sync" + "syscall" + "time" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/listener" @@ -23,15 +30,36 @@ func main() { } defer queue.Close() + var wg sync.WaitGroup + stopped, stop := context.WithCancel(context.Background()) + for _, chainId := range supportedChains { l, err := listener.NewListener(chainId, cfg, queue) if err != nil { log.Fatal(err) } - err = l.Init() + wg.Add(1) + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + err = l.Start(ctx) + cancel() if err != nil { log.Fatal(err) } + + go func() { + defer wg.Done() + <-stopped.Done() + l.Stop() + }() } + + // Handle signals to initiate shutdown + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt, syscall.SIGTERM) + <-c + + fmt.Println("Shutting down...") + stop() + wg.Wait() } diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index aa5e0c3..62672cd 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "math/big" + "sync" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/clients" @@ -18,7 +19,8 @@ import ( ) type Listener interface { - Init() error + Start(ctx context.Context) error + Stop() } type listener struct { @@ -26,6 +28,8 @@ type listener struct { handler handler.Handler query ethereum.FilterQuery logs chan types.Log + stop chan struct{} + wg sync.WaitGroup } func NewListener(srcChainId *big.Int, cfg *config.Config, queue store.Queue) (Listener, error) { @@ -52,16 +56,22 @@ func NewListener(srcChainId *big.Int, cfg *config.Config, queue store.Queue) (Li Topics: [][]common.Hash{{crossChainCallRequestedHash}}, } - return &listener{srcChain: srcChain, handler: h, query: query, logs: make(chan types.Log)}, nil + return &listener{ + srcChain: srcChain, + handler: h, + query: query, + logs: make(chan types.Log), + stop: make(chan struct{}), + }, nil } -func (l *listener) Init() error { +func (l *listener) Start(ctx context.Context) error { client, err := clients.GetEthClient(l.srcChain) if err != nil { return err } - sub, err := client.SubscribeFilterLogs(context.Background(), l.query, l.logs) + sub, err := client.SubscribeFilterLogs(ctx, l.query, l.logs) if err != nil { return err } @@ -70,10 +80,18 @@ func (l *listener) Init() error { fmt.Println("Subscribed to logs") + l.wg.Add(1) + go l.loop(sub) + + return nil +} + +func (l *listener) loop(sub ethereum.Subscription) { + defer l.wg.Done() for { select { case err := <-sub.Err(): - return err + fmt.Printf("Subscription error: %v\n", err) case vLog := <-l.logs: fmt.Println("Log received!") fmt.Printf("Log Block Number: %d\n", vLog.BlockNumber) @@ -81,8 +99,15 @@ func (l *listener) Init() error { err := l.handler.HandleLog(vLog) if err != nil { - return err + fmt.Printf("Error handling log: %v\n", err) } + case <-l.stop: + return } } } + +func (l *listener) Stop() { + close(l.stop) + l.wg.Wait() +} From 49625f45fbc098d7fa16e22168d1e255371c15fd Mon Sep 17 00:00:00 2001 From: Michael de Hoog Date: Mon, 28 Oct 2024 14:04:49 -1000 Subject: [PATCH 22/36] go mod tidy --- services/go-filler/go.mod | 2 + services/go-filler/go.sum | 159 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+) diff --git a/services/go-filler/go.mod b/services/go-filler/go.mod index 03ded6d..cdd016a 100644 --- a/services/go-filler/go.mod +++ b/services/go-filler/go.mod @@ -23,8 +23,10 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/ethereum/c-kzg-4844 v1.0.0 // indirect github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect + github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect + github.com/google/uuid v1.3.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/holiman/uint256 v1.3.1 // indirect github.com/klauspost/compress v1.16.0 // indirect diff --git a/services/go-filler/go.sum b/services/go-filler/go.sum index 2bc66db..a5e55c0 100644 --- a/services/go-filler/go.sum +++ b/services/go-filler/go.sum @@ -1,45 +1,188 @@ +github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= +github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= +github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= +github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= +github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v1.1.2 h1:CUh2IPtR4swHlEj48Rhfzw6l/d0qA31fItcIszQVIsA= +github.com/cockroachdb/pebble v1.1.2/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= +github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= +github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= +github.com/ethereum/go-ethereum v1.14.11 h1:8nFDCUUE67rPc6AKxFj7JKaOa2W/W1Rse3oS6LvvxEY= github.com/ethereum/go-ethereum v1.14.11/go.mod h1:+l/fr42Mma+xBnhefL/+z11/hcmJ2egl+ScIVPjhc7E= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= +github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= +github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= +github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= +github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= +github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= +github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= +github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= +github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= +github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v1.12.0 h1:C+UIj/QWtmqY13Arb8kwMt5j34/0Z2iKamrJ+ryC0Gg= +github.com/prometheus/client_golang v1.12.0/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a h1:CmF68hwI0XsOQ5UwlBopMi2Ow4Pbg32akc4KIVCOm+Y= +github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= +github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= +github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= +github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= +github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= +github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= +github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.mongodb.org/mongo-driver v1.17.1 h1:Wic5cJIwJgSpBhe3lx3+/RybR5PiYRMpVFgO7cOHyIM= go.mongodb.org/mongo-driver v1.17.1/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -47,6 +190,7 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -54,9 +198,11 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -64,11 +210,24 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= From 5c03a359fcbfd49d3b85677af5b0f0d585266995 Mon Sep 17 00:00:00 2001 From: Michael de Hoog Date: Mon, 28 Oct 2024 14:05:07 -1000 Subject: [PATCH 23/36] Switch to using abigen bindings for contract interaction --- .gitignore | 1 + contracts/foundry.toml | 1 + services/go-filler/Makefile | 5 + .../go-filler/bindings/rip_7755_outbox.go | 688 ++++++++++++++++++ .../internal/abis/RIP7755Outbox.go | 620 ---------------- .../log-fetcher/internal/handler/handler.go | 24 +- .../internal/handler/handler_test.go | 74 +- .../log-fetcher/internal/listener/listener.go | 57 +- .../log-fetcher/internal/parser/parser.go | 72 -- .../internal/parser/parser_test.go | 58 -- .../internal/store/mongo_client.go | 17 +- .../internal/store/mongo_client_test.go | 16 +- .../internal/validator/validator.go | 24 +- .../internal/validator/validator_test.go | 8 +- 14 files changed, 784 insertions(+), 881 deletions(-) create mode 100644 .gitignore create mode 100644 services/go-filler/Makefile create mode 100644 services/go-filler/bindings/rip_7755_outbox.go delete mode 100644 services/go-filler/log-fetcher/internal/abis/RIP7755Outbox.go delete mode 100644 services/go-filler/log-fetcher/internal/parser/parser.go delete mode 100644 services/go-filler/log-fetcher/internal/parser/parser_test.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..85e7c1d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea/ diff --git a/contracts/foundry.toml b/contracts/foundry.toml index 1eb8806..811f793 100644 --- a/contracts/foundry.toml +++ b/contracts/foundry.toml @@ -5,3 +5,4 @@ libs = ["lib"] solc_version = "0.8.24" fs_permissions = [{ access = "read-write", path = "./"}] evm_version = "shanghai" +extra_output_files = ['abi'] diff --git a/services/go-filler/Makefile b/services/go-filler/Makefile new file mode 100644 index 0000000..f43ae40 --- /dev/null +++ b/services/go-filler/Makefile @@ -0,0 +1,5 @@ +.PHONY: bindings +bindings: + go install github.com/ethereum/go-ethereum/cmd/abigen@v1.14.11 + cd ../../contracts && forge build + abigen --abi ../../contracts/out/RIP7755Outbox.sol/RIP7755Outbox.abi.json --pkg bindings --type RIP7755Outbox --out bindings/rip_7755_outbox.go diff --git a/services/go-filler/bindings/rip_7755_outbox.go b/services/go-filler/bindings/rip_7755_outbox.go new file mode 100644 index 0000000..45e1897 --- /dev/null +++ b/services/go-filler/bindings/rip_7755_outbox.go @@ -0,0 +1,688 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package bindings + +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 +) + +// Call is an auto generated low-level Go binding around an user-defined struct. +type Call struct { + To common.Address + Data []byte + Value *big.Int +} + +// CrossChainRequest is an auto generated low-level Go binding around an user-defined struct. +type CrossChainRequest struct { + Requester common.Address + Calls []Call + ProverContract common.Address + DestinationChainId *big.Int + InboxContract common.Address + L2Oracle common.Address + L2OracleStorageKey [32]byte + RewardAsset common.Address + RewardAmount *big.Int + FinalityDelaySeconds *big.Int + Nonce *big.Int + Expiry *big.Int + PrecheckContract common.Address + PrecheckData []byte +} + +// RIP7755InboxFulfillmentInfo is an auto generated low-level Go binding around an user-defined struct. +type RIP7755InboxFulfillmentInfo struct { + Timestamp *big.Int + Filler common.Address +} + +// RIP7755OutboxMetaData contains all meta data concerning the RIP7755Outbox contract. +var RIP7755OutboxMetaData = &bind.MetaData{ + ABI: "[{\"type\":\"function\",\"name\":\"CANCEL_DELAY_SECONDS\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"cancelRequest\",\"inputs\":[{\"name\":\"request\",\"type\":\"tuple\",\"internalType\":\"structCrossChainRequest\",\"components\":[{\"name\":\"requester\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"calls\",\"type\":\"tuple[]\",\"internalType\":\"structCall[]\",\"components\":[{\"name\":\"to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"value\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"name\":\"proverContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"destinationChainId\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"inboxContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l2Oracle\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l2OracleStorageKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"rewardAsset\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"rewardAmount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"finalityDelaySeconds\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"expiry\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"precheckContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"precheckData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"claimReward\",\"inputs\":[{\"name\":\"request\",\"type\":\"tuple\",\"internalType\":\"structCrossChainRequest\",\"components\":[{\"name\":\"requester\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"calls\",\"type\":\"tuple[]\",\"internalType\":\"structCall[]\",\"components\":[{\"name\":\"to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"value\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"name\":\"proverContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"destinationChainId\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"inboxContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l2Oracle\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l2OracleStorageKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"rewardAsset\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"rewardAmount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"finalityDelaySeconds\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"expiry\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"precheckContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"precheckData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"name\":\"fulfillmentInfo\",\"type\":\"tuple\",\"internalType\":\"structRIP7755Inbox.FulfillmentInfo\",\"components\":[{\"name\":\"timestamp\",\"type\":\"uint96\",\"internalType\":\"uint96\"},{\"name\":\"filler\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"payTo\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"getRequestStatus\",\"inputs\":[{\"name\":\"requestHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint8\",\"internalType\":\"enumRIP7755Outbox.CrossChainCallStatus\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"hashRequest\",\"inputs\":[{\"name\":\"request\",\"type\":\"tuple\",\"internalType\":\"structCrossChainRequest\",\"components\":[{\"name\":\"requester\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"calls\",\"type\":\"tuple[]\",\"internalType\":\"structCall[]\",\"components\":[{\"name\":\"to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"value\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"name\":\"proverContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"destinationChainId\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"inboxContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l2Oracle\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l2OracleStorageKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"rewardAsset\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"rewardAmount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"finalityDelaySeconds\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"expiry\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"precheckContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"precheckData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"hashRequestMemory\",\"inputs\":[{\"name\":\"request\",\"type\":\"tuple\",\"internalType\":\"structCrossChainRequest\",\"components\":[{\"name\":\"requester\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"calls\",\"type\":\"tuple[]\",\"internalType\":\"structCall[]\",\"components\":[{\"name\":\"to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"value\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"name\":\"proverContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"destinationChainId\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"inboxContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l2Oracle\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l2OracleStorageKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"rewardAsset\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"rewardAmount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"finalityDelaySeconds\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"expiry\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"precheckContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"precheckData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"requestCrossChainCall\",\"inputs\":[{\"name\":\"request\",\"type\":\"tuple\",\"internalType\":\"structCrossChainRequest\",\"components\":[{\"name\":\"requester\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"calls\",\"type\":\"tuple[]\",\"internalType\":\"structCall[]\",\"components\":[{\"name\":\"to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"value\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"name\":\"proverContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"destinationChainId\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"inboxContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l2Oracle\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l2OracleStorageKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"rewardAsset\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"rewardAmount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"finalityDelaySeconds\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"expiry\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"precheckContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"precheckData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"event\",\"name\":\"CrossChainCallCanceled\",\"inputs\":[{\"name\":\"requestHash\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"CrossChainCallRequested\",\"inputs\":[{\"name\":\"requestHash\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"request\",\"type\":\"tuple\",\"indexed\":false,\"internalType\":\"structCrossChainRequest\",\"components\":[{\"name\":\"requester\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"calls\",\"type\":\"tuple[]\",\"internalType\":\"structCall[]\",\"components\":[{\"name\":\"to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"value\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"name\":\"proverContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"destinationChainId\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"inboxContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l2Oracle\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"l2OracleStorageKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"rewardAsset\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"rewardAmount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"finalityDelaySeconds\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"expiry\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"precheckContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"precheckData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"AddressEmptyCode\",\"inputs\":[{\"name\":\"target\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"AddressInsufficientBalance\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"CannotCancelRequestBeforeExpiry\",\"inputs\":[{\"name\":\"currentTimestamp\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"expiry\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"ExpiryTooSoon\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"FailedInnerCall\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidCaller\",\"inputs\":[{\"name\":\"caller\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"expectedCaller\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"InvalidStatus\",\"inputs\":[{\"name\":\"expected\",\"type\":\"uint8\",\"internalType\":\"enumRIP7755Outbox.CrossChainCallStatus\"},{\"name\":\"actual\",\"type\":\"uint8\",\"internalType\":\"enumRIP7755Outbox.CrossChainCallStatus\"}]},{\"type\":\"error\",\"name\":\"InvalidValue\",\"inputs\":[{\"name\":\"expected\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"received\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"ProofValidationFailed\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"SafeERC20FailedOperation\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"}]}]", +} + +// RIP7755OutboxABI is the input ABI used to generate the binding from. +// Deprecated: Use RIP7755OutboxMetaData.ABI instead. +var RIP7755OutboxABI = RIP7755OutboxMetaData.ABI + +// RIP7755Outbox is an auto generated Go binding around an Ethereum contract. +type RIP7755Outbox struct { + RIP7755OutboxCaller // Read-only binding to the contract + RIP7755OutboxTransactor // Write-only binding to the contract + RIP7755OutboxFilterer // Log filterer for contract events +} + +// RIP7755OutboxCaller is an auto generated read-only Go binding around an Ethereum contract. +type RIP7755OutboxCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// RIP7755OutboxTransactor is an auto generated write-only Go binding around an Ethereum contract. +type RIP7755OutboxTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// RIP7755OutboxFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type RIP7755OutboxFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// RIP7755OutboxSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type RIP7755OutboxSession struct { + Contract *RIP7755Outbox // 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 +} + +// RIP7755OutboxCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type RIP7755OutboxCallerSession struct { + Contract *RIP7755OutboxCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// RIP7755OutboxTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type RIP7755OutboxTransactorSession struct { + Contract *RIP7755OutboxTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// RIP7755OutboxRaw is an auto generated low-level Go binding around an Ethereum contract. +type RIP7755OutboxRaw struct { + Contract *RIP7755Outbox // Generic contract binding to access the raw methods on +} + +// RIP7755OutboxCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type RIP7755OutboxCallerRaw struct { + Contract *RIP7755OutboxCaller // Generic read-only contract binding to access the raw methods on +} + +// RIP7755OutboxTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type RIP7755OutboxTransactorRaw struct { + Contract *RIP7755OutboxTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewRIP7755Outbox creates a new instance of RIP7755Outbox, bound to a specific deployed contract. +func NewRIP7755Outbox(address common.Address, backend bind.ContractBackend) (*RIP7755Outbox, error) { + contract, err := bindRIP7755Outbox(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &RIP7755Outbox{RIP7755OutboxCaller: RIP7755OutboxCaller{contract: contract}, RIP7755OutboxTransactor: RIP7755OutboxTransactor{contract: contract}, RIP7755OutboxFilterer: RIP7755OutboxFilterer{contract: contract}}, nil +} + +// NewRIP7755OutboxCaller creates a new read-only instance of RIP7755Outbox, bound to a specific deployed contract. +func NewRIP7755OutboxCaller(address common.Address, caller bind.ContractCaller) (*RIP7755OutboxCaller, error) { + contract, err := bindRIP7755Outbox(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &RIP7755OutboxCaller{contract: contract}, nil +} + +// NewRIP7755OutboxTransactor creates a new write-only instance of RIP7755Outbox, bound to a specific deployed contract. +func NewRIP7755OutboxTransactor(address common.Address, transactor bind.ContractTransactor) (*RIP7755OutboxTransactor, error) { + contract, err := bindRIP7755Outbox(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &RIP7755OutboxTransactor{contract: contract}, nil +} + +// NewRIP7755OutboxFilterer creates a new log filterer instance of RIP7755Outbox, bound to a specific deployed contract. +func NewRIP7755OutboxFilterer(address common.Address, filterer bind.ContractFilterer) (*RIP7755OutboxFilterer, error) { + contract, err := bindRIP7755Outbox(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &RIP7755OutboxFilterer{contract: contract}, nil +} + +// bindRIP7755Outbox binds a generic wrapper to an already deployed contract. +func bindRIP7755Outbox(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := RIP7755OutboxMetaData.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 (_RIP7755Outbox *RIP7755OutboxRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _RIP7755Outbox.Contract.RIP7755OutboxCaller.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 (_RIP7755Outbox *RIP7755OutboxRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _RIP7755Outbox.Contract.RIP7755OutboxTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_RIP7755Outbox *RIP7755OutboxRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _RIP7755Outbox.Contract.RIP7755OutboxTransactor.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 (_RIP7755Outbox *RIP7755OutboxCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _RIP7755Outbox.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 (_RIP7755Outbox *RIP7755OutboxTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _RIP7755Outbox.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_RIP7755Outbox *RIP7755OutboxTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _RIP7755Outbox.Contract.contract.Transact(opts, method, params...) +} + +// CANCELDELAYSECONDS is a free data retrieval call binding the contract method 0xdf130c43. +// +// Solidity: function CANCEL_DELAY_SECONDS() view returns(uint256) +func (_RIP7755Outbox *RIP7755OutboxCaller) CANCELDELAYSECONDS(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _RIP7755Outbox.contract.Call(opts, &out, "CANCEL_DELAY_SECONDS") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// CANCELDELAYSECONDS is a free data retrieval call binding the contract method 0xdf130c43. +// +// Solidity: function CANCEL_DELAY_SECONDS() view returns(uint256) +func (_RIP7755Outbox *RIP7755OutboxSession) CANCELDELAYSECONDS() (*big.Int, error) { + return _RIP7755Outbox.Contract.CANCELDELAYSECONDS(&_RIP7755Outbox.CallOpts) +} + +// CANCELDELAYSECONDS is a free data retrieval call binding the contract method 0xdf130c43. +// +// Solidity: function CANCEL_DELAY_SECONDS() view returns(uint256) +func (_RIP7755Outbox *RIP7755OutboxCallerSession) CANCELDELAYSECONDS() (*big.Int, error) { + return _RIP7755Outbox.Contract.CANCELDELAYSECONDS(&_RIP7755Outbox.CallOpts) +} + +// GetRequestStatus is a free data retrieval call binding the contract method 0x45d07664. +// +// Solidity: function getRequestStatus(bytes32 requestHash) view returns(uint8) +func (_RIP7755Outbox *RIP7755OutboxCaller) GetRequestStatus(opts *bind.CallOpts, requestHash [32]byte) (uint8, error) { + var out []interface{} + err := _RIP7755Outbox.contract.Call(opts, &out, "getRequestStatus", requestHash) + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +// GetRequestStatus is a free data retrieval call binding the contract method 0x45d07664. +// +// Solidity: function getRequestStatus(bytes32 requestHash) view returns(uint8) +func (_RIP7755Outbox *RIP7755OutboxSession) GetRequestStatus(requestHash [32]byte) (uint8, error) { + return _RIP7755Outbox.Contract.GetRequestStatus(&_RIP7755Outbox.CallOpts, requestHash) +} + +// GetRequestStatus is a free data retrieval call binding the contract method 0x45d07664. +// +// Solidity: function getRequestStatus(bytes32 requestHash) view returns(uint8) +func (_RIP7755Outbox *RIP7755OutboxCallerSession) GetRequestStatus(requestHash [32]byte) (uint8, error) { + return _RIP7755Outbox.Contract.GetRequestStatus(&_RIP7755Outbox.CallOpts, requestHash) +} + +// HashRequest is a free data retrieval call binding the contract method 0xdd7d3b6a. +// +// Solidity: function hashRequest((address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request) pure returns(bytes32) +func (_RIP7755Outbox *RIP7755OutboxCaller) HashRequest(opts *bind.CallOpts, request CrossChainRequest) ([32]byte, error) { + var out []interface{} + err := _RIP7755Outbox.contract.Call(opts, &out, "hashRequest", request) + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// HashRequest is a free data retrieval call binding the contract method 0xdd7d3b6a. +// +// Solidity: function hashRequest((address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request) pure returns(bytes32) +func (_RIP7755Outbox *RIP7755OutboxSession) HashRequest(request CrossChainRequest) ([32]byte, error) { + return _RIP7755Outbox.Contract.HashRequest(&_RIP7755Outbox.CallOpts, request) +} + +// HashRequest is a free data retrieval call binding the contract method 0xdd7d3b6a. +// +// Solidity: function hashRequest((address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request) pure returns(bytes32) +func (_RIP7755Outbox *RIP7755OutboxCallerSession) HashRequest(request CrossChainRequest) ([32]byte, error) { + return _RIP7755Outbox.Contract.HashRequest(&_RIP7755Outbox.CallOpts, request) +} + +// HashRequestMemory is a free data retrieval call binding the contract method 0x9110312d. +// +// Solidity: function hashRequestMemory((address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request) pure returns(bytes32) +func (_RIP7755Outbox *RIP7755OutboxCaller) HashRequestMemory(opts *bind.CallOpts, request CrossChainRequest) ([32]byte, error) { + var out []interface{} + err := _RIP7755Outbox.contract.Call(opts, &out, "hashRequestMemory", request) + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// HashRequestMemory is a free data retrieval call binding the contract method 0x9110312d. +// +// Solidity: function hashRequestMemory((address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request) pure returns(bytes32) +func (_RIP7755Outbox *RIP7755OutboxSession) HashRequestMemory(request CrossChainRequest) ([32]byte, error) { + return _RIP7755Outbox.Contract.HashRequestMemory(&_RIP7755Outbox.CallOpts, request) +} + +// HashRequestMemory is a free data retrieval call binding the contract method 0x9110312d. +// +// Solidity: function hashRequestMemory((address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request) pure returns(bytes32) +func (_RIP7755Outbox *RIP7755OutboxCallerSession) HashRequestMemory(request CrossChainRequest) ([32]byte, error) { + return _RIP7755Outbox.Contract.HashRequestMemory(&_RIP7755Outbox.CallOpts, request) +} + +// CancelRequest is a paid mutator transaction binding the contract method 0xa309a4e2. +// +// Solidity: function cancelRequest((address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request) returns() +func (_RIP7755Outbox *RIP7755OutboxTransactor) CancelRequest(opts *bind.TransactOpts, request CrossChainRequest) (*types.Transaction, error) { + return _RIP7755Outbox.contract.Transact(opts, "cancelRequest", request) +} + +// CancelRequest is a paid mutator transaction binding the contract method 0xa309a4e2. +// +// Solidity: function cancelRequest((address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request) returns() +func (_RIP7755Outbox *RIP7755OutboxSession) CancelRequest(request CrossChainRequest) (*types.Transaction, error) { + return _RIP7755Outbox.Contract.CancelRequest(&_RIP7755Outbox.TransactOpts, request) +} + +// CancelRequest is a paid mutator transaction binding the contract method 0xa309a4e2. +// +// Solidity: function cancelRequest((address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request) returns() +func (_RIP7755Outbox *RIP7755OutboxTransactorSession) CancelRequest(request CrossChainRequest) (*types.Transaction, error) { + return _RIP7755Outbox.Contract.CancelRequest(&_RIP7755Outbox.TransactOpts, request) +} + +// ClaimReward is a paid mutator transaction binding the contract method 0x2dc6629c. +// +// Solidity: function claimReward((address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request, (uint96,address) fulfillmentInfo, bytes proof, address payTo) returns() +func (_RIP7755Outbox *RIP7755OutboxTransactor) ClaimReward(opts *bind.TransactOpts, request CrossChainRequest, fulfillmentInfo RIP7755InboxFulfillmentInfo, proof []byte, payTo common.Address) (*types.Transaction, error) { + return _RIP7755Outbox.contract.Transact(opts, "claimReward", request, fulfillmentInfo, proof, payTo) +} + +// ClaimReward is a paid mutator transaction binding the contract method 0x2dc6629c. +// +// Solidity: function claimReward((address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request, (uint96,address) fulfillmentInfo, bytes proof, address payTo) returns() +func (_RIP7755Outbox *RIP7755OutboxSession) ClaimReward(request CrossChainRequest, fulfillmentInfo RIP7755InboxFulfillmentInfo, proof []byte, payTo common.Address) (*types.Transaction, error) { + return _RIP7755Outbox.Contract.ClaimReward(&_RIP7755Outbox.TransactOpts, request, fulfillmentInfo, proof, payTo) +} + +// ClaimReward is a paid mutator transaction binding the contract method 0x2dc6629c. +// +// Solidity: function claimReward((address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request, (uint96,address) fulfillmentInfo, bytes proof, address payTo) returns() +func (_RIP7755Outbox *RIP7755OutboxTransactorSession) ClaimReward(request CrossChainRequest, fulfillmentInfo RIP7755InboxFulfillmentInfo, proof []byte, payTo common.Address) (*types.Transaction, error) { + return _RIP7755Outbox.Contract.ClaimReward(&_RIP7755Outbox.TransactOpts, request, fulfillmentInfo, proof, payTo) +} + +// RequestCrossChainCall is a paid mutator transaction binding the contract method 0xe786188e. +// +// Solidity: function requestCrossChainCall((address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request) payable returns() +func (_RIP7755Outbox *RIP7755OutboxTransactor) RequestCrossChainCall(opts *bind.TransactOpts, request CrossChainRequest) (*types.Transaction, error) { + return _RIP7755Outbox.contract.Transact(opts, "requestCrossChainCall", request) +} + +// RequestCrossChainCall is a paid mutator transaction binding the contract method 0xe786188e. +// +// Solidity: function requestCrossChainCall((address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request) payable returns() +func (_RIP7755Outbox *RIP7755OutboxSession) RequestCrossChainCall(request CrossChainRequest) (*types.Transaction, error) { + return _RIP7755Outbox.Contract.RequestCrossChainCall(&_RIP7755Outbox.TransactOpts, request) +} + +// RequestCrossChainCall is a paid mutator transaction binding the contract method 0xe786188e. +// +// Solidity: function requestCrossChainCall((address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request) payable returns() +func (_RIP7755Outbox *RIP7755OutboxTransactorSession) RequestCrossChainCall(request CrossChainRequest) (*types.Transaction, error) { + return _RIP7755Outbox.Contract.RequestCrossChainCall(&_RIP7755Outbox.TransactOpts, request) +} + +// RIP7755OutboxCrossChainCallCanceledIterator is returned from FilterCrossChainCallCanceled and is used to iterate over the raw logs and unpacked data for CrossChainCallCanceled events raised by the RIP7755Outbox contract. +type RIP7755OutboxCrossChainCallCanceledIterator struct { + Event *RIP7755OutboxCrossChainCallCanceled // 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 *RIP7755OutboxCrossChainCallCanceledIterator) 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(RIP7755OutboxCrossChainCallCanceled) + 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(RIP7755OutboxCrossChainCallCanceled) + 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 *RIP7755OutboxCrossChainCallCanceledIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *RIP7755OutboxCrossChainCallCanceledIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// RIP7755OutboxCrossChainCallCanceled represents a CrossChainCallCanceled event raised by the RIP7755Outbox contract. +type RIP7755OutboxCrossChainCallCanceled struct { + RequestHash [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterCrossChainCallCanceled is a free log retrieval operation binding the contract event 0x1be39b5d9d7a848f6e4636bfaf521d9a6b7a351a73c7d0e945b79ffc7e169346. +// +// Solidity: event CrossChainCallCanceled(bytes32 indexed requestHash) +func (_RIP7755Outbox *RIP7755OutboxFilterer) FilterCrossChainCallCanceled(opts *bind.FilterOpts, requestHash [][32]byte) (*RIP7755OutboxCrossChainCallCanceledIterator, error) { + + var requestHashRule []interface{} + for _, requestHashItem := range requestHash { + requestHashRule = append(requestHashRule, requestHashItem) + } + + logs, sub, err := _RIP7755Outbox.contract.FilterLogs(opts, "CrossChainCallCanceled", requestHashRule) + if err != nil { + return nil, err + } + return &RIP7755OutboxCrossChainCallCanceledIterator{contract: _RIP7755Outbox.contract, event: "CrossChainCallCanceled", logs: logs, sub: sub}, nil +} + +// WatchCrossChainCallCanceled is a free log subscription operation binding the contract event 0x1be39b5d9d7a848f6e4636bfaf521d9a6b7a351a73c7d0e945b79ffc7e169346. +// +// Solidity: event CrossChainCallCanceled(bytes32 indexed requestHash) +func (_RIP7755Outbox *RIP7755OutboxFilterer) WatchCrossChainCallCanceled(opts *bind.WatchOpts, sink chan<- *RIP7755OutboxCrossChainCallCanceled, requestHash [][32]byte) (event.Subscription, error) { + + var requestHashRule []interface{} + for _, requestHashItem := range requestHash { + requestHashRule = append(requestHashRule, requestHashItem) + } + + logs, sub, err := _RIP7755Outbox.contract.WatchLogs(opts, "CrossChainCallCanceled", requestHashRule) + 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(RIP7755OutboxCrossChainCallCanceled) + if err := _RIP7755Outbox.contract.UnpackLog(event, "CrossChainCallCanceled", 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 +} + +// ParseCrossChainCallCanceled is a log parse operation binding the contract event 0x1be39b5d9d7a848f6e4636bfaf521d9a6b7a351a73c7d0e945b79ffc7e169346. +// +// Solidity: event CrossChainCallCanceled(bytes32 indexed requestHash) +func (_RIP7755Outbox *RIP7755OutboxFilterer) ParseCrossChainCallCanceled(log types.Log) (*RIP7755OutboxCrossChainCallCanceled, error) { + event := new(RIP7755OutboxCrossChainCallCanceled) + if err := _RIP7755Outbox.contract.UnpackLog(event, "CrossChainCallCanceled", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// RIP7755OutboxCrossChainCallRequestedIterator is returned from FilterCrossChainCallRequested and is used to iterate over the raw logs and unpacked data for CrossChainCallRequested events raised by the RIP7755Outbox contract. +type RIP7755OutboxCrossChainCallRequestedIterator struct { + Event *RIP7755OutboxCrossChainCallRequested // 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 *RIP7755OutboxCrossChainCallRequestedIterator) 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(RIP7755OutboxCrossChainCallRequested) + 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(RIP7755OutboxCrossChainCallRequested) + 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 *RIP7755OutboxCrossChainCallRequestedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *RIP7755OutboxCrossChainCallRequestedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// RIP7755OutboxCrossChainCallRequested represents a CrossChainCallRequested event raised by the RIP7755Outbox contract. +type RIP7755OutboxCrossChainCallRequested struct { + RequestHash [32]byte + Request CrossChainRequest + Raw types.Log // Blockchain specific contextual infos +} + +// FilterCrossChainCallRequested is a free log retrieval operation binding the contract event 0x91466a77985019372d6bde6728a808e42b6db50de58526264b5b3716bf7d11de. +// +// Solidity: event CrossChainCallRequested(bytes32 indexed requestHash, (address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request) +func (_RIP7755Outbox *RIP7755OutboxFilterer) FilterCrossChainCallRequested(opts *bind.FilterOpts, requestHash [][32]byte) (*RIP7755OutboxCrossChainCallRequestedIterator, error) { + + var requestHashRule []interface{} + for _, requestHashItem := range requestHash { + requestHashRule = append(requestHashRule, requestHashItem) + } + + logs, sub, err := _RIP7755Outbox.contract.FilterLogs(opts, "CrossChainCallRequested", requestHashRule) + if err != nil { + return nil, err + } + return &RIP7755OutboxCrossChainCallRequestedIterator{contract: _RIP7755Outbox.contract, event: "CrossChainCallRequested", logs: logs, sub: sub}, nil +} + +// WatchCrossChainCallRequested is a free log subscription operation binding the contract event 0x91466a77985019372d6bde6728a808e42b6db50de58526264b5b3716bf7d11de. +// +// Solidity: event CrossChainCallRequested(bytes32 indexed requestHash, (address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request) +func (_RIP7755Outbox *RIP7755OutboxFilterer) WatchCrossChainCallRequested(opts *bind.WatchOpts, sink chan<- *RIP7755OutboxCrossChainCallRequested, requestHash [][32]byte) (event.Subscription, error) { + + var requestHashRule []interface{} + for _, requestHashItem := range requestHash { + requestHashRule = append(requestHashRule, requestHashItem) + } + + logs, sub, err := _RIP7755Outbox.contract.WatchLogs(opts, "CrossChainCallRequested", requestHashRule) + 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(RIP7755OutboxCrossChainCallRequested) + if err := _RIP7755Outbox.contract.UnpackLog(event, "CrossChainCallRequested", 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 +} + +// ParseCrossChainCallRequested is a log parse operation binding the contract event 0x91466a77985019372d6bde6728a808e42b6db50de58526264b5b3716bf7d11de. +// +// Solidity: event CrossChainCallRequested(bytes32 indexed requestHash, (address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes) request) +func (_RIP7755Outbox *RIP7755OutboxFilterer) ParseCrossChainCallRequested(log types.Log) (*RIP7755OutboxCrossChainCallRequested, error) { + event := new(RIP7755OutboxCrossChainCallRequested) + if err := _RIP7755Outbox.contract.UnpackLog(event, "CrossChainCallRequested", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/services/go-filler/log-fetcher/internal/abis/RIP7755Outbox.go b/services/go-filler/log-fetcher/internal/abis/RIP7755Outbox.go deleted file mode 100644 index cb98e86..0000000 --- a/services/go-filler/log-fetcher/internal/abis/RIP7755Outbox.go +++ /dev/null @@ -1,620 +0,0 @@ -package abis - -const RIP7755OutboxAbi = `[ - { - "type": "function", - "name": "CANCEL_DELAY_SECONDS", - "inputs": [], - "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "cancelRequest", - "inputs": [ - { - "name": "request", - "type": "tuple", - "internalType": "struct CrossChainRequest", - "components": [ - { - "name": "requester", - "type": "address", - "internalType": "address" - }, - { - "name": "calls", - "type": "tuple[]", - "internalType": "struct Call[]", - "components": [ - { "name": "to", "type": "address", "internalType": "address" }, - { "name": "data", "type": "bytes", "internalType": "bytes" }, - { - "name": "value", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "name": "proverContract", - "type": "address", - "internalType": "address" - }, - { - "name": "destinationChainId", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "inboxContract", - "type": "address", - "internalType": "address" - }, - { - "name": "l2Oracle", - "type": "address", - "internalType": "address" - }, - { - "name": "l2OracleStorageKey", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "rewardAsset", - "type": "address", - "internalType": "address" - }, - { - "name": "rewardAmount", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "finalityDelaySeconds", - "type": "uint256", - "internalType": "uint256" - }, - { "name": "nonce", "type": "uint256", "internalType": "uint256" }, - { "name": "expiry", "type": "uint256", "internalType": "uint256" }, - { - "name": "precheckContract", - "type": "address", - "internalType": "address" - }, - { "name": "precheckData", "type": "bytes", "internalType": "bytes" } - ] - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "claimReward", - "inputs": [ - { - "name": "request", - "type": "tuple", - "internalType": "struct CrossChainRequest", - "components": [ - { - "name": "requester", - "type": "address", - "internalType": "address" - }, - { - "name": "calls", - "type": "tuple[]", - "internalType": "struct Call[]", - "components": [ - { "name": "to", "type": "address", "internalType": "address" }, - { "name": "data", "type": "bytes", "internalType": "bytes" }, - { - "name": "value", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "name": "proverContract", - "type": "address", - "internalType": "address" - }, - { - "name": "destinationChainId", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "inboxContract", - "type": "address", - "internalType": "address" - }, - { - "name": "l2Oracle", - "type": "address", - "internalType": "address" - }, - { - "name": "l2OracleStorageKey", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "rewardAsset", - "type": "address", - "internalType": "address" - }, - { - "name": "rewardAmount", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "finalityDelaySeconds", - "type": "uint256", - "internalType": "uint256" - }, - { "name": "nonce", "type": "uint256", "internalType": "uint256" }, - { "name": "expiry", "type": "uint256", "internalType": "uint256" }, - { - "name": "precheckContract", - "type": "address", - "internalType": "address" - }, - { "name": "precheckData", "type": "bytes", "internalType": "bytes" } - ] - }, - { - "name": "fulfillmentInfo", - "type": "tuple", - "internalType": "struct RIP7755Inbox.FulfillmentInfo", - "components": [ - { "name": "timestamp", "type": "uint96", "internalType": "uint96" }, - { "name": "filler", "type": "address", "internalType": "address" } - ] - }, - { "name": "proof", "type": "bytes", "internalType": "bytes" }, - { "name": "payTo", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "getRequestStatus", - "inputs": [ - { "name": "requestHash", "type": "bytes32", "internalType": "bytes32" } - ], - "outputs": [ - { - "name": "", - "type": "uint8", - "internalType": "enum RIP7755Outbox.CrossChainCallStatus" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "hashRequest", - "inputs": [ - { - "name": "request", - "type": "tuple", - "internalType": "struct CrossChainRequest", - "components": [ - { - "name": "requester", - "type": "address", - "internalType": "address" - }, - { - "name": "calls", - "type": "tuple[]", - "internalType": "struct Call[]", - "components": [ - { "name": "to", "type": "address", "internalType": "address" }, - { "name": "data", "type": "bytes", "internalType": "bytes" }, - { - "name": "value", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "name": "proverContract", - "type": "address", - "internalType": "address" - }, - { - "name": "destinationChainId", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "inboxContract", - "type": "address", - "internalType": "address" - }, - { - "name": "l2Oracle", - "type": "address", - "internalType": "address" - }, - { - "name": "l2OracleStorageKey", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "rewardAsset", - "type": "address", - "internalType": "address" - }, - { - "name": "rewardAmount", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "finalityDelaySeconds", - "type": "uint256", - "internalType": "uint256" - }, - { "name": "nonce", "type": "uint256", "internalType": "uint256" }, - { "name": "expiry", "type": "uint256", "internalType": "uint256" }, - { - "name": "precheckContract", - "type": "address", - "internalType": "address" - }, - { "name": "precheckData", "type": "bytes", "internalType": "bytes" } - ] - } - ], - "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "hashRequestMemory", - "inputs": [ - { - "name": "request", - "type": "tuple", - "internalType": "struct CrossChainRequest", - "components": [ - { - "name": "requester", - "type": "address", - "internalType": "address" - }, - { - "name": "calls", - "type": "tuple[]", - "internalType": "struct Call[]", - "components": [ - { "name": "to", "type": "address", "internalType": "address" }, - { "name": "data", "type": "bytes", "internalType": "bytes" }, - { - "name": "value", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "name": "proverContract", - "type": "address", - "internalType": "address" - }, - { - "name": "destinationChainId", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "inboxContract", - "type": "address", - "internalType": "address" - }, - { - "name": "l2Oracle", - "type": "address", - "internalType": "address" - }, - { - "name": "l2OracleStorageKey", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "rewardAsset", - "type": "address", - "internalType": "address" - }, - { - "name": "rewardAmount", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "finalityDelaySeconds", - "type": "uint256", - "internalType": "uint256" - }, - { "name": "nonce", "type": "uint256", "internalType": "uint256" }, - { "name": "expiry", "type": "uint256", "internalType": "uint256" }, - { - "name": "precheckContract", - "type": "address", - "internalType": "address" - }, - { "name": "precheckData", "type": "bytes", "internalType": "bytes" } - ] - } - ], - "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "requestCrossChainCall", - "inputs": [ - { - "name": "request", - "type": "tuple", - "internalType": "struct CrossChainRequest", - "components": [ - { - "name": "requester", - "type": "address", - "internalType": "address" - }, - { - "name": "calls", - "type": "tuple[]", - "internalType": "struct Call[]", - "components": [ - { "name": "to", "type": "address", "internalType": "address" }, - { "name": "data", "type": "bytes", "internalType": "bytes" }, - { - "name": "value", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "name": "proverContract", - "type": "address", - "internalType": "address" - }, - { - "name": "destinationChainId", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "inboxContract", - "type": "address", - "internalType": "address" - }, - { - "name": "l2Oracle", - "type": "address", - "internalType": "address" - }, - { - "name": "l2OracleStorageKey", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "rewardAsset", - "type": "address", - "internalType": "address" - }, - { - "name": "rewardAmount", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "finalityDelaySeconds", - "type": "uint256", - "internalType": "uint256" - }, - { "name": "nonce", "type": "uint256", "internalType": "uint256" }, - { "name": "expiry", "type": "uint256", "internalType": "uint256" }, - { - "name": "precheckContract", - "type": "address", - "internalType": "address" - }, - { "name": "precheckData", "type": "bytes", "internalType": "bytes" } - ] - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "event", - "name": "CrossChainCallCanceled", - "inputs": [ - { - "name": "requestHash", - "type": "bytes32", - "indexed": true, - "internalType": "bytes32" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "CrossChainCallRequested", - "inputs": [ - { - "name": "requestHash", - "type": "bytes32", - "indexed": true, - "internalType": "bytes32" - }, - { - "name": "request", - "type": "tuple", - "indexed": false, - "internalType": "struct CrossChainRequest", - "components": [ - { - "name": "requester", - "type": "address", - "internalType": "address" - }, - { - "name": "calls", - "type": "tuple[]", - "internalType": "struct Call[]", - "components": [ - { "name": "to", "type": "address", "internalType": "address" }, - { "name": "data", "type": "bytes", "internalType": "bytes" }, - { - "name": "value", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "name": "proverContract", - "type": "address", - "internalType": "address" - }, - { - "name": "destinationChainId", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "inboxContract", - "type": "address", - "internalType": "address" - }, - { - "name": "l2Oracle", - "type": "address", - "internalType": "address" - }, - { - "name": "l2OracleStorageKey", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "rewardAsset", - "type": "address", - "internalType": "address" - }, - { - "name": "rewardAmount", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "finalityDelaySeconds", - "type": "uint256", - "internalType": "uint256" - }, - { "name": "nonce", "type": "uint256", "internalType": "uint256" }, - { "name": "expiry", "type": "uint256", "internalType": "uint256" }, - { - "name": "precheckContract", - "type": "address", - "internalType": "address" - }, - { "name": "precheckData", "type": "bytes", "internalType": "bytes" } - ] - } - ], - "anonymous": false - }, - { - "type": "error", - "name": "AddressEmptyCode", - "inputs": [ - { "name": "target", "type": "address", "internalType": "address" } - ] - }, - { - "type": "error", - "name": "AddressInsufficientBalance", - "inputs": [ - { "name": "account", "type": "address", "internalType": "address" } - ] - }, - { - "type": "error", - "name": "CannotCancelRequestBeforeExpiry", - "inputs": [ - { - "name": "currentTimestamp", - "type": "uint256", - "internalType": "uint256" - }, - { "name": "expiry", "type": "uint256", "internalType": "uint256" } - ] - }, - { "type": "error", "name": "ExpiryTooSoon", "inputs": [] }, - { "type": "error", "name": "FailedInnerCall", "inputs": [] }, - { - "type": "error", - "name": "InvalidCaller", - "inputs": [ - { "name": "caller", "type": "address", "internalType": "address" }, - { - "name": "expectedCaller", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "InvalidStatus", - "inputs": [ - { - "name": "expected", - "type": "uint8", - "internalType": "enum RIP7755Outbox.CrossChainCallStatus" - }, - { - "name": "actual", - "type": "uint8", - "internalType": "enum RIP7755Outbox.CrossChainCallStatus" - } - ] - }, - { - "type": "error", - "name": "InvalidValue", - "inputs": [ - { "name": "expected", "type": "uint256", "internalType": "uint256" }, - { "name": "received", "type": "uint256", "internalType": "uint256" } - ] - }, - { "type": "error", "name": "ProofValidationFailed", "inputs": [] }, - { - "type": "error", - "name": "SafeERC20FailedOperation", - "inputs": [ - { "name": "token", "type": "address", "internalType": "address" } - ] - } -]` diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go index 046bfa2..cf97ae3 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler.go +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -1,45 +1,33 @@ package handler import ( + "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/validator" - "github.com/ethereum/go-ethereum/core/types" ) type Handler interface { - HandleLog(vLog types.Log) error + HandleLog(*bindings.RIP7755OutboxCrossChainCallRequested) error } type handler struct { - parser parser.Parser validator validator.Validator queue store.Queue } func NewHandler(cfg *config.Config, srcChain *chains.ChainConfig, queue store.Queue) (Handler, error) { - parser, err := parser.NewParser() - if err != nil { - return nil, err - } - - return &handler{parser: parser, validator: validator.NewValidator(cfg, srcChain), queue: queue}, nil + return &handler{validator: validator.NewValidator(cfg, srcChain), queue: queue}, nil } -func (h *handler) HandleLog(vLog types.Log) error { - parsedLog, err := h.parser.ParseLog(vLog) - if err != nil { - return err - } - - err = h.validator.ValidateLog(parsedLog) +func (h *handler) HandleLog(log *bindings.RIP7755OutboxCrossChainCallRequested) error { + err := h.validator.ValidateLog(log) if err != nil { return err } - err = h.queue.Enqueue(parsedLog) + err = h.queue.Enqueue(log) if err != nil { return err } diff --git a/services/go-filler/log-fetcher/internal/handler/handler_test.go b/services/go-filler/log-fetcher/internal/handler/handler_test.go index 844fa4b..7abb7a8 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler_test.go +++ b/services/go-filler/log-fetcher/internal/handler/handler_test.go @@ -4,16 +4,11 @@ import ( "errors" "testing" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" - "github.com/ethereum/go-ethereum/core/types" + "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) -type ParserMock struct { - mock.Mock -} - type ValidatorMock struct { mock.Mock } @@ -22,18 +17,13 @@ type QueueMock struct { mock.Mock } -func (p *ParserMock) ParseLog(vLog types.Log) (parser.LogCrossChainCallRequested, error) { - args := p.Called(vLog) - return args.Get(0).(parser.LogCrossChainCallRequested), args.Error(1) -} - -func (v *ValidatorMock) ValidateLog(parsedLog parser.LogCrossChainCallRequested) error { - args := v.Called(parsedLog) +func (v *ValidatorMock) ValidateLog(log *bindings.RIP7755OutboxCrossChainCallRequested) error { + args := v.Called(log) return args.Error(0) } -func (q *QueueMock) Enqueue(parsedLog parser.LogCrossChainCallRequested) error { - args := q.Called(parsedLog) +func (q *QueueMock) Enqueue(log *bindings.RIP7755OutboxCrossChainCallRequested) error { + args := q.Called(log) return args.Error(0) } @@ -43,77 +33,51 @@ func (q *QueueMock) Close() error { } func TestHandler(t *testing.T) { - parserMock := new(ParserMock) validatorMock := new(ValidatorMock) queueMock := new(QueueMock) - vLog := types.Log{} - parsedLog := parser.LogCrossChainCallRequested{} + log := &bindings.RIP7755OutboxCrossChainCallRequested{} - parserMock.On("ParseLog", vLog).Return(parsedLog, nil) - validatorMock.On("ValidateLog", parsedLog).Return(nil) - queueMock.On("Enqueue", parsedLog).Return(nil) + validatorMock.On("ValidateLog", log).Return(nil) + queueMock.On("Enqueue", log).Return(nil) - handler := &handler{parser: parserMock, validator: validatorMock, queue: queueMock} + handler := &handler{validator: validatorMock, queue: queueMock} - err := handler.HandleLog(vLog) + err := handler.HandleLog(log) assert.NoError(t, err) - parserMock.AssertExpectations(t) validatorMock.AssertExpectations(t) queueMock.AssertExpectations(t) } -func TestHandlerReturnsErrorFromParser(t *testing.T) { - parserMock := new(ParserMock) - validatorMock := new(ValidatorMock) - queueMock := new(QueueMock) - - vLog := types.Log{} - - parserMock.On("ParseLog", vLog).Return(parser.LogCrossChainCallRequested{}, errors.New("test error")) - - handler := &handler{parser: parserMock, validator: validatorMock, queue: queueMock} - - err := handler.HandleLog(vLog) - - assert.Error(t, err) -} - func TestHandlerReturnsErrorFromValidator(t *testing.T) { - parserMock := new(ParserMock) validatorMock := new(ValidatorMock) queueMock := new(QueueMock) - vLog := types.Log{} - parsedLog := parser.LogCrossChainCallRequested{} + log := &bindings.RIP7755OutboxCrossChainCallRequested{} - parserMock.On("ParseLog", vLog).Return(parsedLog, nil) - validatorMock.On("ValidateLog", parsedLog).Return(errors.New("test error")) + validatorMock.On("ValidateLog", log).Return(errors.New("test error")) - handler := &handler{parser: parserMock, validator: validatorMock, queue: queueMock} + handler := &handler{validator: validatorMock, queue: queueMock} - err := handler.HandleLog(vLog) + err := handler.HandleLog(log) assert.Error(t, err) } func TestHandlerReturnsErrorFromQueue(t *testing.T) { - parserMock := new(ParserMock) validatorMock := new(ValidatorMock) queueMock := new(QueueMock) - vLog := types.Log{} - parsedLog := parser.LogCrossChainCallRequested{} + log := &bindings.RIP7755OutboxCrossChainCallRequested{} - parserMock.On("ParseLog", vLog).Return(parsedLog, nil) - validatorMock.On("ValidateLog", parsedLog).Return(nil) - queueMock.On("Enqueue", parsedLog).Return(errors.New("test error")) + validatorMock.On("ValidateLog", log).Return(nil) + queueMock.On("Enqueue", log).Return(errors.New("test error")) - handler := &handler{parser: parserMock, validator: validatorMock, queue: queueMock} + handler := &handler{validator: validatorMock, queue: queueMock} - err := handler.HandleLog(vLog) + err := handler.HandleLog(log) assert.Error(t, err) } diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index 62672cd..684f822 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -7,15 +7,15 @@ import ( "math/big" "sync" + "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/clients" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/handler" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" "github.com/ethereum/go-ethereum" + "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/crypto" ) type Listener interface { @@ -24,12 +24,11 @@ type Listener interface { } type listener struct { - srcChain *chains.ChainConfig - handler handler.Handler - query ethereum.FilterQuery - logs chan types.Log - stop chan struct{} - wg sync.WaitGroup + outbox *bindings.RIP7755Outbox + handler handler.Handler + logs chan *bindings.RIP7755OutboxCrossChainCallRequested + stop chan struct{} + wg sync.WaitGroup } func NewListener(srcChainId *big.Int, cfg *config.Config, queue store.Queue) (Listener, error) { @@ -48,36 +47,29 @@ func NewListener(srcChainId *big.Int, cfg *config.Config, queue store.Queue) (Li return nil, fmt.Errorf("source chain %s missing Outbox contract address", srcChain.ChainId) } - crossChainCallRequestedSig := []byte("CrossChainCallRequested(bytes32,(address,(address,bytes,uint256)[],address,uint256,address,address,bytes32,address,uint256,uint256,uint256,uint256,address,bytes))") - crossChainCallRequestedHash := crypto.Keccak256Hash(crossChainCallRequestedSig) - - query := ethereum.FilterQuery{ - Addresses: []common.Address{contractAddress}, - Topics: [][]common.Hash{{crossChainCallRequestedHash}}, + client, err := clients.GetEthClient(srcChain) + if err != nil { + return nil, fmt.Errorf("failed to get eth client: %v", err) + } + outbox, err := bindings.NewRIP7755Outbox(contractAddress, client) + if err != nil { + return nil, fmt.Errorf("failed to create Outbox contract binding: %v", err) } return &listener{ - srcChain: srcChain, - handler: h, - query: query, - logs: make(chan types.Log), - stop: make(chan struct{}), + outbox: outbox, + handler: h, + logs: make(chan *bindings.RIP7755OutboxCrossChainCallRequested), + stop: make(chan struct{}), }, nil } func (l *listener) Start(ctx context.Context) error { - client, err := clients.GetEthClient(l.srcChain) + sub, err := l.outbox.WatchCrossChainCallRequested(&bind.WatchOpts{}, l.logs, [][32]byte{}) if err != nil { - return err + return fmt.Errorf("failed to subscribe to logs: %v", err) } - sub, err := client.SubscribeFilterLogs(ctx, l.query, l.logs) - if err != nil { - return err - } - - defer sub.Unsubscribe() - fmt.Println("Subscribed to logs") l.wg.Add(1) @@ -92,16 +84,17 @@ func (l *listener) loop(sub ethereum.Subscription) { select { case err := <-sub.Err(): fmt.Printf("Subscription error: %v\n", err) - case vLog := <-l.logs: + case log := <-l.logs: fmt.Println("Log received!") - fmt.Printf("Log Block Number: %d\n", vLog.BlockNumber) - fmt.Printf("Log Index: %d\n", vLog.Index) + fmt.Printf("Log Block Number: %d\n", log.Raw.BlockNumber) + fmt.Printf("Log Index: %d\n", log.Raw.Index) - err := l.handler.HandleLog(vLog) + err := l.handler.HandleLog(log) if err != nil { fmt.Printf("Error handling log: %v\n", err) } case <-l.stop: + sub.Unsubscribe() return } } diff --git a/services/go-filler/log-fetcher/internal/parser/parser.go b/services/go-filler/log-fetcher/internal/parser/parser.go deleted file mode 100644 index 4e80baf..0000000 --- a/services/go-filler/log-fetcher/internal/parser/parser.go +++ /dev/null @@ -1,72 +0,0 @@ -package parser - -import ( - "fmt" - "math/big" - "strings" - - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/abis" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" -) - -type Parser interface { - ParseLog(vLog types.Log) (LogCrossChainCallRequested, error) -} - -type parser struct { - outboxAbi abi.ABI -} - -func NewParser() (Parser, error) { - contractAbi, err := abi.JSON(strings.NewReader(abis.RIP7755OutboxAbi)) - if err != nil { - return nil, err - } - - return &parser{outboxAbi: contractAbi}, nil -} - -type Call struct { - To common.Address - Data []byte - Value *big.Int -} - -type CrossChainRequest struct { - Requester common.Address - Calls []Call - ProverContract common.Address - DestinationChainId *big.Int - InboxContract common.Address - L2Oracle common.Address - L2OracleStorageKey [32]byte - RewardAsset common.Address - RewardAmount *big.Int - FinalityDelaySeconds *big.Int - Nonce *big.Int - Expiry *big.Int - PrecheckContract common.Address - PrecheckData []byte -} - -type LogCrossChainCallRequested struct { - RequestHash [32]byte - Request CrossChainRequest -} - -func (p *parser) ParseLog(vLog types.Log) (LogCrossChainCallRequested, error) { - fmt.Println("Parsing log") - - var event LogCrossChainCallRequested - - err := p.outboxAbi.UnpackIntoInterface(&event, "CrossChainCallRequested", vLog.Data) - if err != nil { - return LogCrossChainCallRequested{}, err - } - - event.RequestHash = vLog.Topics[1] - - return event, nil -} diff --git a/services/go-filler/log-fetcher/internal/parser/parser_test.go b/services/go-filler/log-fetcher/internal/parser/parser_test.go deleted file mode 100644 index d5fa0c3..0000000 --- a/services/go-filler/log-fetcher/internal/parser/parser_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package parser - -import ( - "math/big" - "testing" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/stretchr/testify/assert" -) - -var vLog = types.Log{ - Topics: []common.Hash{ - common.HexToHash("0x123456789abcdef"), - common.HexToHash("0xabcdef123456789"), - }, - Data: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 140, 26, 97, 123, 219, 71, 52, 47, 156, 23, 172, 135, 80, 224, 176, 112, 195, 114, 199, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 47, 189, 207, 209, 122, 3, 70, 210, 169, 216, 159, 226, 51, 187, 173, 189, 29, 193, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 74, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, 130, 178, 146, 135, 143, 222, 100, 105, 29, 2, 138, 34, 55, 179, 78, 145, 199, 199, 234, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76, 139, 163, 42, 93, 172, 42, 114, 11, 179, 92, 237, 181, 29, 107, 6, 125, 16, 66, 5, 166, 238, 247, 227, 90, 190, 112, 38, 114, 150, 65, 20, 127, 121, 21, 87, 60, 126, 151, 180, 126, 250, 84, 111, 95, 110, 50, 48, 38, 59, 203, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 58, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 103, 47, 182, 210, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 140, 26, 97, 123, 219, 71, 52, 47, 156, 23, 172, 135, 80, 224, 176, 112, 195, 114, 199, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -} - -func TestParseLog(t *testing.T) { - parser, err := NewParser() - if err != nil { - t.Fatalf("Failed to create parser: %v", err) - } - - parsedLog, err := parser.ParseLog(vLog) - - var expectedRequestHash [32]byte = vLog.Topics[1] - - assert.NoError(t, err) - assert.Equal(t, parsedLog.RequestHash, expectedRequestHash) - assert.Equal(t, parsedLog.Request.Requester, common.HexToAddress("0x8C1a617BdB47342F9C17Ac8750E0b070c372C721")) - assert.Equal(t, parsedLog.Request.Calls[0].To, common.HexToAddress("0x8C1a617BdB47342F9C17Ac8750E0b070c372C721")) - assert.Equal(t, parsedLog.Request.Calls[0].Data, []byte{}) - assert.Equal(t, parsedLog.Request.Calls[0].Value, big.NewInt(1)) - assert.Equal(t, parsedLog.Request.ProverContract, common.HexToAddress("0x062fBdCfd17A0346D2A9d89FE233bbAdBd1DC14C")) - assert.Equal(t, parsedLog.Request.DestinationChainId, big.NewInt(84532)) - assert.Equal(t, parsedLog.Request.InboxContract, common.HexToAddress("0xB482b292878FDe64691d028A2237B34e91c7c7ea")) - assert.Equal(t, parsedLog.Request.L2Oracle, common.HexToAddress("0x4C8BA32A5DAC2A720bb35CeDB51D6B067D104205")) - assert.Equal(t, parsedLog.Request.L2OracleStorageKey, [32]byte{0xa6, 0xee, 0xf7, 0xe3, 0x5a, 0xbe, 0x70, 0x26, 0x72, 0x96, 0x41, 0x14, 0x7f, 0x79, 0x15, 0x57, 0x3c, 0x7e, 0x97, 0xb4, 0x7e, 0xfa, 0x54, 0x6f, 0x5f, 0x6e, 0x32, 0x30, 0x26, 0x3b, 0xcb, 0x49}) - assert.Equal(t, parsedLog.Request.RewardAsset, common.HexToAddress("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE")) - assert.Equal(t, parsedLog.Request.RewardAmount, big.NewInt(2)) - assert.Equal(t, parsedLog.Request.FinalityDelaySeconds, big.NewInt(604800)) - assert.Equal(t, parsedLog.Request.Nonce, big.NewInt(18)) - assert.Equal(t, parsedLog.Request.Expiry, big.NewInt(1731180242)) - assert.Equal(t, parsedLog.Request.PrecheckContract, common.HexToAddress("0x0000000000000000000000000000000000000000")) - assert.Equal(t, parsedLog.Request.PrecheckData, []byte{}) -} - -func TestParseLog_InvalidLog(t *testing.T) { - parser, err := NewParser() - if err != nil { - t.Fatalf("Failed to create parser: %v", err) - } - - _, err = parser.ParseLog(types.Log{}) - assert.Error(t, err) -} diff --git a/services/go-filler/log-fetcher/internal/store/mongo_client.go b/services/go-filler/log-fetcher/internal/store/mongo_client.go index cbfe16a..7e31f8a 100644 --- a/services/go-filler/log-fetcher/internal/store/mongo_client.go +++ b/services/go-filler/log-fetcher/internal/store/mongo_client.go @@ -4,14 +4,14 @@ import ( "context" "fmt" + "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) type Queue interface { - Enqueue(parsedLog parser.LogCrossChainCallRequested) error + Enqueue(*bindings.RIP7755OutboxCrossChainCallRequested) error Close() error } @@ -29,6 +29,11 @@ type queue struct { collection MongoCollection } +type record struct { + RequestHash [32]byte + Request bindings.CrossChainRequest +} + func NewQueue(cfg *config.Config) (Queue, error) { client, err := connect(cfg) if err != nil { @@ -38,10 +43,14 @@ func NewQueue(cfg *config.Config) (Queue, error) { return &queue{client: client, collection: client.Database("calls").Collection("requests")}, nil } -func (q *queue) Enqueue(parsedLog parser.LogCrossChainCallRequested) error { +func (q *queue) Enqueue(log *bindings.RIP7755OutboxCrossChainCallRequested) error { fmt.Println("Sending job to queue") - _, err := q.collection.InsertOne(context.TODO(), parsedLog) + r := record{ + RequestHash: log.RequestHash, + Request: log.Request, + } + _, err := q.collection.InsertOne(context.TODO(), r) if err != nil { return err } diff --git a/services/go-filler/log-fetcher/internal/store/mongo_client_test.go b/services/go-filler/log-fetcher/internal/store/mongo_client_test.go index 526314f..81e131d 100644 --- a/services/go-filler/log-fetcher/internal/store/mongo_client_test.go +++ b/services/go-filler/log-fetcher/internal/store/mongo_client_test.go @@ -5,7 +5,7 @@ import ( "errors" "testing" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" + "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "go.mongodb.org/mongo-driver/mongo" @@ -41,7 +41,7 @@ func TestEnqueue(t *testing.T) { mockConnection.On("InsertOne", mock.Anything, mock.Anything, mock.Anything).Return(&mongo.InsertOneResult{}, nil) - err := queue.Enqueue(parser.LogCrossChainCallRequested{}) + err := queue.Enqueue(&bindings.RIP7755OutboxCrossChainCallRequested{}) assert.NoError(t, err) } @@ -49,11 +49,15 @@ func TestEnqueue(t *testing.T) { func TestEnqueuePassesParsedLogToInsertOne(t *testing.T) { mockConnection := new(MongoConnectionMock) queue := &queue{collection: mockConnection} - parsedLog := parser.LogCrossChainCallRequested{} + log := &bindings.RIP7755OutboxCrossChainCallRequested{} + r := record{ + RequestHash: log.RequestHash, + Request: log.Request, + } - mockConnection.On("InsertOne", context.TODO(), parsedLog, mock.Anything).Return(&mongo.InsertOneResult{}, nil) + mockConnection.On("InsertOne", context.TODO(), r, mock.Anything).Return(&mongo.InsertOneResult{}, nil) - err := queue.Enqueue(parsedLog) + err := queue.Enqueue(log) assert.NoError(t, err) mockConnection.AssertExpectations(t) @@ -65,7 +69,7 @@ func TestEnqueueError(t *testing.T) { mockConnection.On("InsertOne", mock.Anything, mock.Anything, mock.Anything).Return(&mongo.InsertOneResult{}, errors.New("error")) - err := queue.Enqueue(parser.LogCrossChainCallRequested{}) + err := queue.Enqueue(&bindings.RIP7755OutboxCrossChainCallRequested{}) assert.Error(t, err) } diff --git a/services/go-filler/log-fetcher/internal/validator/validator.go b/services/go-filler/log-fetcher/internal/validator/validator.go index 218fe4d..448623d 100644 --- a/services/go-filler/log-fetcher/internal/validator/validator.go +++ b/services/go-filler/log-fetcher/internal/validator/validator.go @@ -5,14 +5,14 @@ import ( "fmt" "math/big" + "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" "github.com/ethereum/go-ethereum/common" ) type Validator interface { - ValidateLog(parsedLog parser.LogCrossChainCallRequested) error + ValidateLog(*bindings.RIP7755OutboxCrossChainCallRequested) error } type validator struct { @@ -24,11 +24,11 @@ func NewValidator(cfg *config.Config, srcChain *chains.ChainConfig) Validator { return &validator{cfg: cfg, srcChain: srcChain} } -func (v *validator) ValidateLog(parsedLog parser.LogCrossChainCallRequested) error { +func (v *validator) ValidateLog(log *bindings.RIP7755OutboxCrossChainCallRequested) error { fmt.Println("Validating log") // - Confirm valid proverContract address on source chain - dstChain, err := chains.GetChainConfig(parsedLog.Request.DestinationChainId, v.cfg.RPCs) + dstChain, err := chains.GetChainConfig(log.Request.DestinationChainId, v.cfg.RPCs) if err != nil { return err } @@ -43,39 +43,39 @@ func (v *validator) ValidateLog(parsedLog parser.LogCrossChainCallRequested) err return errors.New("expected prover address not found for source chain") } - if parsedLog.Request.ProverContract != expectedProverAddr { + if log.Request.ProverContract != expectedProverAddr { return errors.New("unknown Prover contract") } // - Make sure inboxContract matches the trusted inbox for dst chain Id - if parsedLog.Request.InboxContract != dstChain.Contracts.Inbox { + if log.Request.InboxContract != dstChain.Contracts.Inbox { return errors.New("unknown Inbox contract on destination chain") } // - Confirm l2Oracle and l2OracleStorageKey are valid for dst chain - if parsedLog.Request.L2Oracle != dstChain.L2Oracle { + if log.Request.L2Oracle != dstChain.L2Oracle { return errors.New("unknown Oracle contract for destination chain") } - if parsedLog.Request.L2OracleStorageKey != dstChain.L2OracleStorageKey { + if log.Request.L2OracleStorageKey != dstChain.L2OracleStorageKey { return errors.New("unknown storage key for dst L2Oracle") } // - Add up total value needed valueNeeded := big.NewInt(0) - for i := 0; i < len(parsedLog.Request.Calls); i++ { - valueNeeded.Add(valueNeeded, parsedLog.Request.Calls[i].Value) + for i := 0; i < len(log.Request.Calls); i++ { + valueNeeded.Add(valueNeeded, log.Request.Calls[i].Value) } // - rewardAsset + rewardAmount should make sense given requested calls - if !isValidReward(parsedLog.Request, valueNeeded) { + if !isValidReward(&log.Request, valueNeeded) { return errors.New("undesirable reward") } return nil } -func isValidReward(request parser.CrossChainRequest, valueNeeded *big.Int) bool { +func isValidReward(request *bindings.CrossChainRequest, valueNeeded *big.Int) bool { nativeAssetAddr := common.HexToAddress("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE") isGreaterThan := request.RewardAmount.Cmp(valueNeeded) == 1 diff --git a/services/go-filler/log-fetcher/internal/validator/validator_test.go b/services/go-filler/log-fetcher/internal/validator/validator_test.go index 43389c1..a1a18a0 100644 --- a/services/go-filler/log-fetcher/internal/validator/validator_test.go +++ b/services/go-filler/log-fetcher/internal/validator/validator_test.go @@ -6,9 +6,9 @@ import ( "math/big" "testing" + "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/parser" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" ) @@ -26,9 +26,9 @@ var srcChain = &chains.ChainConfig{ }, } -var parsedLog = parser.LogCrossChainCallRequested{ - Request: parser.CrossChainRequest{ - Calls: []parser.Call{ +var parsedLog = &bindings.RIP7755OutboxCrossChainCallRequested{ + Request: bindings.CrossChainRequest{ + Calls: []bindings.Call{ { To: common.HexToAddress("0x1234567890123456789012345678901234567890"), Value: big.NewInt(1000000000000000000), From ed9487446a2222bd51700f4ce0c7605329080932 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Mon, 11 Nov 2024 16:22:54 -0500 Subject: [PATCH 24/36] undo ts-filler changes --- services/ts-filler/scripts/generateProof.ts | 2 +- services/ts-filler/src/handler/handler.service.ts | 5 ++++- services/ts-filler/src/prover/prover.service.ts | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/services/ts-filler/scripts/generateProof.ts b/services/ts-filler/scripts/generateProof.ts index 7b04bd8..254192b 100644 --- a/services/ts-filler/scripts/generateProof.ts +++ b/services/ts-filler/scripts/generateProof.ts @@ -26,7 +26,7 @@ async function main() { const configService = new ConfigService(); const chainService = new ChainService(activeChains, configService); const prover = new Prover(activeChains, chainService); - const proof = await prover.generateProof(config.requestHash); + const proof = await prover.generateProof(); await Bun.write("./Proof.json", JSON.stringify(proof)); } diff --git a/services/ts-filler/src/handler/handler.service.ts b/services/ts-filler/src/handler/handler.service.ts index 47964c3..d55ebac 100644 --- a/services/ts-filler/src/handler/handler.service.ts +++ b/services/ts-filler/src/handler/handler.service.ts @@ -22,7 +22,10 @@ export default class HandlerService { const expectedProverAddr = this.activeChains.src.proverContracts[proverName].toLowerCase(); - if (request.proverContract.toLowerCase() !== expectedProverAddr) { + if ( + this.activeChains.src.proverContracts[proverName].toLowerCase() !== + expectedProverAddr + ) { throw new Error("Unknown Prover contract"); } diff --git a/services/ts-filler/src/prover/prover.service.ts b/services/ts-filler/src/prover/prover.service.ts index 30e4816..18182a0 100644 --- a/services/ts-filler/src/prover/prover.service.ts +++ b/services/ts-filler/src/prover/prover.service.ts @@ -40,7 +40,6 @@ export default class ProverService { requestHash: Address ): Promise { const beaconData = await this.chainService.getBeaconRootAndL2Timestamp(); - console.log(beaconData); const beaconBlock = await this.chainService.getBeaconBlock( beaconData.beaconRoot ); From b1a529d3660562bba38127cacfdaccea30fc031d Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Mon, 11 Nov 2024 16:35:07 -0500 Subject: [PATCH 25/36] fix readme commands --- .../go-filler/{log-fetcher => }/.gitignore | 0 services/go-filler/README.md | 46 ++++++++++++++++++- services/go-filler/log-fetcher/README.md | 44 ++---------------- 3 files changed, 50 insertions(+), 40 deletions(-) rename services/go-filler/{log-fetcher => }/.gitignore (100%) diff --git a/services/go-filler/log-fetcher/.gitignore b/services/go-filler/.gitignore similarity index 100% rename from services/go-filler/log-fetcher/.gitignore rename to services/go-filler/.gitignore diff --git a/services/go-filler/README.md b/services/go-filler/README.md index 350c2ad..1eda891 100644 --- a/services/go-filler/README.md +++ b/services/go-filler/README.md @@ -1 +1,45 @@ -# An Example Filler App implemented in Go \ No newline at end of file +# An Example Fulfiller App implemented in Go + +## Getting Started + +Navigate to the `go-filler` directory: + +```bash +cd services/go-filler +``` + +Install dependencies: + +```bash +go mod tidy +``` + +Spin up the docker containers: + +```bash +docker-compose up -d +``` + +Create a `.env` file (the rpc urls must be websocket): + +```txt +ARBITRUM_SEPOLIA_RPC= +BASE_SEPOLIA_RPC= +OPTIMISM_SEPOLIA_RPC= +SEPOLIA_RPC= +MONGO_URI= +``` + +### Log Fetcher + +Run the log fetcher: + +```bash +go run ./log-fetcher/cmd +``` + +Run log fetcher unit tests: + +```bash +go test ./log-fetcher/internal/... +``` diff --git a/services/go-filler/log-fetcher/README.md b/services/go-filler/log-fetcher/README.md index e6eddd3..8d482c1 100644 --- a/services/go-filler/log-fetcher/README.md +++ b/services/go-filler/log-fetcher/README.md @@ -2,46 +2,12 @@ ## Overview -The Log Fetcher serves as the first component in the RIP-7755 Fulfiller architecture. Its main purpose is to monitor events from `RIP7755Outbox` contracts on supported chains. When it ingests an event representing a cross-chain call request, it first parses the log into an ingestible format. It then validates the request by ensuring all routing information matches pre-defined chain configs for the source / destination chains. It then validates that the reward asset / amount represents a reward that would guarantee profit if this request were accepted by the system. If the request passes validation, the log fetcher passes it along to a Redis queue for further processing. +The Log Fetcher is the initial component in the RIP-7755 Fulfiller architecture. Its primary function is to monitor events emitted by `RIP7755Outbox` contracts across supported blockchain networks. Upon detecting an event that signifies a cross-chain call request, the Log Fetcher parses the log into a format suitable for further processing. -## Getting Started - -Navigate to the `log-fetcher` directory: - -```bash -cd services/go-filler/log-fetcher -``` - -Install dependencies: - -```bash -go mod tidy -``` - -Spin up the docker containers: +Next, it performs a validation of the request by checking that all routing information aligns with the pre-defined configurations for both the source and destination chains. Additionally, it ensures that the specified reward asset and amount are sufficient to guarantee a profit if the request is processed by the system. -```bash -docker-compose up -d -``` +If the request successfully passes all validation checks, the Log Fetcher forwards it to a MongoDB queue for subsequent processing. -Create a `.env` file (the rpc urls must be websocket): - -```txt -ARBITRUM_SEPOLIA_RPC= -BASE_SEPOLIA_RPC= -OPTIMISM_SEPOLIA_RPC= -SEPOLIA_RPC= -MONGO_URI= -``` - -Run the application: - -```bash -go run ./cmd -``` - -Run unit tests: +## Getting Started -```bash -go test ./internal/... -``` +To run the log fetcher, see the [README](../README.md) in the `go-filler` directory. From e57ef66096487804f57d5bbfa7b052917ac82791 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Mon, 11 Nov 2024 16:42:39 -0500 Subject: [PATCH 26/36] move supported chains to config --- services/go-filler/Makefile | 7 +++++++ services/go-filler/README.md | 4 ++-- services/go-filler/log-fetcher/cmd/main.go | 5 +---- services/go-filler/log-fetcher/internal/config/config.go | 9 ++++++--- .../go-filler/log-fetcher/internal/config/config_test.go | 2 ++ 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/services/go-filler/Makefile b/services/go-filler/Makefile index f43ae40..4ea967d 100644 --- a/services/go-filler/Makefile +++ b/services/go-filler/Makefile @@ -1,4 +1,11 @@ .PHONY: bindings + +test-log-fetcher: + go test ./log-fetcher/internal/... + +run-log-fetcher: + go run ./log-fetcher/cmd + bindings: go install github.com/ethereum/go-ethereum/cmd/abigen@v1.14.11 cd ../../contracts && forge build diff --git a/services/go-filler/README.md b/services/go-filler/README.md index 1eda891..47a49db 100644 --- a/services/go-filler/README.md +++ b/services/go-filler/README.md @@ -35,11 +35,11 @@ MONGO_URI= Run the log fetcher: ```bash -go run ./log-fetcher/cmd +make run-log-fetcher ``` Run log fetcher unit tests: ```bash -go test ./log-fetcher/internal/... +make test-log-fetcher ``` diff --git a/services/go-filler/log-fetcher/cmd/main.go b/services/go-filler/log-fetcher/cmd/main.go index 69665f3..087f003 100644 --- a/services/go-filler/log-fetcher/cmd/main.go +++ b/services/go-filler/log-fetcher/cmd/main.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "log" - "math/big" "os" "os/signal" "sync" @@ -16,8 +15,6 @@ import ( "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" ) -var supportedChains = []*big.Int{big.NewInt(421614)} - func main() { cfg, err := config.NewConfig() // Load env vars if err != nil { @@ -33,7 +30,7 @@ func main() { var wg sync.WaitGroup stopped, stop := context.WithCancel(context.Background()) - for _, chainId := range supportedChains { + for _, chainId := range cfg.SupportedChains { l, err := listener.NewListener(chainId, cfg, queue) if err != nil { log.Fatal(err) diff --git a/services/go-filler/log-fetcher/internal/config/config.go b/services/go-filler/log-fetcher/internal/config/config.go index 088a12f..36a853a 100644 --- a/services/go-filler/log-fetcher/internal/config/config.go +++ b/services/go-filler/log-fetcher/internal/config/config.go @@ -2,6 +2,7 @@ package config import ( "log" + "math/big" "os" "github.com/joho/godotenv" @@ -15,8 +16,9 @@ type RPCs struct { } type Config struct { - RPCs *RPCs - MongoUri string + RPCs *RPCs + MongoUri string + SupportedChains []*big.Int } func NewConfig() (*Config, error) { @@ -31,7 +33,8 @@ func NewConfig() (*Config, error) { OptimismSepolia: getEnvStr("OPTIMISM_SEPOLIA_RPC"), Sepolia: getEnvStr("SEPOLIA_RPC"), }, - MongoUri: getEnvStr("MONGO_URI"), + MongoUri: getEnvStr("MONGO_URI"), + SupportedChains: []*big.Int{big.NewInt(421614)}, } return config, nil diff --git a/services/go-filler/log-fetcher/internal/config/config_test.go b/services/go-filler/log-fetcher/internal/config/config_test.go index b7541ee..5bc5a90 100644 --- a/services/go-filler/log-fetcher/internal/config/config_test.go +++ b/services/go-filler/log-fetcher/internal/config/config_test.go @@ -1,6 +1,7 @@ package config import ( + "math/big" "os" "testing" @@ -39,6 +40,7 @@ MONGO_URI=mongodb://localhost:27017/db assert.Equal(t, "https://optimism-sepolia.example.com", config.RPCs.OptimismSepolia) assert.Equal(t, "https://sepolia.example.com", config.RPCs.Sepolia) assert.Equal(t, "mongodb://localhost:27017/db", config.MongoUri) + assert.Equal(t, []*big.Int{big.NewInt(421614)}, config.SupportedChains) } func TestNewConfigMissingEnvVar(t *testing.T) { From be7edf1aad3f7e9b49a227a22df0fac960a77e5f Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Mon, 11 Nov 2024 17:02:08 -0500 Subject: [PATCH 27/36] use geth logger instead of fmt.Println --- services/go-filler/log-fetcher/cmd/main.go | 13 ++++++------- .../log-fetcher/internal/chains/config.go | 4 ++-- .../log-fetcher/internal/clients/eth_client.go | 5 ++--- .../log-fetcher/internal/listener/listener.go | 16 ++++++++-------- .../log-fetcher/internal/store/mongo_client.go | 10 +++++----- .../log-fetcher/internal/validator/validator.go | 4 ++-- 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/services/go-filler/log-fetcher/cmd/main.go b/services/go-filler/log-fetcher/cmd/main.go index 087f003..60f12a3 100644 --- a/services/go-filler/log-fetcher/cmd/main.go +++ b/services/go-filler/log-fetcher/cmd/main.go @@ -2,8 +2,6 @@ package main import ( "context" - "fmt" - "log" "os" "os/signal" "sync" @@ -13,17 +11,18 @@ import ( "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/listener" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" + "github.com/ethereum/go-ethereum/log" ) func main() { cfg, err := config.NewConfig() // Load env vars if err != nil { - log.Fatal(err) + log.Error("Failed to load config", "error", err) } queue, err := store.NewQueue(cfg) if err != nil { - log.Fatal(err) + log.Error("Failed to create queue", "error", err) } defer queue.Close() @@ -33,7 +32,7 @@ func main() { for _, chainId := range cfg.SupportedChains { l, err := listener.NewListener(chainId, cfg, queue) if err != nil { - log.Fatal(err) + log.Error("Failed to create listener", "error", err) } wg.Add(1) @@ -41,7 +40,7 @@ func main() { err = l.Start(ctx) cancel() if err != nil { - log.Fatal(err) + log.Error("Failed to start listener", "error", err) } go func() { @@ -56,7 +55,7 @@ func main() { signal.Notify(c, os.Interrupt, syscall.SIGTERM) <-c - fmt.Println("Shutting down...") + log.Info("Shutting down...") stop() wg.Wait() } diff --git a/services/go-filler/log-fetcher/internal/chains/config.go b/services/go-filler/log-fetcher/internal/chains/config.go index 067eae7..5069e13 100644 --- a/services/go-filler/log-fetcher/internal/chains/config.go +++ b/services/go-filler/log-fetcher/internal/chains/config.go @@ -3,11 +3,11 @@ package chains import ( "encoding/hex" "fmt" - "log" "math/big" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/log" ) type Contracts struct { @@ -113,7 +113,7 @@ func GetChainConfig(chainId *big.Int, rpcConfig *config.RPCs) (*ChainConfig, err func encodeBytes(bytesStr string) [32]byte { bytes, err := hex.DecodeString(bytesStr) if err != nil { - log.Fatal(err) + log.Crit("Failed to decode bytes", "error", err) } var byteArray [32]byte diff --git a/services/go-filler/log-fetcher/internal/clients/eth_client.go b/services/go-filler/log-fetcher/internal/clients/eth_client.go index 3af9ea8..83ff4a5 100644 --- a/services/go-filler/log-fetcher/internal/clients/eth_client.go +++ b/services/go-filler/log-fetcher/internal/clients/eth_client.go @@ -1,10 +1,9 @@ package clients import ( - "fmt" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/ethereum/go-ethereum/ethclient" + "github.com/ethereum/go-ethereum/log" ) func GetEthClient(cfg *chains.ChainConfig) (*ethclient.Client, error) { @@ -13,7 +12,7 @@ func GetEthClient(cfg *chains.ChainConfig) (*ethclient.Client, error) { return nil, err } - fmt.Println("Connected to client") + log.Info("Connected to client", "url", cfg.RpcUrl) return client, nil } diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index 684f822..47b2d3d 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -3,7 +3,6 @@ package listener import ( "context" "fmt" - "log" "math/big" "sync" @@ -16,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + logger "github.com/ethereum/go-ethereum/log" ) type Listener interface { @@ -34,7 +34,7 @@ type listener struct { func NewListener(srcChainId *big.Int, cfg *config.Config, queue store.Queue) (Listener, error) { srcChain, err := chains.GetChainConfig(srcChainId, cfg.RPCs) if err != nil { - log.Fatal(err) + return nil, err } h, err := handler.NewHandler(cfg, srcChain, queue) @@ -70,7 +70,7 @@ func (l *listener) Start(ctx context.Context) error { return fmt.Errorf("failed to subscribe to logs: %v", err) } - fmt.Println("Subscribed to logs") + logger.Info("Subscribed to logs") l.wg.Add(1) go l.loop(sub) @@ -83,15 +83,15 @@ func (l *listener) loop(sub ethereum.Subscription) { for { select { case err := <-sub.Err(): - fmt.Printf("Subscription error: %v\n", err) + logger.Info("Subscription error", "error", err) case log := <-l.logs: - fmt.Println("Log received!") - fmt.Printf("Log Block Number: %d\n", log.Raw.BlockNumber) - fmt.Printf("Log Index: %d\n", log.Raw.Index) + logger.Info("Log received!") + logger.Info("Log Block Number", "blockNumber", log.Raw.BlockNumber) + logger.Info("Log Index", "index", log.Raw.Index) err := l.handler.HandleLog(log) if err != nil { - fmt.Printf("Error handling log: %v\n", err) + logger.Error("Error handling log", "error", err) } case <-l.stop: sub.Unsubscribe() diff --git a/services/go-filler/log-fetcher/internal/store/mongo_client.go b/services/go-filler/log-fetcher/internal/store/mongo_client.go index 7e31f8a..7c50b65 100644 --- a/services/go-filler/log-fetcher/internal/store/mongo_client.go +++ b/services/go-filler/log-fetcher/internal/store/mongo_client.go @@ -2,10 +2,10 @@ package store import ( "context" - "fmt" "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + logger "github.com/ethereum/go-ethereum/log" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) @@ -44,7 +44,7 @@ func NewQueue(cfg *config.Config) (Queue, error) { } func (q *queue) Enqueue(log *bindings.RIP7755OutboxCrossChainCallRequested) error { - fmt.Println("Sending job to queue") + logger.Info("Sending job to queue") r := record{ RequestHash: log.RequestHash, @@ -55,7 +55,7 @@ func (q *queue) Enqueue(log *bindings.RIP7755OutboxCrossChainCallRequested) erro return err } - fmt.Println("Job sent to queue") + logger.Info("Job sent to queue") return nil } @@ -65,13 +65,13 @@ func (q *queue) Close() error { } func connect(cfg *config.Config) (MongoDriverClient, error) { - fmt.Println("Connecting to MongoDB") + logger.Info("Connecting to MongoDB") client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(cfg.MongoUri)) if err != nil { return nil, err } - fmt.Println("Connected to MongoDB") + logger.Info("Connected to MongoDB") return client, nil } diff --git a/services/go-filler/log-fetcher/internal/validator/validator.go b/services/go-filler/log-fetcher/internal/validator/validator.go index 448623d..e55cc8f 100644 --- a/services/go-filler/log-fetcher/internal/validator/validator.go +++ b/services/go-filler/log-fetcher/internal/validator/validator.go @@ -2,13 +2,13 @@ package validator import ( "errors" - "fmt" "math/big" "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/ethereum/go-ethereum/common" + logger "github.com/ethereum/go-ethereum/log" ) type Validator interface { @@ -25,7 +25,7 @@ func NewValidator(cfg *config.Config, srcChain *chains.ChainConfig) Validator { } func (v *validator) ValidateLog(log *bindings.RIP7755OutboxCrossChainCallRequested) error { - fmt.Println("Validating log") + logger.Info("Validating log") // - Confirm valid proverContract address on source chain dstChain, err := chains.GetChainConfig(log.Request.DestinationChainId, v.cfg.RPCs) From bbc899da1b6ebe5a2b3326bd1d1294546e46d3e0 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Mon, 11 Nov 2024 17:23:54 -0500 Subject: [PATCH 28/36] change log.Error to log.Crit --- services/go-filler/log-fetcher/cmd/main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/go-filler/log-fetcher/cmd/main.go b/services/go-filler/log-fetcher/cmd/main.go index 60f12a3..d841de1 100644 --- a/services/go-filler/log-fetcher/cmd/main.go +++ b/services/go-filler/log-fetcher/cmd/main.go @@ -17,12 +17,12 @@ import ( func main() { cfg, err := config.NewConfig() // Load env vars if err != nil { - log.Error("Failed to load config", "error", err) + log.Crit("Failed to load config", "error", err) } queue, err := store.NewQueue(cfg) if err != nil { - log.Error("Failed to create queue", "error", err) + log.Crit("Failed to create queue", "error", err) } defer queue.Close() @@ -32,7 +32,7 @@ func main() { for _, chainId := range cfg.SupportedChains { l, err := listener.NewListener(chainId, cfg, queue) if err != nil { - log.Error("Failed to create listener", "error", err) + log.Crit("Failed to create listener", "error", err) } wg.Add(1) @@ -40,7 +40,7 @@ func main() { err = l.Start(ctx) cancel() if err != nil { - log.Error("Failed to start listener", "error", err) + log.Crit("Failed to start listener", "error", err) } go func() { From 418f0ab4070d2596e11820eefdfa73b32f916cdf Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Mon, 11 Nov 2024 18:19:28 -0500 Subject: [PATCH 29/36] config logger --- services/go-filler/go.mod | 15 ++- services/go-filler/go.sum | 142 +++++++++++++++++---- services/go-filler/log-fetcher/cmd/main.go | 1 + 3 files changed, 126 insertions(+), 32 deletions(-) diff --git a/services/go-filler/go.mod b/services/go-filler/go.mod index cdd016a..c40ecb0 100644 --- a/services/go-filler/go.mod +++ b/services/go-filler/go.mod @@ -11,7 +11,6 @@ require ( require ( github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/StackExchange/wmi v1.2.1 // indirect github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect github.com/consensys/bavard v0.1.13 // indirect @@ -20,28 +19,36 @@ require ( github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.6.0 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect github.com/ethereum/c-kzg-4844 v1.0.0 // indirect github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/uuid v1.3.0 // indirect - github.com/gorilla/websocket v1.4.2 // indirect + github.com/gorilla/websocket v1.5.0 // indirect + github.com/hashicorp/go-bexpr v0.1.11 // indirect github.com/holiman/uint256 v1.3.1 // indirect github.com/klauspost/compress v1.16.0 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/montanaflynn/stats v0.7.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect + github.com/prometheus/client_golang v1.13.0 // indirect + github.com/rivo/uniseg v0.3.4 // indirect + github.com/rs/cors v1.8.2 // indirect + github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/supranational/blst v0.3.13 // indirect + github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.1.2 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect + github.com/yusufpapurcu/wmi v1.2.2 // indirect golang.org/x/crypto v0.26.0 // indirect golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect golang.org/x/sync v0.8.0 // indirect diff --git a/services/go-filler/go.sum b/services/go-filler/go.sum index a5e55c0..8718a2f 100644 --- a/services/go-filler/go.sum +++ b/services/go-filler/go.sum @@ -2,8 +2,6 @@ github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= -github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -18,6 +16,9 @@ github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= @@ -40,58 +41,80 @@ github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLR github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/ethereum/go-ethereum v1.14.11 h1:8nFDCUUE67rPc6AKxFj7JKaOa2W/W1Rse3oS6LvvxEY= github.com/ethereum/go-ethereum v1.14.11/go.mod h1:+l/fr42Mma+xBnhefL/+z11/hcmJ2egl+ScIVPjhc7E= github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= -github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= +github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays= +github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= -github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= -github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hashicorp/go-bexpr v0.1.11 h1:6DqdA/KBjurGby9yTY0bmkathya0lfwF2SeuubCI7dY= +github.com/hashicorp/go-bexpr v0.1.11/go.mod h1:f03lAo0duBlDIUMGCuad8oLcgejw4m7U+N8T+6Kz1AE= github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= @@ -114,49 +137,65 @@ github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4 github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= -github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/pointerstructure v1.2.1 h1:ZhBBeX8tSlRpu/FFhXH4RC4OJzFlqsQhoHZAz4x7TIw= +github.com/mitchellh/pointerstructure v1.2.1/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.12.0 h1:C+UIj/QWtmqY13Arb8kwMt5j34/0Z2iKamrJ+ryC0Gg= -github.com/prometheus/client_golang v1.12.0/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU= +github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a h1:CmF68hwI0XsOQ5UwlBopMi2Ow4Pbg32akc4KIVCOm+Y= github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= +github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= +github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= +github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/rivo/uniseg v0.3.4 h1:3Z3Eu6FGHZWSfNKJTOUiPatWwfc7DzJRU04jFUqJODw= +github.com/rivo/uniseg v0.3.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= -github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= +github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= +github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5fl+nylMaIr9PVV1w343YRDtsy+Rwu7XI= +github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= @@ -175,27 +214,54 @@ github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRT github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= +github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.mongodb.org/mongo-driver v1.17.1 h1:Wic5cJIwJgSpBhe3lx3+/RybR5PiYRMpVFgO7cOHyIM= go.mongodb.org/mongo-driver v1.17.1/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -208,6 +274,7 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= @@ -216,17 +283,36 @@ golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= diff --git a/services/go-filler/log-fetcher/cmd/main.go b/services/go-filler/log-fetcher/cmd/main.go index d841de1..ce2ae87 100644 --- a/services/go-filler/log-fetcher/cmd/main.go +++ b/services/go-filler/log-fetcher/cmd/main.go @@ -15,6 +15,7 @@ import ( ) func main() { + log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelInfo, true))) cfg, err := config.NewConfig() // Load env vars if err != nil { log.Crit("Failed to load config", "error", err) From 5b41616c0e4dea6a4cc21ad2753f7ee39d36bd52 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Wed, 20 Nov 2024 14:50:45 -0500 Subject: [PATCH 30/36] move mongo uri and supported chains to flags package --- services/go-filler/Makefile | 4 +- services/go-filler/go.mod | 4 ++ services/go-filler/go.sum | 12 ++-- services/go-filler/log-fetcher/cmd/main.go | 60 +++------------- .../log-fetcher/internal/config/config.go | 7 +- .../internal/config/config_test.go | 5 -- .../log-fetcher/internal/fetcher/fetcher.go | 72 +++++++++++++++++++ .../log-fetcher/internal/flags/flags.go | 24 +++++++ .../internal/store/mongo_client.go | 10 +-- 9 files changed, 126 insertions(+), 72 deletions(-) create mode 100644 services/go-filler/log-fetcher/internal/fetcher/fetcher.go create mode 100644 services/go-filler/log-fetcher/internal/flags/flags.go diff --git a/services/go-filler/Makefile b/services/go-filler/Makefile index 4ea967d..745cbf4 100644 --- a/services/go-filler/Makefile +++ b/services/go-filler/Makefile @@ -1,10 +1,12 @@ +-include .env + .PHONY: bindings test-log-fetcher: go test ./log-fetcher/internal/... run-log-fetcher: - go run ./log-fetcher/cmd + MONGO_URI=$(MONGO_URI) go run ./log-fetcher/cmd bindings: go install github.com/ethereum/go-ethereum/cmd/abigen@v1.14.11 diff --git a/services/go-filler/go.mod b/services/go-filler/go.mod index c40ecb0..a48a851 100644 --- a/services/go-filler/go.mod +++ b/services/go-filler/go.mod @@ -6,6 +6,7 @@ require ( github.com/ethereum/go-ethereum v1.14.11 github.com/joho/godotenv v1.5.1 github.com/stretchr/testify v1.9.0 + github.com/urfave/cli/v2 v2.27.5 go.mongodb.org/mongo-driver v1.17.1 ) @@ -15,6 +16,7 @@ require ( github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect @@ -38,6 +40,7 @@ require ( github.com/prometheus/client_golang v1.13.0 // indirect github.com/rivo/uniseg v0.3.4 // indirect github.com/rs/cors v1.8.2 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/supranational/blst v0.3.13 // indirect @@ -47,6 +50,7 @@ require ( github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.1.2 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect + github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect golang.org/x/crypto v0.26.0 // indirect diff --git a/services/go-filler/go.sum b/services/go-filler/go.sum index 8718a2f..8160c67 100644 --- a/services/go-filler/go.sum +++ b/services/go-filler/go.sum @@ -35,8 +35,8 @@ github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/Yj github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= -github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= +github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= @@ -202,16 +202,16 @@ github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+F github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= -github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= -github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w= +github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= +github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/services/go-filler/log-fetcher/cmd/main.go b/services/go-filler/log-fetcher/cmd/main.go index ce2ae87..0e4637c 100644 --- a/services/go-filler/log-fetcher/cmd/main.go +++ b/services/go-filler/log-fetcher/cmd/main.go @@ -1,62 +1,24 @@ package main import ( - "context" "os" - "os/signal" - "sync" - "syscall" - "time" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/listener" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/fetcher" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/flags" "github.com/ethereum/go-ethereum/log" + "github.com/urfave/cli/v2" ) func main() { - log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelInfo, true))) - cfg, err := config.NewConfig() // Load env vars - if err != nil { - log.Crit("Failed to load config", "error", err) + app := &cli.App{ + Name: "log-fetcher", + Version: "0.0.1", + Usage: "Fetches logs from a given set of chains and stores them in MongoDB", + Flags: flags.Flags, + Action: fetcher.Main, } - queue, err := store.NewQueue(cfg) - if err != nil { - log.Crit("Failed to create queue", "error", err) + if err := app.Run(os.Args); err != nil { + log.Crit("Failed to run app", "error", err) } - defer queue.Close() - - var wg sync.WaitGroup - stopped, stop := context.WithCancel(context.Background()) - - for _, chainId := range cfg.SupportedChains { - l, err := listener.NewListener(chainId, cfg, queue) - if err != nil { - log.Crit("Failed to create listener", "error", err) - } - - wg.Add(1) - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - err = l.Start(ctx) - cancel() - if err != nil { - log.Crit("Failed to start listener", "error", err) - } - - go func() { - defer wg.Done() - <-stopped.Done() - l.Stop() - }() - } - - // Handle signals to initiate shutdown - c := make(chan os.Signal, 1) - signal.Notify(c, os.Interrupt, syscall.SIGTERM) - <-c - - log.Info("Shutting down...") - stop() - wg.Wait() } diff --git a/services/go-filler/log-fetcher/internal/config/config.go b/services/go-filler/log-fetcher/internal/config/config.go index 36a853a..df3f9f1 100644 --- a/services/go-filler/log-fetcher/internal/config/config.go +++ b/services/go-filler/log-fetcher/internal/config/config.go @@ -2,7 +2,6 @@ package config import ( "log" - "math/big" "os" "github.com/joho/godotenv" @@ -16,9 +15,7 @@ type RPCs struct { } type Config struct { - RPCs *RPCs - MongoUri string - SupportedChains []*big.Int + RPCs *RPCs } func NewConfig() (*Config, error) { @@ -33,8 +30,6 @@ func NewConfig() (*Config, error) { OptimismSepolia: getEnvStr("OPTIMISM_SEPOLIA_RPC"), Sepolia: getEnvStr("SEPOLIA_RPC"), }, - MongoUri: getEnvStr("MONGO_URI"), - SupportedChains: []*big.Int{big.NewInt(421614)}, } return config, nil diff --git a/services/go-filler/log-fetcher/internal/config/config_test.go b/services/go-filler/log-fetcher/internal/config/config_test.go index 5bc5a90..4513676 100644 --- a/services/go-filler/log-fetcher/internal/config/config_test.go +++ b/services/go-filler/log-fetcher/internal/config/config_test.go @@ -1,7 +1,6 @@ package config import ( - "math/big" "os" "testing" @@ -14,7 +13,6 @@ func TestNewConfig(t *testing.T) { os.Setenv("BASE_SEPOLIA_RPC", "https://base-sepolia.example.com") os.Setenv("OPTIMISM_SEPOLIA_RPC", "https://optimism-sepolia.example.com") os.Setenv("SEPOLIA_RPC", "https://sepolia.example.com") - os.Setenv("MONGO_URI", "mongodb://localhost:27017/db") // Create a temporary .env file envContent := ` @@ -22,7 +20,6 @@ ARBITRUM_SEPOLIA_RPC=https://arbitrum-sepolia.example.com BASE_SEPOLIA_RPC=https://base-sepolia.example.com OPTIMISM_SEPOLIA_RPC=https://optimism-sepolia.example.com SEPOLIA_RPC=https://sepolia.example.com -MONGO_URI=mongodb://localhost:27017/db ` err := os.WriteFile(".env", []byte(envContent), 0644) assert.NoError(t, err) @@ -39,8 +36,6 @@ MONGO_URI=mongodb://localhost:27017/db assert.Equal(t, "https://base-sepolia.example.com", config.RPCs.BaseSepolia) assert.Equal(t, "https://optimism-sepolia.example.com", config.RPCs.OptimismSepolia) assert.Equal(t, "https://sepolia.example.com", config.RPCs.Sepolia) - assert.Equal(t, "mongodb://localhost:27017/db", config.MongoUri) - assert.Equal(t, []*big.Int{big.NewInt(421614)}, config.SupportedChains) } func TestNewConfigMissingEnvVar(t *testing.T) { diff --git a/services/go-filler/log-fetcher/internal/fetcher/fetcher.go b/services/go-filler/log-fetcher/internal/fetcher/fetcher.go new file mode 100644 index 0000000..c2faa8f --- /dev/null +++ b/services/go-filler/log-fetcher/internal/fetcher/fetcher.go @@ -0,0 +1,72 @@ +package fetcher + +import ( + "context" + "math/big" + "os" + "os/signal" + "sync" + "syscall" + "time" + + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/listener" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" + "github.com/ethereum/go-ethereum/log" + "github.com/urfave/cli/v2" +) + +func Main(ctx *cli.Context) error { + log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelInfo, true))) + + cfg, err := config.NewConfig() // Load env vars + if err != nil { + return err + } + + queue, err := store.NewQueue(ctx) + if err != nil { + return err + } + defer queue.Close() + + var wg sync.WaitGroup + stopped, stop := context.WithCancel(context.Background()) + + for _, chainId := range ctx.StringSlice("supported-chains") { + chainIdBigInt, ok := new(big.Int).SetString(chainId, 10) + if !ok { + log.Crit("Failed to convert chainId to big.Int", "chainId", chainId) + } + + l, err := listener.NewListener(chainIdBigInt, cfg, queue) + if err != nil { + log.Crit("Failed to create listener", "error", err) + } + + wg.Add(1) + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + err = l.Start(ctx) + cancel() + if err != nil { + log.Crit("Failed to start listener", "error", err) + } + + go func() { + defer wg.Done() + <-stopped.Done() + l.Stop() + }() + } + + // Handle signals to initiate shutdown + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt, syscall.SIGTERM) + <-c + + log.Info("Shutting down...") + stop() + wg.Wait() + + return nil +} diff --git a/services/go-filler/log-fetcher/internal/flags/flags.go b/services/go-filler/log-fetcher/internal/flags/flags.go new file mode 100644 index 0000000..c2508eb --- /dev/null +++ b/services/go-filler/log-fetcher/internal/flags/flags.go @@ -0,0 +1,24 @@ +package flags + +import ( + "github.com/urfave/cli/v2" +) + +var ( + MongoUriFlag = &cli.StringFlag{ + Name: "mongo-uri", + Usage: "Connection string to MongoDB", + EnvVars: []string{"MONGO_URI"}, + Required: true, + } + SupportedChainsFlag = &cli.StringSliceFlag{ + Name: "supported-chains", + Usage: "Comma separated list of supported chains", + Value: cli.NewStringSlice("421614"), + EnvVars: []string{"SUPPORTED_CHAINS"}, + Required: false, + } +) + +// Flags contains the list of configuration options available to the binary. +var Flags = []cli.Flag{MongoUriFlag, SupportedChainsFlag} diff --git a/services/go-filler/log-fetcher/internal/store/mongo_client.go b/services/go-filler/log-fetcher/internal/store/mongo_client.go index 7c50b65..3541561 100644 --- a/services/go-filler/log-fetcher/internal/store/mongo_client.go +++ b/services/go-filler/log-fetcher/internal/store/mongo_client.go @@ -4,8 +4,8 @@ import ( "context" "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" logger "github.com/ethereum/go-ethereum/log" + "github.com/urfave/cli/v2" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) @@ -34,8 +34,8 @@ type record struct { Request bindings.CrossChainRequest } -func NewQueue(cfg *config.Config) (Queue, error) { - client, err := connect(cfg) +func NewQueue(ctx *cli.Context) (Queue, error) { + client, err := connect(ctx) if err != nil { return nil, err } @@ -64,9 +64,9 @@ func (q *queue) Close() error { return q.client.Disconnect(context.TODO()) } -func connect(cfg *config.Config) (MongoDriverClient, error) { +func connect(ctx *cli.Context) (MongoDriverClient, error) { logger.Info("Connecting to MongoDB") - client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(cfg.MongoUri)) + client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(ctx.String("mongo-uri"))) if err != nil { return nil, err } From 91c7169f57cf2d6f5d05be65f61be533e9cbc6f9 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Wed, 20 Nov 2024 17:45:01 -0500 Subject: [PATCH 31/36] move rpc urls to flags package --- services/go-filler/Makefile | 3 +- services/go-filler/go.mod | 1 - services/go-filler/go.sum | 2 - .../log-fetcher/internal/chains/config.go | 14 ++++-- .../internal/chains/config_test.go | 29 +++++++---- .../log-fetcher/internal/config/config.go | 48 ------------------ .../internal/config/config_test.go | 49 ------------------- .../log-fetcher/internal/fetcher/fetcher.go | 8 +-- .../log-fetcher/internal/flags/flags.go | 26 +++++++++- .../log-fetcher/internal/handler/handler.go | 5 +- .../log-fetcher/internal/listener/listener.go | 7 ++- .../internal/listener/listener_test.go | 12 ++--- .../internal/validator/validator.go | 9 ++-- .../internal/validator/validator_test.go | 26 +++++----- 14 files changed, 82 insertions(+), 157 deletions(-) delete mode 100644 services/go-filler/log-fetcher/internal/config/config.go delete mode 100644 services/go-filler/log-fetcher/internal/config/config_test.go diff --git a/services/go-filler/Makefile b/services/go-filler/Makefile index 745cbf4..1c17428 100644 --- a/services/go-filler/Makefile +++ b/services/go-filler/Makefile @@ -1,4 +1,5 @@ -include .env +export .PHONY: bindings @@ -6,7 +7,7 @@ test-log-fetcher: go test ./log-fetcher/internal/... run-log-fetcher: - MONGO_URI=$(MONGO_URI) go run ./log-fetcher/cmd + go run ./log-fetcher/cmd bindings: go install github.com/ethereum/go-ethereum/cmd/abigen@v1.14.11 diff --git a/services/go-filler/go.mod b/services/go-filler/go.mod index a48a851..1b92f9f 100644 --- a/services/go-filler/go.mod +++ b/services/go-filler/go.mod @@ -4,7 +4,6 @@ go 1.23.2 require ( github.com/ethereum/go-ethereum v1.14.11 - github.com/joho/godotenv v1.5.1 github.com/stretchr/testify v1.9.0 github.com/urfave/cli/v2 v2.27.5 go.mongodb.org/mongo-driver v1.17.1 diff --git a/services/go-filler/go.sum b/services/go-filler/go.sum index 8160c67..cbec529 100644 --- a/services/go-filler/go.sum +++ b/services/go-filler/go.sum @@ -117,8 +117,6 @@ github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFck github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= -github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= -github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= diff --git a/services/go-filler/log-fetcher/internal/chains/config.go b/services/go-filler/log-fetcher/internal/chains/config.go index 5069e13..ba4b747 100644 --- a/services/go-filler/log-fetcher/internal/chains/config.go +++ b/services/go-filler/log-fetcher/internal/chains/config.go @@ -28,7 +28,11 @@ type ChainConfig struct { TargetProver config.Prover } -func GetChainConfig(chainId *big.Int, rpcConfig *config.RPCs) (*ChainConfig, error) { +type CliContext interface { + String(name string) string +} + +func GetChainConfig(chainId *big.Int, ctx CliContext) (*ChainConfig, error) { var chainConfig *ChainConfig switch chainId.Int64() { @@ -45,7 +49,7 @@ func GetChainConfig(chainId *big.Int, rpcConfig *config.RPCs) (*ChainConfig, err chainConfig = &ChainConfig{ ChainId: chainId, ProverContracts: provers, - RpcUrl: rpcConfig.ArbitrumSepolia, + RpcUrl: ctx.String("arbitrum-sepolia-rpc"), L2Oracle: common.HexToAddress("0xd80810638dbDF9081b72C1B33c65375e807281C8"), L2OracleStorageKey: encodeBytes("0000000000000000000000000000000000000000000000000000000000000076"), Contracts: contracts, @@ -65,7 +69,7 @@ func GetChainConfig(chainId *big.Int, rpcConfig *config.RPCs) (*ChainConfig, err chainConfig = &ChainConfig{ ChainId: chainId, ProverContracts: provers, - RpcUrl: rpcConfig.BaseSepolia, + RpcUrl: ctx.String("base-sepolia-rpc"), L2Oracle: common.HexToAddress("0x4C8BA32A5DAC2A720bb35CeDB51D6B067D104205"), L2OracleStorageKey: encodeBytes("a6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49"), Contracts: contracts, @@ -82,7 +86,7 @@ func GetChainConfig(chainId *big.Int, rpcConfig *config.RPCs) (*ChainConfig, err chainConfig = &ChainConfig{ ChainId: chainId, ProverContracts: provers, - RpcUrl: rpcConfig.OptimismSepolia, + RpcUrl: ctx.String("optimism-sepolia-rpc"), L2Oracle: common.HexToAddress("0x218CD9489199F321E1177b56385d333c5B598629"), L2OracleStorageKey: encodeBytes("a6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49"), Contracts: contracts, @@ -99,7 +103,7 @@ func GetChainConfig(chainId *big.Int, rpcConfig *config.RPCs) (*ChainConfig, err chainConfig = &ChainConfig{ ChainId: chainId, ProverContracts: provers, - RpcUrl: rpcConfig.Sepolia, + RpcUrl: ctx.String("sepolia-rpc"), Contracts: contracts, TargetProver: config.NilProver, } diff --git a/services/go-filler/log-fetcher/internal/chains/config_test.go b/services/go-filler/log-fetcher/internal/chains/config_test.go index 78ef1da..d379350 100644 --- a/services/go-filler/log-fetcher/internal/chains/config_test.go +++ b/services/go-filler/log-fetcher/internal/chains/config_test.go @@ -7,20 +7,29 @@ import ( "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/ethereum/go-ethereum/common" + "github.com/urfave/cli/v2" ) +type cliContext struct { + rpcUrl string +} + +func (c *cliContext) String(name string) string { + return c.rpcUrl +} + func TestGetChainConfig(t *testing.T) { testCases := []struct { name string chainID int64 - rpcConfig *config.RPCs + rpcConfig CliContext expected *ChainConfig }{ { name: "Arbitrum Sepolia", chainID: 421614, - rpcConfig: &config.RPCs{ - ArbitrumSepolia: "https://arb-sepolia.example.com", + rpcConfig: &cliContext{ + rpcUrl: "https://arb-sepolia.example.com", }, expected: &ChainConfig{ ChainId: big.NewInt(421614), @@ -40,8 +49,8 @@ func TestGetChainConfig(t *testing.T) { { name: "Base Sepolia", chainID: 84532, - rpcConfig: &config.RPCs{ - BaseSepolia: "https://base-sepolia.example.com", + rpcConfig: &cliContext{ + rpcUrl: "https://base-sepolia.example.com", }, expected: &ChainConfig{ ChainId: big.NewInt(84532), @@ -62,8 +71,8 @@ func TestGetChainConfig(t *testing.T) { { name: "Optimism Sepolia", chainID: 11155420, - rpcConfig: &config.RPCs{ - OptimismSepolia: "https://opt-sepolia.example.com", + rpcConfig: &cliContext{ + rpcUrl: "https://opt-sepolia.example.com", }, expected: &ChainConfig{ ChainId: big.NewInt(11155420), @@ -81,8 +90,8 @@ func TestGetChainConfig(t *testing.T) { { name: "Sepolia", chainID: 11155111, - rpcConfig: &config.RPCs{ - Sepolia: "https://sepolia.example.com", + rpcConfig: &cliContext{ + rpcUrl: "https://sepolia.example.com", }, expected: &ChainConfig{ ChainId: big.NewInt(11155111), @@ -113,7 +122,7 @@ func TestGetChainConfig(t *testing.T) { func TestGetChainConfig_UnknownChain(t *testing.T) { unknownChainID := big.NewInt(999999) - result, err := GetChainConfig(unknownChainID, &config.RPCs{}) + result, err := GetChainConfig(unknownChainID, &cli.Context{}) if err == nil { t.Errorf("GetChainConfig(%d) = %+v, want error", unknownChainID, result) } diff --git a/services/go-filler/log-fetcher/internal/config/config.go b/services/go-filler/log-fetcher/internal/config/config.go deleted file mode 100644 index df3f9f1..0000000 --- a/services/go-filler/log-fetcher/internal/config/config.go +++ /dev/null @@ -1,48 +0,0 @@ -package config - -import ( - "log" - "os" - - "github.com/joho/godotenv" -) - -type RPCs struct { - ArbitrumSepolia string - BaseSepolia string - OptimismSepolia string - Sepolia string -} - -type Config struct { - RPCs *RPCs -} - -func NewConfig() (*Config, error) { - if err := godotenv.Load(".env"); err != nil { - return nil, err - } - - config := &Config{ - RPCs: &RPCs{ - ArbitrumSepolia: getEnvStr("ARBITRUM_SEPOLIA_RPC"), - BaseSepolia: getEnvStr("BASE_SEPOLIA_RPC"), - OptimismSepolia: getEnvStr("OPTIMISM_SEPOLIA_RPC"), - Sepolia: getEnvStr("SEPOLIA_RPC"), - }, - } - - return config, nil -} - -// getEnvStr ... Reads env var from process environment, panics if not found -func getEnvStr(key string) string { - envVar, ok := os.LookupEnv(key) - - // Not found - if !ok { - log.Fatalf("could not find env var given key: %s", key) - } - - return envVar -} diff --git a/services/go-filler/log-fetcher/internal/config/config_test.go b/services/go-filler/log-fetcher/internal/config/config_test.go deleted file mode 100644 index 4513676..0000000 --- a/services/go-filler/log-fetcher/internal/config/config_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package config - -import ( - "os" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewConfig(t *testing.T) { - // Setup test environment variables - os.Setenv("ARBITRUM_SEPOLIA_RPC", "https://arbitrum-sepolia.example.com") - os.Setenv("BASE_SEPOLIA_RPC", "https://base-sepolia.example.com") - os.Setenv("OPTIMISM_SEPOLIA_RPC", "https://optimism-sepolia.example.com") - os.Setenv("SEPOLIA_RPC", "https://sepolia.example.com") - - // Create a temporary .env file - envContent := ` -ARBITRUM_SEPOLIA_RPC=https://arbitrum-sepolia.example.com -BASE_SEPOLIA_RPC=https://base-sepolia.example.com -OPTIMISM_SEPOLIA_RPC=https://optimism-sepolia.example.com -SEPOLIA_RPC=https://sepolia.example.com -` - err := os.WriteFile(".env", []byte(envContent), 0644) - assert.NoError(t, err) - defer os.Remove(".env") - - // Test NewConfig - config, err := NewConfig() - - assert.NoError(t, err) - - assert.NotNil(t, config) - assert.NotNil(t, config.RPCs) - assert.Equal(t, "https://arbitrum-sepolia.example.com", config.RPCs.ArbitrumSepolia) - assert.Equal(t, "https://base-sepolia.example.com", config.RPCs.BaseSepolia) - assert.Equal(t, "https://optimism-sepolia.example.com", config.RPCs.OptimismSepolia) - assert.Equal(t, "https://sepolia.example.com", config.RPCs.Sepolia) -} - -func TestNewConfigMissingEnvVar(t *testing.T) { - // Ensure no environment variables are set - os.Clearenv() - - _, err := NewConfig() - if err == nil { - t.Fatal("expected an error due to missing environment variables, got none") - } -} diff --git a/services/go-filler/log-fetcher/internal/fetcher/fetcher.go b/services/go-filler/log-fetcher/internal/fetcher/fetcher.go index c2faa8f..2bf62c0 100644 --- a/services/go-filler/log-fetcher/internal/fetcher/fetcher.go +++ b/services/go-filler/log-fetcher/internal/fetcher/fetcher.go @@ -9,7 +9,6 @@ import ( "syscall" "time" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/listener" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" "github.com/ethereum/go-ethereum/log" @@ -19,11 +18,6 @@ import ( func Main(ctx *cli.Context) error { log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelInfo, true))) - cfg, err := config.NewConfig() // Load env vars - if err != nil { - return err - } - queue, err := store.NewQueue(ctx) if err != nil { return err @@ -39,7 +33,7 @@ func Main(ctx *cli.Context) error { log.Crit("Failed to convert chainId to big.Int", "chainId", chainId) } - l, err := listener.NewListener(chainIdBigInt, cfg, queue) + l, err := listener.NewListener(chainIdBigInt, ctx, queue) if err != nil { log.Crit("Failed to create listener", "error", err) } diff --git a/services/go-filler/log-fetcher/internal/flags/flags.go b/services/go-filler/log-fetcher/internal/flags/flags.go index c2508eb..a3a4ed4 100644 --- a/services/go-filler/log-fetcher/internal/flags/flags.go +++ b/services/go-filler/log-fetcher/internal/flags/flags.go @@ -11,6 +11,30 @@ var ( EnvVars: []string{"MONGO_URI"}, Required: true, } + ArbitrumSepoliaRpcFlag = &cli.StringFlag{ + Name: "arbitrum-sepolia-rpc", + Usage: "Arbitrum Sepolia RPC", + EnvVars: []string{"ARBITRUM_SEPOLIA_RPC"}, + Required: true, + } + BaseSepoliaRpcFlag = &cli.StringFlag{ + Name: "base-sepolia-rpc", + Usage: "Base Sepolia RPC", + EnvVars: []string{"BASE_SEPOLIA_RPC"}, + Required: true, + } + OptimismSepoliaRpcFlag = &cli.StringFlag{ + Name: "optimism-sepolia-rpc", + Usage: "Optimism Sepolia RPC", + EnvVars: []string{"OPTIMISM_SEPOLIA_RPC"}, + Required: true, + } + SepoliaRpcFlag = &cli.StringFlag{ + Name: "sepolia-rpc", + Usage: "Sepolia RPC", + EnvVars: []string{"SEPOLIA_RPC"}, + Required: true, + } SupportedChainsFlag = &cli.StringSliceFlag{ Name: "supported-chains", Usage: "Comma separated list of supported chains", @@ -21,4 +45,4 @@ var ( ) // Flags contains the list of configuration options available to the binary. -var Flags = []cli.Flag{MongoUriFlag, SupportedChainsFlag} +var Flags = []cli.Flag{MongoUriFlag, ArbitrumSepoliaRpcFlag, BaseSepoliaRpcFlag, OptimismSepoliaRpcFlag, SepoliaRpcFlag, SupportedChainsFlag} diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go index cf97ae3..8b990bc 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler.go +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -3,7 +3,6 @@ package handler import ( "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/validator" ) @@ -17,8 +16,8 @@ type handler struct { queue store.Queue } -func NewHandler(cfg *config.Config, srcChain *chains.ChainConfig, queue store.Queue) (Handler, error) { - return &handler{validator: validator.NewValidator(cfg, srcChain), queue: queue}, nil +func NewHandler(ctx chains.CliContext, srcChain *chains.ChainConfig, queue store.Queue) (Handler, error) { + return &handler{validator: validator.NewValidator(ctx, srcChain), queue: queue}, nil } func (h *handler) HandleLog(log *bindings.RIP7755OutboxCrossChainCallRequested) error { diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index 47b2d3d..3720160 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -9,7 +9,6 @@ import ( "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/clients" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/handler" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" "github.com/ethereum/go-ethereum" @@ -31,13 +30,13 @@ type listener struct { wg sync.WaitGroup } -func NewListener(srcChainId *big.Int, cfg *config.Config, queue store.Queue) (Listener, error) { - srcChain, err := chains.GetChainConfig(srcChainId, cfg.RPCs) +func NewListener(srcChainId *big.Int, ctx chains.CliContext, queue store.Queue) (Listener, error) { + srcChain, err := chains.GetChainConfig(srcChainId, ctx) if err != nil { return nil, err } - h, err := handler.NewHandler(cfg, srcChain, queue) + h, err := handler.NewHandler(ctx, srcChain, queue) if err != nil { return nil, err } diff --git a/services/go-filler/log-fetcher/internal/listener/listener_test.go b/services/go-filler/log-fetcher/internal/listener/listener_test.go index 4bc1529..2f044c4 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener_test.go +++ b/services/go-filler/log-fetcher/internal/listener/listener_test.go @@ -4,20 +4,20 @@ import ( "math/big" "testing" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" "github.com/stretchr/testify/assert" ) -var cfg *config.Config = &config.Config{ - RPCs: &config.RPCs{ - ArbitrumSepolia: "https://arbitrum-sepolia.com", - }, +type cliContext struct{} + +func (c *cliContext) String(name string) string { + return "https://arbitrum-sepolia.com" } + var queue store.Queue func TestNewListener(t *testing.T) { - l, err := NewListener(big.NewInt(421614), cfg, queue) + l, err := NewListener(big.NewInt(421614), &cliContext{}, queue) if err != nil { t.Fatalf("Failed to create listener: %v", err) } diff --git a/services/go-filler/log-fetcher/internal/validator/validator.go b/services/go-filler/log-fetcher/internal/validator/validator.go index e55cc8f..5d148ef 100644 --- a/services/go-filler/log-fetcher/internal/validator/validator.go +++ b/services/go-filler/log-fetcher/internal/validator/validator.go @@ -6,7 +6,6 @@ import ( "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/ethereum/go-ethereum/common" logger "github.com/ethereum/go-ethereum/log" ) @@ -16,19 +15,19 @@ type Validator interface { } type validator struct { - cfg *config.Config + ctx chains.CliContext srcChain *chains.ChainConfig } -func NewValidator(cfg *config.Config, srcChain *chains.ChainConfig) Validator { - return &validator{cfg: cfg, srcChain: srcChain} +func NewValidator(ctx chains.CliContext, srcChain *chains.ChainConfig) Validator { + return &validator{ctx: ctx, srcChain: srcChain} } func (v *validator) ValidateLog(log *bindings.RIP7755OutboxCrossChainCallRequested) error { logger.Info("Validating log") // - Confirm valid proverContract address on source chain - dstChain, err := chains.GetChainConfig(log.Request.DestinationChainId, v.cfg.RPCs) + dstChain, err := chains.GetChainConfig(log.Request.DestinationChainId, v.ctx) if err != nil { return err } diff --git a/services/go-filler/log-fetcher/internal/validator/validator_test.go b/services/go-filler/log-fetcher/internal/validator/validator_test.go index a1a18a0..64c12c3 100644 --- a/services/go-filler/log-fetcher/internal/validator/validator_test.go +++ b/services/go-filler/log-fetcher/internal/validator/validator_test.go @@ -8,16 +8,12 @@ import ( "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" + "github.com/urfave/cli/v2" ) -var cfg = &config.Config{ - RPCs: &config.RPCs{ - ArbitrumSepolia: "https://arbitrum-sepolia.llamarpc.com", - }, -} +var ctx *cli.Context var srcChain = &chains.ChainConfig{ ChainId: big.NewInt(42161), @@ -45,7 +41,7 @@ var parsedLog = &bindings.RIP7755OutboxCrossChainCallRequested{ } func TestValidateLog(t *testing.T) { - validator := NewValidator(cfg, srcChain) + validator := NewValidator(ctx, srcChain) err := validator.ValidateLog(parsedLog) @@ -53,7 +49,7 @@ func TestValidateLog(t *testing.T) { } func TestValidateLog_UnknownDestinationChain(t *testing.T) { - validator := NewValidator(cfg, srcChain) + validator := NewValidator(ctx, srcChain) prevDstChainId := parsedLog.Request.DestinationChainId parsedLog.Request.DestinationChainId = big.NewInt(11155112) @@ -65,7 +61,7 @@ func TestValidateLog_UnknownDestinationChain(t *testing.T) { } func TestValidateLog_UnknownProverName(t *testing.T) { - validator := NewValidator(cfg, srcChain) + validator := NewValidator(ctx, srcChain) prevDstChainId := parsedLog.Request.DestinationChainId parsedLog.Request.DestinationChainId = big.NewInt(11155111) @@ -77,7 +73,7 @@ func TestValidateLog_UnknownProverName(t *testing.T) { } func TestValidateLog_UnknownProverContract(t *testing.T) { - validator := NewValidator(cfg, srcChain) + validator := NewValidator(ctx, srcChain) prevProverContract := parsedLog.Request.ProverContract parsedLog.Request.ProverContract = common.HexToAddress("0x1234567890123456789012345678901234567891") @@ -89,7 +85,7 @@ func TestValidateLog_UnknownProverContract(t *testing.T) { } func TestValidateLog_UnknownInboxContract(t *testing.T) { - validator := NewValidator(cfg, srcChain) + validator := NewValidator(ctx, srcChain) prevInboxContract := parsedLog.Request.InboxContract parsedLog.Request.InboxContract = common.HexToAddress("0x1234567890123456789012345678901234567891") @@ -101,7 +97,7 @@ func TestValidateLog_UnknownInboxContract(t *testing.T) { } func TestValidateLog_UnknownL2Oracle(t *testing.T) { - validator := NewValidator(cfg, srcChain) + validator := NewValidator(ctx, srcChain) prevL2Oracle := parsedLog.Request.L2Oracle parsedLog.Request.L2Oracle = common.HexToAddress("0x1234567890123456789012345678901234567891") @@ -113,7 +109,7 @@ func TestValidateLog_UnknownL2Oracle(t *testing.T) { } func TestValidateLog_UnknownL2OracleStorageKey(t *testing.T) { - validator := NewValidator(cfg, srcChain) + validator := NewValidator(ctx, srcChain) prevL2OracleStorageKey := parsedLog.Request.L2OracleStorageKey parsedLog.Request.L2OracleStorageKey = encodeBytes("1234567890123456789012345678901234567891") @@ -125,7 +121,7 @@ func TestValidateLog_UnknownL2OracleStorageKey(t *testing.T) { } func TestValidateLog_InvalidReward_NotNativeAsset(t *testing.T) { - validator := NewValidator(cfg, srcChain) + validator := NewValidator(ctx, srcChain) prevRewardAsset := parsedLog.Request.RewardAsset parsedLog.Request.RewardAsset = common.HexToAddress("0x1234567890123456789012345678901234567891") @@ -137,7 +133,7 @@ func TestValidateLog_InvalidReward_NotNativeAsset(t *testing.T) { } func TestValidateLog_InvalidReward_NotGreaterThanValueNeeded(t *testing.T) { - validator := NewValidator(cfg, srcChain) + validator := NewValidator(ctx, srcChain) prevRewardAmount := parsedLog.Request.RewardAmount parsedLog.Request.RewardAmount = big.NewInt(1000000000000000000) From ea4fc8d3e2c5a4fc08a101fb908dfcfc7b692043 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Thu, 21 Nov 2024 11:47:52 -0500 Subject: [PATCH 32/36] use yaml file for chain configs --- services/go-filler/go.mod | 1 + .../log-fetcher/config/networks.yaml | 42 ++++++ .../log-fetcher/internal/chains/config.go | 127 +++------------- .../internal/chains/config_test.go | 137 +++--------------- .../log-fetcher/internal/fetcher/fetcher.go | 18 ++- .../log-fetcher/internal/handler/handler.go | 4 +- .../log-fetcher/internal/listener/listener.go | 6 +- .../internal/listener/listener_test.go | 17 ++- .../internal/validator/validator.go | 10 +- .../internal/validator/validator_test.go | 57 ++++---- 10 files changed, 155 insertions(+), 264 deletions(-) create mode 100644 services/go-filler/log-fetcher/config/networks.yaml diff --git a/services/go-filler/go.mod b/services/go-filler/go.mod index 1b92f9f..cf88ba5 100644 --- a/services/go-filler/go.mod +++ b/services/go-filler/go.mod @@ -7,6 +7,7 @@ require ( github.com/stretchr/testify v1.9.0 github.com/urfave/cli/v2 v2.27.5 go.mongodb.org/mongo-driver v1.17.1 + gopkg.in/yaml.v2 v2.4.0 ) require ( diff --git a/services/go-filler/log-fetcher/config/networks.yaml b/services/go-filler/log-fetcher/config/networks.yaml new file mode 100644 index 0000000..32e752f --- /dev/null +++ b/services/go-filler/log-fetcher/config/networks.yaml @@ -0,0 +1,42 @@ +networks: + 421614: # Arbitrum Sepolia + chain-id: 421614 + prover-contracts: + OPStack: 0x062fBdCfd17A0346D2A9d89FE233bbAdBd1DC14C + rpc-url: ${ARBITRUM_SEPOLIA_RPC} + l2-oracle: 0xd80810638dbDF9081b72C1B33c65375e807281C8 + l2-oracle-storage-key: 0x0000000000000000000000000000000000000000000000000000000000000076 + contracts: + inbox: 0xeE962eD1671F655a806cB22623eEA8A7cCc233bC + outbox: 0xBCd5762cF9B07EF5597014c350CE2efB2b0DB2D2 + target-prover: 1 + 84532: # Base Sepolia + chain-id: 84532 + prover-contracts: + Arbitrum: 0x49E2cDC9e81825B6C718ae8244fe0D5b062F4874 + OPStack: 0x562879614C9Db8Da9379be1D5B52BAEcDD456d78 + rpc-url: ${BASE_SEPOLIA_RPC} + l2-oracle: 0x4C8BA32A5DAC2A720bb35CeDB51D6B067D104205 + l2-oracle-storage-key: 0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49 + contracts: + inbox: 0xB482b292878FDe64691d028A2237B34e91c7c7ea + outbox: 0xD7a5A114A07cC4B5ebd9C5e1cD1136a99fFA3d68 + target-prover: 2 + 11155420: # Optimism Sepolia + chain-id: 11155420 + prover-contracts: + rpc-url: ${OPTIMISM_SEPOLIA_RPC} + l2-oracle: 0x218CD9489199F321E1177b56385d333c5B598629 + l2-oracle-storage-key: 0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49 + contracts: + inbox: 0x49E2cDC9e81825B6C718ae8244fe0D5b062F4874 + l2-message-passer: 0x4200000000000000000000000000000000000016 + target-prover: 2 + 11155111: # Sepolia + chain-id: 11155111 + prover-contracts: + rpc-url: ${SEPOLIA_RPC} + contracts: + anchor-state-registry: 0x218CD9489199F321E1177b56385d333c5B598629 + arb-rollup: 0xd80810638dbDF9081b72C1B33c65375e807281C8 + target-prover: 0 diff --git a/services/go-filler/log-fetcher/internal/chains/config.go b/services/go-filler/log-fetcher/internal/chains/config.go index ba4b747..eed2aaa 100644 --- a/services/go-filler/log-fetcher/internal/chains/config.go +++ b/services/go-filler/log-fetcher/internal/chains/config.go @@ -1,126 +1,41 @@ package chains import ( - "encoding/hex" "fmt" "math/big" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/log" ) -type Contracts struct { - AnchorStateRegistry common.Address - ArbRollup common.Address - L2MessagePasser common.Address - Inbox common.Address - Outbox common.Address +type NetworksConfig struct { + Networks Networks `yaml:"networks"` } +type Networks map[string]ChainConfig -type ChainConfig struct { - ChainId *big.Int - ProverContracts map[string]common.Address - RpcUrl string - L2Oracle common.Address - L2OracleStorageKey [32]byte - Contracts *Contracts - TargetProver config.Prover +type Contracts struct { + AnchorStateRegistry common.Address `yaml:"anchor-state-registry"` + ArbRollup common.Address `yaml:"arb-rollup"` + L2MessagePasser common.Address `yaml:"l2-message-passer"` + Inbox common.Address `yaml:"inbox"` + Outbox common.Address `yaml:"outbox"` } -type CliContext interface { - String(name string) string +type ChainConfig struct { + ChainId *big.Int `yaml:"chain-id"` + ProverContracts map[string]common.Address `yaml:"prover-contracts"` + RpcUrl string `yaml:"rpc-url"` + L2Oracle common.Address `yaml:"l2-oracle"` + L2OracleStorageKey string `yaml:"l2-oracle-storage-key"` + Contracts *Contracts `yaml:"contracts"` + TargetProver config.Prover `yaml:"target-prover"` } -func GetChainConfig(chainId *big.Int, ctx CliContext) (*ChainConfig, error) { - var chainConfig *ChainConfig - - switch chainId.Int64() { - // Arbitrum Sepolia - case 421614: - provers := map[string]common.Address{ - config.OPStackProver.String(): common.HexToAddress("0x062fBdCfd17A0346D2A9d89FE233bbAdBd1DC14C"), - } - contracts := &Contracts{ - Inbox: common.HexToAddress("0xeE962eD1671F655a806cB22623eEA8A7cCc233bC"), - Outbox: common.HexToAddress("0xBCd5762cF9B07EF5597014c350CE2efB2b0DB2D2"), - } - - chainConfig = &ChainConfig{ - ChainId: chainId, - ProverContracts: provers, - RpcUrl: ctx.String("arbitrum-sepolia-rpc"), - L2Oracle: common.HexToAddress("0xd80810638dbDF9081b72C1B33c65375e807281C8"), - L2OracleStorageKey: encodeBytes("0000000000000000000000000000000000000000000000000000000000000076"), - Contracts: contracts, - TargetProver: config.ArbitrumProver, - } - // Base Sepolia - case 84532: - provers := map[string]common.Address{ - config.ArbitrumProver.String(): common.HexToAddress("0x49E2cDC9e81825B6C718ae8244fe0D5b062F4874"), - config.OPStackProver.String(): common.HexToAddress("0x562879614C9Db8Da9379be1D5B52BAEcDD456d78"), - } - contracts := &Contracts{ - Inbox: common.HexToAddress("0xB482b292878FDe64691d028A2237B34e91c7c7ea"), - Outbox: common.HexToAddress("0xD7a5A114A07cC4B5ebd9C5e1cD1136a99fFA3d68"), - } - - chainConfig = &ChainConfig{ - ChainId: chainId, - ProverContracts: provers, - RpcUrl: ctx.String("base-sepolia-rpc"), - L2Oracle: common.HexToAddress("0x4C8BA32A5DAC2A720bb35CeDB51D6B067D104205"), - L2OracleStorageKey: encodeBytes("a6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49"), - Contracts: contracts, - TargetProver: config.OPStackProver, - } - // Optimism Sepolia - case 11155420: - provers := map[string]common.Address{} - contracts := &Contracts{ - L2MessagePasser: common.HexToAddress("0x4200000000000000000000000000000000000016"), - Inbox: common.HexToAddress("0x49E2cDC9e81825B6C718ae8244fe0D5b062F4874"), - } - - chainConfig = &ChainConfig{ - ChainId: chainId, - ProverContracts: provers, - RpcUrl: ctx.String("optimism-sepolia-rpc"), - L2Oracle: common.HexToAddress("0x218CD9489199F321E1177b56385d333c5B598629"), - L2OracleStorageKey: encodeBytes("a6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49"), - Contracts: contracts, - TargetProver: config.OPStackProver, - } - // Sepolia - case 11155111: - provers := map[string]common.Address{} - contracts := &Contracts{ - AnchorStateRegistry: common.HexToAddress("0x218CD9489199F321E1177b56385d333c5B598629"), - ArbRollup: common.HexToAddress("0xd80810638dbDF9081b72C1B33c65375e807281C8"), - } - - chainConfig = &ChainConfig{ - ChainId: chainId, - ProverContracts: provers, - RpcUrl: ctx.String("sepolia-rpc"), - Contracts: contracts, - TargetProver: config.NilProver, - } - default: +func (n *Networks) GetChainConfig(chainId *big.Int) (*ChainConfig, error) { + chainConfig, ok := (*n)[chainId.String()] + if !ok { return nil, fmt.Errorf("unknown chainId: %d", chainId.Int64()) } - return chainConfig, nil -} - -func encodeBytes(bytesStr string) [32]byte { - bytes, err := hex.DecodeString(bytesStr) - if err != nil { - log.Crit("Failed to decode bytes", "error", err) - } - - var byteArray [32]byte - copy(byteArray[32-len(bytes):], bytes) - return byteArray + return &chainConfig, nil } diff --git a/services/go-filler/log-fetcher/internal/chains/config_test.go b/services/go-filler/log-fetcher/internal/chains/config_test.go index d379350..6e7cd88 100644 --- a/services/go-filler/log-fetcher/internal/chains/config_test.go +++ b/services/go-filler/log-fetcher/internal/chains/config_test.go @@ -7,30 +7,18 @@ import ( "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/ethereum/go-ethereum/common" - "github.com/urfave/cli/v2" ) -type cliContext struct { - rpcUrl string -} - -func (c *cliContext) String(name string) string { - return c.rpcUrl -} - func TestGetChainConfig(t *testing.T) { testCases := []struct { - name string - chainID int64 - rpcConfig CliContext - expected *ChainConfig + name string + chainID *big.Int + expected *ChainConfig + networks Networks }{ { name: "Arbitrum Sepolia", - chainID: 421614, - rpcConfig: &cliContext{ - rpcUrl: "https://arb-sepolia.example.com", - }, + chainID: big.NewInt(421614), expected: &ChainConfig{ ChainId: big.NewInt(421614), ProverContracts: map[string]common.Address{ @@ -38,77 +26,35 @@ func TestGetChainConfig(t *testing.T) { }, RpcUrl: "https://arb-sepolia.example.com", L2Oracle: common.HexToAddress("0xd80810638dbDF9081b72C1B33c65375e807281C8"), - L2OracleStorageKey: encodeBytes("0000000000000000000000000000000000000000000000000000000000000076"), + L2OracleStorageKey: "0x0000000000000000000000000000000000000000000000000000000000000076", Contracts: &Contracts{ Inbox: common.HexToAddress("0xeE962eD1671F655a806cB22623eEA8A7cCc233bC"), Outbox: common.HexToAddress("0xBCd5762cF9B07EF5597014c350CE2efB2b0DB2D2"), }, TargetProver: config.ArbitrumProver, }, - }, - { - name: "Base Sepolia", - chainID: 84532, - rpcConfig: &cliContext{ - rpcUrl: "https://base-sepolia.example.com", - }, - expected: &ChainConfig{ - ChainId: big.NewInt(84532), - ProverContracts: map[string]common.Address{ - config.ArbitrumProver.String(): common.HexToAddress("0x49E2cDC9e81825B6C718ae8244fe0D5b062F4874"), - config.OPStackProver.String(): common.HexToAddress("0x562879614C9Db8Da9379be1D5B52BAEcDD456d78"), - }, - RpcUrl: "https://base-sepolia.example.com", - L2Oracle: common.HexToAddress("0x4C8BA32A5DAC2A720bb35CeDB51D6B067D104205"), - L2OracleStorageKey: encodeBytes("a6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49"), - Contracts: &Contracts{ - Inbox: common.HexToAddress("0xB482b292878FDe64691d028A2237B34e91c7c7ea"), - Outbox: common.HexToAddress("0xD7a5A114A07cC4B5ebd9C5e1cD1136a99fFA3d68"), - }, - TargetProver: config.OPStackProver, - }, - }, - { - name: "Optimism Sepolia", - chainID: 11155420, - rpcConfig: &cliContext{ - rpcUrl: "https://opt-sepolia.example.com", - }, - expected: &ChainConfig{ - ChainId: big.NewInt(11155420), - ProverContracts: map[string]common.Address{}, - RpcUrl: "https://opt-sepolia.example.com", - L2Oracle: common.HexToAddress("0x218CD9489199F321E1177b56385d333c5B598629"), - L2OracleStorageKey: encodeBytes("a6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49"), - Contracts: &Contracts{ - L2MessagePasser: common.HexToAddress("0x4200000000000000000000000000000000000016"), - Inbox: common.HexToAddress("0x49E2cDC9e81825B6C718ae8244fe0D5b062F4874"), - }, - TargetProver: config.OPStackProver, - }, - }, - { - name: "Sepolia", - chainID: 11155111, - rpcConfig: &cliContext{ - rpcUrl: "https://sepolia.example.com", - }, - expected: &ChainConfig{ - ChainId: big.NewInt(11155111), - ProverContracts: map[string]common.Address{}, - RpcUrl: "https://sepolia.example.com", - Contracts: &Contracts{ - AnchorStateRegistry: common.HexToAddress("0x218CD9489199F321E1177b56385d333c5B598629"), - ArbRollup: common.HexToAddress("0xd80810638dbDF9081b72C1B33c65375e807281C8"), + networks: Networks{ + "421614": { + ChainId: big.NewInt(421614), + ProverContracts: map[string]common.Address{ + config.OPStackProver.String(): common.HexToAddress("0x062fBdCfd17A0346D2A9d89FE233bbAdBd1DC14C"), + }, + RpcUrl: "https://arb-sepolia.example.com", + L2Oracle: common.HexToAddress("0xd80810638dbDF9081b72C1B33c65375e807281C8"), + L2OracleStorageKey: "0x0000000000000000000000000000000000000000000000000000000000000076", + Contracts: &Contracts{ + Inbox: common.HexToAddress("0xeE962eD1671F655a806cB22623eEA8A7cCc233bC"), + Outbox: common.HexToAddress("0xBCd5762cF9B07EF5597014c350CE2efB2b0DB2D2"), + }, + TargetProver: config.ArbitrumProver, }, - TargetProver: config.NilProver, }, }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - result, err := GetChainConfig(big.NewInt(tc.chainID), tc.rpcConfig) + result, err := tc.networks.GetChainConfig(tc.chainID) if err != nil { t.Errorf("GetChainConfig(%d) returned error: %v", tc.chainID, err) } @@ -122,47 +68,8 @@ func TestGetChainConfig(t *testing.T) { func TestGetChainConfig_UnknownChain(t *testing.T) { unknownChainID := big.NewInt(999999) - result, err := GetChainConfig(unknownChainID, &cli.Context{}) + result, err := (&Networks{}).GetChainConfig(unknownChainID) if err == nil { t.Errorf("GetChainConfig(%d) = %+v, want error", unknownChainID, result) } } - -func TestEncodeBytes(t *testing.T) { - testCases := []struct { - name string - input string - expected [32]byte - }{ - { - name: "Empty string", - input: "", - expected: [32]byte{}, - }, - { - name: "Short string", - input: "0102030405", - expected: [32]byte{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, - }, - }, - { - name: "Full 32-byte string", - input: "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20", - expected: [32]byte{ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - }, - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - result := encodeBytes(tc.input) - if !reflect.DeepEqual(result, tc.expected) { - t.Errorf("encodeBytes(%s) = %v, want %v", tc.input, result, tc.expected) - } - }) - } -} diff --git a/services/go-filler/log-fetcher/internal/fetcher/fetcher.go b/services/go-filler/log-fetcher/internal/fetcher/fetcher.go index 2bf62c0..00f9245 100644 --- a/services/go-filler/log-fetcher/internal/fetcher/fetcher.go +++ b/services/go-filler/log-fetcher/internal/fetcher/fetcher.go @@ -9,15 +9,31 @@ import ( "syscall" "time" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/listener" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" "github.com/ethereum/go-ethereum/log" "github.com/urfave/cli/v2" + "gopkg.in/yaml.v2" ) func Main(ctx *cli.Context) error { log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelInfo, true))) + networksFile, err := os.ReadFile("log-fetcher/config/networks.yaml") + if err != nil { + log.Crit("Failed to read networks file", "error", err) + } + + // expand environment variables + networksFile = []byte(os.ExpandEnv(string(networksFile))) + + var cfg chains.NetworksConfig + err = yaml.Unmarshal(networksFile, &cfg) + if err != nil { + log.Crit("Failed to unmarshal networks file", "error", err) + } + queue, err := store.NewQueue(ctx) if err != nil { return err @@ -33,7 +49,7 @@ func Main(ctx *cli.Context) error { log.Crit("Failed to convert chainId to big.Int", "chainId", chainId) } - l, err := listener.NewListener(chainIdBigInt, ctx, queue) + l, err := listener.NewListener(chainIdBigInt, cfg.Networks, queue) if err != nil { log.Crit("Failed to create listener", "error", err) } diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go index 8b990bc..5dfcce0 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler.go +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -16,8 +16,8 @@ type handler struct { queue store.Queue } -func NewHandler(ctx chains.CliContext, srcChain *chains.ChainConfig, queue store.Queue) (Handler, error) { - return &handler{validator: validator.NewValidator(ctx, srcChain), queue: queue}, nil +func NewHandler(srcChain *chains.ChainConfig, networks chains.Networks, queue store.Queue) (Handler, error) { + return &handler{validator: validator.NewValidator(srcChain, networks), queue: queue}, nil } func (h *handler) HandleLog(log *bindings.RIP7755OutboxCrossChainCallRequested) error { diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index 3720160..0ae5eb6 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -30,13 +30,13 @@ type listener struct { wg sync.WaitGroup } -func NewListener(srcChainId *big.Int, ctx chains.CliContext, queue store.Queue) (Listener, error) { - srcChain, err := chains.GetChainConfig(srcChainId, ctx) +func NewListener(srcChainId *big.Int, networks chains.Networks, queue store.Queue) (Listener, error) { + srcChain, err := networks.GetChainConfig(srcChainId) if err != nil { return nil, err } - h, err := handler.NewHandler(ctx, srcChain, queue) + h, err := handler.NewHandler(srcChain, networks, queue) if err != nil { return nil, err } diff --git a/services/go-filler/log-fetcher/internal/listener/listener_test.go b/services/go-filler/log-fetcher/internal/listener/listener_test.go index 2f044c4..f34e341 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener_test.go +++ b/services/go-filler/log-fetcher/internal/listener/listener_test.go @@ -4,20 +4,27 @@ import ( "math/big" "testing" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/store" + "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" ) -type cliContext struct{} - -func (c *cliContext) String(name string) string { - return "https://arbitrum-sepolia.com" +var networksCfg chains.NetworksConfig = chains.NetworksConfig{ + Networks: chains.Networks{ + "421614": chains.ChainConfig{ + RpcUrl: "https://arb-sepolia.example.com", + Contracts: &chains.Contracts{ + Outbox: common.HexToAddress("0xBCd5762cF9B07EF5597014c350CE2efB2b0DB2D2"), + }, + }, + }, } var queue store.Queue func TestNewListener(t *testing.T) { - l, err := NewListener(big.NewInt(421614), &cliContext{}, queue) + l, err := NewListener(big.NewInt(421614), networksCfg.Networks, queue) if err != nil { t.Fatalf("Failed to create listener: %v", err) } diff --git a/services/go-filler/log-fetcher/internal/validator/validator.go b/services/go-filler/log-fetcher/internal/validator/validator.go index 5d148ef..8c8fe0c 100644 --- a/services/go-filler/log-fetcher/internal/validator/validator.go +++ b/services/go-filler/log-fetcher/internal/validator/validator.go @@ -15,19 +15,19 @@ type Validator interface { } type validator struct { - ctx chains.CliContext srcChain *chains.ChainConfig + networks chains.Networks } -func NewValidator(ctx chains.CliContext, srcChain *chains.ChainConfig) Validator { - return &validator{ctx: ctx, srcChain: srcChain} +func NewValidator(srcChain *chains.ChainConfig, networks chains.Networks) Validator { + return &validator{srcChain: srcChain, networks: networks} } func (v *validator) ValidateLog(log *bindings.RIP7755OutboxCrossChainCallRequested) error { logger.Info("Validating log") // - Confirm valid proverContract address on source chain - dstChain, err := chains.GetChainConfig(log.Request.DestinationChainId, v.ctx) + dstChain, err := v.networks.GetChainConfig(log.Request.DestinationChainId) if err != nil { return err } @@ -55,7 +55,7 @@ func (v *validator) ValidateLog(log *bindings.RIP7755OutboxCrossChainCallRequest if log.Request.L2Oracle != dstChain.L2Oracle { return errors.New("unknown Oracle contract for destination chain") } - if log.Request.L2OracleStorageKey != dstChain.L2OracleStorageKey { + if log.Request.L2OracleStorageKey != common.HexToHash(dstChain.L2OracleStorageKey) { return errors.New("unknown storage key for dst L2Oracle") } diff --git a/services/go-filler/log-fetcher/internal/validator/validator_test.go b/services/go-filler/log-fetcher/internal/validator/validator_test.go index 64c12c3..09f18ab 100644 --- a/services/go-filler/log-fetcher/internal/validator/validator_test.go +++ b/services/go-filler/log-fetcher/internal/validator/validator_test.go @@ -1,22 +1,36 @@ package validator import ( - "encoding/hex" - "log" "math/big" "testing" "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" - "github.com/urfave/cli/v2" ) -var ctx *cli.Context +var networksCfg chains.NetworksConfig = chains.NetworksConfig{ + Networks: chains.Networks{ + "421614": chains.ChainConfig{ + ProverContracts: map[string]common.Address{ + "OPStackProver": common.HexToAddress("0x1234567890123456789012345678901234567890"), + }, + }, + "84532": chains.ChainConfig{ + Contracts: &chains.Contracts{ + Inbox: common.HexToAddress("0xB482b292878FDe64691d028A2237B34e91c7c7ea"), + }, + L2Oracle: common.HexToAddress("0x4C8BA32A5DAC2A720bb35CeDB51D6B067D104205"), + L2OracleStorageKey: "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49", + TargetProver: config.OPStackProver, + }, + }, +} var srcChain = &chains.ChainConfig{ - ChainId: big.NewInt(42161), + ChainId: big.NewInt(421614), ProverContracts: map[string]common.Address{ "OPStackProver": common.HexToAddress("0x1234567890123456789012345678901234567890"), }, @@ -33,7 +47,7 @@ var parsedLog = &bindings.RIP7755OutboxCrossChainCallRequested{ DestinationChainId: big.NewInt(84532), InboxContract: common.HexToAddress("0xB482b292878FDe64691d028A2237B34e91c7c7ea"), L2Oracle: common.HexToAddress("0x4C8BA32A5DAC2A720bb35CeDB51D6B067D104205"), - L2OracleStorageKey: encodeBytes("a6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49"), + L2OracleStorageKey: common.HexToHash("0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49"), ProverContract: common.HexToAddress("0x1234567890123456789012345678901234567890"), RewardAsset: common.HexToAddress("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"), RewardAmount: big.NewInt(2000000000000000000), @@ -41,7 +55,7 @@ var parsedLog = &bindings.RIP7755OutboxCrossChainCallRequested{ } func TestValidateLog(t *testing.T) { - validator := NewValidator(ctx, srcChain) + validator := NewValidator(srcChain, networksCfg.Networks) err := validator.ValidateLog(parsedLog) @@ -49,7 +63,7 @@ func TestValidateLog(t *testing.T) { } func TestValidateLog_UnknownDestinationChain(t *testing.T) { - validator := NewValidator(ctx, srcChain) + validator := NewValidator(srcChain, networksCfg.Networks) prevDstChainId := parsedLog.Request.DestinationChainId parsedLog.Request.DestinationChainId = big.NewInt(11155112) @@ -61,7 +75,7 @@ func TestValidateLog_UnknownDestinationChain(t *testing.T) { } func TestValidateLog_UnknownProverName(t *testing.T) { - validator := NewValidator(ctx, srcChain) + validator := NewValidator(srcChain, networksCfg.Networks) prevDstChainId := parsedLog.Request.DestinationChainId parsedLog.Request.DestinationChainId = big.NewInt(11155111) @@ -73,7 +87,7 @@ func TestValidateLog_UnknownProverName(t *testing.T) { } func TestValidateLog_UnknownProverContract(t *testing.T) { - validator := NewValidator(ctx, srcChain) + validator := NewValidator(srcChain, networksCfg.Networks) prevProverContract := parsedLog.Request.ProverContract parsedLog.Request.ProverContract = common.HexToAddress("0x1234567890123456789012345678901234567891") @@ -85,7 +99,7 @@ func TestValidateLog_UnknownProverContract(t *testing.T) { } func TestValidateLog_UnknownInboxContract(t *testing.T) { - validator := NewValidator(ctx, srcChain) + validator := NewValidator(srcChain, networksCfg.Networks) prevInboxContract := parsedLog.Request.InboxContract parsedLog.Request.InboxContract = common.HexToAddress("0x1234567890123456789012345678901234567891") @@ -97,7 +111,7 @@ func TestValidateLog_UnknownInboxContract(t *testing.T) { } func TestValidateLog_UnknownL2Oracle(t *testing.T) { - validator := NewValidator(ctx, srcChain) + validator := NewValidator(srcChain, networksCfg.Networks) prevL2Oracle := parsedLog.Request.L2Oracle parsedLog.Request.L2Oracle = common.HexToAddress("0x1234567890123456789012345678901234567891") @@ -109,10 +123,10 @@ func TestValidateLog_UnknownL2Oracle(t *testing.T) { } func TestValidateLog_UnknownL2OracleStorageKey(t *testing.T) { - validator := NewValidator(ctx, srcChain) + validator := NewValidator(srcChain, networksCfg.Networks) prevL2OracleStorageKey := parsedLog.Request.L2OracleStorageKey - parsedLog.Request.L2OracleStorageKey = encodeBytes("1234567890123456789012345678901234567891") + parsedLog.Request.L2OracleStorageKey = common.HexToHash("0x1234567890123456789012345678901234567891") defer func() { parsedLog.Request.L2OracleStorageKey = prevL2OracleStorageKey }() err := validator.ValidateLog(parsedLog) @@ -121,7 +135,7 @@ func TestValidateLog_UnknownL2OracleStorageKey(t *testing.T) { } func TestValidateLog_InvalidReward_NotNativeAsset(t *testing.T) { - validator := NewValidator(ctx, srcChain) + validator := NewValidator(srcChain, networksCfg.Networks) prevRewardAsset := parsedLog.Request.RewardAsset parsedLog.Request.RewardAsset = common.HexToAddress("0x1234567890123456789012345678901234567891") @@ -133,7 +147,7 @@ func TestValidateLog_InvalidReward_NotNativeAsset(t *testing.T) { } func TestValidateLog_InvalidReward_NotGreaterThanValueNeeded(t *testing.T) { - validator := NewValidator(ctx, srcChain) + validator := NewValidator(srcChain, networksCfg.Networks) prevRewardAmount := parsedLog.Request.RewardAmount parsedLog.Request.RewardAmount = big.NewInt(1000000000000000000) @@ -143,14 +157,3 @@ func TestValidateLog_InvalidReward_NotGreaterThanValueNeeded(t *testing.T) { assert.Error(t, err) } - -func encodeBytes(bytesStr string) [32]byte { - bytes, err := hex.DecodeString(bytesStr) - if err != nil { - log.Fatal(err) - } - - var byteArray [32]byte - copy(byteArray[32-len(bytes):], bytes) - return byteArray -} From ca20118d8f829a822cd942ffcdd5b09f5319860d Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Thu, 21 Nov 2024 11:59:21 -0500 Subject: [PATCH 33/36] change provers type to string --- .../log-fetcher/config/networks.yaml | 8 ++++---- .../log-fetcher/internal/chains/config.go | 4 ++-- .../internal/chains/config_test.go | 10 +++++----- .../log-fetcher/internal/config/provers.go | 19 ------------------- .../log-fetcher/internal/provers/provers.go | 9 +++++++++ .../internal/validator/validator.go | 2 +- .../internal/validator/validator_test.go | 4 ++-- 7 files changed, 23 insertions(+), 33 deletions(-) delete mode 100644 services/go-filler/log-fetcher/internal/config/provers.go create mode 100644 services/go-filler/log-fetcher/internal/provers/provers.go diff --git a/services/go-filler/log-fetcher/config/networks.yaml b/services/go-filler/log-fetcher/config/networks.yaml index 32e752f..89c5720 100644 --- a/services/go-filler/log-fetcher/config/networks.yaml +++ b/services/go-filler/log-fetcher/config/networks.yaml @@ -9,7 +9,7 @@ networks: contracts: inbox: 0xeE962eD1671F655a806cB22623eEA8A7cCc233bC outbox: 0xBCd5762cF9B07EF5597014c350CE2efB2b0DB2D2 - target-prover: 1 + target-prover: ArbitrumProver 84532: # Base Sepolia chain-id: 84532 prover-contracts: @@ -21,7 +21,7 @@ networks: contracts: inbox: 0xB482b292878FDe64691d028A2237B34e91c7c7ea outbox: 0xD7a5A114A07cC4B5ebd9C5e1cD1136a99fFA3d68 - target-prover: 2 + target-prover: OPStackProver 11155420: # Optimism Sepolia chain-id: 11155420 prover-contracts: @@ -31,7 +31,7 @@ networks: contracts: inbox: 0x49E2cDC9e81825B6C718ae8244fe0D5b062F4874 l2-message-passer: 0x4200000000000000000000000000000000000016 - target-prover: 2 + target-prover: OPStackProver 11155111: # Sepolia chain-id: 11155111 prover-contracts: @@ -39,4 +39,4 @@ networks: contracts: anchor-state-registry: 0x218CD9489199F321E1177b56385d333c5B598629 arb-rollup: 0xd80810638dbDF9081b72C1B33c65375e807281C8 - target-prover: 0 + target-prover: None diff --git a/services/go-filler/log-fetcher/internal/chains/config.go b/services/go-filler/log-fetcher/internal/chains/config.go index eed2aaa..ab79abc 100644 --- a/services/go-filler/log-fetcher/internal/chains/config.go +++ b/services/go-filler/log-fetcher/internal/chains/config.go @@ -4,7 +4,7 @@ import ( "fmt" "math/big" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/provers" "github.com/ethereum/go-ethereum/common" ) @@ -28,7 +28,7 @@ type ChainConfig struct { L2Oracle common.Address `yaml:"l2-oracle"` L2OracleStorageKey string `yaml:"l2-oracle-storage-key"` Contracts *Contracts `yaml:"contracts"` - TargetProver config.Prover `yaml:"target-prover"` + TargetProver provers.Prover `yaml:"target-prover"` } func (n *Networks) GetChainConfig(chainId *big.Int) (*ChainConfig, error) { diff --git a/services/go-filler/log-fetcher/internal/chains/config_test.go b/services/go-filler/log-fetcher/internal/chains/config_test.go index 6e7cd88..9030c51 100644 --- a/services/go-filler/log-fetcher/internal/chains/config_test.go +++ b/services/go-filler/log-fetcher/internal/chains/config_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/provers" "github.com/ethereum/go-ethereum/common" ) @@ -22,7 +22,7 @@ func TestGetChainConfig(t *testing.T) { expected: &ChainConfig{ ChainId: big.NewInt(421614), ProverContracts: map[string]common.Address{ - config.OPStackProver.String(): common.HexToAddress("0x062fBdCfd17A0346D2A9d89FE233bbAdBd1DC14C"), + string(provers.OPStackProver): common.HexToAddress("0x062fBdCfd17A0346D2A9d89FE233bbAdBd1DC14C"), }, RpcUrl: "https://arb-sepolia.example.com", L2Oracle: common.HexToAddress("0xd80810638dbDF9081b72C1B33c65375e807281C8"), @@ -31,13 +31,13 @@ func TestGetChainConfig(t *testing.T) { Inbox: common.HexToAddress("0xeE962eD1671F655a806cB22623eEA8A7cCc233bC"), Outbox: common.HexToAddress("0xBCd5762cF9B07EF5597014c350CE2efB2b0DB2D2"), }, - TargetProver: config.ArbitrumProver, + TargetProver: provers.ArbitrumProver, }, networks: Networks{ "421614": { ChainId: big.NewInt(421614), ProverContracts: map[string]common.Address{ - config.OPStackProver.String(): common.HexToAddress("0x062fBdCfd17A0346D2A9d89FE233bbAdBd1DC14C"), + string(provers.OPStackProver): common.HexToAddress("0x062fBdCfd17A0346D2A9d89FE233bbAdBd1DC14C"), }, RpcUrl: "https://arb-sepolia.example.com", L2Oracle: common.HexToAddress("0xd80810638dbDF9081b72C1B33c65375e807281C8"), @@ -46,7 +46,7 @@ func TestGetChainConfig(t *testing.T) { Inbox: common.HexToAddress("0xeE962eD1671F655a806cB22623eEA8A7cCc233bC"), Outbox: common.HexToAddress("0xBCd5762cF9B07EF5597014c350CE2efB2b0DB2D2"), }, - TargetProver: config.ArbitrumProver, + TargetProver: provers.ArbitrumProver, }, }, }, diff --git a/services/go-filler/log-fetcher/internal/config/provers.go b/services/go-filler/log-fetcher/internal/config/provers.go deleted file mode 100644 index c1fc2ca..0000000 --- a/services/go-filler/log-fetcher/internal/config/provers.go +++ /dev/null @@ -1,19 +0,0 @@ -package config - -type Prover int - -const ( - NilProver Prover = iota - ArbitrumProver - OPStackProver -) - -var proverName = map[Prover]string{ - NilProver: "None", - ArbitrumProver: "ArbitrumProver", - OPStackProver: "OPStackProver", -} - -func (ss Prover) String() string { - return proverName[ss] -} diff --git a/services/go-filler/log-fetcher/internal/provers/provers.go b/services/go-filler/log-fetcher/internal/provers/provers.go new file mode 100644 index 0000000..280b765 --- /dev/null +++ b/services/go-filler/log-fetcher/internal/provers/provers.go @@ -0,0 +1,9 @@ +package provers + +type Prover string + +const ( + NilProver Prover = "None" + ArbitrumProver Prover = "ArbitrumProver" + OPStackProver Prover = "OPStackProver" +) diff --git a/services/go-filler/log-fetcher/internal/validator/validator.go b/services/go-filler/log-fetcher/internal/validator/validator.go index 8c8fe0c..801f954 100644 --- a/services/go-filler/log-fetcher/internal/validator/validator.go +++ b/services/go-filler/log-fetcher/internal/validator/validator.go @@ -32,7 +32,7 @@ func (v *validator) ValidateLog(log *bindings.RIP7755OutboxCrossChainCallRequest return err } - proverName := dstChain.TargetProver.String() + proverName := string(dstChain.TargetProver) if proverName == "" { return errors.New("destination chain missing Prover name") } diff --git a/services/go-filler/log-fetcher/internal/validator/validator_test.go b/services/go-filler/log-fetcher/internal/validator/validator_test.go index 09f18ab..8487fd2 100644 --- a/services/go-filler/log-fetcher/internal/validator/validator_test.go +++ b/services/go-filler/log-fetcher/internal/validator/validator_test.go @@ -6,7 +6,7 @@ import ( "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" - "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/config" + "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/provers" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" ) @@ -24,7 +24,7 @@ var networksCfg chains.NetworksConfig = chains.NetworksConfig{ }, L2Oracle: common.HexToAddress("0x4C8BA32A5DAC2A720bb35CeDB51D6B067D104205"), L2OracleStorageKey: "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49", - TargetProver: config.OPStackProver, + TargetProver: provers.OPStackProver, }, }, } From 22c9140e6efeb4126c0dba6379982e88b97bbe98 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Thu, 21 Nov 2024 16:43:41 -0500 Subject: [PATCH 34/36] add support for http providers --- .../log-fetcher/config/networks.yaml | 6 +- .../log-fetcher/internal/fetcher/fetcher.go | 5 +- .../log-fetcher/internal/listener/listener.go | 93 ++++++++++++++++--- .../log-fetcher/internal/provers/provers.go | 4 +- .../internal/validator/validator_test.go | 4 +- 5 files changed, 90 insertions(+), 22 deletions(-) diff --git a/services/go-filler/log-fetcher/config/networks.yaml b/services/go-filler/log-fetcher/config/networks.yaml index 89c5720..93f0b92 100644 --- a/services/go-filler/log-fetcher/config/networks.yaml +++ b/services/go-filler/log-fetcher/config/networks.yaml @@ -9,7 +9,7 @@ networks: contracts: inbox: 0xeE962eD1671F655a806cB22623eEA8A7cCc233bC outbox: 0xBCd5762cF9B07EF5597014c350CE2efB2b0DB2D2 - target-prover: ArbitrumProver + target-prover: Arbitrum 84532: # Base Sepolia chain-id: 84532 prover-contracts: @@ -21,7 +21,7 @@ networks: contracts: inbox: 0xB482b292878FDe64691d028A2237B34e91c7c7ea outbox: 0xD7a5A114A07cC4B5ebd9C5e1cD1136a99fFA3d68 - target-prover: OPStackProver + target-prover: OPStack 11155420: # Optimism Sepolia chain-id: 11155420 prover-contracts: @@ -31,7 +31,7 @@ networks: contracts: inbox: 0x49E2cDC9e81825B6C718ae8244fe0D5b062F4874 l2-message-passer: 0x4200000000000000000000000000000000000016 - target-prover: OPStackProver + target-prover: OPStack 11155111: # Sepolia chain-id: 11155111 prover-contracts: diff --git a/services/go-filler/log-fetcher/internal/fetcher/fetcher.go b/services/go-filler/log-fetcher/internal/fetcher/fetcher.go index 00f9245..221ad7c 100644 --- a/services/go-filler/log-fetcher/internal/fetcher/fetcher.go +++ b/services/go-filler/log-fetcher/internal/fetcher/fetcher.go @@ -7,7 +7,6 @@ import ( "os/signal" "sync" "syscall" - "time" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/listener" @@ -55,9 +54,7 @@ func Main(ctx *cli.Context) error { } wg.Add(1) - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - err = l.Start(ctx) - cancel() + err = l.Start() if err != nil { log.Crit("Failed to start listener", "error", err) } diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index 0ae5eb6..4b98e44 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -4,7 +4,9 @@ import ( "context" "fmt" "math/big" + "regexp" "sync" + "time" "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" "github.com/base-org/RIP-7755-poc/services/go-filler/log-fetcher/internal/chains" @@ -18,18 +20,23 @@ import ( ) type Listener interface { - Start(ctx context.Context) error + Start() error Stop() } type listener struct { - outbox *bindings.RIP7755Outbox - handler handler.Handler - logs chan *bindings.RIP7755OutboxCrossChainCallRequested - stop chan struct{} - wg sync.WaitGroup + outbox *bindings.RIP7755Outbox + handler handler.Handler + logs chan *bindings.RIP7755OutboxCrossChainCallRequested + stop chan struct{} + wg sync.WaitGroup + pollRate time.Duration + pollReqCh chan struct{} + polling bool } +var httpRegex = regexp.MustCompile("^http(s)?://") + func NewListener(srcChainId *big.Int, networks chains.Networks, queue store.Queue) (Listener, error) { srcChain, err := networks.GetChainConfig(srcChainId) if err != nil { @@ -56,14 +63,25 @@ func NewListener(srcChainId *big.Int, networks chains.Networks, queue store.Queu } return &listener{ - outbox: outbox, - handler: h, - logs: make(chan *bindings.RIP7755OutboxCrossChainCallRequested), - stop: make(chan struct{}), + outbox: outbox, + handler: h, + logs: make(chan *bindings.RIP7755OutboxCrossChainCallRequested), + stop: make(chan struct{}), + pollReqCh: make(chan struct{}, 1), + pollRate: 3 * time.Second, + polling: httpRegex.MatchString(srcChain.RpcUrl), }, nil } -func (l *listener) Start(ctx context.Context) error { +func (l *listener) Start() error { + if l.polling { + return pollListener(l) + } + + return webSocketListener(l) +} + +func webSocketListener(l *listener) error { sub, err := l.outbox.WatchCrossChainCallRequested(&bind.WatchOpts{}, l.logs, [][32]byte{}) if err != nil { return fmt.Errorf("failed to subscribe to logs: %v", err) @@ -77,6 +95,55 @@ func (l *listener) Start(ctx context.Context) error { return nil } +func pollListener(l *listener) error { + logger.Info("Polling for logs") + reqPollAfter := func() { + if l.pollRate == 0 { + return + } + time.AfterFunc(l.pollRate, l.reqPoll) + } + + reqPollAfter() + + for { + select { + case <-l.pollReqCh: + logger.Info("Running") + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + logIterator, err := l.outbox.FilterCrossChainCallRequested(&bind.FilterOpts{Context: ctx}, [][32]byte{}) + if err != nil { + logger.Error("failed to filter logs", "error", err) + cancel() + logIterator.Close() + reqPollAfter() + continue + } + + for logIterator.Next() { + err := logIterator.Error() + if err != nil { + logger.Error("error iterating over logs", "error", err) + continue + } + + log := logIterator.Event + err = l.handler.HandleLog(log) + if err != nil { + logger.Error("failed to handle log", "error", err) + continue + } + } + + cancel() + logIterator.Close() + reqPollAfter() + case <-l.stop: + return nil + } + } +} + func (l *listener) loop(sub ethereum.Subscription) { defer l.wg.Done() for { @@ -103,3 +170,7 @@ func (l *listener) Stop() { close(l.stop) l.wg.Wait() } + +func (l *listener) reqPoll() { + l.pollReqCh <- struct{}{} +} diff --git a/services/go-filler/log-fetcher/internal/provers/provers.go b/services/go-filler/log-fetcher/internal/provers/provers.go index 280b765..895e010 100644 --- a/services/go-filler/log-fetcher/internal/provers/provers.go +++ b/services/go-filler/log-fetcher/internal/provers/provers.go @@ -4,6 +4,6 @@ type Prover string const ( NilProver Prover = "None" - ArbitrumProver Prover = "ArbitrumProver" - OPStackProver Prover = "OPStackProver" + ArbitrumProver Prover = "Arbitrum" + OPStackProver Prover = "OPStack" ) diff --git a/services/go-filler/log-fetcher/internal/validator/validator_test.go b/services/go-filler/log-fetcher/internal/validator/validator_test.go index 8487fd2..eaa0ecf 100644 --- a/services/go-filler/log-fetcher/internal/validator/validator_test.go +++ b/services/go-filler/log-fetcher/internal/validator/validator_test.go @@ -15,7 +15,7 @@ var networksCfg chains.NetworksConfig = chains.NetworksConfig{ Networks: chains.Networks{ "421614": chains.ChainConfig{ ProverContracts: map[string]common.Address{ - "OPStackProver": common.HexToAddress("0x1234567890123456789012345678901234567890"), + "OPStack": common.HexToAddress("0x1234567890123456789012345678901234567890"), }, }, "84532": chains.ChainConfig{ @@ -32,7 +32,7 @@ var networksCfg chains.NetworksConfig = chains.NetworksConfig{ var srcChain = &chains.ChainConfig{ ChainId: big.NewInt(421614), ProverContracts: map[string]common.Address{ - "OPStackProver": common.HexToAddress("0x1234567890123456789012345678901234567890"), + "OPStack": common.HexToAddress("0x1234567890123456789012345678901234567890"), }, } From ae1c7966c904034a985324d0bb76ca65bf01645e Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Thu, 21 Nov 2024 17:25:23 -0500 Subject: [PATCH 35/36] add blockNumber checkpoint handling --- .../log-fetcher/internal/fetcher/fetcher.go | 7 ++- .../log-fetcher/internal/handler/handler.go | 9 +++- .../internal/handler/handler_test.go | 35 +++++++++++++-- .../log-fetcher/internal/listener/listener.go | 44 ++++++++++--------- .../internal/listener/listener_test.go | 2 +- .../internal/store/mongo_client.go | 43 +++++++++++++++++- .../internal/store/mongo_client_test.go | 10 +++++ 7 files changed, 121 insertions(+), 29 deletions(-) diff --git a/services/go-filler/log-fetcher/internal/fetcher/fetcher.go b/services/go-filler/log-fetcher/internal/fetcher/fetcher.go index 221ad7c..f15bde8 100644 --- a/services/go-filler/log-fetcher/internal/fetcher/fetcher.go +++ b/services/go-filler/log-fetcher/internal/fetcher/fetcher.go @@ -48,7 +48,12 @@ func Main(ctx *cli.Context) error { log.Crit("Failed to convert chainId to big.Int", "chainId", chainId) } - l, err := listener.NewListener(chainIdBigInt, cfg.Networks, queue) + checkpoint, err := queue.ReadCheckpoint(chainId) + if err != nil { + log.Crit("Failed to read checkpoint", "error", err) + } + + l, err := listener.NewListener(chainIdBigInt, cfg.Networks, queue, checkpoint) if err != nil { log.Crit("Failed to create listener", "error", err) } diff --git a/services/go-filler/log-fetcher/internal/handler/handler.go b/services/go-filler/log-fetcher/internal/handler/handler.go index 5dfcce0..1e93c5d 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler.go +++ b/services/go-filler/log-fetcher/internal/handler/handler.go @@ -8,7 +8,7 @@ import ( ) type Handler interface { - HandleLog(*bindings.RIP7755OutboxCrossChainCallRequested) error + HandleLog(chainId string, log *bindings.RIP7755OutboxCrossChainCallRequested) error } type handler struct { @@ -20,7 +20,7 @@ func NewHandler(srcChain *chains.ChainConfig, networks chains.Networks, queue st return &handler{validator: validator.NewValidator(srcChain, networks), queue: queue}, nil } -func (h *handler) HandleLog(log *bindings.RIP7755OutboxCrossChainCallRequested) error { +func (h *handler) HandleLog(chainId string, log *bindings.RIP7755OutboxCrossChainCallRequested) error { err := h.validator.ValidateLog(log) if err != nil { return err @@ -31,5 +31,10 @@ func (h *handler) HandleLog(log *bindings.RIP7755OutboxCrossChainCallRequested) return err } + err = h.queue.WriteCheckpoint(chainId, log.Raw.BlockNumber) + if err != nil { + return err + } + return nil } diff --git a/services/go-filler/log-fetcher/internal/handler/handler_test.go b/services/go-filler/log-fetcher/internal/handler/handler_test.go index 7abb7a8..1a8258b 100644 --- a/services/go-filler/log-fetcher/internal/handler/handler_test.go +++ b/services/go-filler/log-fetcher/internal/handler/handler_test.go @@ -27,6 +27,16 @@ func (q *QueueMock) Enqueue(log *bindings.RIP7755OutboxCrossChainCallRequested) return args.Error(0) } +func (q *QueueMock) ReadCheckpoint(checkpointId string) (uint64, error) { + args := q.Called(checkpointId) + return args.Get(0).(uint64), args.Error(1) +} + +func (q *QueueMock) WriteCheckpoint(checkpointId string, blockNumber uint64) error { + args := q.Called(checkpointId, blockNumber) + return args.Error(0) +} + func (q *QueueMock) Close() error { args := q.Called() return args.Error(0) @@ -40,10 +50,10 @@ func TestHandler(t *testing.T) { validatorMock.On("ValidateLog", log).Return(nil) queueMock.On("Enqueue", log).Return(nil) - + queueMock.On("WriteCheckpoint", "test", log.Raw.BlockNumber).Return(nil) handler := &handler{validator: validatorMock, queue: queueMock} - err := handler.HandleLog(log) + err := handler.HandleLog("test", log) assert.NoError(t, err) @@ -61,7 +71,7 @@ func TestHandlerReturnsErrorFromValidator(t *testing.T) { handler := &handler{validator: validatorMock, queue: queueMock} - err := handler.HandleLog(log) + err := handler.HandleLog("test", log) assert.Error(t, err) } @@ -77,7 +87,24 @@ func TestHandlerReturnsErrorFromQueue(t *testing.T) { handler := &handler{validator: validatorMock, queue: queueMock} - err := handler.HandleLog(log) + err := handler.HandleLog("test", log) + + assert.Error(t, err) +} + +func TestHandlerReturnsErrorFromWriteCheckpoint(t *testing.T) { + validatorMock := new(ValidatorMock) + queueMock := new(QueueMock) + + log := &bindings.RIP7755OutboxCrossChainCallRequested{} + + validatorMock.On("ValidateLog", log).Return(nil) + queueMock.On("Enqueue", log).Return(nil) + queueMock.On("WriteCheckpoint", "test", log.Raw.BlockNumber).Return(errors.New("test error")) + + handler := &handler{validator: validatorMock, queue: queueMock} + + err := handler.HandleLog("test", log) assert.Error(t, err) } diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index 4b98e44..b7adaee 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -25,19 +25,21 @@ type Listener interface { } type listener struct { - outbox *bindings.RIP7755Outbox - handler handler.Handler - logs chan *bindings.RIP7755OutboxCrossChainCallRequested - stop chan struct{} - wg sync.WaitGroup - pollRate time.Duration - pollReqCh chan struct{} - polling bool + outbox *bindings.RIP7755Outbox + handler handler.Handler + logs chan *bindings.RIP7755OutboxCrossChainCallRequested + stop chan struct{} + wg sync.WaitGroup + pollRate time.Duration + pollReqCh chan struct{} + polling bool + startingBlock uint64 + srcChainId string } var httpRegex = regexp.MustCompile("^http(s)?://") -func NewListener(srcChainId *big.Int, networks chains.Networks, queue store.Queue) (Listener, error) { +func NewListener(srcChainId *big.Int, networks chains.Networks, queue store.Queue, startingBlock uint64) (Listener, error) { srcChain, err := networks.GetChainConfig(srcChainId) if err != nil { return nil, err @@ -63,13 +65,15 @@ func NewListener(srcChainId *big.Int, networks chains.Networks, queue store.Queu } return &listener{ - outbox: outbox, - handler: h, - logs: make(chan *bindings.RIP7755OutboxCrossChainCallRequested), - stop: make(chan struct{}), - pollReqCh: make(chan struct{}, 1), - pollRate: 3 * time.Second, - polling: httpRegex.MatchString(srcChain.RpcUrl), + outbox: outbox, + handler: h, + logs: make(chan *bindings.RIP7755OutboxCrossChainCallRequested), + stop: make(chan struct{}), + pollReqCh: make(chan struct{}, 1), + pollRate: 3 * time.Second, + polling: httpRegex.MatchString(srcChain.RpcUrl), + startingBlock: startingBlock, + srcChainId: srcChainId.String(), }, nil } @@ -82,7 +86,7 @@ func (l *listener) Start() error { } func webSocketListener(l *listener) error { - sub, err := l.outbox.WatchCrossChainCallRequested(&bind.WatchOpts{}, l.logs, [][32]byte{}) + sub, err := l.outbox.WatchCrossChainCallRequested(&bind.WatchOpts{Start: &l.startingBlock}, l.logs, [][32]byte{}) if err != nil { return fmt.Errorf("failed to subscribe to logs: %v", err) } @@ -111,7 +115,7 @@ func pollListener(l *listener) error { case <-l.pollReqCh: logger.Info("Running") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - logIterator, err := l.outbox.FilterCrossChainCallRequested(&bind.FilterOpts{Context: ctx}, [][32]byte{}) + logIterator, err := l.outbox.FilterCrossChainCallRequested(&bind.FilterOpts{Context: ctx, Start: l.startingBlock}, [][32]byte{}) if err != nil { logger.Error("failed to filter logs", "error", err) cancel() @@ -128,7 +132,7 @@ func pollListener(l *listener) error { } log := logIterator.Event - err = l.handler.HandleLog(log) + err = l.handler.HandleLog(l.srcChainId, log) if err != nil { logger.Error("failed to handle log", "error", err) continue @@ -155,7 +159,7 @@ func (l *listener) loop(sub ethereum.Subscription) { logger.Info("Log Block Number", "blockNumber", log.Raw.BlockNumber) logger.Info("Log Index", "index", log.Raw.Index) - err := l.handler.HandleLog(log) + err := l.handler.HandleLog(l.srcChainId, log) if err != nil { logger.Error("Error handling log", "error", err) } diff --git a/services/go-filler/log-fetcher/internal/listener/listener_test.go b/services/go-filler/log-fetcher/internal/listener/listener_test.go index f34e341..d3d31bc 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener_test.go +++ b/services/go-filler/log-fetcher/internal/listener/listener_test.go @@ -24,7 +24,7 @@ var networksCfg chains.NetworksConfig = chains.NetworksConfig{ var queue store.Queue func TestNewListener(t *testing.T) { - l, err := NewListener(big.NewInt(421614), networksCfg.Networks, queue) + l, err := NewListener(big.NewInt(421614), networksCfg.Networks, queue, 0) if err != nil { t.Fatalf("Failed to create listener: %v", err) } diff --git a/services/go-filler/log-fetcher/internal/store/mongo_client.go b/services/go-filler/log-fetcher/internal/store/mongo_client.go index 3541561..21d4bb5 100644 --- a/services/go-filler/log-fetcher/internal/store/mongo_client.go +++ b/services/go-filler/log-fetcher/internal/store/mongo_client.go @@ -6,17 +6,22 @@ import ( "github.com/base-org/RIP-7755-poc/services/go-filler/bindings" logger "github.com/ethereum/go-ethereum/log" "github.com/urfave/cli/v2" + "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) type Queue interface { Enqueue(*bindings.RIP7755OutboxCrossChainCallRequested) error + ReadCheckpoint(checkpointId string) (uint64, error) + WriteCheckpoint(checkpointId string, blockNumber uint64) error Close() error } type MongoCollection interface { InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error) + UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error) + FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult } type MongoDriverClient interface { @@ -27,6 +32,7 @@ type MongoDriverClient interface { type queue struct { client MongoDriverClient collection MongoCollection + checkpoint MongoCollection } type record struct { @@ -34,13 +40,17 @@ type record struct { Request bindings.CrossChainRequest } +type checkpoint struct { + BlockNumber uint64 +} + func NewQueue(ctx *cli.Context) (Queue, error) { client, err := connect(ctx) if err != nil { return nil, err } - return &queue{client: client, collection: client.Database("calls").Collection("requests")}, nil + return &queue{client: client, collection: client.Database("calls").Collection("requests"), checkpoint: client.Database("calls").Collection("checkpoint")}, nil } func (q *queue) Enqueue(log *bindings.RIP7755OutboxCrossChainCallRequested) error { @@ -60,6 +70,37 @@ func (q *queue) Enqueue(log *bindings.RIP7755OutboxCrossChainCallRequested) erro return nil } +func (q *queue) ReadCheckpoint(checkpointId string) (uint64, error) { + res := q.checkpoint.FindOne(context.TODO(), bson.M{"id": checkpointId}) + if res.Err() != nil { + // If the checkpoint doesn't exist, return 0 as starting block + if res.Err() == mongo.ErrNoDocuments { + return 0, nil + } + return 0, res.Err() + } + + var c checkpoint + if err := res.Decode(&c); err != nil { + return 0, err + } + + return c.BlockNumber, nil +} + +func (q *queue) WriteCheckpoint(checkpointId string, blockNumber uint64) error { + c := checkpoint{ + BlockNumber: blockNumber, + } + opts := options.Update().SetUpsert(true) + _, err := q.checkpoint.UpdateOne(context.TODO(), bson.M{"id": checkpointId}, bson.M{"$set": c}, opts) + if err != nil { + return err + } + + return nil +} + func (q *queue) Close() error { return q.client.Disconnect(context.TODO()) } diff --git a/services/go-filler/log-fetcher/internal/store/mongo_client_test.go b/services/go-filler/log-fetcher/internal/store/mongo_client_test.go index 81e131d..ac2c701 100644 --- a/services/go-filler/log-fetcher/internal/store/mongo_client_test.go +++ b/services/go-filler/log-fetcher/internal/store/mongo_client_test.go @@ -25,6 +25,16 @@ func (c *MongoConnectionMock) InsertOne(ctx context.Context, document interface{ return args.Get(0).(*mongo.InsertOneResult), args.Error(1) } +func (c *MongoConnectionMock) UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error) { + args := c.Called(ctx, filter, update, opts) + return args.Get(0).(*mongo.UpdateResult), args.Error(1) +} + +func (c *MongoConnectionMock) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult { + args := c.Called(ctx, filter, opts) + return args.Get(0).(*mongo.SingleResult) +} + func (m *MongoClientMock) Database(name string, opts ...*options.DatabaseOptions) *mongo.Database { args := m.Called(name, opts) return args.Get(0).(*mongo.Database) From f19cea04c4c9712d4811cd37b7f0ad338d6f2ab1 Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Thu, 21 Nov 2024 17:46:04 -0500 Subject: [PATCH 36/36] add mongo client tests --- .../log-fetcher/internal/fetcher/fetcher.go | 2 +- .../log-fetcher/internal/listener/listener.go | 1 - .../internal/store/mongo_client_test.go | 25 +++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/services/go-filler/log-fetcher/internal/fetcher/fetcher.go b/services/go-filler/log-fetcher/internal/fetcher/fetcher.go index f15bde8..e727084 100644 --- a/services/go-filler/log-fetcher/internal/fetcher/fetcher.go +++ b/services/go-filler/log-fetcher/internal/fetcher/fetcher.go @@ -53,7 +53,7 @@ func Main(ctx *cli.Context) error { log.Crit("Failed to read checkpoint", "error", err) } - l, err := listener.NewListener(chainIdBigInt, cfg.Networks, queue, checkpoint) + l, err := listener.NewListener(chainIdBigInt, cfg.Networks, queue, checkpoint+1) if err != nil { log.Crit("Failed to create listener", "error", err) } diff --git a/services/go-filler/log-fetcher/internal/listener/listener.go b/services/go-filler/log-fetcher/internal/listener/listener.go index b7adaee..128f686 100644 --- a/services/go-filler/log-fetcher/internal/listener/listener.go +++ b/services/go-filler/log-fetcher/internal/listener/listener.go @@ -113,7 +113,6 @@ func pollListener(l *listener) error { for { select { case <-l.pollReqCh: - logger.Info("Running") ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) logIterator, err := l.outbox.FilterCrossChainCallRequested(&bind.FilterOpts{Context: ctx, Start: l.startingBlock}, [][32]byte{}) if err != nil { diff --git a/services/go-filler/log-fetcher/internal/store/mongo_client_test.go b/services/go-filler/log-fetcher/internal/store/mongo_client_test.go index ac2c701..909c776 100644 --- a/services/go-filler/log-fetcher/internal/store/mongo_client_test.go +++ b/services/go-filler/log-fetcher/internal/store/mongo_client_test.go @@ -84,6 +84,31 @@ func TestEnqueueError(t *testing.T) { assert.Error(t, err) } +func TestReadCheckpoint(t *testing.T) { + mockConnection := new(MongoConnectionMock) + queue := &queue{checkpoint: mockConnection} + + mockConnection.On("FindOne", mock.Anything, mock.Anything, mock.Anything).Return(&mongo.SingleResult{}) + + checkpoint, err := queue.ReadCheckpoint("test") + + assert.NoError(t, err) + assert.Equal(t, uint64(0), checkpoint) + mockConnection.AssertExpectations(t) +} + +func TestWriteCheckpoint(t *testing.T) { + mockConnection := new(MongoConnectionMock) + queue := &queue{checkpoint: mockConnection} + + mockConnection.On("UpdateOne", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&mongo.UpdateResult{}, nil) + + err := queue.WriteCheckpoint("test", 1) + + assert.NoError(t, err) + mockConnection.AssertExpectations(t) +} + func TestClose(t *testing.T) { mockClient := new(MongoClientMock) queue := &queue{client: mockClient}