From 6a13ba9125bfbea186d06b69bfa153d693fcdc62 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Mon, 16 Jun 2025 14:53:39 -0500 Subject: [PATCH] remove eth1voting tool (#15415) --- changelog/pvl-rm-eth1voting-tool.md | 3 + tools/eth1voting/BUILD.bazel | 29 --------- tools/eth1voting/README.md | 60 ------------------ tools/eth1voting/main.go | 95 ----------------------------- tools/eth1voting/votes.go | 91 --------------------------- 5 files changed, 3 insertions(+), 275 deletions(-) create mode 100644 changelog/pvl-rm-eth1voting-tool.md delete mode 100644 tools/eth1voting/BUILD.bazel delete mode 100644 tools/eth1voting/README.md delete mode 100644 tools/eth1voting/main.go delete mode 100644 tools/eth1voting/votes.go diff --git a/changelog/pvl-rm-eth1voting-tool.md b/changelog/pvl-rm-eth1voting-tool.md new file mode 100644 index 0000000000..76d4d0d72a --- /dev/null +++ b/changelog/pvl-rm-eth1voting-tool.md @@ -0,0 +1,3 @@ +### Removed + +- Removed //tools/eth1voting tool. This is no longer needed as the beacon chain no longer uses eth1data voting since Electra. diff --git a/tools/eth1voting/BUILD.bazel b/tools/eth1voting/BUILD.bazel deleted file mode 100644 index f09264eaed..0000000000 --- a/tools/eth1voting/BUILD.bazel +++ /dev/null @@ -1,29 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary") -load("@prysm//tools/go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "main.go", - "votes.go", - ], - importpath = "github.com/OffchainLabs/prysm/v6/tools/eth1voting", - visibility = ["//visibility:private"], - deps = [ - "//config/params:go_default_library", - "//consensus-types/blocks:go_default_library", - "//consensus-types/interfaces:go_default_library", - "//consensus-types/primitives:go_default_library", - "//encoding/bytesutil:go_default_library", - "//proto/prysm/v1alpha1:go_default_library", - "//time/slots:go_default_library", - "@org_golang_google_grpc//:go_default_library", - "@org_golang_x_sync//errgroup:go_default_library", - ], -) - -go_binary( - name = "eth1voting", - embed = [":go_default_library"], - visibility = ["//visibility:public"], -) diff --git a/tools/eth1voting/README.md b/tools/eth1voting/README.md deleted file mode 100644 index 76841888b2..0000000000 --- a/tools/eth1voting/README.md +++ /dev/null @@ -1,60 +0,0 @@ -# eth1voting - -This tool can be used to query a Prysm node to print eth1voting information. - -Flags: -``` - -beacon string - gRPC address of the Prysm beacon node (default "127.0.0.1:4000") - -genesis uint - Genesis time. mainnet=1606824023, holesky=1695902400 (default 1606824023) -``` - -Usage: -``` -bazel run //tools/eth1voting -- -beacon=127.0.0.1:4000 -genesis=1606824023 -``` - -Example response -``` -Looking back from current epoch 71132 back to 71104 -Next period starts at epoch 71168 (3h50m1.542950367s) -====Eth1Data Voting Report==== - -Total votes: 732 - -Block Hashes -0xd3c1132b8cebb601872a32277af708ec0f026b74e814956b0f1456516234c48e=656 -0x6b418e33ac6a7d181408af0306c475adff9ea28a43b97e1f85e82070988f9288=11 -0x1957243971efcd4897e219769b235807f7c2fb726efb78917478416c7ecccf4a=1 -0x8e13121c1e4e86c134cf89dbb43971fd7e17d5388a88b6e8cfd2271a403dd80f=1 -0x38d0c96aa2d7dc31b26923637023f0ec1bfa2c661f6194f39bad8862b4a8d8a0=63 - -Deposit Roots -0x7145788308cae4edce32d919d55363b9bf33e26598ce08d591da1b973fa3f5bc=638 -0x1cd4bea86b7d65ddd49541f828cf2e7b0068cd00bb7e4888aaf4630b11b15b15=11 -0x3abb67c5bba4d0c3cbf7f2aacbd01b8fcf59840c8ce36f82e8d03bb51a987677=1 -0xf44e4b56d4190d89d897e5641d0cea3a8adbfd419d1258a9180732f0a0caee26=64 -0xdd868cee8ef3eaee5a6707fc2e68682a8d7d77fdc349cf1fd8f8f88303a1faa8=18 - -Deposit Counts -66629=638 -66623=11 -66624=1 -66627=64 -66628=18 - -Votes -deposit_root:"݆\x8c\xee\x8e\xf3\xea\xeeZg\x07\xfc.hh*\x8d}w\xfd\xc3I\xcf\x1f\xd8\xf8\xf8\x83\x03\xa1\xfa\xa8" deposit_count:66628 block_hash:"\xd3\xc1\x13+\x -8c\xeb\xb6\x01\x87*2'z\xf7\x08\xec\x0f\x02kt\xe8\x14\x95k\x0f\x14VQb4Ď"=18 -deposit_root:"qEx\x83\x08\xca\xe4\xed\xce2\xd9\x19\xd5Sc\xb9\xbf3\xe2e\x98\xce\x08Ց\xda\x1b\x97?\xa3\xf5\xbc" deposit_count:66629 block_hash:"\xd3\xc1\x13+\ -x8c\xeb\xb6\x01\x87*2'z\xf7\x08\xec\x0f\x02kt\xe8\x14\x95k\x0f\x14VQb4Ď"=638 -deposit_root:"\x1cԾ\xa8k}e\xddԕA\xf8(\xcf.{\x00h\xcd\x00\xbb~H\x88\xaa\xf4c\x0b\x11\xb1[\x15" deposit_count:66623 block_hash:"kA\x8e3\xacj}\x18\x14\x08\xaf\ -x03\x06\xc4u\xad\xff\x9e\xa2\x8aC\xb9~\x1f\x85\xe8 p\x98\x8f\x92\x88"=11 -deposit_root:":\xbbgŻ\xa4\xd0\xc3\xcb\xf7\xf2\xaa\xcb\xd0\x1b\x8f\xcfY\x84\x0c\x8c\xe3o\x82\xe8\xd0;\xb5\x1a\x98vw" deposit_count:66624 block_hash:"\x19W$9q -\xef\xcdH\x97\xe2\x19v\x9b#X\x07\xf7\xc2\xfbrn\xfbx\x91txAl~\xcc\xcfJ"=1 -deposit_root:"\xf4NKV\xd4\x19\r\x89ؗ\xe5d\x1d\x0c\xea:\x8a\xdb\xfdA\x9d\x12X\xa9\x18\x072\xf0\xa0\xca\xee&" deposit_count:66627 block_hash:"\x8e\x13\x12\x1c\ -x1eN\x86\xc14ω۴9q\xfd~\x17\xd58\x8a\x88\xb6\xe8\xcf\xd2'\x1a@=\xd8\x0f"=1 -deposit_root:"\xf4NKV\xd4\x19\r\x89ؗ\xe5d\x1d\x0c\xea:\x8a\xdb\xfdA\x9d\x12X\xa9\x18\x072\xf0\xa0\xca\xee&" deposit_count:66627 block_hash:"8\xd0\xc9j\xa2\xd -7\xdc1\xb2i#cp#\xf0\xec\x1b\xfa,f\x1fa\x94󛭈b\xb4\xa8ؠ"=63 -``` \ No newline at end of file diff --git a/tools/eth1voting/main.go b/tools/eth1voting/main.go deleted file mode 100644 index a2e515fedf..0000000000 --- a/tools/eth1voting/main.go +++ /dev/null @@ -1,95 +0,0 @@ -package main - -import ( - "context" - "flag" - "fmt" - "math" - "time" - - "github.com/OffchainLabs/prysm/v6/config/params" - "github.com/OffchainLabs/prysm/v6/consensus-types/blocks" - "github.com/OffchainLabs/prysm/v6/consensus-types/interfaces" - "github.com/OffchainLabs/prysm/v6/consensus-types/primitives" - v1alpha1 "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1" - "github.com/OffchainLabs/prysm/v6/time/slots" - "golang.org/x/sync/errgroup" - "google.golang.org/grpc" -) - -var ( - beacon = flag.String("beacon", "127.0.0.1:4000", "gRPC address of the Prysm beacon node") - genesis = flag.Uint64("genesis", 1606824023, "Genesis time. mainnet=1606824023, holesky=1695902400") -) - -func main() { - flag.Parse() - ctx := context.Background() - - cc, err := grpc.DialContext(ctx, *beacon, grpc.WithInsecure(), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(math.MaxInt64))) - if err != nil { - panic(err) - } - c := v1alpha1.NewBeaconChainClient(cc) - g, ctx := errgroup.WithContext(ctx) - v := newVotes() - - current := slots.ToEpoch(slots.CurrentSlot(*genesis)) - start := current.Div(uint64(params.BeaconConfig().EpochsPerEth1VotingPeriod)).Mul(uint64(params.BeaconConfig().EpochsPerEth1VotingPeriod)) - nextStart := start.AddEpoch(params.BeaconConfig().EpochsPerEth1VotingPeriod) - - fmt.Printf("Looking back from current epoch %d back to %d\n", current, start) - nextStartSlot, err := slots.EpochStart(nextStart) - if err != nil { - panic(err) - } - nextStartTime, err := slots.ToTime(*genesis, nextStartSlot) - if err != nil { - panic(err) - } - fmt.Printf("Next period starts at epoch %d (%s)\n", nextStart, time.Until(nextStartTime)) - - for i := primitives.Epoch(0); i < current.Sub(uint64(start)); i++ { - j := i - g.Go(func() error { - resp, err := c.ListBeaconBlocks(ctx, &v1alpha1.ListBlocksRequest{ - QueryFilter: &v1alpha1.ListBlocksRequest_Epoch{Epoch: current.Sub(uint64(j))}, - }) - if err != nil { - return err - } - for _, c := range resp.GetBlockContainers() { - v.Insert(wrapBlock(c)) - } - - return nil - }) - } - - if err := g.Wait(); err != nil { - panic(err) - } - - fmt.Println(v.Report()) -} - -func wrapBlock(b *v1alpha1.BeaconBlockContainer) interfaces.ReadOnlyBeaconBlock { - var err error - var wb interfaces.ReadOnlySignedBeaconBlock - switch bb := b.Block.(type) { - case *v1alpha1.BeaconBlockContainer_Phase0Block: - wb, err = blocks.NewSignedBeaconBlock(bb.Phase0Block) - case *v1alpha1.BeaconBlockContainer_AltairBlock: - wb, err = blocks.NewSignedBeaconBlock(bb.AltairBlock) - case *v1alpha1.BeaconBlockContainer_BellatrixBlock: - wb, err = blocks.NewSignedBeaconBlock(bb.BellatrixBlock) - case *v1alpha1.BeaconBlockContainer_CapellaBlock: - wb, err = blocks.NewSignedBeaconBlock(bb.CapellaBlock) - case *v1alpha1.BeaconBlockContainer_BlindedCapellaBlock: - wb, err = blocks.NewSignedBeaconBlock(bb.BlindedCapellaBlock) - } - if err != nil { - panic("no block") - } - return wb.Block() -} diff --git a/tools/eth1voting/votes.go b/tools/eth1voting/votes.go deleted file mode 100644 index fe76ecbda7..0000000000 --- a/tools/eth1voting/votes.go +++ /dev/null @@ -1,91 +0,0 @@ -package main - -import ( - "fmt" - "sync" - - "github.com/OffchainLabs/prysm/v6/consensus-types/interfaces" - "github.com/OffchainLabs/prysm/v6/encoding/bytesutil" - v1alpha1 "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1" -) - -type votes struct { - l sync.RWMutex - - hashes map[[32]byte]uint - roots map[[32]byte]uint - counts map[uint64]uint - votes map[[32]byte]*v1alpha1.Eth1Data - voteCounts map[[32]byte]uint - total uint -} - -func newVotes() *votes { - return &votes{ - hashes: make(map[[32]byte]uint), - roots: make(map[[32]byte]uint), - counts: make(map[uint64]uint), - votes: make(map[[32]byte]*v1alpha1.Eth1Data), - voteCounts: make(map[[32]byte]uint), - } -} - -func (v *votes) Insert(blk interfaces.ReadOnlyBeaconBlock) { - v.l.Lock() - defer v.l.Unlock() - - e1d := blk.Body().Eth1Data() - htr, err := e1d.HashTreeRoot() - if err != nil { - panic(err) // lint:nopanic -- Panic is OK for this tool. - } - v.hashes[bytesutil.ToBytes32(e1d.BlockHash)]++ - v.roots[bytesutil.ToBytes32(e1d.DepositRoot)]++ - v.counts[e1d.DepositCount]++ - v.votes[htr] = e1d - v.voteCounts[htr]++ - v.total++ -} - -func (v *votes) Report() string { - v.l.RLock() - defer v.l.RUnlock() - format := `====Eth1Data Voting Report==== - -Total votes: %d - -Block Hashes -%s -Deposit Roots -%s -Deposit Counts -%s -Votes -%s -` - var blockHashes string - for r, cnt := range v.hashes { - blockHashes += fmt.Sprintf("%#x=%d\n", r, cnt) - } - var depositRoots string - for r, cnt := range v.roots { - depositRoots += fmt.Sprintf("%#x=%d\n", r, cnt) - } - var depositCounts string - for dc, cnt := range v.counts { - depositCounts += fmt.Sprintf("%d=%d\n", dc, cnt) - } - var votes string - for htr, e1d := range v.votes { - votes += fmt.Sprintf("%s=%d\n", e1d.String(), v.voteCounts[htr]) - } - - return fmt.Sprintf( - format, - v.total, - blockHashes, - depositRoots, - depositCounts, - votes, - ) -}