Skip to content

Commit 8beb366

Browse files
Darioush Jalaliceyonur
andauthored
coreth sync: 0.12.4-rc.0 -> 0.12.7 (#975)
* coreth sync: 0.12.4-rc.0 -> 0.12.7 * Review coreth 0.12.7 (#980) * Apply suggested changes from https://github.com/ava-labs/coreth/pull/381/files * drop reexec=0 * add txHashes * bump avalanchego * remove manager * fix compat test * bump version for e2e tests --------- Co-authored-by: Ceyhun Onur <ceyhun.onur@avalabs.org>
1 parent bb9aca9 commit 8beb366

File tree

273 files changed

+5703
-3238
lines changed

Some content is hidden

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

273 files changed

+5703
-3238
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This file configures github.com/golangci/golangci-lint.
22

33
run:
4-
timeout: 3m
4+
timeout: 10m
55
tests: true
66
# default is true. Enables skipping of directories:
77
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$

SECURITY.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Security Policy
2+
3+
Avalanche takes the security of the platform and of its users very seriously. We and our community recognize the critical role of external security researchers and developers and welcome
4+
responsible disclosures. Valid reports will be eligible for a reward (terms and conditions apply).
5+
6+
## Reporting a Vulnerability
7+
8+
**Please do not file a public ticket** mentioning the vulnerability. To disclose a vulnerability submit it through our [Bug Bounty Program](https://hackenproof.com/avalanche).
9+
10+
Vulnerabilities must be disclosed to us privately with reasonable time to respond, and avoid compromise of other users and accounts, or loss of funds that are not your own. We do not reward spam or
11+
social engineering vulnerabilities.
12+
13+
Do not test for or validate any security issues in the live Avalanche networks (Mainnet and Fuji testnet), confirm all exploits in a local private testnet.
14+
15+
Please refer to the [Bug Bounty Page](https://hackenproof.com/avalanche) for the most up-to-date program rules and scope.
16+
17+
## Supported Versions
18+
19+
Please use the [most recently released version](https://github.com/ava-labs/subnet-evm/releases/latest) to perform testing and to validate security issues.

accounts/abi/abi.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,17 @@ func (abi *ABI) EventByID(topic common.Hash) (*Event, error) {
341341
return nil, fmt.Errorf("no event with id: %#x", topic.Hex())
342342
}
343343

344+
// ErrorByID looks up an error by the 4-byte id,
345+
// returns nil if none found.
346+
func (abi *ABI) ErrorByID(sigdata [4]byte) (*Error, error) {
347+
for _, errABI := range abi.Errors {
348+
if bytes.Equal(errABI.ID[:4], sigdata[:]) {
349+
return &errABI, nil
350+
}
351+
}
352+
return nil, fmt.Errorf("no error with id: %#x", sigdata[:])
353+
}
354+
344355
// HasFallback returns an indicator whether a fallback function is included.
345356
func (abi *ABI) HasFallback() bool {
346357
return abi.Fallback.Type == Fallback

accounts/abi/abi_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,34 @@ func TestABI_EventById(t *testing.T) {
10681068
}
10691069
}
10701070

1071+
func TestABI_ErrorByID(t *testing.T) {
1072+
abi, err := JSON(strings.NewReader(`[
1073+
{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"MyError1","type":"error"},
1074+
{"inputs":[{"components":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"string","name":"b","type":"string"},{"internalType":"address","name":"c","type":"address"}],"internalType":"struct MyError.MyStruct","name":"x","type":"tuple"},{"internalType":"address","name":"y","type":"address"},{"components":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"string","name":"b","type":"string"},{"internalType":"address","name":"c","type":"address"}],"internalType":"struct MyError.MyStruct","name":"z","type":"tuple"}],"name":"MyError2","type":"error"},
1075+
{"inputs":[{"internalType":"uint256[]","name":"x","type":"uint256[]"}],"name":"MyError3","type":"error"}
1076+
]`))
1077+
if err != nil {
1078+
t.Fatal(err)
1079+
}
1080+
for name, m := range abi.Errors {
1081+
a := fmt.Sprintf("%v", &m)
1082+
var id [4]byte
1083+
copy(id[:], m.ID[:4])
1084+
m2, err := abi.ErrorByID(id)
1085+
if err != nil {
1086+
t.Fatalf("Failed to look up ABI error: %v", err)
1087+
}
1088+
b := fmt.Sprintf("%v", m2)
1089+
if a != b {
1090+
t.Errorf("Error %v (id %x) not 'findable' by id in ABI", name, id)
1091+
}
1092+
}
1093+
// test unsuccessful lookups
1094+
if _, err = abi.ErrorByID([4]byte{}); err == nil {
1095+
t.Error("Expected error: no error with this id")
1096+
}
1097+
}
1098+
10711099
// TestDoubleDuplicateMethodNames checks that if transfer0 already exists, there won't be a name
10721100
// conflict and that the second transfer method will be renamed transfer1.
10731101
func TestDoubleDuplicateMethodNames(t *testing.T) {

accounts/abi/bind/backends/simulated.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
723723
return errors.New("could not fetch parent")
724724
}
725725
// Check transaction validity
726-
signer := types.NewLondonSigner(b.blockchain.Config().ChainID)
726+
signer := types.MakeSigner(b.blockchain.Config(), block.Number(), block.Time())
727727
sender, err := types.Sender(signer, tx)
728728
if err != nil {
729729
return fmt.Errorf("invalid transaction: %v", err)
@@ -940,7 +940,11 @@ func (fb *filterBackend) GetReceipts(ctx context.Context, hash common.Hash) (typ
940940
if number == nil {
941941
return nil, nil
942942
}
943-
return rawdb.ReadReceipts(fb.db, hash, *number, fb.bc.Config()), nil
943+
header := rawdb.ReadHeader(fb.db, hash, *number)
944+
if header == nil {
945+
return nil, nil
946+
}
947+
return rawdb.ReadReceipts(fb.db, hash, *number, header.Time, fb.bc.Config()), nil
944948
}
945949

946950
func (fb *filterBackend) GetLogs(ctx context.Context, hash common.Hash, number uint64) ([][]*types.Log, error) {

accounts/abi/bind/backends/simulated_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ func TestSimulatedBackend(t *testing.T) {
7575
code := `6060604052600a8060106000396000f360606040526008565b00`
7676
var gas uint64 = 3000000
7777
tx := types.NewContractCreation(0, big.NewInt(0), gas, gasPrice, common.FromHex(code))
78-
signer := types.NewLondonSigner(big.NewInt(1337))
79-
tx, _ = types.SignTx(tx, signer, key)
78+
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, key)
8079

8180
err = sim.SendTransaction(context.Background(), tx)
8281
if err != nil {

accounts/abi/bind/base.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ func (c *BoundContract) WatchLogs(opts *WatchOpts, name string, query ...[]inter
503503

504504
// UnpackLog unpacks a retrieved log into the provided output structure.
505505
func (c *BoundContract) UnpackLog(out interface{}, event string, log types.Log) error {
506+
// Anonymous events are not supported.
506507
if len(log.Topics) == 0 {
507508
return errNoEventSignature
508509
}
@@ -525,6 +526,7 @@ func (c *BoundContract) UnpackLog(out interface{}, event string, log types.Log)
525526

526527
// UnpackLogIntoMap unpacks a retrieved log into the provided map.
527528
func (c *BoundContract) UnpackLogIntoMap(out map[string]interface{}, event string, log types.Log) error {
529+
// Anonymous events are not supported.
528530
if len(log.Topics) == 0 {
529531
return errNoEventSignature
530532
}

accounts/abi/bind/base_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,23 @@ func TestUnpackIndexedStringTyLogIntoMap(t *testing.T) {
195195
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
196196
}
197197

198+
func TestUnpackAnonymousLogIntoMap(t *testing.T) {
199+
mockLog := newMockLog(nil, common.HexToHash("0x0"))
200+
201+
abiString := `[{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"}],"name":"received","type":"event"}]`
202+
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
203+
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
204+
205+
var received map[string]interface{}
206+
err := bc.UnpackLogIntoMap(received, "received", mockLog)
207+
if err == nil {
208+
t.Error("unpacking anonymous event is not supported")
209+
}
210+
if err.Error() != "no event signature" {
211+
t.Errorf("expected error 'no event signature', got '%s'", err)
212+
}
213+
}
214+
198215
func TestUnpackIndexedSliceTyLogIntoMap(t *testing.T) {
199216
sliceBytes, err := rlp.EncodeToBytes([]string{"name1", "name2", "name3", "name4"})
200217
if err != nil {

accounts/abi/bind/bind.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,19 @@ func BindHelper(types []string, abis []string, bytecodes []string, fsigs []map[s
150150
// Normalize the method for capital cases and non-anonymous inputs/outputs
151151
normalized := original
152152
normalizedName := methodNormalizer[lang](alias(aliases, original.Name))
153-
154153
// Ensure there is no duplicated identifier
155154
identifiers := callIdentifiers
156155
if !original.IsConstant() {
157156
identifiers = transactIdentifiers
158157
}
158+
// Name shouldn't start with a digit. It will make the generated code invalid.
159+
if len(normalizedName) > 0 && unicode.IsDigit(rune(normalizedName[0])) {
160+
normalizedName = fmt.Sprintf("M%s", normalizedName)
161+
normalizedName = abi.ResolveNameConflict(normalizedName, func(name string) bool {
162+
_, ok := identifiers[name]
163+
return ok
164+
})
165+
}
159166
if identifiers[normalizedName] {
160167
return "", fmt.Errorf("duplicated identifier \"%s\"(normalized \"%s\"), use --alias for renaming", original.Name, normalizedName)
161168
}
@@ -199,6 +206,14 @@ func BindHelper(types []string, abis []string, bytecodes []string, fsigs []map[s
199206

200207
// Ensure there is no duplicated identifier
201208
normalizedName := methodNormalizer[lang](alias(aliases, original.Name))
209+
// Name shouldn't start with a digit. It will make the generated code invalid.
210+
if len(normalizedName) > 0 && unicode.IsDigit(rune(normalizedName[0])) {
211+
normalizedName = fmt.Sprintf("E%s", normalizedName)
212+
normalizedName = abi.ResolveNameConflict(normalizedName, func(name string) bool {
213+
_, ok := eventIdentifiers[name]
214+
return ok
215+
})
216+
}
202217
if eventIdentifiers[normalizedName] {
203218
return "", fmt.Errorf("duplicated identifier \"%s\"(normalized \"%s\"), use --alias for renaming", original.Name, normalizedName)
204219
}

accounts/abi/bind/bind_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,29 @@ var bindTests = []struct {
20532053
t.Errorf("error deploying the contract: %v", err)
20542054
}
20552055
`,
2056+
}, {
2057+
name: "NumericMethodName",
2058+
contract: `
2059+
// SPDX-License-Identifier: GPL-3.0
2060+
pragma solidity >=0.4.22 <0.9.0;
2061+
2062+
contract NumericMethodName {
2063+
event _1TestEvent(address _param);
2064+
function _1test() public pure {}
2065+
function __1test() public pure {}
2066+
function __2test() public pure {}
2067+
}
2068+
`,
2069+
bytecode: []string{"0x6080604052348015600f57600080fd5b5060958061001e6000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c80639d993132146041578063d02767c7146049578063ffa02795146051575b600080fd5b60476059565b005b604f605b565b005b6057605d565b005b565b565b56fea26469706673582212200382ca602dff96a7e2ba54657985e2b4ac423a56abe4a1f0667bc635c4d4371f64736f6c63430008110033"},
2070+
abi: []string{`[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_param","type":"address"}],"name":"_1TestEvent","type":"event"},{"inputs":[],"name":"_1test","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"__1test","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"__2test","outputs":[],"stateMutability":"pure","type":"function"}]`},
2071+
imports: `
2072+
"github.com/ethereum/go-ethereum/common"
2073+
`,
2074+
tester: `
2075+
if b, err := NewNumericMethodName(common.Address{}, nil); b == nil || err != nil {
2076+
t.Fatalf("combined binding (%v) nil or error (%v) not nil", b, nil)
2077+
}
2078+
`,
20562079
},
20572080
}
20582081

0 commit comments

Comments
 (0)