all: use 0x-prefix string for type Address in log message (#1874)

This commit is contained in:
wit liu 2025-12-19 12:55:21 +08:00 committed by GitHub
parent d3b35cba42
commit a83c43f240
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 22 additions and 22 deletions

View file

@ -316,7 +316,7 @@ func IsValidRelayer(statedb *state.StateDB, address common.Address) bool {
return false return false
} }
if IsResignedRelayer(address, statedb) { if IsResignedRelayer(address, statedb) {
log.Debug("Relayer has resigned", "relayer", address.String()) log.Debug("Relayer has resigned", "relayer", address)
return false return false
} }
return true return true

View file

@ -165,7 +165,7 @@ func AddTokenBalance(addr common.Address, value *big.Int, token common.Address,
log.Debug("ApplyXDCXMatchedTransaction settle balance: ADD TOKEN XDC NATIVE BEFORE", "token", common.XDCNativeAddress, "address", addr, "balance", balance, "orderValue", value) log.Debug("ApplyXDCXMatchedTransaction settle balance: ADD TOKEN XDC NATIVE BEFORE", "token", common.XDCNativeAddress, "address", addr, "balance", balance, "orderValue", value)
statedb.AddBalance(addr, value, tracing.BalanceChangeUnspecified) statedb.AddBalance(addr, value, tracing.BalanceChangeUnspecified)
balance = statedb.GetBalance(addr) balance = statedb.GetBalance(addr)
log.Debug("ApplyXDCXMatchedTransaction settle balance: ADD XDC NATIVE BALANCE AFTER", "token", token.String(), "address", addr, "balance", balance, "orderValue", value) log.Debug("ApplyXDCXMatchedTransaction settle balance: ADD XDC NATIVE BALANCE AFTER", "token", token, "address", addr, "balance", balance, "orderValue", value)
return nil return nil
} }
@ -195,7 +195,7 @@ func SubTokenBalance(addr common.Address, value *big.Int, token common.Address,
} }
statedb.SubBalance(addr, value, tracing.BalanceChangeUnspecified) statedb.SubBalance(addr, value, tracing.BalanceChangeUnspecified)
balance = statedb.GetBalance(addr) balance = statedb.GetBalance(addr)
log.Debug("ApplyXDCXMatchedTransaction settle balance: SUB XDC NATIVE BALANCE AFTER", "token", token.String(), "address", addr, "balance", balance, "orderValue", value) log.Debug("ApplyXDCXMatchedTransaction settle balance: SUB XDC NATIVE BALANCE AFTER", "token", token, "address", addr, "balance", balance, "orderValue", value)
return nil return nil
} }
@ -204,13 +204,13 @@ func SubTokenBalance(addr common.Address, value *big.Int, token common.Address,
slot := TokenMappingSlot["balances"] slot := TokenMappingSlot["balances"]
locHash := common.BigToHash(GetLocMappingAtKey(addr.Hash(), slot)) locHash := common.BigToHash(GetLocMappingAtKey(addr.Hash(), slot))
balance := statedb.GetState(token, locHash).Big() balance := statedb.GetState(token, locHash).Big()
log.Debug("ApplyXDCXMatchedTransaction settle balance: SUB TOKEN BALANCE BEFORE", "token", token.String(), "address", addr, "balance", balance, "orderValue", value) log.Debug("ApplyXDCXMatchedTransaction settle balance: SUB TOKEN BALANCE BEFORE", "token", token, "address", addr, "balance", balance, "orderValue", value)
if balance.Cmp(value) < 0 { if balance.Cmp(value) < 0 {
return errors.Errorf("value %s in token %s not enough , have : %s , want : %s ", addr.String(), token.String(), balance, value) return errors.Errorf("value %s in token %s not enough , have : %s , want : %s ", addr.String(), token.String(), balance, value)
} }
balance = new(big.Int).Sub(balance, value) balance = new(big.Int).Sub(balance, value)
statedb.SetState(token, locHash, common.BigToHash(balance)) statedb.SetState(token, locHash, common.BigToHash(balance))
log.Debug("ApplyXDCXMatchedTransaction settle balance: SUB TOKEN BALANCE AFTER", "token", token.String(), "address", addr, "balance", balance, "orderValue", value) log.Debug("ApplyXDCXMatchedTransaction settle balance: SUB TOKEN BALANCE AFTER", "token", token, "address", addr, "balance", balance, "orderValue", value)
return nil return nil
} else { } else {
return errors.Errorf("token %s isn't exist", token.String()) return errors.Errorf("token %s isn't exist", token.String())
@ -230,7 +230,7 @@ func CheckSubTokenBalance(addr common.Address, value *big.Int, token common.Addr
return nil, errors.Errorf("value %s in token %s not enough , have : %s , want : %s ", addr.String(), token.String(), balance, value) return nil, errors.Errorf("value %s in token %s not enough , have : %s , want : %s ", addr.String(), token.String(), balance, value)
} }
newBalance := new(big.Int).Sub(balance, value) newBalance := new(big.Int).Sub(balance, value)
log.Debug("CheckSubTokenBalance settle balance: SUB XDC NATIVE BALANCE ", "token", token, "address", addr.String(), "balance", balance, "value", value, "newBalance", newBalance) log.Debug("CheckSubTokenBalance settle balance: SUB XDC NATIVE BALANCE ", "token", token, "address", addr, "balance", balance, "value", value, "newBalance", newBalance)
return newBalance, nil return newBalance, nil
} }
// TRC tokens // TRC tokens

View file

@ -205,7 +205,7 @@ func initGenesis(ctx *cli.Context) error {
utils.Fatalf("Failed to write genesis block: %v", err) utils.Fatalf("Failed to write genesis block: %v", err)
} }
chaindb.Close() chaindb.Close()
log.Info("Successfully wrote genesis state", "database", name, "hash", hash.String()) log.Info("Successfully wrote genesis state", "database", name, "hash", hash)
return nil return nil
} }

View file

@ -358,7 +358,7 @@ func (w *wizard) makeGenesis() {
storage := make(map[common.Hash]common.Hash) storage := make(map[common.Hash]common.Hash)
f := func(key, val common.Hash) bool { f := func(key, val common.Hash) bool {
storage[key] = common.BytesToHash(val.Bytes()) storage[key] = common.BytesToHash(val.Bytes())
log.Info("DecodeBytes", "value", val.String(), "decode", storage[key].String()) log.Info("DecodeBytes", "value", val, "decode", storage[key])
return true return true
} }
contractBackend.ForEachStorageAt(ctx, validatorAddress, nil, f) contractBackend.ForEachStorageAt(ctx, validatorAddress, nil, f)

View file

@ -916,13 +916,13 @@ func setWhiteBlackListPeers(ctx *cli.Context, cfg *p2p.Config) {
node1, err1 := discover.HexID(url) node1, err1 := discover.HexID(url)
if err1 == nil { if err1 == nil {
cfg.WhitePeers[node1] = struct{}{} cfg.WhitePeers[node1] = struct{}{}
log.Info("Add peer to whitelist", "id", node1.String()) log.Info("Add peer to whitelist", "id", node1)
continue continue
} }
node2, err2 := discover.ParseNode(url) node2, err2 := discover.ParseNode(url)
if err2 == nil { if err2 == nil {
cfg.WhitePeers[node2.ID] = struct{}{} cfg.WhitePeers[node2.ID] = struct{}{}
log.Info("Add peer to whitelist", "enode", url, "id", node2.ID.String()) log.Info("Add peer to whitelist", "enode", url, "id", node2.ID)
continue continue
} }
log.Crit("Invalid peer id for whitelist", "url", url, "err1", err1, "err2", err2) log.Crit("Invalid peer id for whitelist", "url", url, "err1", err1, "err2", err2)
@ -939,13 +939,13 @@ func setWhiteBlackListPeers(ctx *cli.Context, cfg *p2p.Config) {
node1, err1 := discover.HexID(url) node1, err1 := discover.HexID(url)
if err1 == nil { if err1 == nil {
cfg.BlackPeers[node1] = struct{}{} cfg.BlackPeers[node1] = struct{}{}
log.Info("Add peer to blacklsit", "id", node1.String()) log.Info("Add peer to blacklist", "id", node1)
continue continue
} }
node2, err2 := discover.ParseNode(url) node2, err2 := discover.ParseNode(url)
if err2 == nil { if err2 == nil {
cfg.BlackPeers[node2.ID] = struct{}{} cfg.BlackPeers[node2.ID] = struct{}{}
log.Info("Add peer to blacklsit", "enode", url, "id", node2.ID.String()) log.Info("Add peer to blacklist", "enode", url, "id", node2.ID)
continue continue
} }
log.Crit("Invalid peer id for blacklist", "url", url, "err1", err1, "err2", err2) log.Crit("Invalid peer id for blacklist", "url", url, "err1", err1, "err2", err2)
@ -963,7 +963,7 @@ func removeBlackPeers(cfg *p2p.Config) {
filteredNodes := make([]*discover.Node, 0, len(cfg.BootstrapNodes)) filteredNodes := make([]*discover.Node, 0, len(cfg.BootstrapNodes))
for _, node := range cfg.BootstrapNodes { for _, node := range cfg.BootstrapNodes {
if _, ok := cfg.BlackPeers[node.ID]; ok { if _, ok := cfg.BlackPeers[node.ID]; ok {
log.Info("Remove black peer", "enode", node.String(), "id", node.ID) log.Info("Remove black peer", "enode", node, "id", node.ID)
continue continue
} }
filteredNodes = append(filteredNodes, node) filteredNodes = append(filteredNodes, node)
@ -1363,7 +1363,7 @@ func setSmartCard(ctx *cli.Context, cfg *node.Config) {
return return
} }
if fi.Mode()&os.ModeType != os.ModeSocket { if fi.Mode()&os.ModeType != os.ModeSocket {
log.Error("Invalid smartcard daemon path", "path", path, "type", fi.Mode().String()) log.Error("Invalid smartcard daemon path", "path", path, "type", fi.Mode())
return return
} }
// Smartcard daemon path exists and is a socket, enable it // Smartcard daemon path exists and is a socket, enable it

View file

@ -531,7 +531,7 @@ func (x *XDPoS) CacheNoneTIPSigningTxs(header *types.Header, txs []*types.Transa
} }
} }
log.Debug("Save tx signers to cache", "hash", header.Hash().String(), "number", header.Number, "len(txs)", len(signTxs)) log.Debug("Save tx signers to cache", "hash", header.Hash(), "number", header.Number, "len(txs)", len(signTxs))
x.signingTxsCache.Add(header.Hash(), signTxs) x.signingTxsCache.Add(header.Hash(), signTxs)
return signTxs return signTxs
@ -545,7 +545,7 @@ func (x *XDPoS) CacheSigningTxs(hash common.Hash, txs []*types.Transaction) []*t
signTxs = append(signTxs, tx) signTxs = append(signTxs, tx)
} }
} }
log.Debug("Save tx signers to cache", "hash", hash.String(), "len(txs)", len(signTxs)) log.Debug("Save tx signers to cache", "hash", hash, "len(txs)", len(signTxs))
x.signingTxsCache.Add(hash, signTxs) x.signingTxsCache.Add(hash, signTxs)
return signTxs return signTxs
} }

View file

@ -913,7 +913,7 @@ func (x *XDPoS_v1) Seal(chain consensus.ChainReader, block *types.Block, stop <-
if limit := uint64(2); number < limit || seen > number-limit { if limit := uint64(2); number < limit || seen > number-limit {
// Only take into account the non-epoch blocks // Only take into account the non-epoch blocks
if number%x.config.Epoch != 0 { if number%x.config.Epoch != 0 {
log.Info("Signed recently, must wait for others ", "len(masternodes)", len(masternodes), "number", number, "limit", limit, "seen", seen, "recent", recent.String(), "snap.Recents", snap.Recents) log.Info("Signed recently, must wait for others ", "len(masternodes)", len(masternodes), "number", number, "limit", limit, "seen", seen, "recent", recent, "snap.Recents", snap.Recents)
<-stop <-stop
return nil, nil return nil, nil
} }

View file

@ -331,7 +331,7 @@ func GetRewardForCheckpoint(c *XDPoS.XDPoS, chain consensus.ChainReader, header
mapBlkHash[i] = header.Hash() mapBlkHash[i] = header.Hash()
signingTxs, ok := c.GetCachedSigningTxs(header.Hash()) signingTxs, ok := c.GetCachedSigningTxs(header.Hash())
if !ok { if !ok {
log.Debug("Failed get from cached", "hash", header.Hash().String(), "number", i) log.Debug("Failed get from cached", "hash", header.Hash(), "number", i)
block := chain.GetBlock(header.Hash(), i) block := chain.GetBlock(header.Hash(), i)
txs := block.Transactions() txs := block.Transactions()
if !chain.Config().IsTIPSigning(header.Number) { if !chain.Config().IsTIPSigning(header.Number) {

View file

@ -503,7 +503,7 @@ func GetSigningTxCount(c *XDPoS.XDPoS, chain consensus.ChainReader, header *type
mapBlkHash[i] = h.Hash() mapBlkHash[i] = h.Hash()
signingTxs, ok := c.GetCachedSigningTxs(h.Hash()) signingTxs, ok := c.GetCachedSigningTxs(h.Hash())
if !ok { if !ok {
log.Debug("Failed get from cached", "hash", h.Hash().String(), "number", i) log.Debug("Failed get from cached", "hash", h.Hash(), "number", i)
block := chain.GetBlock(h.Hash(), i) block := chain.GetBlock(h.Hash(), i)
if block != nil { if block != nil {
txs := block.Transactions() txs := block.Transactions()

View file

@ -112,7 +112,7 @@ func RunGit(args ...string) string {
} }
return "" return ""
} }
log.Fatal(strings.Join(cmd.Args, " "), ": ", err, "\n", stderr.String()) log.Fatal(strings.Join(cmd.Args, " "), ": ", err, "\n", stderr)
} }
return strings.TrimSpace(stdout.String()) return strings.TrimSpace(stdout.String())
} }

View file

@ -64,7 +64,7 @@ func TestJSONHandler(t *testing.T) {
logger = slog.New(handler) logger = slog.New(handler)
logger.Debug("hi there") logger.Debug("hi there")
if len(out.String()) != 0 { if len(out.String()) != 0 {
t.Errorf("expected empty debug log output, but got: %v", out.String()) t.Errorf("expected empty debug log output, but got: %v", out)
} }
} }

View file

@ -86,7 +86,7 @@ func (sa *SimAdapter) NewNode(config *NodeConfig) (Node, error) {
Dialer: sa, Dialer: sa,
EnableMsgEvents: true, EnableMsgEvents: true,
}, },
Logger: log.New("node.id", id.String()), Logger: log.New("node.id", id),
}) })
if err != nil { if err != nil {
return nil, err return nil, err