Skip to content
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

Implement GetDepositContract in the config API #8316

Merged
merged 16 commits into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions beacon-chain/rpc/beaconv1/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ go_library(
"//proto/beacon/p2p/v1:go_default_library",
"//proto/migration:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/params:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@io_opencensus_go//trace:go_default_library",
"@org_golang_google_grpc//codes:go_default_library",
"@org_golang_google_grpc//status:go_default_library",
],
Expand All @@ -46,6 +48,7 @@ go_test(
name = "go_default_test",
srcs = [
"blocks_test.go",
"config_test.go",
"server_test.go",
],
embed = [":go_default_library"],
Expand All @@ -62,6 +65,7 @@ go_test(
"//shared/testutil:go_default_library",
"//shared/testutil/assert:go_default_library",
"//shared/testutil/require:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
],
Expand Down
12 changes: 11 additions & 1 deletion beacon-chain/rpc/beaconv1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (

ptypes "github.com/gogo/protobuf/types"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1"
"github.com/prysmaticlabs/prysm/shared/params"
"go.opencensus.io/trace"
)

// GetForkSchedule retrieve all scheduled upcoming forks this node is aware of.
Expand All @@ -23,5 +25,13 @@ func (bs *Server) GetSpec(ctx context.Context, req *ptypes.Empty) (*ethpb.SpecRe

// GetDepositContract retrieves deposit contract address and genesis fork version.
func (bs *Server) GetDepositContract(ctx context.Context, req *ptypes.Empty) (*ethpb.DepositContractResponse, error) {
return nil, errors.New("unimplemented")
ctx, span := trace.StartSpan(ctx, "beaconv1.GetDepositContract")
defer span.End()

return &ethpb.DepositContractResponse{
Data: &ethpb.DepositContract{
ChainId: params.BeaconConfig().DepositChainID,
Address: params.BeaconConfig().DepositContractAddress,
},
}, nil
}
28 changes: 28 additions & 0 deletions beacon-chain/rpc/beaconv1/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package beaconv1

import (
"context"
"testing"

ptypes "github.com/gogo/protobuf/types"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
)

func TestGetDepositContract(t *testing.T) {
const chainId = 99
const address = "0x0000000000000000000000000000000000000009"
params.SetupTestConfigCleanup(t)
config := params.BeaconConfig()
config.DepositChainID = chainId

config.DepositContractAddress = address
params.OverrideBeaconConfig(config)

s := Server{}
resp, err := s.GetDepositContract(context.Background(), &ptypes.Empty{})
require.NoError(t, err)
assert.Equal(t, uint64(chainId), resp.Data.ChainId)
assert.Equal(t, address, resp.Data.Address)
}