Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Update "Debugging a smart contract" guide #1112

Merged
merged 13 commits into from
Dec 17, 2021
Merged

Conversation

its-everdred
Copy link
Contributor

@its-everdred its-everdred commented Dec 14, 2021

Problem

The Debugging a smart contract guide is outdated: #1077

Solution

  1. Updated all solc versions to latest.
  2. Updated all console outputs to reflect the updated responses.
  3. Commented out the infinite loop example until the relevant issue is resolved.

@its-everdred
Copy link
Contributor Author

This is branched off of #1106 so until that is merged, this branch will include those changes as well. Set it to blocked for now.

Copy link
Contributor

@fainashalts fainashalts left a comment

Choose a reason for hiding this comment

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

Had a couple of minor suggestions, and I also noticed some remnants from a merge conflict that I noted. Looks good otherwise, just request my re-review when changes are addressed. Thanks! 🎉

})
.then(function (value) {
return value.toNumber();
});
```

This command looks at the SimpleStorage contract, and then calls the `get()` function as defined inside it. It then returns the output, which is usually rendered as a string, and converts it to a number:

```javascript
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```javascript

Copy link
Contributor Author

@its-everdred its-everdred Dec 15, 2021

Choose a reason for hiding this comment

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

Did you mean to delete only the open tag here? I believe commiting this while leaving the closing ``` would turn the rest of the document into a code block.

})
.then(function (value) {
return value.toNumber();
});
```

The output should look like this:

```javascript
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```javascript

Copy link
Contributor Author

@its-everdred its-everdred Dec 15, 2021

Choose a reason for hiding this comment

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

Did you mean to delete only the open tag here? I believe commiting this while leaving the closing ``` would turn the rest of the document into a code block.

Copy link
Contributor

Choose a reason for hiding this comment

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

Whoops! I meant to just delete the javascript tag. :)

```

**It is this last event that is triggering the error.** You can see that it is the `assert()` that is to blame.

<<<<<<< HEAD:src/guides/debugging-an-example-smart-contract.md
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is leftover from a merge conflict. I may have missed other parts of this so its probably worth going over it again to see!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohhh thank you!


### Issue #3: A function isn't operating as desired

> > > > > > > origin/update-debugging-your-contracts:src/guides/debugging-an-example-smart-contract/index.md
Copy link
Contributor

Choose a reason for hiding this comment

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

This part too, I assume!

Copy link
Member

Choose a reason for hiding this comment

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

oh wow, where did these merge conflicts come from? Was it from the transition from old to new website?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, perhaps. I'm wondering if I forgot to pull. When I started this, the guides were individual files with no sub-directories, ex: "src/guides/debugging-a-smart-contract.md"

Copy link
Member

Choose a reason for hiding this comment

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

Hrm, would you mind doing a rebase instead? Would be happy to help out

```

**The problem is revealed.** The conditional is leading to the wrong event.


## Conclusion

With the ability to debug your contracts directly within Truffle, you have even more power at your hands to make your smart contracts rock-solid and ready to deploy. Make sure to read more about Truffle Develop console and the debugger in the docs. If you have any questions, please join our [community Gitter channel](https://gitter.im/ConsenSys/truffle) where hundreds of fellow Trufflers congregate to answer your questions!
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking we could remove the part about heading over to our Gitter and recommend people open an issue on Github if they have any questions. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I like this point, agreed!

@@ -144,13 +135,11 @@ If you want an interactive console but want to use an existing blockchain, use `

See the [Using the console](/docs/getting_started/console) section for more details.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if this link works. May just be that I can't find it but when I try going to it I get a 404.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Option:

* `--log`: Start/Connect to a Truffle develop session and log all RPC activity.
See the [Log RPC Activity](docs/getting_started/console#log-rpc-activity)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

Copy link
Contributor Author

@its-everdred its-everdred Dec 15, 2021

Choose a reason for hiding this comment

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

* `<package_name>`: Name of the package as listed in the Ethereum Package Registry. (required)
* `@<version>`: When specified, will install a specific version of the package, otherwise will install the latest version.
- `<package_name>`: Name of the package as listed in the Ethereum Package Registry. (required)
- `@<version>`: When specified, will install a specific version of the package, otherwise will install the latest version.

See the [Package Management with EthPM](/docs/getting_started/packages-ethpm) section for more details.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@its-everdred its-everdred merged commit 4ac87d7 into main Dec 17, 2021
@its-everdred its-everdred deleted the fix-debugging-guide branch December 17, 2021 20:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants