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

Render events as json in stellar events pretty output instead of as rust debug #1615

Closed
leighmcculloch opened this issue Sep 18, 2024 · 7 comments · May be fixed by #1659
Closed

Render events as json in stellar events pretty output instead of as rust debug #1615

leighmcculloch opened this issue Sep 18, 2024 · 7 comments · May be fixed by #1659
Assignees

Comments

@leighmcculloch
Copy link
Member

leighmcculloch commented Sep 18, 2024

Events in pretty print mode print as Rust debug format.

We should print as JSON for the same reasons as, because developers are more familiar with the JSON format than the Rust debug format:

Example:

$ stellar contract event --ledger 3423
...
Event 0000014701673062400-0000000000 [DIAGNOSTIC]:
  Ledger:   3423 (closed at 2024-09-17T22:20:30Z)
  Contract: 
  Topics:
            Symbol(ScSymbol(StringM(fn_call)))
            Bytes(ScBytes(BytesM(2ab7f467d192fcb2aefa138e0aae1f596216692d5e3d631a2c2ee81e263ab83f)))
            Symbol(ScSymbol(StringM(set_price)))
  Value: Vec(Some(ScVec(VecM([Vec(Some(ScVec(VecM([I128(Int128Parts { hi: 0, lo: 0 }), I128(Int128Parts { hi: 0, lo: 62622635909 }), I128(Int128Parts { hi: 0, lo: 99750087794911 }), I128(Int128Parts { hi: 0, lo: 1498490882301 }), I128(Int128Parts { hi: 0, lo: 199315054592 }), I128(Int128Parts { hi: 0, lo: 80315405446 }), I128(Int128Parts { hi: 0, lo: 110532281494896 })])))), U64(1726611600000)]))))
...
@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in DevX Sep 18, 2024
@janewang janewang moved this from Backlog (Not Ready) to Todo (Ready for Dev) in DevX Sep 24, 2024
@Gerson2102
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged


Hey! I'm Gerson. 👋

Member of Dojo Coding. I have contributed before to other Rust projects like:

  • Cairo Native
  • kakarot-rpc
  • ef-tests
  • Madara

Can I work on this issue?

Check my OnlyDust profile, I've contributed to many projects: Profile


How I plan on tackling this issue

Plan to Solve the Issue:

  1. Understand the task by carefully reviewing the issue details.
  2. If I encounter new concepts or things I don't know, I will consult the Rust book for guidance.
  3. I will also conduct my own research to find the best way to implement the solution.
  4. If I get stuck, I will ask questions ASAP to solve the issue efficiently.
  5. Once the work is completed, I'll open a PR and wait for your feedback.

@juandiegocv27
Copy link

juandiegocv27 commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello! I'm Juan Diego Carballo, a software engineer and a member of the Dojo Coding community. My expertise lies in Rust, C#, and blockchain technologies. I've contributed to open-source projects like Starknet Quest, Dojo, and Op-Scan, focusing on enhancing user interfaces and improving system performance.

At Mafisa, I led the development of an HR web application, which involved real-time data interaction and optimizing system reliability. This experience sharpened my skills in delivering efficient and user-friendly solutions. Additionally, my participation in events like the Starknet Brussels HackerHouse and Starkhack has deepened my understanding of blockchain ecosystems.

Given my background in Rust and experience with command-line tools and blockchain applications, I'm confident that I can effectively contribute to the Stellar CLI project. I have a solid understanding of Rust's formatting traits and serialization techniques, which are essential for addressing the issue of changing the event output from Rust debug format to JSON.

How I plan on tackling this issue

Plan to Solve the Issue:

  • Understand the Task:

    • Carefully review the issue details to fully grasp the requirements.
    • Analyze the current implementation of event logging in the Stellar CLI.
  • Research and Planning:

    • Look into Rust's serde and serde_json crates for serialization.
    • Ensure compatibility with existing dependencies and project guidelines.
  • Implementation:

    • Modify the event logging to replace Rust's fmt::Debug with JSON serialization.
    • Implement necessary changes to serialize event data structures into JSON format.
  • Testing:

    • Write unit tests to verify that events are correctly serialized to JSON.
    • Manually test the CLI to compare outputs before and after the changes.
  • Consultation:

    • If I encounter new concepts or uncertainties, I will consult the Rust book and documentation.
    • Reach out with questions ASAP to ensure efficient problem-solving.
  • Finalization:

    • Ensure the code adheres to the project's style and contribution guidelines.
    • Update documentation if necessary to reflect changes in the output format.
  • Submission:

    • Once the work is completed, I'll open a PR and wait for your feedback.

I'm excited about the opportunity to contribute to the Stellar CLI project and believe my skills align well with the requirements of this issue.

@Ugo-X
Copy link

Ugo-X commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a Full Stack blockchain Developer with expertise in Next.js, Nest.js, TypeScript, JavaScript, React, Node.js, Three.js, Solidity and rust. My journey with OnlyDust hackathons began at Edition 1, and I've since made 69 contributions across 14 projects. With my extensive experience on the OnlyDust platform (profile: https://app.onlydust.com/u/Ugo-X), I've honed my skills in delivering quality solutions under pressure.

I bring a unique blend of technical proficiency and user-focused design to every project, whether it's crafting immersive 3D experiences or developing smart contracts. My track record shows I can adapt quickly and contribute effectively to diverse challenges.

As we surf through Edition 8, I'm excited to leverage my skills and hackathon experience to push the boundaries of blockchain development. I'm confident in my ability to tackle new challenges and drive innovation in this space.

How I plan on tackling this issue

I will modify the logging output to render events in JSON format.

  • Step 1: I will identify the component responsible for rendering event logs, focusing on how it currently formats data using Rust’s debug format.

  • Step 2: I will create a new function that constructs a JSON object representing the event data, ensuring it includes all necessary fields such as ledger, contract, topics, and values.

  • Step 3: I will replace the existing output formatting logic with calls to this new JSON function.

  • Step 4: I will implement error handling to ensure that malformed data does not crash the logging system.

  • Step 5: I will add tests to confirm that events are formatted correctly as JSON and validate against expected output structures.

  • Step 6: I will update the documentation to inform developers of the new JSON format for event logs.

@MullerTheScientist
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a full-stack developer with experience in QA testing and languages like Python, Cairo, Solidity, React, and JavaScript.

How I plan on tackling this issue

i will Identify Event Rendering Code
Locate the code responsible for rendering events in the Stellar events pretty output.
Determine the programming language and framework used.
Update Event Rendering Logic
Modify the event rendering logic to serialize events to JSON
Use a JSON serialization library (e.g., serde_json in Rust)
Convert event data structures to JSON-compatible formats

@DanielEmmanuel1
Copy link

DanielEmmanuel1 commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Good Morning Team, My name is Deon and I'd like to apply formally for the task presented. I am a Web and blockchain engineer with a passion for building user interfaces and Dapps that deliver meaningful experiences. With a background in Computer Science (BSc) and hands-on experience. If given the chance to contribute this will be my second official contribution via onlydust and I'm confident in my ability to deliver on the feature you're looking for.

How I plan on tackling this issue

I will employ the following approach to ensure disableInitializers is called to prevent uninitialized contracts from being exploited:

Understand the Contract Initialization Flow:
I will review the Starklane contract’s initialization process, focusing on how the proxy pattern interacts with the implementation contract. This will help ensure that the proxy’s implementation contract cannot be initialized multiple times or taken over by an attacker.

Add disableInitializers() to the Constructor:
I will update the Starklane contract’s constructor to include a call to disableInitializers(). This will lock the contract's initialization function, preventing any further calls to initialize, which could otherwise be exploited by an attacker to set arbitrary values.

Write Unit Tests for Verification:
I will write unit tests to ensure that after deployment, the initialize function cannot be called on the implementation contract. These tests will confirm that calling initialize post-deployment throws an error, validating that the contract has been correctly locked.

Comprehensive Coverage:
I will ensure that the solution applies across the entire upgradeable contract lifecycle, preventing any misuse of the initialization function and securing the proxy pattern implementation.

By following this approach, I will safeguard the Starklane contract from being exploited due to uninitialized contracts.

@juandiegocv27
Copy link

Thank you for assigned to me tis issue @leighmcculloch, I would send my pr as soon as possible

@juandiegocv27
Copy link

@leighmcculloch Hi, let me know if you´re ready to discuss about my pr please, I want to know

@janewang janewang removed the ODHack8 label Oct 29, 2024
@sagpatil sagpatil moved this from Needs Review to Done in DevX Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
8 participants