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

Display System Logs in Console Output #254

Open
koloz193 opened this issue Jan 26, 2024 · 1 comment
Open

Display System Logs in Console Output #254

koloz193 opened this issue Jan 26, 2024 · 1 comment
Labels
feature ➕ Feature item medium 🚩 Indicates moderately difficult item p2 🟡 Indicates moderately high priority item

Comments

@koloz193
Copy link

🌟 Feature Request

📝 Description

In era we have a concept of system logs. These are used to pass information from L2 to L1 related to L2 state, including but not limited to pubdata commitment, hash of state diffs, log root, etc. The desire is to see these logs displayed in era test node similar to how console logs are displayed.

🤔 Rationale

Ensuring that these logs have the correct information helps us catch bugs early and gives us better insight into era.

🖼️ Mockups/Examples

System logs take on the form of each represented as bytes32 so displaying these 2 values similar to 2 bytes32 console logs would work.

📋 Additional Context

System logs are sent via this function

@koloz193 koloz193 changed the title Console Log System Logs Display System Logs in Console Output Jan 26, 2024
@dutterbutter dutterbutter added feature ➕ Feature item p2 🟡 Indicates moderately high priority item labels Jan 30, 2024
@MexicanAce
Copy link
Collaborator

An update on this feature request (as I attempted to get this working locally):

It appears that the call(...) made from the SystemContractHelper.toL1(...) function is not being returned in the Call Tracer we're using. I'm unsure why, but if it's not being returned then we'll need to make changes to the SystemContractHelper.sol to add some debug functionality

I've proven out that we could add a few console.log() and console.logBytes32() statements within toL1, however hardhat's console.sol contract does not allow for logging a single line of both string and byte32, so it would need to be separated by multiple lines. Example:

    function toL1(bool _isService, bytes32 _key, bytes32 _value) internal {
        console.log("[SYSTEM_LOG]");
        console.logBytes32(_key);
        console.logBytes32(_value);
09:59:15  INFO ==== Console logs: 
09:59:15  INFO [SYSTEM_LOG]
09:59:15  INFO 0000000000000000000000000000000000000000000000000000000000000004
09:59:15  INFO 0000000000000000000000000000000000000000000000000000000000000000

Another approach we can take is to avoid using console.log() and use events or even a custom debug slot of memory similar to what we do with custom gas data from bootloader.yul. Example:

    event SystemContractHelperToL1(address _address, bytes32 _key, bytes32 _value);

    function toL1(bool _isService, bytes32 _key, bytes32 _value) internal {
        emit SystemContractHelperToL1(callAddr, _key, _value);

Then we can filter out this special Topic address and format it into a section something like below:

09:59:15  INFO ==== System logs: 
09:59:15  INFO key:   0000000000000000000000000000000000000000000000000000000000000004
09:59:15  INFO value: 0000000000000000000000000000000000000000000000000000000000000000
09:59:15  INFO
09:59:15  INFO key:   0000000000000000000000000000000000000000000000000000000000000005
09:59:15  INFO value: 0000000000000000000000000000000000000000000000000000000000000000
09:59:15  INFO
09:59:15  INFO key:   0000000000000000000000000000000000000000000000000000000000000006
09:59:15  INFO value: 0000000000000000000000000000000000000000000000000000000000000000

@MexicanAce MexicanAce added the medium 🚩 Indicates moderately difficult item label Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ➕ Feature item medium 🚩 Indicates moderately difficult item p2 🟡 Indicates moderately high priority item
Projects
None yet
Development

No branches or pull requests

3 participants