Skip to content

Commit

Permalink
refactor states and new fields (#17)
Browse files Browse the repository at this point in the history
* refactor states and new fields

* properly finalize mined txs

* add file persistence
  • Loading branch information
ToniRamirezM authored Feb 4, 2024
1 parent 681b231 commit 22c0311
Show file tree
Hide file tree
Showing 9 changed files with 257 additions and 264 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
.idea/
.env
test/sepolia.keystore
test/ethtxmanager-persistence.json
test/ethtxmanager-persistence.json.tmp
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# zkevm-ethtx-manager
Stateless manager to sent transactions to L1.
Stateless manager to send transactions to L1.

## Main Funtions
### Add Transaction
Expand All @@ -9,6 +9,11 @@ Adds a transaction to be sent to L1. The returned hash is calculated over the *t

Parameter forcedNonce is optional, if nil is passed the current nonce is obtained from the L1 node.

### Remove Transaction
`func (c *Client) Remove(ctx context.Context, id common.Hash) error `

Removes a transaction. Should be called when a finalized transactions is not relevant any more.

### Get Transaction Status
`func (c *Client) Result(ctx context.Context, id common.Hash) (MonitoredTxResult, error)`

Expand All @@ -25,9 +30,5 @@ If the statuses are empty, all the statuses are considered.
- **Created**: the tx was just added to the volatile storage
- **Sent**: transaction was sent to L1
- **Failed**: the tx was already mined and failed with an error that can't be recovered automatically, ex: the data in the tx is invalid and the tx gets reverted
- **Confirmed**: the tx was already mined and the receipt status is Successful. Confirmation waits for the configured number of blocks to be considered final.

#### Legacy statuses

- **Reorged**: is used when a monitored tx was already confirmed but the L1 block where this tx was confirmed has been reorged, in this situation the caller needs to review this information and wait until it gets confirmed again in a future block.
- **Done**: the tx was set by the owner as done
- **Mined**: the tx was already mined and the receipt status is Successful.
- **Finalized**: The tx was mined before the configured number of confirmation blocks.
3 changes: 2 additions & 1 deletion ethtxmanager/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ type Config struct {
// max gas price limit: 110
// tx gas price = 110
MaxGasPriceLimit uint64 `mapstructure:"MaxGasPriceLimit"`

// Sender Address
From common.Address `mapstructure:"From"`
// PersistenceFilename is the filename to store the memory storage
PersistenceFilename string `mapstructure:"PersistenceFilename"`
// Etherman configuration
Etherman etherman.Config `mapstructure:"Etherman"`
}
Loading

0 comments on commit 22c0311

Please sign in to comment.