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

Update log levels #609

Merged
merged 2 commits into from
Apr 10, 2023
Merged

Update log levels #609

merged 2 commits into from
Apr 10, 2023

Conversation

aaronbuchwald
Copy link
Collaborator

Why this should be merged

This PR updates the log levels in Subnet-EVM to ensure that they follow best practices.

How this works

Updates log levels

How this was tested

n/a

How is this documented

Debug - information useful for debugging that should not be surfaced in normal operation
Info - basic information about the program that a normal user would want to be aware of
Warn - not necessarily harmful, but unexpected
Error - should never happen and should cause a page to whoever is running the node and the maintainers of the repo to debug
Fatal - fatal error that should never happen has occurred

Note: the descriptions of Error and Fatal assume that the operator is using the application correctly. User error may lead to an error or fatal log that does not indicate a bug in the code.

There's a lot written up about log levels, but no canonical place for standards. Here is a decent write up that summarizes reasonable standards for logging in a little more detail: https://stackify.com/logging-levels-101/.

@@ -572,7 +572,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call interfaces.Call
if transfer == nil {
transfer = new(big.Int)
}
log.Warn("Gas estimation capped by limited funds", "original", hi, "balance", balance,
log.Info("Gas estimation capped by limited funds", "original", hi, "balance", balance,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can occur if a user requests too much gas, so we should not consider it an unexpected warn log

@@ -1508,7 +1508,7 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
logFn(msg, "number", commonBlock.Number(), "hash", commonBlock.Hash(),
"drop", len(oldChain), "dropfrom", oldChain[0].Hash(), "add", len(newChain), "addfrom", newChain[0].Hash())
} else {
log.Warn("Unlikely preference change (rewind to ancestor) occurred", "oldnum", oldHead.Number(), "oldhash", oldHead.Hash(), "newnum", newHead.Number(), "newhash", newHead.Hash())
log.Debug("Preference change (rewind to ancestor) occurred", "oldnum", oldHead.Number(), "oldhash", oldHead.Hash(), "newnum", newHead.Number(), "newhash", newHead.Hash())
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follows update made in Coreth to reduce this to Debug since this can occur on restart when a node rewinds its preference to the last accepted block.

Comment on lines +46 to +58
log.Error("error occurred with JSON unmarshalling ethCallRequest.RequestArgs", "err", err)
return nil, nil
}

result, err := ethapi.DoCall(ctx, c.backend, transactionArgs, lastAcceptedBlockNumberOrHash, nil, c.backend.RPCEVMTimeout(), c.backend.RPCGasCap())
if err != nil {
log.Debug("error occurred with EthCall", "err", err, "transactionArgs", ethCallRequest.RequestArgs, "blockNumberOrHash", lastAcceptedBlockNumberOrHash)
log.Error("error occurred with EthCall", "err", err, "transactionArgs", ethCallRequest.RequestArgs, "blockNumberOrHash", lastAcceptedBlockNumberOrHash)
return nil, nil
}

executionResult, err := json.Marshal(&result)
if err != nil {
log.Debug("error occurred with JSON marshalling result", "err", err)
log.Error("error occurred with JSON marshalling result", "err", err)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These requests should only come from a VM running on the same node, so failing to serve the request should be considered a warning at this time.

Note: CrossChainHandler is not used by any VM at this time

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be a Warn? not an Error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is assuming that requests coming from the same node. This is a feature that's not in use atm, so it depends on if VMs that wanted to use this should only send requests that should be successful 🤔

That was my logic when updating to Error at least.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of right now, if this log showed up I'd want to know about it rather than only wanting to know about it if it showed up in a large quantity or a surge, so I'm going to leave this as is for now.

We may want to change this in the future if the access pattern for it changes.

@@ -257,7 +257,7 @@ func (client *stateSyncerClient) syncBlocks(ctx context.Context, fromHash common
}
blocks, err := client.client.GetBlocks(ctx, nextHash, nextHeight, parentsPerRequest)
if err != nil {
log.Warn("could not get blocks from peer", "err", err, "nextHash", nextHash, "remaining", i+1)
log.Error("could not get blocks from peer", "err", err, "nextHash", nextHash, "remaining", i+1)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that it has failed to sync, so this should be increased from Warn to Error

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be possible for the peer to send us a malformed blocks and trigger this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call to client.client.GetBlocks includes retries so if we exhaust retries we can log Error since we will return err and the sync has failed.

Copy link
Collaborator

@darioush darioush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross chain messages could be Warn

@aaronbuchwald
Copy link
Collaborator Author

Cross chain messages could be Warn

Responded to Stephen's comment. Going to leave as Error for now because if these logs showed up I would want to know about it immediately. If access patterns change, that could certainly change.

@aaronbuchwald aaronbuchwald merged commit a1865cc into master Apr 10, 2023
@aaronbuchwald aaronbuchwald deleted the update-log-levels branch April 10, 2023 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants