From c1337d747173c3625dd880a09a5711ed3b70690c Mon Sep 17 00:00:00 2001 From: michaelhly Date: Thu, 20 Aug 2020 16:25:50 -0500 Subject: [PATCH 01/13] Update ethereumapis --- deps.bzl | 12 ++++++------ go.mod | 4 ++-- go.sum | 4 ++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/deps.bzl b/deps.bzl index d5f19c44a46e..76d0ea27943c 100644 --- a/deps.bzl +++ b/deps.bzl @@ -45,8 +45,8 @@ def prysm_deps(): name = "com_github_ferranbt_fastssz", importpath = "github.com/ferranbt/fastssz", nofuzz = True, - sum = "h1:maoKvILdMk6CSWHanFcUdxXIZGKD9YpWIaVbUQ/4kfg=", - version = "v0.0.0-20200514094935-99fccaf93472", + sum = "h1:qLZC3oQLJ5eb18EZS3yDcnX7zmlEt8WTWlQR7x5wS5I=", + version = "v0.0.0-20200728110133-0b6e349af87a", ) go_repository( name = "com_github_prysmaticlabs_bazel_go_ethereum", @@ -1027,8 +1027,8 @@ def prysm_deps(): go_repository( name = "com_github_mitchellh_mapstructure", importpath = "github.com/mitchellh/mapstructure", - sum = "h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=", - version = "v1.1.2", + sum = "h1:mRS76wmkOn3KkKAyXDu42V+6ebnXWIztFSYGN7GeoRg=", + version = "v1.3.2", ) go_repository( name = "com_github_mmcloughlin_avo", @@ -2570,8 +2570,8 @@ def prysm_deps(): name = "com_github_prysmaticlabs_ethereumapis", build_file_generation = "off", importpath = "github.com/prysmaticlabs/ethereumapis", - sum = "h1:GjYix8Y4VpQhlsjA2ickr3HxjIns4bI36zOmC+lwaNw=", - version = "v0.0.0-20200709024211-e8095222f77b", + sum = "h1:0f++UXRfp4/Mrmlfj3UaCnYj2lPr6El0gWWTBb9MD2Y=", + version = "v0.0.0-20200812153649-a842fc47c2c3", ) go_repository( name = "com_github_prysmaticlabs_go_bitfield", diff --git a/go.mod b/go.mod index b72464af25d2..8a5fce7f1176 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/emicklei/dot v0.11.0 github.com/ethereum/go-ethereum v0.0.0-00010101000000-000000000000 github.com/fatih/color v1.9.0 // indirect - github.com/ferranbt/fastssz v0.0.0-20200514094935-99fccaf93472 + github.com/ferranbt/fastssz v0.0.0-20200728110133-0b6e349af87a github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect github.com/ghodss/yaml v1.0.0 @@ -87,7 +87,7 @@ require ( github.com/prometheus/client_golang v1.7.1 github.com/prometheus/tsdb v0.10.0 // indirect github.com/protolambda/zssz v0.1.5 - github.com/prysmaticlabs/ethereumapis v0.0.0-20200709024211-e8095222f77b + github.com/prysmaticlabs/ethereumapis v0.0.0-20200812153649-a842fc47c2c3 github.com/prysmaticlabs/go-bitfield v0.0.0-20200618145306-2ae0807bef65 github.com/prysmaticlabs/go-ssz v0.0.0-20200612203617-6d5c9aa213ae github.com/prysmaticlabs/prombbolt v0.0.0-20200324184628-09789ef63796 diff --git a/go.sum b/go.sum index 49f4e42bea4e..cf94c5de71d7 100644 --- a/go.sum +++ b/go.sum @@ -215,6 +215,7 @@ github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/ferranbt/fastssz v0.0.0-20200514094935-99fccaf93472 h1:maoKvILdMk6CSWHanFcUdxXIZGKD9YpWIaVbUQ/4kfg= github.com/ferranbt/fastssz v0.0.0-20200514094935-99fccaf93472/go.mod h1:LlFXPmgrgVYsuoFDwV8rDJ9tvt1pLQdjKvU1b5IRES0= +github.com/ferranbt/fastssz v0.0.0-20200728110133-0b6e349af87a/go.mod h1:DyEu2iuLBnb/T51BlsiO3yLYdJC6UbGMrIkqK1KmQxM= github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= @@ -808,6 +809,7 @@ github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0 github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v0.0.0-20170523030023-d0303fe80992/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= 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= @@ -984,6 +986,8 @@ github.com/prysmaticlabs/bazel-go-ethereum v0.0.0-20200626171358-a933315235ec h1 github.com/prysmaticlabs/bazel-go-ethereum v0.0.0-20200626171358-a933315235ec/go.mod h1:oP8FC5+TbICUyftkTWs+8JryntjIJLJvWvApK3z2AYw= github.com/prysmaticlabs/ethereumapis v0.0.0-20200709024211-e8095222f77b h1:GjYix8Y4VpQhlsjA2ickr3HxjIns4bI36zOmC+lwaNw= github.com/prysmaticlabs/ethereumapis v0.0.0-20200709024211-e8095222f77b/go.mod h1:rs05kpTfWKl0KflsBWzBQFstoyPFMTWQTbxSAyGHe78= +github.com/prysmaticlabs/ethereumapis v0.0.0-20200812153649-a842fc47c2c3 h1:0f++UXRfp4/Mrmlfj3UaCnYj2lPr6El0gWWTBb9MD2Y= +github.com/prysmaticlabs/ethereumapis v0.0.0-20200812153649-a842fc47c2c3/go.mod h1:k7b2dxy6RppCG6kmOJkNOXzRpEoTdsPygc2aQhsUsZk= github.com/prysmaticlabs/go-bitfield v0.0.0-20191017011753-53b773adde52/go.mod h1:hCwmef+4qXWjv0jLDbQdWnL0Ol7cS7/lCSS26WR+u6s= github.com/prysmaticlabs/go-bitfield v0.0.0-20200322041314-62c2aee71669 h1:cX6YRZnZ9sgMqM5U14llxUiXVNJ3u07Res1IIjTOgtI= github.com/prysmaticlabs/go-bitfield v0.0.0-20200322041314-62c2aee71669/go.mod h1:hCwmef+4qXWjv0jLDbQdWnL0Ol7cS7/lCSS26WR+u6s= From 84fa1f2ee3b403cef52587d53de661c3dbe49345 Mon Sep 17 00:00:00 2001 From: michaelhly Date: Thu, 20 Aug 2020 16:28:28 -0500 Subject: [PATCH 02/13] Add PARTIALLY_DEPOSITED status --- beacon-chain/rpc/validator/status.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/beacon-chain/rpc/validator/status.go b/beacon-chain/rpc/validator/status.go index 921e2d2163e4..bf7781d5c83e 100644 --- a/beacon-chain/rpc/validator/status.go +++ b/beacon-chain/rpc/validator/status.go @@ -180,7 +180,10 @@ func (vs *Server) validatorStatus( } // Mark a validator as DEPOSITED if their deposit is visible. resp.Status = ethpb.ValidatorStatus_DEPOSITED - + // Check if 32 ETH was deposited. If less assign PARTIALLY_DEPOSITED status. + if deposit.Data.Amount < params.BeaconConfig().MaxEffectiveBalance { + resp.Status = ethpb.ValidatorStatus_PARTIALLY_DEPOSITED + } resp.Eth1DepositBlockNumber = eth1BlockNumBigInt.Uint64() depositBlockSlot, err := vs.depositBlockSlot(ctx, headState, eth1BlockNumBigInt) @@ -189,8 +192,8 @@ func (vs *Server) validatorStatus( } resp.DepositInclusionSlot = depositBlockSlot return resp, nonExistentIndex - // Deposited and Pending mean the validator has been put into the state. - case ethpb.ValidatorStatus_DEPOSITED, ethpb.ValidatorStatus_PENDING: + // Deposited, Pending or Partialy Deposited mean the validator has been put into the state. + case ethpb.ValidatorStatus_DEPOSITED, ethpb.ValidatorStatus_PENDING, ethpb.ValidatorStatus_PARTIALLY_DEPOSITED: var lastActivatedValidatorIdx uint64 for j := headState.NumValidators() - 1; j >= 0; j-- { val, err := headState.ValidatorAtIndexReadOnly(uint64(j)) @@ -238,6 +241,9 @@ func assignmentStatus(beaconState *stateTrie.BeaconState, validatorIdx uint64) e return ethpb.ValidatorStatus_DEPOSITED } if currentEpoch < validator.ActivationEpoch() { + if validator.EffectiveBalance() < params.BeaconConfig().MaxEffectiveBalance { + return ethpb.ValidatorStatus_PARTIALLY_DEPOSITED + } return ethpb.ValidatorStatus_PENDING } if validator.ExitEpoch() == farFutureEpoch { From d347c95749c1aead40bd557c5e5fd18b95b4485c Mon Sep 17 00:00:00 2001 From: michaelhly Date: Thu, 20 Aug 2020 16:44:48 -0500 Subject: [PATCH 03/13] go mod tidy --- go.sum | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/go.sum b/go.sum index cf94c5de71d7..5f86c6c5f18c 100644 --- a/go.sum +++ b/go.sum @@ -215,6 +215,7 @@ github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/ferranbt/fastssz v0.0.0-20200514094935-99fccaf93472 h1:maoKvILdMk6CSWHanFcUdxXIZGKD9YpWIaVbUQ/4kfg= github.com/ferranbt/fastssz v0.0.0-20200514094935-99fccaf93472/go.mod h1:LlFXPmgrgVYsuoFDwV8rDJ9tvt1pLQdjKvU1b5IRES0= +github.com/ferranbt/fastssz v0.0.0-20200728110133-0b6e349af87a h1:qLZC3oQLJ5eb18EZS3yDcnX7zmlEt8WTWlQR7x5wS5I= github.com/ferranbt/fastssz v0.0.0-20200728110133-0b6e349af87a/go.mod h1:DyEu2iuLBnb/T51BlsiO3yLYdJC6UbGMrIkqK1KmQxM= github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= @@ -984,8 +985,6 @@ github.com/protolambda/zssz v0.1.5 h1:7fjJjissZIIaa2QcvmhS/pZISMX21zVITt49sW1oue github.com/protolambda/zssz v0.1.5/go.mod h1:a4iwOX5FE7/JkKA+J/PH0Mjo9oXftN6P8NZyL28gpag= github.com/prysmaticlabs/bazel-go-ethereum v0.0.0-20200626171358-a933315235ec h1:9JrPtwqCvV38DXYaHbB855KUIHYMwjJBE88lL8lMu8Q= github.com/prysmaticlabs/bazel-go-ethereum v0.0.0-20200626171358-a933315235ec/go.mod h1:oP8FC5+TbICUyftkTWs+8JryntjIJLJvWvApK3z2AYw= -github.com/prysmaticlabs/ethereumapis v0.0.0-20200709024211-e8095222f77b h1:GjYix8Y4VpQhlsjA2ickr3HxjIns4bI36zOmC+lwaNw= -github.com/prysmaticlabs/ethereumapis v0.0.0-20200709024211-e8095222f77b/go.mod h1:rs05kpTfWKl0KflsBWzBQFstoyPFMTWQTbxSAyGHe78= github.com/prysmaticlabs/ethereumapis v0.0.0-20200812153649-a842fc47c2c3 h1:0f++UXRfp4/Mrmlfj3UaCnYj2lPr6El0gWWTBb9MD2Y= github.com/prysmaticlabs/ethereumapis v0.0.0-20200812153649-a842fc47c2c3/go.mod h1:k7b2dxy6RppCG6kmOJkNOXzRpEoTdsPygc2aQhsUsZk= github.com/prysmaticlabs/go-bitfield v0.0.0-20191017011753-53b773adde52/go.mod h1:hCwmef+4qXWjv0jLDbQdWnL0Ol7cS7/lCSS26WR+u6s= From f9043314d2fc9c4b0cd525e2fe4da948018e2f6e Mon Sep 17 00:00:00 2001 From: michaelhly Date: Sat, 22 Aug 2020 17:45:35 -0500 Subject: [PATCH 04/13] Fix bug --- beacon-chain/rpc/validator/status.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beacon-chain/rpc/validator/status.go b/beacon-chain/rpc/validator/status.go index bf7781d5c83e..5baca13ad40f 100644 --- a/beacon-chain/rpc/validator/status.go +++ b/beacon-chain/rpc/validator/status.go @@ -241,7 +241,8 @@ func assignmentStatus(beaconState *stateTrie.BeaconState, validatorIdx uint64) e return ethpb.ValidatorStatus_DEPOSITED } if currentEpoch < validator.ActivationEpoch() { - if validator.EffectiveBalance() < params.BeaconConfig().MaxEffectiveBalance { + balance := validator.EffectiveBalance() + if balance > 0 && balance < params.BeaconConfig().MaxEffectiveBalance { return ethpb.ValidatorStatus_PARTIALLY_DEPOSITED } return ethpb.ValidatorStatus_PENDING From 360fc2fcfb6eefd072c0798e2e619f331855144d Mon Sep 17 00:00:00 2001 From: michaelhly Date: Sat, 22 Aug 2020 17:57:58 -0500 Subject: [PATCH 05/13] Fixup --- beacon-chain/rpc/validator/status.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/beacon-chain/rpc/validator/status.go b/beacon-chain/rpc/validator/status.go index 5baca13ad40f..24b906f94645 100644 --- a/beacon-chain/rpc/validator/status.go +++ b/beacon-chain/rpc/validator/status.go @@ -233,16 +233,19 @@ func assignmentStatus(beaconState *stateTrie.BeaconState, validatorIdx uint64) e } currentEpoch := helpers.CurrentEpoch(beaconState) farFutureEpoch := params.BeaconConfig().FarFutureEpoch + validatorBalance := validator.EffectiveBalance() if validator == nil { return ethpb.ValidatorStatus_UNKNOWN_STATUS } if currentEpoch < validator.ActivationEligibilityEpoch() { + if validatorBalance < params.BeaconConfig().MaxEffectiveBalance { + return ethpb.ValidatorStatus_PARTIALLY_DEPOSITED + } return ethpb.ValidatorStatus_DEPOSITED } if currentEpoch < validator.ActivationEpoch() { - balance := validator.EffectiveBalance() - if balance > 0 && balance < params.BeaconConfig().MaxEffectiveBalance { + if validatorBalance > 0 && validatorBalance < params.BeaconConfig().MaxEffectiveBalance { return ethpb.ValidatorStatus_PARTIALLY_DEPOSITED } return ethpb.ValidatorStatus_PENDING From 9122e94f0beaf616131c2f4054135e358b072e9a Mon Sep 17 00:00:00 2001 From: michaelhly Date: Sat, 22 Aug 2020 18:40:32 -0500 Subject: [PATCH 06/13] Fixup --- beacon-chain/rpc/validator/status.go | 29 ++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/beacon-chain/rpc/validator/status.go b/beacon-chain/rpc/validator/status.go index 24b906f94645..cf5d9b4119ee 100644 --- a/beacon-chain/rpc/validator/status.go +++ b/beacon-chain/rpc/validator/status.go @@ -194,6 +194,20 @@ func (vs *Server) validatorStatus( return resp, nonExistentIndex // Deposited, Pending or Partialy Deposited mean the validator has been put into the state. case ethpb.ValidatorStatus_DEPOSITED, ethpb.ValidatorStatus_PENDING, ethpb.ValidatorStatus_PARTIALLY_DEPOSITED: + if resp.Status == ethpb.ValidatorStatus_PENDING { + if vs.DepositFetcher == nil { + log.Warn("Not connected to ETH1. Cannot determine validator ETH1 deposit.") + } else { + // Check if there was a deposit deposit. + deposit, eth1BlockNumBigInt := vs.DepositFetcher.DepositByPubkey(ctx, pubKey) + if eth1BlockNumBigInt != nil && deposit.Data.Amount >= params.BeaconConfig().MaxEffectiveBalance { + resp.Status = ethpb.ValidatorStatus_DEPOSITED + } else if eth1BlockNumBigInt != nil && deposit.Data.Amount > 0 { + resp.Status = ethpb.ValidatorStatus_PARTIALLY_DEPOSITED + } + } + } + var lastActivatedValidatorIdx uint64 for j := headState.NumValidators() - 1; j >= 0; j-- { val, err := headState.ValidatorAtIndexReadOnly(uint64(j)) @@ -239,16 +253,19 @@ func assignmentStatus(beaconState *stateTrie.BeaconState, validatorIdx uint64) e return ethpb.ValidatorStatus_UNKNOWN_STATUS } if currentEpoch < validator.ActivationEligibilityEpoch() { - if validatorBalance < params.BeaconConfig().MaxEffectiveBalance { - return ethpb.ValidatorStatus_PARTIALLY_DEPOSITED + if validatorBalance == 0 { + return ethpb.ValidatorStatus_PENDING + } + if validatorBalance >= params.BeaconConfig().MaxEffectiveBalance { + return ethpb.ValidatorStatus_DEPOSITED } - return ethpb.ValidatorStatus_DEPOSITED + return ethpb.ValidatorStatus_PARTIALLY_DEPOSITED } if currentEpoch < validator.ActivationEpoch() { - if validatorBalance > 0 && validatorBalance < params.BeaconConfig().MaxEffectiveBalance { - return ethpb.ValidatorStatus_PARTIALLY_DEPOSITED + if validatorBalance == 0 { + return ethpb.ValidatorStatus_PENDING } - return ethpb.ValidatorStatus_PENDING + return ethpb.ValidatorStatus_PARTIALLY_DEPOSITED } if validator.ExitEpoch() == farFutureEpoch { return ethpb.ValidatorStatus_ACTIVE From 817f89db1dde9ad2d626540f1ae51cdcc35cca7d Mon Sep 17 00:00:00 2001 From: michaelhly Date: Sat, 22 Aug 2020 18:55:15 -0500 Subject: [PATCH 07/13] Fix tests --- beacon-chain/rpc/validator/status_test.go | 56 +++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/beacon-chain/rpc/validator/status_test.go b/beacon-chain/rpc/validator/status_test.go index 84d9f17f45fe..777ddc4de4a8 100644 --- a/beacon-chain/rpc/validator/status_test.go +++ b/beacon-chain/rpc/validator/status_test.go @@ -70,6 +70,7 @@ func TestValidatorStatus_Deposited(t *testing.T) { pubKey1 := pubKey(1) depData := ðpb.Deposit_Data{ + Amount: params.BeaconConfig().MaxEffectiveBalance, PublicKey: pubKey1, Signature: []byte("hi"), WithdrawalCredentials: []byte("hey"), @@ -115,6 +116,58 @@ func TestValidatorStatus_Deposited(t *testing.T) { assert.Equal(t, ethpb.ValidatorStatus_DEPOSITED, resp.Status) } +func TestValidatorStatus_PartiallyDeposited(t *testing.T) { + db, _ := dbutil.SetupDB(t) + ctx := context.Background() + + pubKey1 := pubKey(1) + depData := ðpb.Deposit_Data{ + Amount: params.BeaconConfig().MinDepositAmount, + PublicKey: pubKey1, + Signature: []byte("hi"), + WithdrawalCredentials: []byte("hey"), + } + deposit := ðpb.Deposit{ + Data: depData, + } + depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) + require.NoError(t, err, "Could not setup deposit trie") + depositCache, err := depositcache.NewDepositCache() + require.NoError(t, err) + + depositCache.InsertDeposit(ctx, deposit, 0 /*blockNum*/, 0, depositTrie.Root()) + height := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix() + p := &mockPOW.POWChain{ + TimesByHeight: map[int]uint64{ + 0: uint64(height), + }, + } + stateObj, err := stateTrie.InitializeFromProtoUnsafe(&pbp2p.BeaconState{ + Validators: []*ethpb.Validator{ + { + PublicKey: pubKey1, + ActivationEligibilityEpoch: 1, + }, + }, + }) + require.NoError(t, err) + vs := &Server{ + BeaconDB: db, + DepositFetcher: depositCache, + BlockFetcher: p, + HeadFetcher: &mockChain.ChainService{ + State: stateObj, + }, + Eth1InfoFetcher: p, + } + req := ðpb.ValidatorStatusRequest{ + PublicKey: pubKey1, + } + resp, err := vs.ValidatorStatus(context.Background(), req) + require.NoError(t, err, "Could not get validator status") + assert.Equal(t, ethpb.ValidatorStatus_PARTIALLY_DEPOSITED, resp.Status) +} + func TestValidatorStatus_Pending(t *testing.T) { db, _ := dbutil.SetupDB(t) ctx := context.Background() @@ -486,6 +539,7 @@ func TestActivationStatus_OK(t *testing.T) { ActivationEligibilityEpoch: 700, ExitEpoch: params.BeaconConfig().FarFutureEpoch, PublicKey: pubKeys[3], + EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, }, }, }) @@ -795,6 +849,7 @@ func TestMultipleValidatorStatus_Pubkeys(t *testing.T) { ActivationEligibilityEpoch: 700, ExitEpoch: params.BeaconConfig().FarFutureEpoch, PublicKey: pubKeys[3], + EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, }, }, }) @@ -879,6 +934,7 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) { ActivationEligibilityEpoch: 700, ExitEpoch: params.BeaconConfig().FarFutureEpoch, PublicKey: pubKeys[2], + EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, }, { Slashed: true, From 8b460e2bb138c6be05a8b9628d4c9f4fd27f921d Mon Sep 17 00:00:00 2001 From: michaelhly Date: Sat, 22 Aug 2020 18:57:16 -0500 Subject: [PATCH 08/13] Revert fast ssz bump --- deps.bzl | 4 ++-- go.mod | 2 +- go.sum | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/deps.bzl b/deps.bzl index 76d0ea27943c..0e313d6da5d7 100644 --- a/deps.bzl +++ b/deps.bzl @@ -45,8 +45,8 @@ def prysm_deps(): name = "com_github_ferranbt_fastssz", importpath = "github.com/ferranbt/fastssz", nofuzz = True, - sum = "h1:qLZC3oQLJ5eb18EZS3yDcnX7zmlEt8WTWlQR7x5wS5I=", - version = "v0.0.0-20200728110133-0b6e349af87a", + sum = "h1:maoKvILdMk6CSWHanFcUdxXIZGKD9YpWIaVbUQ/4kfg=", + version = "v0.0.0-20200514094935-99fccaf93472", ) go_repository( name = "com_github_prysmaticlabs_bazel_go_ethereum", diff --git a/go.mod b/go.mod index 8a5fce7f1176..c74eedec737b 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/emicklei/dot v0.11.0 github.com/ethereum/go-ethereum v0.0.0-00010101000000-000000000000 github.com/fatih/color v1.9.0 // indirect - github.com/ferranbt/fastssz v0.0.0-20200728110133-0b6e349af87a + github.com/ferranbt/fastssz v0.0.0-20200514094935-99fccaf93472 github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect github.com/ghodss/yaml v1.0.0 diff --git a/go.sum b/go.sum index 5f86c6c5f18c..f3255d07704d 100644 --- a/go.sum +++ b/go.sum @@ -215,8 +215,6 @@ github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/ferranbt/fastssz v0.0.0-20200514094935-99fccaf93472 h1:maoKvILdMk6CSWHanFcUdxXIZGKD9YpWIaVbUQ/4kfg= github.com/ferranbt/fastssz v0.0.0-20200514094935-99fccaf93472/go.mod h1:LlFXPmgrgVYsuoFDwV8rDJ9tvt1pLQdjKvU1b5IRES0= -github.com/ferranbt/fastssz v0.0.0-20200728110133-0b6e349af87a h1:qLZC3oQLJ5eb18EZS3yDcnX7zmlEt8WTWlQR7x5wS5I= -github.com/ferranbt/fastssz v0.0.0-20200728110133-0b6e349af87a/go.mod h1:DyEu2iuLBnb/T51BlsiO3yLYdJC6UbGMrIkqK1KmQxM= github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= From 4d604114532c2d769b2c2374b14ad45ad663db11 Mon Sep 17 00:00:00 2001 From: michaelhly Date: Sat, 22 Aug 2020 19:00:58 -0500 Subject: [PATCH 09/13] Pending status if deposit amount is 0 --- beacon-chain/rpc/validator/status.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/beacon-chain/rpc/validator/status.go b/beacon-chain/rpc/validator/status.go index cf5d9b4119ee..3da7b28b6bb6 100644 --- a/beacon-chain/rpc/validator/status.go +++ b/beacon-chain/rpc/validator/status.go @@ -180,8 +180,10 @@ func (vs *Server) validatorStatus( } // Mark a validator as DEPOSITED if their deposit is visible. resp.Status = ethpb.ValidatorStatus_DEPOSITED - // Check if 32 ETH was deposited. If less assign PARTIALLY_DEPOSITED status. - if deposit.Data.Amount < params.BeaconConfig().MaxEffectiveBalance { + // Check if 32 ETH was deposited. If less assign PENDING or PARTIALLY_DEPOSITED status. + if deposit.Data.Amount == 0 { + resp.Status = ethpb.ValidatorStatus_PENDING + } else if deposit.Data.Amount < params.BeaconConfig().MaxEffectiveBalance { resp.Status = ethpb.ValidatorStatus_PARTIALLY_DEPOSITED } resp.Eth1DepositBlockNumber = eth1BlockNumBigInt.Uint64() From a8315ce9edad027a318e03c0d3ca630ccef74198 Mon Sep 17 00:00:00 2001 From: michaelhly Date: Sat, 22 Aug 2020 19:05:56 -0500 Subject: [PATCH 10/13] go mod tidy --- go.mod | 4 ++-- go.sum | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index c74eedec737b..b72464af25d2 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/emicklei/dot v0.11.0 github.com/ethereum/go-ethereum v0.0.0-00010101000000-000000000000 github.com/fatih/color v1.9.0 // indirect - github.com/ferranbt/fastssz v0.0.0-20200514094935-99fccaf93472 + github.com/ferranbt/fastssz v0.0.0-20200514094935-99fccaf93472 github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect github.com/ghodss/yaml v1.0.0 @@ -87,7 +87,7 @@ require ( github.com/prometheus/client_golang v1.7.1 github.com/prometheus/tsdb v0.10.0 // indirect github.com/protolambda/zssz v0.1.5 - github.com/prysmaticlabs/ethereumapis v0.0.0-20200812153649-a842fc47c2c3 + github.com/prysmaticlabs/ethereumapis v0.0.0-20200709024211-e8095222f77b github.com/prysmaticlabs/go-bitfield v0.0.0-20200618145306-2ae0807bef65 github.com/prysmaticlabs/go-ssz v0.0.0-20200612203617-6d5c9aa213ae github.com/prysmaticlabs/prombbolt v0.0.0-20200324184628-09789ef63796 diff --git a/go.sum b/go.sum index f3255d07704d..49f4e42bea4e 100644 --- a/go.sum +++ b/go.sum @@ -808,7 +808,6 @@ github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0 github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v0.0.0-20170523030023-d0303fe80992/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= 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= @@ -983,8 +982,8 @@ github.com/protolambda/zssz v0.1.5 h1:7fjJjissZIIaa2QcvmhS/pZISMX21zVITt49sW1oue github.com/protolambda/zssz v0.1.5/go.mod h1:a4iwOX5FE7/JkKA+J/PH0Mjo9oXftN6P8NZyL28gpag= github.com/prysmaticlabs/bazel-go-ethereum v0.0.0-20200626171358-a933315235ec h1:9JrPtwqCvV38DXYaHbB855KUIHYMwjJBE88lL8lMu8Q= github.com/prysmaticlabs/bazel-go-ethereum v0.0.0-20200626171358-a933315235ec/go.mod h1:oP8FC5+TbICUyftkTWs+8JryntjIJLJvWvApK3z2AYw= -github.com/prysmaticlabs/ethereumapis v0.0.0-20200812153649-a842fc47c2c3 h1:0f++UXRfp4/Mrmlfj3UaCnYj2lPr6El0gWWTBb9MD2Y= -github.com/prysmaticlabs/ethereumapis v0.0.0-20200812153649-a842fc47c2c3/go.mod h1:k7b2dxy6RppCG6kmOJkNOXzRpEoTdsPygc2aQhsUsZk= +github.com/prysmaticlabs/ethereumapis v0.0.0-20200709024211-e8095222f77b h1:GjYix8Y4VpQhlsjA2ickr3HxjIns4bI36zOmC+lwaNw= +github.com/prysmaticlabs/ethereumapis v0.0.0-20200709024211-e8095222f77b/go.mod h1:rs05kpTfWKl0KflsBWzBQFstoyPFMTWQTbxSAyGHe78= github.com/prysmaticlabs/go-bitfield v0.0.0-20191017011753-53b773adde52/go.mod h1:hCwmef+4qXWjv0jLDbQdWnL0Ol7cS7/lCSS26WR+u6s= github.com/prysmaticlabs/go-bitfield v0.0.0-20200322041314-62c2aee71669 h1:cX6YRZnZ9sgMqM5U14llxUiXVNJ3u07Res1IIjTOgtI= github.com/prysmaticlabs/go-bitfield v0.0.0-20200322041314-62c2aee71669/go.mod h1:hCwmef+4qXWjv0jLDbQdWnL0Ol7cS7/lCSS26WR+u6s= From 2bceb4c1b4a92b085bd407ab878c90357b44773e Mon Sep 17 00:00:00 2001 From: michaelhly Date: Sat, 22 Aug 2020 19:22:32 -0500 Subject: [PATCH 11/13] More tests --- beacon-chain/rpc/validator/status_test.go | 49 +++++++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/beacon-chain/rpc/validator/status_test.go b/beacon-chain/rpc/validator/status_test.go index 777ddc4de4a8..68ea3f008f39 100644 --- a/beacon-chain/rpc/validator/status_test.go +++ b/beacon-chain/rpc/validator/status_test.go @@ -830,8 +830,15 @@ func TestMultipleValidatorStatus_Pubkeys(t *testing.T) { db, _ := dbutil.SetupDB(t) ctx := context.Background() - deposits, _, err := testutil.DeterministicDepositsAndKeys(4) - pubKeys := [][]byte{deposits[0].Data.PublicKey, deposits[1].Data.PublicKey, deposits[2].Data.PublicKey, deposits[3].Data.PublicKey} + deposits, _, err := testutil.DeterministicDepositsAndKeys(6) + pubKeys := [][]byte{ + deposits[0].Data.PublicKey, + deposits[1].Data.PublicKey, + deposits[2].Data.PublicKey, + deposits[3].Data.PublicKey, + deposits[4].Data.PublicKey, + deposits[5].Data.PublicKey, + } stateObj, err := stateTrie.InitializeFromProtoUnsafe(&pbp2p.BeaconState{ Slot: 4000, Validators: []*ethpb.Validator{ @@ -851,17 +858,28 @@ func TestMultipleValidatorStatus_Pubkeys(t *testing.T) { PublicKey: pubKeys[3], EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance, }, + { + ActivationEligibilityEpoch: 700, + ExitEpoch: params.BeaconConfig().FarFutureEpoch, + PublicKey: pubKeys[4], + EffectiveBalance: params.BeaconConfig().MinDepositAmount, + }, + { + ActivationEligibilityEpoch: 700, + ExitEpoch: params.BeaconConfig().FarFutureEpoch, + PublicKey: pubKeys[5], + }, }, }) block := testutil.NewBeaconBlock() genesisRoot, err := stateutil.BlockRoot(block.Block) require.NoError(t, err, "Could not get signing root") - dep := deposits[0] depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth)) require.NoError(t, err, "Could not setup deposit trie") depositCache, err := depositcache.NewDepositCache() require.NoError(t, err) + dep := deposits[0] depositCache.InsertDeposit(ctx, dep, 10 /*blockNum*/, 0, depositTrie.Root()) dep = deposits[2] depositTrie.Insert(dep.Data.Signature, 15) @@ -894,6 +912,12 @@ func TestMultipleValidatorStatus_Pubkeys(t *testing.T) { { Status: ethpb.ValidatorStatus_DEPOSITED, }, + { + Status: ethpb.ValidatorStatus_PARTIALLY_DEPOSITED, + }, + { + Status: ethpb.ValidatorStatus_PENDING, + }, } req := ðpb.MultipleValidatorStatusRequest{PublicKeys: pubKeys} @@ -916,7 +940,7 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) { db, _ := dbutil.SetupDB(t) slot := uint64(10000) epoch := helpers.SlotToEpoch(slot) - pubKeys := [][]byte{pubKey(1), pubKey(2), pubKey(3), pubKey(4)} + pubKeys := [][]byte{pubKey(1), pubKey(2), pubKey(3), pubKey(4), pubKey(5), pubKey(6)} beaconState := &pbp2p.BeaconState{ Slot: 4000, Validators: []*ethpb.Validator{ @@ -941,6 +965,17 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) { ExitEpoch: epoch + 1, PublicKey: pubKeys[3], }, + { + ActivationEligibilityEpoch: 700, + ExitEpoch: params.BeaconConfig().FarFutureEpoch, + PublicKey: pubKeys[4], + EffectiveBalance: params.BeaconConfig().MinDepositAmount, + }, + { + ActivationEligibilityEpoch: 700, + ExitEpoch: params.BeaconConfig().FarFutureEpoch, + PublicKey: pubKeys[2], + }, }, } stateObj, err := stateTrie.InitializeFromProtoUnsafe(beaconState) @@ -972,6 +1007,12 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) { { Status: ethpb.ValidatorStatus_SLASHING, }, + { + Status: ethpb.ValidatorStatus_PARTIALLY_DEPOSITED, + }, + { + Status: ethpb.ValidatorStatus_PENDING, + }, } // Note: Index 4 should be skipped. From 8f6757209af834754a9728c042d93075d3dedd9e Mon Sep 17 00:00:00 2001 From: michaelhly Date: Sat, 22 Aug 2020 19:27:32 -0500 Subject: [PATCH 12/13] Trigger Buildkite From 02e627e134e7b1c3ca916f5795979b5ff194b9eb Mon Sep 17 00:00:00 2001 From: michaelhly Date: Sat, 22 Aug 2020 19:52:38 -0500 Subject: [PATCH 13/13] Fix TestMultipleValidatorStatus_Indices --- beacon-chain/rpc/validator/status_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/beacon-chain/rpc/validator/status_test.go b/beacon-chain/rpc/validator/status_test.go index 68ea3f008f39..f4573b419aed 100644 --- a/beacon-chain/rpc/validator/status_test.go +++ b/beacon-chain/rpc/validator/status_test.go @@ -940,7 +940,7 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) { db, _ := dbutil.SetupDB(t) slot := uint64(10000) epoch := helpers.SlotToEpoch(slot) - pubKeys := [][]byte{pubKey(1), pubKey(2), pubKey(3), pubKey(4), pubKey(5), pubKey(6)} + pubKeys := [][]byte{pubKey(1), pubKey(2), pubKey(3), pubKey(4), pubKey(5), pubKey(6), pubKey(7)} beaconState := &pbp2p.BeaconState{ Slot: 4000, Validators: []*ethpb.Validator{ @@ -974,7 +974,7 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) { { ActivationEligibilityEpoch: 700, ExitEpoch: params.BeaconConfig().FarFutureEpoch, - PublicKey: pubKeys[2], + PublicKey: pubKeys[5], }, }, } @@ -1015,8 +1015,8 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) { }, } - // Note: Index 4 should be skipped. - req := ðpb.MultipleValidatorStatusRequest{Indices: []int64{0, 1, 2, 3, 4}} + // Note: Index 6 should be skipped. + req := ðpb.MultipleValidatorStatusRequest{Indices: []int64{0, 1, 2, 3, 4, 5, 6}} response, err := vs.MultipleValidatorStatus(context.Background(), req) require.NoError(t, err)