Skip to content

Commit 8d4e798

Browse files
Revert changes (we can do it better)
1 parent 21a80cb commit 8d4e798

File tree

125 files changed

+569
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+569
-480
lines changed

accounts/abi/abi.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
"io"
2525
"math/big"
2626

27+
"github.com/ethereum/go-ethereum/arbkeccak"
2728
"github.com/ethereum/go-ethereum/common"
28-
"github.com/ethereum/go-ethereum/crypto"
2929
)
3030

3131
// The ABI holds information about a contract's context and available
@@ -248,10 +248,10 @@ func (abi *ABI) HasReceive() bool {
248248
}
249249

250250
// revertSelector is a special function selector for revert reason unpacking.
251-
var revertSelector = crypto.Keccak256([]byte("Error(string)"))[:4]
251+
var revertSelector = arbkeccak.Keccak256([]byte("Error(string)"))[:4]
252252

253253
// panicSelector is a special function selector for panic reason unpacking.
254-
var panicSelector = crypto.Keccak256([]byte("Panic(uint256)"))[:4]
254+
var panicSelector = arbkeccak.Keccak256([]byte("Panic(uint256)"))[:4]
255255

256256
// panicReasons map is for readable panic codes
257257
// see this linkage for the details

accounts/abi/abi_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ import (
2626
"strings"
2727
"testing"
2828

29+
"github.com/ethereum/go-ethereum/arbkeccak"
2930
"github.com/ethereum/go-ethereum/common"
3031
"github.com/ethereum/go-ethereum/common/math"
31-
"github.com/ethereum/go-ethereum/crypto"
3232
"github.com/ethereum/go-ethereum/internal/testrand"
3333
)
3434

@@ -248,7 +248,7 @@ func TestMethodSignature(t *testing.T) {
248248
t.Error("signature mismatch", exp, "!=", m.Sig)
249249
}
250250

251-
idexp := crypto.Keccak256([]byte(exp))[:4]
251+
idexp := arbkeccak.Keccak256([]byte(exp))[:4]
252252
if !bytes.Equal(m.ID, idexp) {
253253
t.Errorf("expected ids to match %x != %x", m.ID, idexp)
254254
}
@@ -357,7 +357,7 @@ func TestMultiPack(t *testing.T) {
357357
t.Fatal(err)
358358
}
359359

360-
sig := crypto.Keccak256([]byte("bar(uint32,uint16)"))[:4]
360+
sig := arbkeccak.Keccak256([]byte("bar(uint32,uint16)"))[:4]
361361
sig = append(sig, make([]byte, 64)...)
362362
sig[35] = 10
363363
sig[67] = 11
@@ -1026,7 +1026,7 @@ func TestABI_MethodById(t *testing.T) {
10261026
}
10271027
}
10281028
// test unsuccessful lookups
1029-
if _, err = abi.MethodById(crypto.Keccak256()); err == nil {
1029+
if _, err = abi.MethodById(arbkeccak.Keccak256()); err == nil {
10301030
t.Error("Expected error: no method with this id")
10311031
}
10321032
// Also test empty
@@ -1085,7 +1085,7 @@ func TestABI_EventById(t *testing.T) {
10851085
}
10861086

10871087
topic := test.event
1088-
topicID := crypto.Keccak256Hash([]byte(topic))
1088+
topicID := arbkeccak.Keccak256Hash([]byte(topic))
10891089

10901090
event, err := abi.EventByID(topicID)
10911091
if err != nil {
@@ -1097,7 +1097,7 @@ func TestABI_EventById(t *testing.T) {
10971097
t.Errorf("Event id %s does not match topic %s, test #%d", event.ID.Hex(), topicID.Hex(), testnum)
10981098
}
10991099

1100-
unknowntopicID := crypto.Keccak256Hash([]byte("unknownEvent"))
1100+
unknowntopicID := arbkeccak.Keccak256Hash([]byte("unknownEvent"))
11011101
unknownEvent, err := abi.EventByID(unknowntopicID)
11021102
if err == nil {
11031103
t.Errorf("EventByID should return an error if a topic is not found, test #%d", testnum)

accounts/abi/abigen/bindv2_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"testing"
2424

2525
"github.com/ethereum/go-ethereum/accounts/abi"
26-
"github.com/ethereum/go-ethereum/crypto"
26+
"github.com/ethereum/go-ethereum/arbkeccak"
2727
)
2828

2929
type bindV2Test struct {
@@ -52,7 +52,7 @@ func bindCombinedJSON(test *bindV2Test) (string, error) {
5252
// hex encoding of the keccak256 hash of the fully qualified library name.
5353
// Note that the fully qualified library name is the path of its source
5454
// file and the library name separated by ":".
55-
libPattern := crypto.Keccak256Hash([]byte(typeName)).String()[2:36] // the first 2 chars are 0x
55+
libPattern := arbkeccak.Keccak256Hash([]byte(typeName)).String()[2:36] // the first 2 chars are 0x
5656
libs[libPattern] = typeName
5757
}
5858
if test.aliases == nil {

accounts/abi/bind/v2/base_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ import (
2727
"github.com/ethereum/go-ethereum"
2828
"github.com/ethereum/go-ethereum/accounts/abi"
2929
"github.com/ethereum/go-ethereum/accounts/abi/bind/v2"
30+
"github.com/ethereum/go-ethereum/arbkeccak"
3031
"github.com/ethereum/go-ethereum/common"
3132
"github.com/ethereum/go-ethereum/common/hexutil"
3233
"github.com/ethereum/go-ethereum/core/types"
33-
"github.com/ethereum/go-ethereum/crypto"
3434
"github.com/ethereum/go-ethereum/rlp"
3535
"github.com/stretchr/testify/assert"
3636
)
@@ -188,9 +188,9 @@ const hexData = "0x000000000000000000000000376c47978271565f56deb45495afa69e59c16
188188

189189
func TestUnpackIndexedStringTyLogIntoMap(t *testing.T) {
190190
t.Parallel()
191-
hash := crypto.Keccak256Hash([]byte("testName"))
191+
hash := arbkeccak.Keccak256Hash([]byte("testName"))
192192
topics := []common.Hash{
193-
crypto.Keccak256Hash([]byte("received(string,address,uint256,bytes)")),
193+
arbkeccak.Keccak256Hash([]byte("received(string,address,uint256,bytes)")),
194194
hash,
195195
}
196196
mockLog := newMockLog(topics, common.HexToHash("0x0"))
@@ -232,9 +232,9 @@ func TestUnpackIndexedSliceTyLogIntoMap(t *testing.T) {
232232
if err != nil {
233233
t.Fatal(err)
234234
}
235-
hash := crypto.Keccak256Hash(sliceBytes)
235+
hash := arbkeccak.Keccak256Hash(sliceBytes)
236236
topics := []common.Hash{
237-
crypto.Keccak256Hash([]byte("received(string[],address,uint256,bytes)")),
237+
arbkeccak.Keccak256Hash([]byte("received(string[],address,uint256,bytes)")),
238238
hash,
239239
}
240240
mockLog := newMockLog(topics, common.HexToHash("0x0"))
@@ -258,9 +258,9 @@ func TestUnpackIndexedArrayTyLogIntoMap(t *testing.T) {
258258
if err != nil {
259259
t.Fatal(err)
260260
}
261-
hash := crypto.Keccak256Hash(arrBytes)
261+
hash := arbkeccak.Keccak256Hash(arrBytes)
262262
topics := []common.Hash{
263-
crypto.Keccak256Hash([]byte("received(address[2],address,uint256,bytes)")),
263+
arbkeccak.Keccak256Hash([]byte("received(address[2],address,uint256,bytes)")),
264264
hash,
265265
}
266266
mockLog := newMockLog(topics, common.HexToHash("0x0"))
@@ -282,13 +282,13 @@ func TestUnpackIndexedFuncTyLogIntoMap(t *testing.T) {
282282
t.Parallel()
283283
mockAddress := common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2")
284284
addrBytes := mockAddress.Bytes()
285-
hash := crypto.Keccak256Hash([]byte("mockFunction(address,uint)"))
285+
hash := arbkeccak.Keccak256Hash([]byte("mockFunction(address,uint)"))
286286
functionSelector := hash[:4]
287287
functionTyBytes := append(addrBytes, functionSelector...)
288288
var functionTy [24]byte
289289
copy(functionTy[:], functionTyBytes[0:24])
290290
topics := []common.Hash{
291-
crypto.Keccak256Hash([]byte("received(function,address,uint256,bytes)")),
291+
arbkeccak.Keccak256Hash([]byte("received(function,address,uint256,bytes)")),
292292
common.BytesToHash(functionTyBytes),
293293
}
294294
mockLog := newMockLog(topics, common.HexToHash("0x5c698f13940a2153440c6d19660878bc90219d9298fdcf37365aa8d88d40fc42"))
@@ -308,9 +308,9 @@ func TestUnpackIndexedFuncTyLogIntoMap(t *testing.T) {
308308
func TestUnpackIndexedBytesTyLogIntoMap(t *testing.T) {
309309
t.Parallel()
310310
bytes := []byte{1, 2, 3, 4, 5}
311-
hash := crypto.Keccak256Hash(bytes)
311+
hash := arbkeccak.Keccak256Hash(bytes)
312312
topics := []common.Hash{
313-
crypto.Keccak256Hash([]byte("received(bytes,address,uint256,bytes)")),
313+
arbkeccak.Keccak256Hash([]byte("received(bytes,address,uint256,bytes)")),
314314
hash,
315315
}
316316
mockLog := newMockLog(topics, common.HexToHash("0x5c698f13940a2153440c6d19660878bc90219d9298fdcf37365aa8d88d40fc42"))

accounts/abi/bind/v2/dep_tree_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"regexp"
2222
"testing"
2323

24+
"github.com/ethereum/go-ethereum/arbkeccak"
2425
"github.com/ethereum/go-ethereum/common"
2526
"github.com/ethereum/go-ethereum/core/types"
2627
"github.com/ethereum/go-ethereum/crypto"
@@ -69,12 +70,12 @@ func makeLinkTestCase(input map[rune][]rune, overrides map[rune]common.Address)
6970
for contract, deps := range input {
7071
inputMap[contract] = make(map[rune]struct{})
7172
if _, ok := patternMap[contract]; !ok {
72-
patternMap[contract] = crypto.Keccak256Hash([]byte(string(contract))).String()[2:36]
73+
patternMap[contract] = arbkeccak.Keccak256Hash([]byte(string(contract))).String()[2:36]
7374
}
7475

7576
for _, dep := range deps {
7677
if _, ok := patternMap[dep]; !ok {
77-
patternMap[dep] = crypto.Keccak256Hash([]byte(string(dep))).String()[2:36]
78+
patternMap[dep] = arbkeccak.Keccak256Hash([]byte(string(dep))).String()[2:36]
7879
}
7980
codes[patternMap[contract]] = codes[patternMap[contract]] + fmt.Sprintf("__$%s$__", patternMap[dep])
8081
inputMap[contract][dep] = struct{}{}
@@ -83,7 +84,7 @@ func makeLinkTestCase(input map[rune][]rune, overrides map[rune]common.Address)
8384
}
8485
overridesPatterns := make(map[string]common.Address)
8586
for contractId, overrideAddr := range overrides {
86-
pattern := crypto.Keccak256Hash([]byte(string(contractId))).String()[2:36]
87+
pattern := arbkeccak.Keccak256Hash([]byte(string(contractId))).String()[2:36]
8788
overridesPatterns[pattern] = overrideAddr
8889
}
8990

@@ -228,7 +229,7 @@ func testLinkCase(tcInput linkTestCaseInput) error {
228229
return fmt.Errorf("got %d deployed contracts. expected %d.\n", len(res.Addresses), len(tcInput.expectDeployed))
229230
}
230231
for contract := range tcInput.expectDeployed {
231-
pattern := crypto.Keccak256Hash([]byte(string(contract))).String()[2:36]
232+
pattern := arbkeccak.Keccak256Hash([]byte(string(contract))).String()[2:36]
232233
if _, ok := res.Addresses[pattern]; !ok {
233234
return fmt.Errorf("expected contract %s was not deployed\n", string(contract))
234235
}

accounts/abi/bind/v2/generate_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import (
2424
"testing"
2525

2626
"github.com/ethereum/go-ethereum/accounts/abi/abigen"
27+
"github.com/ethereum/go-ethereum/arbkeccak"
2728
"github.com/ethereum/go-ethereum/cmd/utils"
2829
"github.com/ethereum/go-ethereum/common/compiler"
29-
"github.com/ethereum/go-ethereum/crypto"
3030
)
3131

3232
// Run go generate to recreate the test bindings.
@@ -83,7 +83,7 @@ func TestBindingGeneration(t *testing.T) {
8383
// hex encoding of the keccak256 hash of the fully qualified library name.
8484
// Note that the fully qualified library name is the path of its source
8585
// file and the library name separated by ":".
86-
libPattern := crypto.Keccak256Hash([]byte(name)).String()[2:36] // the first 2 chars are 0x
86+
libPattern := arbkeccak.Keccak256Hash([]byte(name)).String()[2:36] // the first 2 chars are 0x
8787
libs[libPattern] = typeName
8888
}
8989
code, err := abigen.BindV2(types, abis, bins, dir, libs, make(map[string]string))

accounts/abi/error.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
"fmt"
2222
"strings"
2323

24+
"github.com/ethereum/go-ethereum/arbkeccak"
2425
"github.com/ethereum/go-ethereum/common"
25-
"github.com/ethereum/go-ethereum/crypto"
2626
)
2727

2828
type Error struct {
@@ -66,7 +66,7 @@ func NewError(name string, inputs Arguments) Error {
6666

6767
str := fmt.Sprintf("error %v(%v)", name, strings.Join(names, ", "))
6868
sig := fmt.Sprintf("%v(%v)", name, strings.Join(types, ","))
69-
id := common.BytesToHash(crypto.Keccak256([]byte(sig)))
69+
id := common.BytesToHash(arbkeccak.Keccak256([]byte(sig)))
7070

7171
return Error{
7272
Name: name,

accounts/abi/event.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
"fmt"
2121
"strings"
2222

23+
"github.com/ethereum/go-ethereum/arbkeccak"
2324
"github.com/ethereum/go-ethereum/common"
24-
"github.com/ethereum/go-ethereum/crypto"
2525
)
2626

2727
// Event is an event potentially triggered by the EVM's LOG mechanism. The Event
@@ -85,7 +85,7 @@ func NewEvent(name, rawName string, anonymous bool, inputs Arguments) Event {
8585

8686
str := fmt.Sprintf("event %v(%v)", rawName, strings.Join(names, ", "))
8787
sig := fmt.Sprintf("%v(%v)", rawName, strings.Join(types, ","))
88-
id := common.BytesToHash(crypto.Keccak256([]byte(sig)))
88+
id := common.BytesToHash(arbkeccak.Keccak256([]byte(sig)))
8989

9090
return Event{
9191
Name: name,

accounts/abi/event_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525
"strings"
2626
"testing"
2727

28+
"github.com/ethereum/go-ethereum/arbkeccak"
2829
"github.com/ethereum/go-ethereum/common"
29-
"github.com/ethereum/go-ethereum/crypto"
3030
"github.com/stretchr/testify/assert"
3131
"github.com/stretchr/testify/require"
3232
)
@@ -92,8 +92,8 @@ func TestEventId(t *testing.T) {
9292
{ "type" : "event", "name" : "Check", "inputs": [{ "name" : "t", "type": "address" }, { "name": "b", "type": "uint256" }] }
9393
]`,
9494
expectations: map[string]common.Hash{
95-
"Balance": crypto.Keccak256Hash([]byte("Balance(uint256)")),
96-
"Check": crypto.Keccak256Hash([]byte("Check(address,uint256)")),
95+
"Balance": arbkeccak.Keccak256Hash([]byte("Balance(uint256)")),
96+
"Check": arbkeccak.Keccak256Hash([]byte("Check(address,uint256)")),
9797
},
9898
},
9999
}

accounts/abi/method.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"fmt"
2121
"strings"
2222

23-
"github.com/ethereum/go-ethereum/crypto"
23+
"github.com/ethereum/go-ethereum/arbkeccak"
2424
)
2525

2626
// FunctionType represents different types of functions a contract might have.
@@ -115,7 +115,7 @@ func NewMethod(name string, rawName string, funType FunctionType, mutability str
115115
)
116116
if funType == Function {
117117
sig = fmt.Sprintf("%v(%v)", rawName, strings.Join(types, ","))
118-
id = crypto.Keccak256([]byte(sig))[:4]
118+
id = arbkeccak.Keccak256([]byte(sig))[:4]
119119
}
120120
identity := fmt.Sprintf("function %v", rawName)
121121
switch funType {

0 commit comments

Comments
 (0)