mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
Merge branch 'ethereum:master' into portal
This commit is contained in:
commit
e6f3769e93
3 changed files with 143 additions and 2 deletions
|
|
@ -56,7 +56,7 @@ On the evening of 17th, we discussed options on how to handle it. We made a stat
|
|||
It was decided that in this specific instance, it would be possible to make a public announcement and a patch release:
|
||||
|
||||
- The fix can be made pretty 'generically', e.g. always copying data on input to precompiles.
|
||||
- The flaw is pretty difficult to find, given a generic fix in the call. The attacker needs to figure out that it concerns the precompiles, specifically the datcopy, and that it concerns the `RETURNDATA` buffer rather than the regular memory, and lastly the special circumstances to trigger it (overlapping but shifted input/output).
|
||||
- The flaw is pretty difficult to find, given a generic fix in the call. The attacker needs to figure out that it concerns the precompiles, specifically the datacopy, and that it concerns the `RETURNDATA` buffer rather than the regular memory, and lastly the special circumstances to trigger it (overlapping but shifted input/output).
|
||||
|
||||
Since we had merged the removal of `ETH65`, if the entire network were to upgrade, then nodes which have not yet implemented `ETH66` would be cut off from the network. After further discussions, we decided to:
|
||||
|
||||
|
|
|
|||
140
p2p/netutil/addrutil_test.go
Normal file
140
p2p/netutil/addrutil_test.go
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
// Copyright 2024 The go-ethereum Authors
|
||||
// This file is part of the go-ethereum library.
|
||||
//
|
||||
// The go-ethereum 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 go-ethereum 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 go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package netutil
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/netip"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// customNetAddr is a custom implementation of net.Addr for testing purposes.
|
||||
type customNetAddr struct{}
|
||||
|
||||
func (c *customNetAddr) Network() string { return "custom" }
|
||||
func (c *customNetAddr) String() string { return "custom" }
|
||||
|
||||
func TestAddrAddr(t *testing.T) {
|
||||
tempDir := t.TempDir()
|
||||
tests := []struct {
|
||||
name string
|
||||
addr net.Addr
|
||||
want netip.Addr
|
||||
}{
|
||||
{
|
||||
name: "IPAddr IPv4",
|
||||
addr: &net.IPAddr{IP: net.ParseIP("192.0.2.1")},
|
||||
want: netip.MustParseAddr("192.0.2.1"),
|
||||
},
|
||||
{
|
||||
name: "IPAddr IPv6",
|
||||
addr: &net.IPAddr{IP: net.ParseIP("2001:db8::1")},
|
||||
want: netip.MustParseAddr("2001:db8::1"),
|
||||
},
|
||||
{
|
||||
name: "TCPAddr IPv4",
|
||||
addr: &net.TCPAddr{IP: net.ParseIP("192.0.2.1"), Port: 8080},
|
||||
want: netip.MustParseAddr("192.0.2.1"),
|
||||
},
|
||||
{
|
||||
name: "TCPAddr IPv6",
|
||||
addr: &net.TCPAddr{IP: net.ParseIP("2001:db8::1"), Port: 8080},
|
||||
want: netip.MustParseAddr("2001:db8::1"),
|
||||
},
|
||||
{
|
||||
name: "UDPAddr IPv4",
|
||||
addr: &net.UDPAddr{IP: net.ParseIP("192.0.2.1"), Port: 8080},
|
||||
want: netip.MustParseAddr("192.0.2.1"),
|
||||
},
|
||||
{
|
||||
name: "UDPAddr IPv6",
|
||||
addr: &net.UDPAddr{IP: net.ParseIP("2001:db8::1"), Port: 8080},
|
||||
want: netip.MustParseAddr("2001:db8::1"),
|
||||
},
|
||||
{
|
||||
name: "Unsupported Addr type",
|
||||
addr: &net.UnixAddr{Name: filepath.Join(tempDir, "test.sock"), Net: "unix"},
|
||||
want: netip.Addr{},
|
||||
},
|
||||
{
|
||||
name: "Nil input",
|
||||
addr: nil,
|
||||
want: netip.Addr{},
|
||||
},
|
||||
{
|
||||
name: "Custom net.Addr implementation",
|
||||
addr: &customNetAddr{},
|
||||
want: netip.Addr{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := AddrAddr(tt.addr); got != tt.want {
|
||||
t.Errorf("AddrAddr() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIPToAddr(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
ip net.IP
|
||||
want netip.Addr
|
||||
}{
|
||||
{
|
||||
name: "IPv4",
|
||||
ip: net.ParseIP("192.0.2.1"),
|
||||
want: netip.MustParseAddr("192.0.2.1"),
|
||||
},
|
||||
{
|
||||
name: "IPv6",
|
||||
ip: net.ParseIP("2001:db8::1"),
|
||||
want: netip.MustParseAddr("2001:db8::1"),
|
||||
},
|
||||
{
|
||||
name: "Invalid IP",
|
||||
ip: net.IP{1, 2, 3},
|
||||
want: netip.Addr{},
|
||||
},
|
||||
{
|
||||
name: "Invalid IP (5 octets)",
|
||||
ip: net.IP{192, 0, 2, 1, 1},
|
||||
want: netip.Addr{},
|
||||
},
|
||||
{
|
||||
name: "IPv4-mapped IPv6",
|
||||
ip: net.ParseIP("::ffff:192.0.2.1"),
|
||||
want: netip.MustParseAddr("192.0.2.1"),
|
||||
},
|
||||
{
|
||||
name: "Nil input",
|
||||
ip: nil,
|
||||
want: netip.Addr{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := IPToAddr(tt.ip); got != tt.want {
|
||||
t.Errorf("IPToAddr() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -308,6 +308,7 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
|
|||
if tracer := evm.Config.Tracer; tracer != nil && tracer.OnTxEnd != nil {
|
||||
evm.Config.Tracer.OnTxEnd(nil, err)
|
||||
}
|
||||
return st, common.Hash{}, 0, err
|
||||
}
|
||||
// Add 0-value mining reward. This only makes a difference in the cases
|
||||
// where
|
||||
|
|
@ -322,7 +323,7 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
|
|||
receipt := &types.Receipt{GasUsed: vmRet.UsedGas}
|
||||
tracer.OnTxEnd(receipt, nil)
|
||||
}
|
||||
return st, root, vmRet.UsedGas, err
|
||||
return st, root, vmRet.UsedGas, nil
|
||||
}
|
||||
|
||||
func (t *StateTest) gasLimit(subtest StateSubtest) uint64 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue