Skip to content

Commit a1b426a

Browse files
Merge branch 'master' of github.com:ethereum/go-ethereum
# Conflicts: # internal/ethapi/api.go
2 parents 9671bfc + 50dbe8e commit a1b426a

File tree

9 files changed

+15
-130
lines changed

9 files changed

+15
-130
lines changed

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,11 @@ FROM alpine:latest
1212
RUN apk add --no-cache ca-certificates
1313
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
1414

15+
RUN addgroup -g 1000 geth && \
16+
adduser -h /root -D -u 1000 -G geth geth && \
17+
chown geth:geth /root
18+
19+
USER geth
20+
1521
EXPOSE 8545 8546 30303 30303/udp 30304/udp
1622
ENTRYPOINT ["geth"]

Dockerfile.alltools

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@ FROM alpine:latest
1212
RUN apk add --no-cache ca-certificates
1313
COPY --from=builder /go-ethereum/build/bin/* /usr/local/bin/
1414

15+
RUN addgroup -g 1000 geth && \
16+
adduser -h /root -D -u 1000 -G geth geth \
17+
chown geth:geth /root
18+
19+
USER geth
20+
1521
EXPOSE 8545 8546 30303 30303/udp 30304/udp

core/database_util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ func TestLookupStorage(t *testing.T) {
317317
if hash != block.Hash() || number != block.NumberU64() || index != uint64(i) {
318318
t.Fatalf("tx #%d [%x]: positional metadata mismatch: have %x/%d/%d, want %x/%v/%v", i, tx.Hash(), hash, number, index, block.Hash(), block.NumberU64(), i)
319319
}
320-
if tx.String() != txn.String() {
320+
if tx.Hash() != txn.Hash() {
321321
t.Fatalf("tx #%d [%x]: transaction mismatch: have %v, want %v", i, tx.Hash(), txn, tx)
322322
}
323323
}

core/types/block.go

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package types
1919

2020
import (
2121
"encoding/binary"
22-
"fmt"
2322
"io"
2423
"math/big"
2524
"sort"
@@ -389,40 +388,6 @@ func (b *Block) Hash() common.Hash {
389388
return v
390389
}
391390

392-
func (b *Block) String() string {
393-
str := fmt.Sprintf(`Block(#%v): Size: %v {
394-
MinerHash: %x
395-
%v
396-
Transactions:
397-
%v
398-
Uncles:
399-
%v
400-
}
401-
`, b.Number(), b.Size(), b.header.HashNoNonce(), b.header, b.transactions, b.uncles)
402-
return str
403-
}
404-
405-
func (h *Header) String() string {
406-
return fmt.Sprintf(`Header(%x):
407-
[
408-
ParentHash: %x
409-
UncleHash: %x
410-
Coinbase: %x
411-
Root: %x
412-
TxSha %x
413-
ReceiptSha: %x
414-
Bloom: %x
415-
Difficulty: %v
416-
Number: %v
417-
GasLimit: %v
418-
GasUsed: %v
419-
Time: %v
420-
Extra: %s
421-
MixDigest: %x
422-
Nonce: %x
423-
]`, h.Hash(), h.ParentHash, h.UncleHash, h.Coinbase, h.Root, h.TxHash, h.ReceiptHash, h.Bloom, h.Difficulty, h.Number, h.GasLimit, h.GasUsed, h.Time, h.Extra, h.MixDigest, h.Nonce)
424-
}
425-
426391
type Blocks []*Block
427392

428393
type BlockBy func(b1, b2 *Block) bool

core/types/log.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package types
1818

1919
import (
20-
"fmt"
2120
"io"
2221

2322
"github.com/ethereum/go-ethereum/common"
@@ -95,10 +94,6 @@ func (l *Log) DecodeRLP(s *rlp.Stream) error {
9594
return err
9695
}
9796

98-
func (l *Log) String() string {
99-
return fmt.Sprintf(`log: %x %x %x %x %d %x %d`, l.Address, l.Topics, l.Data, l.TxHash, l.TxIndex, l.BlockHash, l.Index)
100-
}
101-
10297
// LogForStorage is a wrapper around a Log that flattens and parses the entire content of
10398
// a log including non-consensus fields.
10499
type LogForStorage Log

core/types/receipt.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,6 @@ func (r *Receipt) Size() common.StorageSize {
149149
return size
150150
}
151151

152-
// String implements the Stringer interface.
153-
func (r *Receipt) String() string {
154-
if len(r.PostState) == 0 {
155-
return fmt.Sprintf("receipt{status=%d cgas=%v bloom=%x logs=%v}", r.Status, r.CumulativeGasUsed, r.Bloom, r.Logs)
156-
}
157-
return fmt.Sprintf("receipt{med=%x cgas=%v bloom=%x logs=%v}", r.PostState, r.CumulativeGasUsed, r.Bloom, r.Logs)
158-
}
159-
160152
// ReceiptForStorage is a wrapper around a Receipt that flattens and parses the
161153
// entire content of a receipt, as opposed to only the consensus fields originally.
162154
type ReceiptForStorage Receipt

core/types/transaction.go

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package types
1919
import (
2020
"container/heap"
2121
"errors"
22-
"fmt"
2322
"io"
2423
"math/big"
2524
"sync/atomic"
@@ -262,58 +261,6 @@ func (tx *Transaction) RawSignatureValues() (*big.Int, *big.Int, *big.Int) {
262261
return tx.data.V, tx.data.R, tx.data.S
263262
}
264263

265-
func (tx *Transaction) String() string {
266-
var from, to string
267-
if tx.data.V != nil {
268-
// make a best guess about the signer and use that to derive
269-
// the sender.
270-
signer := deriveSigner(tx.data.V)
271-
if f, err := Sender(signer, tx); err != nil { // derive but don't cache
272-
from = "[invalid sender: invalid sig]"
273-
} else {
274-
from = fmt.Sprintf("%x", f[:])
275-
}
276-
} else {
277-
from = "[invalid sender: nil V field]"
278-
}
279-
280-
if tx.data.Recipient == nil {
281-
to = "[contract creation]"
282-
} else {
283-
to = fmt.Sprintf("%x", tx.data.Recipient[:])
284-
}
285-
enc, _ := rlp.EncodeToBytes(&tx.data)
286-
return fmt.Sprintf(`
287-
TX(%x)
288-
Contract: %v
289-
From: %s
290-
To: %s
291-
Nonce: %v
292-
GasPrice: %#x
293-
GasLimit %#x
294-
Value: %#x
295-
Data: 0x%x
296-
V: %#x
297-
R: %#x
298-
S: %#x
299-
Hex: %x
300-
`,
301-
tx.Hash(),
302-
tx.data.Recipient == nil,
303-
from,
304-
to,
305-
tx.data.AccountNonce,
306-
tx.data.Price,
307-
tx.data.GasLimit,
308-
tx.data.Amount,
309-
tx.data.Payload,
310-
tx.data.V,
311-
tx.data.R,
312-
tx.data.S,
313-
enc,
314-
)
315-
}
316-
317264
// Transactions is a Transaction slice type for basic sorting.
318265
type Transactions []*Transaction
319266

internal/ethapi/api.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ import (
2525
"strings"
2626
"time"
2727

28-
"github.com/syndtr/goleveldb/leveldb"
29-
"github.com/syndtr/goleveldb/leveldb/util"
30-
28+
"github.com/davecgh/go-spew/spew"
3129
"github.com/ethereum/go-ethereum/accounts"
3230
"github.com/ethereum/go-ethereum/accounts/keystore"
3331
"github.com/ethereum/go-ethereum/common"
@@ -1389,7 +1387,7 @@ func (api *PublicDebugAPI) PrintBlock(ctx context.Context, number uint64) (strin
13891387
if block == nil {
13901388
return "", fmt.Errorf("block #%d not found", number)
13911389
}
1392-
return block.String(), nil
1390+
return spew.Sdump(block), nil
13931391
}
13941392

13951393
// SeedHash retrieves the seed hash of a block.

mobile/types.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,6 @@ func (h *Header) EncodeJSON() (string, error) {
9797
return string(data), err
9898
}
9999

100-
// String implements the fmt.Stringer interface to print some semi-meaningful
101-
// data dump of the header for debugging purposes.
102-
func (h *Header) String() string {
103-
return h.header.String()
104-
}
105-
106100
func (h *Header) GetParentHash() *Hash { return &Hash{h.header.ParentHash} }
107101
func (h *Header) GetUncleHash() *Hash { return &Hash{h.header.UncleHash} }
108102
func (h *Header) GetCoinbase() *Address { return &Address{h.header.Coinbase} }
@@ -174,12 +168,6 @@ func (b *Block) EncodeJSON() (string, error) {
174168
return string(data), err
175169
}
176170

177-
// String implements the fmt.Stringer interface to print some semi-meaningful
178-
// data dump of the block for debugging purposes.
179-
func (b *Block) String() string {
180-
return b.block.String()
181-
}
182-
183171
func (b *Block) GetParentHash() *Hash { return &Hash{b.block.ParentHash()} }
184172
func (b *Block) GetUncleHash() *Hash { return &Hash{b.block.UncleHash()} }
185173
func (b *Block) GetCoinbase() *Address { return &Address{b.block.Coinbase()} }
@@ -249,12 +237,6 @@ func (tx *Transaction) EncodeJSON() (string, error) {
249237
return string(data), err
250238
}
251239

252-
// String implements the fmt.Stringer interface to print some semi-meaningful
253-
// data dump of the transaction for debugging purposes.
254-
func (tx *Transaction) String() string {
255-
return tx.tx.String()
256-
}
257-
258240
func (tx *Transaction) GetData() []byte { return tx.tx.Data() }
259241
func (tx *Transaction) GetGas() int64 { return int64(tx.tx.Gas()) }
260242
func (tx *Transaction) GetGasPrice() *BigInt { return &BigInt{tx.tx.GasPrice()} }
@@ -347,12 +329,6 @@ func (r *Receipt) EncodeJSON() (string, error) {
347329
return string(data), err
348330
}
349331

350-
// String implements the fmt.Stringer interface to print some semi-meaningful
351-
// data dump of the transaction receipt for debugging purposes.
352-
func (r *Receipt) String() string {
353-
return r.receipt.String()
354-
}
355-
356332
func (r *Receipt) GetPostState() []byte { return r.receipt.PostState }
357333
func (r *Receipt) GetCumulativeGasUsed() int64 { return int64(r.receipt.CumulativeGasUsed) }
358334
func (r *Receipt) GetBloom() *Bloom { return &Bloom{r.receipt.Bloom} }

0 commit comments

Comments
 (0)