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

Fix/eth tx manager refactoring #1462

Closed
wants to merge 36 commits into from

Conversation

tclemos
Copy link
Contributor

@tclemos tclemos commented Dec 15, 2022

*************** WIP ***************

Closes #.

What does this PR do?

improves eth tx manage to be more fault tolerant when sending txs to L1

Reviewers

Main reviewers:

kind84 and others added 17 commits November 9, 2022 11:25
Bumps [github.com/urfave/cli/v2](https://github.com/urfave/cli) from 2.23.5 to 2.23.6.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](urfave/cli@v2.23.5...v2.23.6)

---
updated-dependencies:
- dependency-name: github.com/urfave/cli/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Add Grafana docker for visualization

* Update test/Makefile

Co-authored-by: Paolo Grisoli <[email protected]>
Background

For development purposes, it would be nice to have a script to send an arbitrary number of transactions.

Basically the behavior should be the same of the TestEthTransfer e2e test, but without dealing with creating/destroying the node local stack, which is assumed to be already running.
What does this PR do?

This PR proposes to add a txsender script in test/scripts that accepts as argument the number of transactions to be sent (it defaults to 1 transaction).

    Can send either on layer 1, layer 2 or both, specifying the --network flag.
    Can wait for transactions to be validated using the --wait flag.

Please refer to the README.md file in the script folder to see some examples.

This PR also removes the send_transfer script as the one proposed here is a more flexible solution of that script.
In the future we may think about a full fledged CLI development application to include this and other useful script.

In order avoid duplication, the code shared between TestEthTransfer and the new script has been moved to operations.ApplyL1Txs and operations.ApplyL2Txs.
* Add initial goreleaser config

* Add OS config
* Fix erroneous return in VerifyBatches function

* Update ethtxmanager/ethtxmanager.go

Co-authored-by: cool-developer <[email protected]>

* Update ethtxmanager/ethtxmanager.go

Co-authored-by: cool-developer <[email protected]>

* fix: add ErrMaxRetriesExceeded error

Co-authored-by: cool-developer <[email protected]>
Co-authored-by: Paolo Grisoli <[email protected]>
### What does this PR do?

This PR proposes to revamp our `log` package. The idea is to have more information in the logs without having to add them manually on each log line.

This is accomplished by providing a way to get **child loggers** derived from the **root** one: 
- **Every function** that needs to inject new fields in the logs can do so by calling `WithFields` on the current logger. 
- **This returns** a new child logger that will print the provided fields on every log line (within the function scope) in addition to the parent logger fields.

### Example

```go
// use root logger
log.Debug("This is a debug log line from the root logger")

// derive a child logger from the root one, with additional fields
childLog := log.WithFields("txHash", "0xbanana", "chainId", 42)

// these two log lines will be decorated with the `txHash` and `chainId` fields
childLog.Debug("This is a debug log line")
childLog.Debug("This is another debug log line")

// derive a child logger from the previous child, adding another field
grandChildLog := childLog.WithFields("proverId", "prover123")

// this log line will be decorated with the `txHash`, `chainId` and `proverId` fields
grandChildLog.Debug("This is a debug log line from the granchild logger")

// derive another child logger from the root one, with another field
childLog2 := log.WithFields("batchNum": 8)

// this line will only have the `batchNum` field
childLog2.Debug("This is a debug log line from the second child logger")
```


**NOTE:** here 2 default fields have been added to **every** log line: `version` and `pid`.
They are purely demonstrative and can be removed/replaced with better ones.

Other logs have been decorated with fields inside `jsonrpc` and `metrics` package. The idea is to gradually start using the feature while developing.

**ENCODING**
Now the encoding of the logs can be specified in the config file choosing between `console` and `json`. The default value is `console`, but `json` can be used in a deployed environment for better logs ingestion.

### Bonus

The log message on startup has been polished a bit:
```sh
Version:      v0.0.1-RC1-5-g8538ace
Git revision: 8538ace
Git branch:   feature/revamp-logs
Go version:   go1.17.13
Built:        Fri, 02 Dec 2022 16:47:58 +0000
OS/Arch:      linux/amd64
```

The env var to pass the commit hash is not needed any more, instead it is sourced from the `Makefile` through a linker flag.
Bumps [github.com/urfave/cli/v2](https://github.com/urfave/cli) from 2.23.6 to 2.23.7.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](urfave/cli@v2.23.6...v2.23.7)

---
updated-dependencies:
- dependency-name: github.com/urfave/cli/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@cla-bot cla-bot bot added the cla-signed label Dec 15, 2022
@tclemos tclemos force-pushed the fix/eth-tx-manager-refactoring branch from c94f057 to 3bf2117 Compare December 20, 2022 19:05
@tclemos tclemos changed the base branch from develop to release/v0.0.1 December 20, 2022 19:06
@tclemos tclemos self-assigned this Dec 22, 2022
@tclemos
Copy link
Contributor Author

tclemos commented Dec 22, 2022

messed up with release and develop merges and we decided to add this new feature on top of develop instead of release

closing this PR and continuing it here: #1484

@tclemos tclemos closed this Dec 22, 2022
@tclemos tclemos deleted the fix/eth-tx-manager-refactoring branch December 22, 2022 23:42
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.

7 participants