-
Notifications
You must be signed in to change notification settings - Fork 589
consensus/bor, internal/cli: full grpc implementation #2194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marcello33
wants to merge
16
commits into
develop
Choose a base branch
from
mardizzone/grpc_improv
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
68f5e58
implement full grpc comms with heimdall
marcello33 fd961fa
Merge branch 'develop' into mardizzone/grpc_improv
marcello33 fe62ec8
address comments
marcello33 edafc70
address comments
marcello33 43b6efc
address comments
marcello33 84b7d5c
address comments
marcello33 5d681d7
address comments
marcello33 a7ebf67
revert tracers/data.csv
marcello33 97b4b6f
internal/cli, docs: skip gRPC on empty addr, warn unauth non-loopback
marcello33 9efe569
internal/cli: address comments
marcello33 130917f
Merge branch 'develop' into mardizzone/grpc_improv
marcello33 fcbf924
internal/cli: address comment
marcello33 9f68605
internal/cli: implement additional tests
marcello33 5bfd163
internal/cli: address comments and improve tests/validation
marcello33 f980175
internal/cli: address comments and add new tests
marcello33 3c51b89
internal/cli/server: map reorg & non-contiguous range sentinels; tidy…
marcello33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -220,6 +220,7 @@ devfakeauthor = false | |
|
|
||
| [grpc] | ||
| addr = "127.0.0.1:3131" | ||
| token = "" | ||
|
|
||
| [developer] | ||
| dev = false | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package cli | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // TestMeta2Conn_NoToken: default behaviour (no token) keeps the original | ||
| // insecure-only dial. No regressions for the loopback no-auth flow. | ||
| func TestMeta2Conn_NoToken(t *testing.T) { | ||
| t.Setenv("BOR_GRPC_TOKEN", "") | ||
| m := &Meta2{addr: "127.0.0.1:3131"} | ||
| conn, err := m.Conn() | ||
| require.NoError(t, err) | ||
| t.Cleanup(func() { _ = conn.Close() }) | ||
| } | ||
|
|
||
| // TestMeta2Conn_LoopbackWithToken: token attached over plaintext is allowed | ||
| // when the dial address is loopback (the typical same-host validator pair). | ||
| func TestMeta2Conn_LoopbackWithToken(t *testing.T) { | ||
| t.Setenv("BOR_GRPC_TOKEN", "") | ||
| m := &Meta2{addr: "127.0.0.1:3131", token: "secret"} | ||
| conn, err := m.Conn() | ||
| require.NoError(t, err) | ||
| t.Cleanup(func() { _ = conn.Close() }) | ||
| } | ||
|
|
||
| // TestMeta2Conn_NonLoopbackWithTokenRefused: refuse to send a bearer token in | ||
| // cleartext to a remote host. Mirrors the heimdall-side guarantee. | ||
| func TestMeta2Conn_NonLoopbackWithTokenRefused(t *testing.T) { | ||
| t.Setenv("BOR_GRPC_TOKEN", "") | ||
| m := &Meta2{addr: "bor.example.net:3131", token: "secret"} | ||
| _, err := m.Conn() | ||
| require.Error(t, err) | ||
| require.Contains(t, err.Error(), "refusing to send bearer token to non-loopback") | ||
| } | ||
|
|
||
| // TestMeta2Conn_EnvVarFallback: BOR_GRPC_TOKEN env var is used when --token is | ||
| // not passed. The non-loopback refusal applies to env-supplied tokens too. | ||
| func TestMeta2Conn_EnvVarFallback(t *testing.T) { | ||
| t.Setenv("BOR_GRPC_TOKEN", "from-env") | ||
| m := &Meta2{addr: "bor.example.net:3131"} | ||
| _, err := m.Conn() | ||
| require.Error(t, err) | ||
| require.Contains(t, err.Error(), "refusing to send bearer token to non-loopback") | ||
| } | ||
|
|
||
| // TestBearerCreds_GetRequestMetadata returns the correctly framed Authorization | ||
| // header with a Bearer scheme. | ||
| func TestBearerCreds_GetRequestMetadata(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| md, err := bearerCreds{token: "abc123"}.GetRequestMetadata(nil) | ||
| require.NoError(t, err) | ||
| require.Equal(t, "Bearer abc123", md["authorization"]) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.