Remove bazel-go-ethereum fork, use upstream go-ethereum (#9725)

* Check in go-ethereum crypto/sepc256k1 package with proper build rules

* gaz

* Add karalabe/usb

* viz improvement

* Remove bazel-go-ethereum, use vendored libraries only

* move vendor stuff to third_party so that go mod wont be mad anymore

* fix geth e2e flags

* fix geth e2e flags

* remove old rules_foreign_cc toolchain

* Update cross compile docker image to support os x

* works for geth build

* remove copy of sepc256k1

* revert changes in tools/cross-toolchain

* gaz

* Update go-ethereum to 1.10.10

* Revert "revert changes in tools/cross-toolchain"

This reverts commit 2e8128f7c3.

* revert tags changes

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Preston Van Loon
2021-10-18 19:00:22 -05:00
committed by GitHub
parent 7b8aedbfe4
commit 65db331eaf
23 changed files with 800 additions and 126 deletions

View File

@@ -0,0 +1,58 @@
diff --color -ruN a/crypto/secp256k1/BUILD.bazel b/crypto/secp256k1/BUILD.bazel
--- a/crypto/secp256k1/BUILD.bazel 2021-10-14 20:32:30.202922024 -0500
+++ b/crypto/secp256k1/BUILD.bazel 2021-10-14 20:30:17.921027939 -0500
@@ -11,10 +11,11 @@
"scalar_mult_nocgo.go",
"secp256.go",
],
+ cdeps = ["//crypto/secp256k1/libsecp256k1:hdrs"],
cgo = True,
copts = [
- "-Icrypto/secp256k1/libsecp256k1",
- "-Icrypto/secp256k1/libsecp256k1/src",
+ "-Iexternal/com_github_ethereum_go_ethereum/crypto/secp256k1/libsecp256k1",
+ "-Iexternal/com_github_ethereum_go_ethereum/crypto/secp256k1/libsecp256k1/src",
],
importpath = "github.com/ethereum/go-ethereum/crypto/secp256k1",
visibility = ["//visibility:public"],
diff --color -ruN a/crypto/secp256k1/libsecp256k1/BUILD.bazel b/crypto/secp256k1/libsecp256k1/BUILD.bazel
--- a/crypto/secp256k1/libsecp256k1/BUILD.bazel 1969-12-31 18:00:00.000000000 -0600
+++ b/crypto/secp256k1/libsecp256k1/BUILD.bazel 2021-10-14 12:54:27.704265206 -0500
@@ -0,0 +1,37 @@
+cc_library(
+ name = "hdrs",
+ hdrs = [
+ "include/secp256k1.h",
+ "include/secp256k1_recovery.h",
+ "src/ecdsa.h",
+ "src/ecdsa_impl.h",
+ "src/eckey.h",
+ "src/eckey_impl.h",
+ "src/ecmult.h",
+ "src/ecmult_const.h",
+ "src/ecmult_const_impl.h",
+ "src/ecmult_gen.h",
+ "src/ecmult_gen_impl.h",
+ "src/ecmult_impl.h",
+ "src/field.h",
+ "src/field_5x52.h",
+ "src/field_5x52_impl.h",
+ "src/field_5x52_int128_impl.h",
+ "src/field_impl.h",
+ "src/group.h",
+ "src/group_impl.h",
+ "src/hash.h",
+ "src/hash_impl.h",
+ "src/modules/recovery/main_impl.h",
+ "src/num.h",
+ "src/num_impl.h",
+ "src/scalar.h",
+ "src/scalar_4x64.h",
+ "src/scalar_4x64_impl.h",
+ "src/scalar_impl.h",
+ "src/secp256k1.c",
+ "src/util.h",
+ ],
+ visibility = ["//visibility:public"],
+)
+

7
third_party/usb/AUTHORS vendored Normal file
View File

@@ -0,0 +1,7 @@
Felix Lange <fjl@twurst.com>
Guillaume Ballet <gballet@gmail.com>
Jakob Weisblat <jakobw@yubico.com>
Martin Holst Swende <martin@swende.se>
Mateusz Mikołajczyk <mikolajczyk.mateusz@gmail.com>
Péter Szilágyi <peterke@gmail.com>
Rosen Penev <rosenp@gmail.com>

21
third_party/usb/BUILD.bazel vendored Normal file
View File

@@ -0,0 +1,21 @@
load("@prysm//tools/go:def.bzl", "go_library", "go_test")
# gazelle:prefix github.com/karalabe/usb
go_library(
name = "go_default_library",
srcs = [
"hid_disabled.go",
"raw_disabled.go",
"usb.go",
"usb_disabled.go",
],
importpath = "github.com/karalabe/usb",
visibility = ["@com_github_ethereum_go_ethereum//:__subpackages__"],
)
go_test(
name = "go_default_test",
srcs = ["usb_test.go"],
embed = [":go_default_library"],
)

165
third_party/usb/LICENSE vendored Normal file
View File

@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

6
third_party/usb/README.md vendored Normal file
View File

@@ -0,0 +1,6 @@
# usb
This is a copy of github.com/karalabe/usb, except that it is fully disabled.
The current karalabe/usb library requires a bit of handwritten cc_library targets.
This library isn't used in Prysm anyway, so it is disabled for now.

40
third_party/usb/hid_disabled.go vendored Normal file
View File

@@ -0,0 +1,40 @@
// usb - Self contained USB and HID library for Go
// Copyright 2017 The library Authors
//
// This library is free software: you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// The library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
// A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along
// with the library. If not, see <http://www.gnu.org/licenses/>.
package usb
// HidDevice is a live HID USB connected device handle. On platforms that this file
// implements, the type lacks the actual HID device and all methods are noop.
type HidDevice struct {
DeviceInfo // Embed the infos for easier access
}
// Close releases the HID USB device handle. On platforms that this file implements,
// the method is just a noop.
func (dev *HidDevice) Close() error {
return ErrUnsupportedPlatform
}
// Write sends an output report to a HID device. On platforms that this file
// implements, the method just returns an error.
func (dev *HidDevice) Write(b []byte) (int, error) {
return 0, ErrUnsupportedPlatform
}
// Read retrieves an input report from a HID device. On platforms that this file
// implements, the method just returns an error.
func (dev *HidDevice) Read(b []byte) (int, error) {
return 0, ErrUnsupportedPlatform
}

40
third_party/usb/raw_disabled.go vendored Normal file
View File

@@ -0,0 +1,40 @@
// usb - Self contained USB and HID library for Go
// Copyright 2017 The library Authors
//
// This library is free software: you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// The library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
// A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along
// with the library. If not, see <http://www.gnu.org/licenses/>.
package usb
// RawDevice is a live raw USB connected device handle. On platforms that this file
// implements, the type lacks the actual USB device and all methods are noop.
type RawDevice struct {
DeviceInfo // Embed the infos for easier access
}
// Close releases the USB device handle. On platforms that this file implements,
// the method is just a noop.
func (dev *RawDevice) Close() error {
return ErrUnsupportedPlatform
}
// Write sends a binary blob to a USB device. On platforms that this file
// implements, the method just returns an error.
func (dev *RawDevice) Write(b []byte) (int, error) {
return 0, ErrUnsupportedPlatform
}
// Read retrieves a binary blob from a USB device. On platforms that this file
// implements, the method just returns an error.
func (dev *RawDevice) Read(b []byte) (int, error) {
return 0, ErrUnsupportedPlatform
}

68
third_party/usb/usb.go vendored Normal file
View File

@@ -0,0 +1,68 @@
// usb - Self contained USB and HID library for Go
// Copyright 2019 The library Authors
//
// This library is free software: you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// The library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
// A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along
// with the library. If not, see <http://www.gnu.org/licenses/>.
// Package usb provide interfaces for generic USB devices.
package usb
import "errors"
// ErrDeviceClosed is returned for operations where the device closed before or
// during the execution.
var ErrDeviceClosed = errors.New("usb: device closed")
// ErrUnsupportedPlatform is returned for all operations where the underlying
// operating system is not supported by the library.
var ErrUnsupportedPlatform = errors.New("usb: unsupported platform")
// DeviceInfo contains all the information we know about a USB device. In case of
// HID devices, that might be a lot more extensive (empty fields for raw USB).
type DeviceInfo struct {
Path string // Platform-specific device path
VendorID uint16 // Device Vendor ID
ProductID uint16 // Device Product ID
Release uint16 // Device Release Number in binary-coded decimal, also known as Device Version Number
Serial string // Serial Number
Manufacturer string // Manufacturer String
Product string // Product string
UsagePage uint16 // Usage Page for this Device/Interface (Windows/Mac only)
Usage uint16 // Usage for this Device/Interface (Windows/Mac only)
// The USB interface which this logical device
// represents. Valid on both Linux implementations
// in all cases, and valid on the Windows implementation
// only if the device contains more than one interface.
Interface int
// Raw low level libusb endpoint data for simplified communication
rawDevice interface{}
rawPort *uint8 // Pointer to differentiate between unset and port 0
rawReader *uint8 // Pointer to differentiate between unset and endpoint 0
rawWriter *uint8 // Pointer to differentiate between unset and endpoint 0
}
// Device is a generic USB device interface. It may either be backed by a USB HID
// device or a low level raw (libusb) device.
type Device interface {
// Close releases the USB device handle.
Close() error
// Write sends a binary blob to a USB device. For HID devices write uses reports,
// for low level USB write uses interrupt transfers.
Write(b []byte) (int, error)
// Read retrieves a binary blob from a USB device. For HID devices read uses
// reports, for low level USB read uses interrupt transfers.
Read(b []byte) (int, error)
}

49
third_party/usb/usb_disabled.go vendored Normal file
View File

@@ -0,0 +1,49 @@
// usb - Self contained USB and HID library for Go
// Copyright 2019 The library Authors
//
// This library is free software: you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// The library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
// A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along
// with the library. If not, see <http://www.gnu.org/licenses/>.
package usb
// Supported returns whether this platform is supported by the USB library or not.
// The goal of this method is to allow programatically handling platforms that do
// not support USB and not having to fall back to build constraints.
func Supported() bool {
return false
}
// Enumerate returns a list of all the USB devices attached to the system which
// match the vendor and product id. On platforms that this file implements the
// function is a noop and returns an empty list always.
func Enumerate(vendorID uint16, productID uint16) ([]DeviceInfo, error) {
return nil, nil
}
// EnumerateRaw returns a list of all the USB devices attached to the system which
// match the vendor and product id. On platforms that this file implements the
// function is a noop and returns an empty list always.
func EnumerateRaw(vendorID uint16, productID uint16) ([]DeviceInfo, error) {
return nil, nil
}
// EnumerateHid returns a list of all the HID devices attached to the system which
// match the vendor and product id. On platforms that this file implements the
// function is a noop and returns an empty list always.
func EnumerateHid(vendorID uint16, productID uint16) ([]DeviceInfo, error) {
return nil, nil
}
// Open connects to a previsouly discovered USB device.
func (info DeviceInfo) Open() (Device, error) {
return nil, ErrUnsupportedPlatform
}

86
third_party/usb/usb_test.go vendored Normal file
View File

@@ -0,0 +1,86 @@
// usb - Self contained USB and HID library for Go
// Copyright 2017 The library Authors
//
// This library is free software: you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// The library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
// A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along
// with the library. If not, see <http://www.gnu.org/licenses/>.
package usb
import (
"os"
"runtime"
"sync"
"testing"
)
// Tests that HID enumeration can be called concurrently from multiple threads.
func TestThreadedEnumerateHid(t *testing.T) {
var pend sync.WaitGroup
for i := 0; i < 8; i++ {
pend.Add(1)
go func(index int) {
defer pend.Done()
for j := 0; j < 512; j++ {
if _, err := EnumerateHid(uint16(index), 0); err != nil {
t.Errorf("thread %d, iter %d: failed to enumerate: %v", index, j, err)
}
}
}(i)
}
pend.Wait()
}
// Tests that RAW enumeration can be called concurrently from multiple threads.
func TestThreadedEnumerateRaw(t *testing.T) {
// Travis does not have usbfs enabled in the Linux kernel
if os.Getenv("TRAVIS") != "" && runtime.GOOS == "linux" {
t.Skip("Linux on Travis doesn't have usbfs, skipping test")
}
// Yay, we can actually test this
var pend sync.WaitGroup
for i := 0; i < 8; i++ {
pend.Add(1)
go func(index int) {
defer pend.Done()
for j := 0; j < 512; j++ {
if _, err := EnumerateRaw(uint16(index), 0); err != nil {
t.Errorf("thread %d, iter %d: failed to enumerate: %v", index, j, err)
}
}
}(i)
}
pend.Wait()
}
// Tests that generic enumeration can be called concurrently from multiple threads.
func TestThreadedEnumerate(t *testing.T) {
// Travis does not have usbfs enabled in the Linux kernel
if os.Getenv("TRAVIS") != "" && runtime.GOOS == "linux" {
t.Skip("Linux on Travis doesn't have usbfs, skipping test")
}
var pend sync.WaitGroup
for i := 0; i < 8; i++ {
pend.Add(1)
go func(index int) {
defer pend.Done()
for j := 0; j < 512; j++ {
if _, err := Enumerate(uint16(index), 0); err != nil {
t.Errorf("thread %d, iter %d: failed to enumerate: %v", index, j, err)
}
}
}(i)
}
pend.Wait()
}