Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: upstream patches #1076

Merged
merged 31 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4bb491f
go.mod : upnp 1.0.3 stable version (#24573)
ucwong Mar 29, 2022
b4573de
eth/tracers/logger: use omitempty to reduce log bloat (#24547)
holiman Mar 29, 2022
c273e20
eth: change snapshot extension registration failure to warning instea…
nicjansma Mar 30, 2022
9106e8d
eth/fetcher: if peers never respond, drop them
karalabe Apr 6, 2022
e5200ca
core/state/snapshot: remove noop map item assignment
karalabe Apr 7, 2022
2a88da0
les: fix panic in ultralight client sync (#24641)
rjl493456442 Apr 8, 2022
ba4b9b0
core/types: make "miner" optional in Header JSON (#24666)
fjl Apr 11, 2022
2551bc8
core: fix benchmark panic (#24657)
rjl493456442 Apr 12, 2022
c80d620
trie: remove unused makeHashNode (#24702)
darioush Apr 20, 2022
42a3496
eth/tracers/logger: remove unnecessary comparisons in accessList.equa…
Apr 21, 2022
ed7fbb9
cmd/evm: ensure input length is even (#24721)
jwasinger Apr 25, 2022
08938b6
mobile: fix receipt encoding to json (#24701)
enginegl Apr 25, 2022
c63e648
p2p: fix type of DiscSubprotocolError (#24747)
henopied Apr 25, 2022
65abd1f
core/types: fix unhandled errors in TestTransactionCoding (#24692)
tia-99 Apr 27, 2022
1c69124
ethclient/gethclient: return storage proofs in GetProof (#24697)
trianglesphere Apr 27, 2022
f1f412a
eth/filters: remove unused struct fields (#24782)
hero5512 Apr 29, 2022
896a730
docker: speed up docker image build (#24796)
eval-exec May 3, 2022
2979192
cmd/utils: double limit on free-disk monitor (#24781)
holiman May 3, 2022
a8733ae
build: fix formatted logs (#24807)
freaker2k7 May 3, 2022
3f29f8f
eth/filters: remove explicit continue label in filterLogs (#24795)
eval-exec May 5, 2022
67777dc
p2p/simulations: escape mockerType value from request (#24822)
ImanSharaf May 5, 2022
e086e8d
eth/fetcher: avoid hang in tests (partial fix for #23331) (#23351)
holiman May 6, 2022
c5f1088
abi: fix checks when all fields are indexed (#24792)
rachel-bousfield May 6, 2022
a1ed98b
core/state/snapshot: fix race condition (#24685)
MariusVanDerWijden May 6, 2022
ee5ac4e
internal: drop TestSignCliqueBlock (#24837)
s1na May 10, 2022
9bdc1d1
core/vm: update benchmark to use Errorf instead of Sprintf (#24845)
aaronbuchwald May 10, 2022
031c496
core/vm: clean up some dead functions (#24851)
s7v7nislands May 11, 2022
3d84485
graphql: fix long literal passed in a variable (#24864)
s1na May 12, 2022
04d24d0
core/asm: use strings.Builder and fix godoc issues (#24861)
s7v7nislands May 16, 2022
d53c048
all: use strings.EqualFold for string comparison (#24890)
estensen May 17, 2022
bbf0ed3
core: fix the order of address in queue (#24907)
zhaochonghe May 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ ARG BUILDNUM=""
FROM golang:1.17-alpine as builder

RUN apk add --no-cache make gcc musl-dev linux-headers git bash
# Get dependencies - will also be cached if we won't change go.mod/go.sum
COPY go.mod /go-ethereum/
COPY go.sum /go-ethereum/
RUN cd /go-ethereum && go mod download

ADD . /go-ethereum
RUN cd /go-ethereum && go run build/ci.go install ./cmd/geth
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile.alltools
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ ARG BUILDNUM=""
FROM golang:1.17-alpine as builder

RUN apk add --no-cache gcc musl-dev linux-headers git
# Get dependencies - will also be cached if we won't change go.mod/go.sum
COPY go.mod /go-ethereum/
COPY go.sum /go-ethereum/
RUN cd /go-ethereum && go mod download

ADD . /go-ethereum
RUN cd /go-ethereum && go run build/ci.go install
Expand Down
8 changes: 4 additions & 4 deletions accounts/abi/argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (arguments Arguments) isTuple() bool {
// Unpack performs the operation hexdata -> Go format.
func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
if len(data) == 0 {
if len(arguments) != 0 {
if len(arguments.NonIndexed()) != 0 {
return nil, fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
}
return make([]interface{}, 0), nil
Expand All @@ -93,7 +93,7 @@ func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte)
return fmt.Errorf("abi: cannot unpack into a nil map")
}
if len(data) == 0 {
if len(arguments) != 0 {
if len(arguments.NonIndexed()) != 0 {
return fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
}
return nil // Nothing to unmarshal, return
Expand All @@ -115,8 +115,8 @@ func (arguments Arguments) Copy(v interface{}, values []interface{}) error {
return fmt.Errorf("abi: Unpack(non-pointer %T)", v)
}
if len(values) == 0 {
if len(arguments) != 0 {
return fmt.Errorf("abi: attempting to copy no values while %d arguments are expected", len(arguments))
if len(arguments.NonIndexed()) != 0 {
return fmt.Errorf("abi: attempting to copy no values while arguments are expected")
}
return nil // Nothing to copy, return
}
Expand Down
17 changes: 17 additions & 0 deletions accounts/abi/unpack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,23 @@ var unpackTests = []unpackTest{
IntOne *big.Int
}{big.NewInt(1)},
},
{
def: `[{"type":"bool"}]`,
enc: "",
want: false,
err: "abi: attempting to unmarshall an empty string while arguments are expected",
},
{
def: `[{"type":"bytes32","indexed":true},{"type":"uint256","indexed":false}]`,
enc: "",
want: false,
err: "abi: attempting to unmarshall an empty string while arguments are expected",
},
{
def: `[{"type":"bool","indexed":true},{"type":"uint64","indexed":true}]`,
enc: "",
want: false,
},
}

// TestLocalUnpackTests runs test specially designed only for unpacking.
Expand Down
4 changes: 2 additions & 2 deletions build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -961,10 +961,10 @@ func doWindowsInstaller(cmdline []string) {
build.Render("build/nsis.pathupdate.nsh", filepath.Join(*workdir, "PathUpdate.nsh"), 0644, nil)
build.Render("build/nsis.envvarupdate.nsh", filepath.Join(*workdir, "EnvVarUpdate.nsh"), 0644, nil)
if err := cp.CopyFile(filepath.Join(*workdir, "SimpleFC.dll"), "build/nsis.simplefc.dll"); err != nil {
log.Fatal("Failed to copy SimpleFC.dll: %v", err)
log.Fatalf("Failed to copy SimpleFC.dll: %v", err)
}
if err := cp.CopyFile(filepath.Join(*workdir, "COPYING"), "COPYING"); err != nil {
log.Fatal("Failed to copy copyright note: %v", err)
log.Fatalf("Failed to copy copyright note: %v", err)
}
// Build the installer. This assumes that all the needed files have been previously
// built (don't mix building and packaging to keep cross compilation complexity to a
Expand Down
7 changes: 6 additions & 1 deletion cmd/evm/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,12 @@ func runCmd(ctx *cli.Context) error {
} else {
hexInput = []byte(ctx.GlobalString(InputFlag.Name))
}
input := common.FromHex(string(bytes.TrimSpace(hexInput)))
hexInput = bytes.TrimSpace(hexInput)
if len(hexInput)%2 != 0 {
fmt.Println("input length must be even")
os.Exit(1)
}
input := common.FromHex(string(hexInput))

var execFunc func() ([]byte, uint64, error)
if ctx.GlobalBool(CreateFlag.Name) {
Expand Down
3 changes: 2 additions & 1 deletion cmd/geth/consolecmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ func runMinimalGeth(t *testing.T, args ...string) *testgeth {
// --networkid=1337 to avoid cache bump
// --syncmode=full to avoid allocating fast sync bloom
allArgs := []string{"--ropsten", "--networkid", "1337", "--syncmode=full", "--port", "0",
"--nat", "none", "--nodiscover", "--maxpeers", "0", "--cache", "64"}
"--nat", "none", "--nodiscover", "--maxpeers", "0", "--cache", "64",
"--datadir.minfreedisk", "0"}
return runGeth(t, append(allArgs, args...)...)
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/utils/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ func StartNode(ctx *cli.Context, stack *node.Node, isConsole bool) {
signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM)
defer signal.Stop(sigc)

minFreeDiskSpace := ethconfig.Defaults.TrieDirtyCache
minFreeDiskSpace := 2 * ethconfig.Defaults.TrieDirtyCache // Default 2 * 256Mb
if ctx.GlobalIsSet(MinFreeDiskSpaceFlag.Name) {
minFreeDiskSpace = ctx.GlobalInt(MinFreeDiskSpaceFlag.Name)
} else if ctx.GlobalIsSet(CacheFlag.Name) || ctx.GlobalIsSet(CacheGCFlag.Name) {
minFreeDiskSpace = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheGCFlag.Name) / 100
minFreeDiskSpace = 2 * ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheGCFlag.Name) / 100
}
if minFreeDiskSpace > 0 {
go monitorFreeDiskSpace(sigc, stack.InstanceDir(), uint64(minFreeDiskSpace)*1024*1024)
Expand Down Expand Up @@ -131,7 +131,7 @@ func monitorFreeDiskSpace(sigc chan os.Signal, path string, freeDiskSpaceCritica
} else if freeSpace < 2*freeDiskSpaceCritical {
log.Warn("Disk space is running low. Geth will shutdown if disk space runs below critical level.", "available", common.StorageSize(freeSpace), "critical_level", common.StorageSize(freeDiskSpaceCritical))
}
time.Sleep(60 * time.Second)
time.Sleep(30 * time.Second)
}
}

Expand Down
2 changes: 1 addition & 1 deletion console/prompt/prompter.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (p *terminalPrompter) PromptPassword(prompt string) (passwd string, err err
// choice to be made, returning that choice.
func (p *terminalPrompter) PromptConfirm(prompt string) (bool, error) {
input, err := p.Prompt(prompt + " [y/n] ")
if len(input) > 0 && strings.ToUpper(input[:1]) == "Y" {
if len(input) > 0 && strings.EqualFold(input[:1], "y") {
return true, nil
}
return false, err
Expand Down
18 changes: 9 additions & 9 deletions core/asm/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// 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/>.

// Provides support for dealing with EVM assembly instructions (e.g., disassembling them).
// Package asm provides support for dealing with EVM assembly instructions (e.g., disassembling them).
package asm

import (
Expand All @@ -34,14 +34,14 @@ type instructionIterator struct {
started bool
}

// Create a new instruction iterator.
// NewInstructionIterator create a new instruction iterator.
func NewInstructionIterator(code []byte) *instructionIterator {
it := new(instructionIterator)
it.code = code
return it
}

// Returns true if there is a next instruction and moves on.
// Next returns true if there is a next instruction and moves on.
func (it *instructionIterator) Next() bool {
if it.error != nil || uint64(len(it.code)) <= it.pc {
// We previously reached an error or the end.
Expand Down Expand Up @@ -79,27 +79,27 @@ func (it *instructionIterator) Next() bool {
return true
}

// Returns any error that may have been encountered.
// Error returns any error that may have been encountered.
func (it *instructionIterator) Error() error {
return it.error
}

// Returns the PC of the current instruction.
// PC returns the PC of the current instruction.
func (it *instructionIterator) PC() uint64 {
return it.pc
}

// Returns the opcode of the current instruction.
// Op returns the opcode of the current instruction.
func (it *instructionIterator) Op() vm.OpCode {
return it.op
}

// Returns the argument of the current instruction.
// Arg returns the argument of the current instruction.
func (it *instructionIterator) Arg() []byte {
return it.arg
}

// Pretty-print all disassembled EVM instructions to stdout.
// PrintDisassembled pretty-print all disassembled EVM instructions to stdout.
func PrintDisassembled(code string) error {
script, err := hex.DecodeString(code)
if err != nil {
Expand All @@ -117,7 +117,7 @@ func PrintDisassembled(code string) error {
return it.Error()
}

// Return all disassembled EVM instructions in human-readable format.
// Disassemble returns all disassembled EVM instructions in human-readable format.
func Disassemble(script []byte) ([]string, error) {
instrs := make([]string, 0)

Expand Down
14 changes: 7 additions & 7 deletions core/asm/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Compiler struct {
debug bool
}

// newCompiler returns a new allocated compiler.
// NewCompiler returns a new allocated compiler.
func NewCompiler(debug bool) *Compiler {
return &Compiler{
labels: make(map[string]int),
Expand Down Expand Up @@ -105,16 +105,16 @@ func (c *Compiler) Compile() (string, []error) {
}

// turn the binary to hex
var bin string
var bin strings.Builder
for _, v := range c.binary {
switch v := v.(type) {
case vm.OpCode:
bin += fmt.Sprintf("%x", []byte{byte(v)})
bin.WriteString(fmt.Sprintf("%x", []byte{byte(v)}))
case []byte:
bin += fmt.Sprintf("%x", v)
bin.WriteString(fmt.Sprintf("%x", v))
}
}
return bin, errors
return bin.String(), errors
}

// next returns the next token and increments the
Expand Down Expand Up @@ -243,12 +243,12 @@ func (c *Compiler) pushBin(v interface{}) {
// isPush returns whether the string op is either any of
// push(N).
func isPush(op string) bool {
return strings.ToUpper(op) == "PUSH"
return strings.EqualFold(op, "PUSH")
}

// isJump returns whether the string op is jump(i)
func isJump(op string) bool {
return strings.ToUpper(op) == "JUMPI" || strings.ToUpper(op) == "JUMP"
return strings.EqualFold(op, "JUMPI") || strings.EqualFold(op, "JUMP")
}

// toBinary converts text to a vm.OpCode
Expand Down
2 changes: 1 addition & 1 deletion core/asm/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type lexer struct {
debug bool // flag for triggering debug output
}

// lex lexes the program by name with the given source. It returns a
// Lex lexes the program by name with the given source. It returns a
// channel on which the tokens are delivered.
func Lex(source []byte, debug bool) <-chan token {
ch := make(chan token)
Expand Down
2 changes: 1 addition & 1 deletion core/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func genTxRing(naccounts int) func(int, *BlockGen) {

// genUncles generates blocks with two uncle headers.
func genUncles(i int, gen *BlockGen) {
if i >= 6 {
if i >= 7 {
b2 := gen.PrevBlock(i - 6).Header()
b2.Extra = []byte("foo")
gen.AddUncle(b2)
Expand Down
4 changes: 3 additions & 1 deletion core/state/snapshot/difflayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ func (dl *diffLayer) CorrectAccounts(accounts map[common.Hash][]byte) {

// Parent returns the subsequent layer of a diff layer.
func (dl *diffLayer) Parent() snapshot {
dl.lock.RLock()
defer dl.lock.RUnlock()

return dl.parent
}

Expand Down Expand Up @@ -527,7 +530,6 @@ func (dl *diffLayer) flatten() snapshot {
for storageHash, data := range storage {
comboData[storageHash] = data
}
parent.storageData[accountHash] = comboData
}
// Return the combo parent
return &diffLayer{
Expand Down
2 changes: 1 addition & 1 deletion core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ func (pool *TxPool) truncateQueue() {
addresses = append(addresses, addressByHeartbeat{addr, pool.beats[addr]})
}
}
sort.Sort(addresses)
sort.Sort(sort.Reverse(addresses))
brilliant-lx marked this conversation as resolved.
Show resolved Hide resolved

// Drop transactions until the total is below the limit or only locals remain
for drop := queued - pool.config.GlobalQueue; drop > 0 && len(addresses) > 0; {
Expand Down
2 changes: 1 addition & 1 deletion core/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (n *BlockNonce) UnmarshalText(input []byte) error {
type Header struct {
ParentHash common.Hash `json:"parentHash" gencodec:"required"`
UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"`
Coinbase common.Address `json:"miner" gencodec:"required"`
Coinbase common.Address `json:"miner"`
Root common.Hash `json:"stateRoot" gencodec:"required"`
TxHash common.Hash `json:"transactionsRoot" gencodec:"required"`
ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"`
Expand Down
9 changes: 4 additions & 5 deletions core/types/gen_header_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions core/types/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,14 +548,18 @@ func TestTransactionCoding(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assertEqual(parsedTx, tx)
if err := assertEqual(parsedTx, tx); err != nil {
t.Fatal(err)
}

// JSON
parsedTx, err = encodeDecodeJSON(tx)
if err != nil {
t.Fatal(err)
}
assertEqual(parsedTx, tx)
if err := assertEqual(parsedTx, tx); err != nil {
t.Fatal(err)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ func (c *blake2F) Run(input []byte) ([]byte, error) {
// Parse the input into the Blake2b call parameters
var (
rounds = binary.BigEndian.Uint32(input[0:4])
final = (input[212] == blake2FFinalBlockBytes)
final = input[212] == blake2FFinalBlockBytes

h [8]uint64
m [16]uint64
Expand Down
2 changes: 1 addition & 1 deletion core/vm/contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func benchmarkPrecompiled(addr string, test precompiledTest, bench *testing.B) {
return
}
if common.Bytes2Hex(res) != test.Expected {
bench.Error(fmt.Sprintf("Expected %v, got %v", test.Expected, common.Bytes2Hex(res)))
bench.Errorf("Expected %v, got %v", test.Expected, common.Bytes2Hex(res))
return
}
})
Expand Down
2 changes: 1 addition & 1 deletion core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ func opDifficulty(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
}

func opRandom(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
v := new(uint256.Int).SetBytes((interpreter.evm.Context.Random.Bytes()))
v := new(uint256.Int).SetBytes(interpreter.evm.Context.Random.Bytes())
scope.Stack.push(v)
return nil, nil
}
Expand Down
Loading