diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..a382a0e6 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,77 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "main" ] + schedule: + - cron: '17 5 * * 1' + +env: + GO_VERSION: '1.21.1' + +jobs: + analyze: + name: Analyze + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners + # Consider using larger runners for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go' ] + # CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ] + # Use only 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + - uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Build binary + run: | + make build + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/docs/bootstrapper.md b/docs/bootstrapper.md index a04e4ddc..43ce1cdd 100644 --- a/docs/bootstrapper.md +++ b/docs/bootstrapper.md @@ -19,7 +19,7 @@ blobstream bootstrapper init By default, the store will be created un `~/.bootstrapper`. However, if you want to specify a custom location, you can use the `--home` flag. Or, you can use the following environment variable: | Variable | Explanation | Default value | Required | -|---------------------|-------------------------------------|-------------------|----------| +| ------------------- | ----------------------------------- | ----------------- | -------- | | `BOOTSTRAPPER_HOME` | Home directory for the bootstrapper | `~/.bootstrapper` | Optional | ### Add keys diff --git a/docs/deploy.md b/docs/deploy.md index 5c007633..066b3ec9 100644 --- a/docs/deploy.md +++ b/docs/deploy.md @@ -70,6 +70,6 @@ The `latest` can be replaced by the following: - `latest`: to deploy the Blobstream contract starting from the latest validator set. - `earliest`: to deploy the Blobstream contract starting from genesis. -- `nonce`: you can provide a custom nonce on where you want the Blobstream to start. If the provided nonce is not a `Valset` attestation, then the one before it will be used to deploy the Blobstream smart contract. +- `nonce`: you can provide a custom nonce on where you want Blobstream to start. If the provided nonce is not a `Valset` attestation, then the one before it will be used to deploy the Blobstream smart contract. And, now you will see the Blobstream smart contract address in the logs along with the transaction hash. diff --git a/docs/keys.md b/docs/keys.md index e81912a7..720d7c2d 100644 --- a/docs/keys.md +++ b/docs/keys.md @@ -13,25 +13,25 @@ The Blobstream `keys` command allows managing EVM private keys and P2P identitie The `blobstream orchestrator keys` command manages keys for the orchestrator. By default, it uses the orchestrator default home directory to store the keys: `~/.orchestrator/keystore`. However, the default home can be changed either by specifying a different directory using the `--home` flag or setting the following environment variable: -| Variable | Explanation | Default value | Required | -|---------------------|---------------------------------------|-------------------|----------| -| `ORCHESTRATOR_HOME` | Home directory for the orchestrator | `~/.orchestrator` | Optional | +| Variable | Explanation | Default value | Required | +| ------------------- | ----------------------------------- | ----------------- | -------- | +| `ORCHESTRATOR_HOME` | Home directory for the orchestrator | `~/.orchestrator` | Optional | ## Relayer command The `blobstream relayer keys` command manages keys for the relayer. By default, it uses the relayer default home directory to store the keys: `~/.relayer/keystore`. However, the default home can be changed either by specifying a different directory using the `--home` flag or setting the following environment variable: -| Variable | Explanation | Default value | Required | -|---------------------|---------------------------------------|-------------------|----------| -| `RELAYER_HOME` | Home directory for the relayer | `~/.relayer` | Optional | +| Variable | Explanation | Default value | Required | +| -------------- | ------------------------------ | ------------- | -------- | +| `RELAYER_HOME` | Home directory for the relayer | `~/.relayer` | Optional | ## Deploy command The `blobstream deploy keys` command manages keys for the deployer. By default, it uses the deployer default home directory to store the keys: `~/.deployer/keystore`. However, the default home can be changed either by specifying a different directory using the `--home` flag or setting the following environment variable: -| Variable | Explanation | Default value | Required | -|---------------------|---------------------------------------|-------------------|----------| -| `DEPLOYER_HOME` | Home directory for the deploy command | `~/.deployer` | Optional | +| Variable | Explanation | Default value | Required | +| --------------- | ------------------------------------- | ------------- | -------- | +| `DEPLOYER_HOME` | Home directory for the deploy command | `~/.deployer` | Optional | ## Store initialization (!) @@ -119,7 +119,7 @@ After creating a new key, you will see its corresponding address printed: blobstream orchestrator keys evm add I[2023-04-13|14:16:11.387] successfully opened store path=/home/midnight/.orchestrator -I[2023-04-13|14:16:11.387] please provide a passphrase for your account +I[2023-04-13|14:16:11.387] please provide a passphrase for your account I[2023-04-13|14:16:30.533] account created successfully address=0xaF319b70de80232539ad576f88739afD2dF44187 I[2023-04-13|14:16:30.534] successfully closed store path=/home/midnight/.orchestrator ``` @@ -144,12 +144,12 @@ After running the command, you will be prompted to enter the passphrase for the Then, you will be prompted to confirm that you want to delete that private key. Make sure to verify if you're deleting the right one because once deleted, it can no longer be recovered! ```ssh -blobstream orchestrator keys evm delete 0x27a1F8CE94187E4b043f4D57548EF2348Ed556c7 +blobstream orchestrator keys evm delete 0x27a1F8CE94187E4b043f4D57548EF2348Ed556c7 I[2023-04-13|15:01:41.308] successfully opened store path=/home/midnight/.orchestrator I[2023-04-13|15:01:41.309] deleting account address=0x27a1F8CE94187E4b043f4D57548EF2348Ed556c7 -I[2023-04-13|15:01:41.309] please provide the address passphrase -I[2023-04-13|15:01:43.268] Are you sure you want to delete your private key? This action cannot be undone and may result in permanent loss of access to your account. +I[2023-04-13|15:01:41.309] please provide the address passphrase +I[2023-04-13|15:01:43.268] Are you sure you want to delete your private key? This action cannot be undone and may result in permanent loss of access to your account. Please enter 'yes' or 'no' to confirm your decision: yes I[2023-04-13|15:01:45.532] private key has been deleted successfully address=0x27a1F8CE94187E4b043f4D57548EF2348Ed556c7 I[2023-04-13|15:01:45.534] successfully closed store path=/home/midnight/.orchestrator @@ -163,8 +163,8 @@ The `list` subcommand allows listing the existing keys in the keystore: blobstream orchestrator keys evm list I[2023-04-13|16:08:45.084] successfully opened store path=/home/midnight/.orchestrator -I[2023-04-13|16:08:45.084] listing accounts available in store -I[2023-04-13|16:08:45.084] 0x7Dd8F9CAfe6D25165249A454F2d0b72FD149Bbba +I[2023-04-13|16:08:45.084] listing accounts available in store +I[2023-04-13|16:08:45.084] 0x7Dd8F9CAfe6D25165249A454F2d0b72FD149Bbba I[2023-04-13|16:08:45.084] successfully closed store path=/home/midnight/.orchestrator ``` @@ -190,8 +190,8 @@ blobstream orchestrator evm update 0x7Dd8F9CAfe6D25165249A454F2d0b72FD149Bbba I[2023-04-13|16:21:17.139] successfully opened store path=/home/midnight/.orchestrator I[2023-04-13|16:21:17.140] updating account address=0x7Dd8F9CAfe6D25165249A454F2d0b72FD149Bbba -I[2023-04-13|16:21:17.140] please provide the address passphrase -I[2023-04-13|16:21:18.134] please provide the address new passphrase +I[2023-04-13|16:21:17.140] please provide the address passphrase +I[2023-04-13|16:21:18.134] please provide the address new passphrase I[2023-04-13|16:21:22.403] successfully updated the passphrase address=0x7Dd8F9CAfe6D25165249A454F2d0b72FD149Bbba I[2023-04-13|16:21:22.420] successfully closed store path=/home/midnight/.orchestrator ``` @@ -232,8 +232,8 @@ Example: blobstream orchestrator keys evm import ecdsa da6ed55cb2894ac2c9c10209c09de8e8b9d109b910338d5bf3d747a7e1fc9eb7 I[2023-04-13|17:00:48.617] successfully opened store path=/home/midnight/.orchestrator -I[2023-04-13|17:00:48.617] importing account -I[2023-04-13|17:00:48.617] please provide the address passphrase +I[2023-04-13|17:00:48.617] importing account +I[2023-04-13|17:00:48.617] please provide the address passphrase I[2023-04-13|17:00:51.989] successfully imported file address=0x6B452Da14195b0aDc3C960E56a078Cf8f50448f8 I[2023-04-13|17:00:51.990] successfully closed store path=/home/midnight/.orchestrator ``` @@ -257,9 +257,9 @@ For example, if we have a file in the current directory containing a private key blobstream orchestrator keys evm import file UTC--2023-04-13T15-00-50.302148204Z--966e6f22781ef6a6a82bbb4db3df8e225dfd9488 I[2023-04-13|17:31:53.307] successfully opened store path=/home/midnight/.orchestrator -I[2023-04-13|17:31:53.307] importing account -I[2023-04-13|17:31:53.308] please provide the address passphrase -I[2023-04-13|17:31:54.440] please provide the address new passphrase +I[2023-04-13|17:31:53.307] importing account +I[2023-04-13|17:31:53.308] please provide the address passphrase +I[2023-04-13|17:31:54.440] please provide the address new passphrase I[2023-04-13|17:31:58.436] successfully imported file address=0x966e6f22781EF6a6A82BBB4DB3df8E225DfD9488 I[2023-04-13|17:31:58.437] successfully closed store path=/home/midnight/.orchestrator ``` diff --git a/docs/orchestrator.md b/docs/orchestrator.md index cea2c169..f623ee96 100644 --- a/docs/orchestrator.md +++ b/docs/orchestrator.md @@ -24,7 +24,7 @@ The orchestrator connects to a separate P2P network than the consensus or the da Bootstrapper for the Blockspace Race is: -* `/dns/bootstr-incent-1.celestia.tools/tcp/30000/p2p/12D3KooWSGZ2LXW2soQFHgU82uLfN7pNW5gMMkTnu1fhMXG43TvP` +- `/dns/bootstr-incent-1.celestia.tools/tcp/30000/p2p/12D3KooWSGZ2LXW2soQFHgU82uLfN7pNW5gMMkTnu1fhMXG43TvP` Make sure to specify it using the `-b` flag when running the orchestrator. @@ -42,9 +42,9 @@ I[2023-04-26|00:04:28.175] waiting for routing table to populate targetnu To run an orchestrator, you will need to have access to the following: -* *Access to your EVM address private key. This latter doesn't need to be funded in any network. If yours is not yet set, check the [register an EVM address](#register-evm-address) section. -* *A list of bootstrappers for the P2P network. These will be shared by the team for every network we plan on supporting. -* *Access to your consensus node RPC and gRPC ports. +- Access to your EVM address private key. This latter doesn't need to be funded in any network. If yours is not yet set, check the [register an EVM address](#register-evm-address) section. +- A list of bootstrappers for the P2P network. These will be shared by the team for every network we plan on supporting. +- Access to your consensus node RPC and gRPC ports. ### Install the Blobstream binary @@ -60,16 +60,16 @@ blobstream orchestrator init By default, the store will be created under `~/.orchestrator`. However, if you want to specify a custom location, you can use the `--home` flag. Or, you can use the following environment variable: -| Variable | Explanation | Default value | Required | -|---------------------|---------------------------------------|-------------------|----------| -| `ORCHESTRATOR_HOME` | Home directory for the orchestrator | `~/.orchestrator` | Optional | +| Variable | Explanation | Default value | Required | +| ------------------- | ----------------------------------- | ----------------- | -------- | +| `ORCHESTRATOR_HOME` | Home directory for the orchestrator | `~/.orchestrator` | Optional | ### Add keys In order for the orchestrator to start, it will need two private keys: -* *EVM private key -* *P2P private key +- EVM private key +- P2P private key The EVM private key is the most important one since it needs to correspond to the EVM address provided when creating the validator. @@ -268,8 +268,8 @@ Note: A validator set change is triggered if more than 5% of the total staking p If you want to start the orchestrator as a `systemd` service, you could use the following: -* *Make sure you have the store initialized and the EVM address private key imported. Check the above sections for how to do that. -* *Put the following configuration under: `/etc/systemd/system/orchestrator.service`: +- Make sure you have the store initialized and the EVM address private key imported. Check the above sections for how to do that. +- Put the following configuration under: `/etc/systemd/system/orchestrator.service`: ```text [Unit] @@ -293,13 +293,13 @@ TTYPath=/dev/tty0 WantedBy=multi-user.target ``` -* *Start the orchestrator service using: +- Start the orchestrator service using: ```shell sudo systemctl start orchestrator ``` -* Follow the logs to see if everything is running correctly: +- Follow the logs to see if everything is running correctly: ```shell sudo journalctl -f -u orchestrator diff --git a/docs/relayer.md b/docs/relayer.md index fd4f1fdc..1afbc822 100644 --- a/docs/relayer.md +++ b/docs/relayer.md @@ -50,9 +50,9 @@ blobstream relayer init By default, the store will be created un `~/.relayer`. However, if you want to specify a custom location, you can use the `--home` flag. Or, you can use the following environment variable: -| Variable | Explanation | Default value | Required | -|---------------------|---------------------------------------|-------------------|----------| -| `RELAYER_HOME` | Home directory for the relayer | `~/.relayer` | Optional | +| Variable | Explanation | Default value | Required | +| -------------- | ------------------------------ | ------------- | -------- | +| `RELAYER_HOME` | Home directory for the relayer | `~/.relayer` | Optional | ### Add keys diff --git a/go.mod b/go.mod index 1762dd75..5ca16769 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/celestiaorg/orchestrator-relayer go 1.21.1 require ( - github.com/celestiaorg/celestia-app v1.0.0-rc18 + github.com/celestiaorg/celestia-app v1.0.0 github.com/celestiaorg/nmt v0.20.0 // indirect github.com/ethereum/go-ethereum v1.13.2 github.com/gogo/protobuf v1.3.3 // indirect @@ -20,7 +20,7 @@ require ( golang.org/x/sys v0.13.0 // indirect golang.org/x/term v0.13.0 google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect - google.golang.org/grpc v1.58.2 + google.golang.org/grpc v1.58.3 ) require ( @@ -45,7 +45,7 @@ require ( cloud.google.com/go/iam v1.1.1 // indirect cloud.google.com/go/storage v1.30.1 // indirect cosmossdk.io/errors v1.0.0-beta.7 // indirect - cosmossdk.io/math v1.0.0-rc.0 // indirect + cosmossdk.io/math v1.1.2 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect @@ -257,7 +257,7 @@ require ( github.com/moby/sys/sequential v0.5.0 // indirect github.com/moby/sys/signal v0.7.0 // indirect github.com/moby/sys/symlink v0.2.0 // indirect - github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect + github.com/moby/term v0.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/morikuni/aec v1.0.0 // indirect @@ -303,7 +303,7 @@ require ( github.com/rivo/uniseg v0.2.0 // indirect github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/rs/cors v1.8.2 // indirect - github.com/rs/zerolog v1.29.1 // indirect + github.com/rs/zerolog v1.31.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/serialx/hashring v0.0.0-20190422032157-8b2912629002 // indirect github.com/shirou/gopsutil v3.21.6+incompatible // indirect diff --git a/go.sum b/go.sum index ec883f78..cf68bb35 100644 --- a/go.sum +++ b/go.sum @@ -195,8 +195,8 @@ cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoIS collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= -cosmossdk.io/math v1.0.0-rc.0 h1:ml46ukocrAAoBpYKMidF0R2tQJ1Uxfns0yH8wqgMAFc= -cosmossdk.io/math v1.0.0-rc.0/go.mod h1:Ygz4wBHrgc7g0N+8+MrnTfS9LLn9aaTGa9hKopuym5k= +cosmossdk.io/math v1.1.2 h1:ORZetZCTyWkI5GlZ6CZS28fMHi83ZYf+A2vVnHNzZBM= +cosmossdk.io/math v1.1.2/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU= @@ -394,8 +394,8 @@ github.com/bugsnag/panicwrap v1.2.0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywR github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= -github.com/celestiaorg/celestia-app v1.0.0-rc18 h1:d2+KYPr4ri10aOtnXih3hOUd6ap94c/Hv46JFzpWzy0= -github.com/celestiaorg/celestia-app v1.0.0-rc18/go.mod h1:Q375ijriqMv8PjKmMujNs2WzMAsgxjpbeUoQt+AZre0= +github.com/celestiaorg/celestia-app v1.0.0 h1:CJX0y3JE1gEKzb0Hr3/qS0Z/tZgYGJyCHJzc0+SVxYM= +github.com/celestiaorg/celestia-app v1.0.0/go.mod h1:8FN8f/iZC5D6A7QYJhK86nyRKrmQrzXFucV19vLv9Es= github.com/celestiaorg/celestia-core v1.29.0-tm-v0.34.29 h1:Fd7ymPUzExPGNl2gZw4i5S74arMw+iDHLE78M/cCxl4= github.com/celestiaorg/celestia-core v1.29.0-tm-v0.34.29/go.mod h1:xrICN0PBhp3AdTaZ8q4wS5Jvi32V02HNjaC2EsWiEKk= github.com/celestiaorg/cosmos-sdk v1.18.1-sdk-v0.46.14 h1:c4cMVLU2bGTesZW1ZVgeoCB++gOOJTF3OvBsqBvo6n0= @@ -1290,7 +1290,6 @@ github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= 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.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= @@ -1383,8 +1382,8 @@ github.com/moby/sys/signal v0.7.0 h1:25RW3d5TnQEoKvRbEKUGay6DCQ46IxAVTT9CUMgmsSI github.com/moby/sys/signal v0.7.0/go.mod h1:GQ6ObYZfqacOwTtlXvcmh9A26dVRul/hbOZn88Kg8Tg= github.com/moby/sys/symlink v0.2.0 h1:tk1rOM+Ljp0nFmfOIBtlV3rTDlWOwFRhjEeAhZB0nZc= github.com/moby/sys/symlink v0.2.0/go.mod h1:7uZVF2dqJjG/NsClqul95CqKOBRQyYSNnJ6BMgR/gFs= -github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA= -github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= +github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= +github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -1629,9 +1628,9 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj 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/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= -github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= +github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -2294,6 +2293,7 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.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.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= @@ -2644,8 +2644,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I= -google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= +google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= +google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= 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= diff --git a/orchestrator/orchestrator.go b/orchestrator/orchestrator.go index dfd1164c..9a4c0f30 100644 --- a/orchestrator/orchestrator.go +++ b/orchestrator/orchestrator.go @@ -300,29 +300,17 @@ func (orch Orchestrator) Process(ctx context.Context, nonce uint64) error { if att == nil { return celestiatypes.ErrAttestationNotFound } - // check if the validator is part of the needed valset - var previousValset *celestiatypes.Valset - if att.GetNonce() == 1 { - // if nonce == 1, then, the current valset should sign the confirm. - // In fact, the first nonce should never be signed. Because, the first attestation, in the case - // where the `earliest` flag is specified when deploying the contract, will be relayed as part of - // the deployment of the Blobstream contract. - // It will be signed temporarily for now. - previousValset, err = orch.AppQuerier.QueryValsetByNonce(ctx, att.GetNonce()) - if err != nil { - return err - } - } else { - previousValset, err = orch.AppQuerier.QueryLastValsetBeforeNonce(ctx, att.GetNonce()) - if err != nil { - return err - } - } - if !ValidatorPartOfValset(previousValset.Members, orch.EvmAccount.Address.Hex()) { + + // check if we need to sign or not + previousValset, err := orch.AppQuerier.QueryLastValsetBeforeNonce(ctx, att.GetNonce()) + if err != nil { + orch.Logger.Debug("failed to query last valset before nonce (most likely pruned). signing anyway", "err", err.Error()) + } else if !ValidatorPartOfValset(previousValset.Members, orch.EvmAccount.Address.Hex()) { // no need to sign if the orchestrator is not part of the validator set that needs to sign the attestation orch.Logger.Debug("validator not part of valset. won't sign", "nonce", nonce) return nil } + switch castedAtt := att.(type) { case *celestiatypes.Valset: signBytes, err := castedAtt.SignBytes() diff --git a/orchestrator/orchestrator_test.go b/orchestrator/orchestrator_test.go index e8566d73..e60a2ed1 100644 --- a/orchestrator/orchestrator_test.go +++ b/orchestrator/orchestrator_test.go @@ -6,6 +6,9 @@ import ( "testing" "time" + "github.com/celestiaorg/celestia-app/test/util/testnode" + qgbtesting "github.com/celestiaorg/orchestrator-relayer/testing" + "github.com/celestiaorg/celestia-app/app" "github.com/celestiaorg/celestia-app/app/encoding" "github.com/celestiaorg/orchestrator-relayer/rpc" @@ -163,3 +166,29 @@ func (s *OrchestratorTestSuite) TestEnqueuingAttestationNonces() { close(noncesQueue) assert.GreaterOrEqual(t, len(noncesQueue), int(latestNonce)) } + +func TestProcessWithoutValsetInStore(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + codec := encoding.MakeConfig(app.ModuleEncodingRegisters...).Codec + node := qgbtesting.NewTestNode( + ctx, + t, + qgbtesting.CelestiaNetworkParams{ + GenesisOpts: []testnode.GenesisOption{ + testnode.ImmediateProposals(codec), + qgbtesting.SetDataCommitmentWindowParams(codec, celestiatypes.Params{DataCommitmentWindow: 101}), + }, + TimeIotaMs: 6048000, // to have enough time to sign attestations after they're pruned + }, + ) + _, err := node.CelestiaNetwork.WaitForHeight(400) + require.NoError(t, err) + + orch := qgbtesting.NewOrchestrator(t, node) + + latestNonce, err := orch.AppQuerier.QueryLatestAttestationNonce(ctx) + require.NoError(t, err) + assert.NoError(t, orch.Process(ctx, latestNonce)) +} diff --git a/orchestrator/suite_test.go b/orchestrator/suite_test.go index 01f0cbd0..bafba568 100644 --- a/orchestrator/suite_test.go +++ b/orchestrator/suite_test.go @@ -26,9 +26,13 @@ func (s *OrchestratorTestSuite) SetupSuite() { s.Node = blobstreamtesting.NewTestNode( ctx, t, - testnode.ImmediateProposals(codec), - blobstreamtesting.SetDataCommitmentWindowParams(codec, types.Params{DataCommitmentWindow: 101}), - // blobstreamtesting.SetVotingParams(codec, v1beta1.VotingParams{VotingPeriod: 100 * time.Hour}), + blobstreamtesting.CelestiaNetworkParams{ + GenesisOpts: []testnode.GenesisOption{ + testnode.ImmediateProposals(codec), + blobstreamtesting.SetDataCommitmentWindowParams(codec, types.Params{DataCommitmentWindow: 101}), + }, + TimeIotaMs: 1, + }, ) s.Orchestrator = blobstreamtesting.NewOrchestrator(t, s.Node) } diff --git a/relayer/suite_test.go b/relayer/suite_test.go index 5f72ab25..22d87716 100644 --- a/relayer/suite_test.go +++ b/relayer/suite_test.go @@ -26,7 +26,7 @@ func (s *RelayerTestSuite) SetupSuite() { t.Skip("skipping relayer tests in short mode.") } ctx := context.Background() - s.Node = blobstreamtesting.NewTestNode(ctx, t) + s.Node = blobstreamtesting.NewTestNode(ctx, t, blobstreamtesting.DefaultCelestiaNetworkParams()) _, err := s.Node.CelestiaNetwork.WaitForHeight(2) require.NoError(t, err) s.Orchestrator = blobstreamtesting.NewOrchestrator(t, s.Node) diff --git a/testing/celestia_network.go b/testing/celestia_network.go index 960b5fd9..5afa8c41 100644 --- a/testing/celestia_network.go +++ b/testing/celestia_network.go @@ -41,10 +41,22 @@ type CelestiaNetwork struct { GRPCAddr string } +type CelestiaNetworkParams struct { + GenesisOpts []celestiatestnode.GenesisOption + TimeIotaMs int64 +} + +func DefaultCelestiaNetworkParams() CelestiaNetworkParams { + return CelestiaNetworkParams{ + GenesisOpts: nil, + TimeIotaMs: 1, + } +} + // NewCelestiaNetwork creates a new CelestiaNetwork. // Uses `testing.T` to fail if an error happens. // Only supports the creation of a single validator currently. -func NewCelestiaNetwork(ctx context.Context, t *testing.T, genesisOpts ...celestiatestnode.GenesisOption) *CelestiaNetwork { +func NewCelestiaNetwork(ctx context.Context, t *testing.T, params CelestiaNetworkParams) *CelestiaNetwork { if testing.Short() { // The main reason for skipping these tests in short mode is to avoid detecting unrelated // race conditions. @@ -63,14 +75,17 @@ func NewCelestiaNetwork(ctx context.Context, t *testing.T, genesisOpts ...celest tmCfg := celestiatestnode.DefaultTendermintConfig() tmCfg.Consensus.TimeoutCommit = time.Millisecond * 5 appConf := celestiatestnode.DefaultAppConfig() + consensusParams := celestiatestnode.DefaultParams() + consensusParams.Block.TimeIotaMs = params.TimeIotaMs clientContext, _, _ := celestiatestnode.NewNetwork( t, celestiatestnode.DefaultConfig(). WithAppConfig(appConf). + WithConsensusParams(consensusParams). WithTendermintConfig(tmCfg). WithAccounts(accounts). - WithGenesisOptions(genesisOpts...). + WithGenesisOptions(params.GenesisOpts...). WithChainID("qgb-test"), ) diff --git a/testing/testnode.go b/testing/testnode.go index ddc956da..89a4cd9e 100644 --- a/testing/testnode.go +++ b/testing/testnode.go @@ -3,8 +3,6 @@ package testing import ( "context" "testing" - - celestiatestnode "github.com/celestiaorg/celestia-app/test/util/testnode" ) // TestNode contains a DHTNetwork along with a test Celestia network and a simulated EVM chain. @@ -15,8 +13,8 @@ type TestNode struct { EVMChain *EVMChain } -func NewTestNode(ctx context.Context, t *testing.T, genesisOpts ...celestiatestnode.GenesisOption) *TestNode { - celestiaNetwork := NewCelestiaNetwork(ctx, t, genesisOpts...) +func NewTestNode(ctx context.Context, t *testing.T, celestiaParams CelestiaNetworkParams) *TestNode { + celestiaNetwork := NewCelestiaNetwork(ctx, t, celestiaParams) dhtNetwork := NewDHTNetwork(ctx, 2) evmChain := NewEVMChain(NodeEVMPrivateKey)