Skip to content

Commit

Permalink
add gas offset (#34)
Browse files Browse the repository at this point in the history
* add gas offset
  • Loading branch information
ToniRamirezM authored May 6, 2024
1 parent 0fd1c4d commit 9b73f0b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Stateless manager to send transactions to L1.

## Main Funtions
### Add Transaction
`func (c *Client) Add(ctx context.Context, to *common.Address, forcedNonce *uint64, value *big.Int, data []byte) (common.Hash, error)`
`func (c *Client) Add(ctx context.Context, to *common.Address, forcedNonce *uint64, value *big.Int, data []byte, gasOffset uint64, sidecar *types.BlobTxSidecar) (common.Hash, error)`

Adds a transaction to be sent to L1. The returned hash is calculated over the *to*, *nonce*, *value* and *data* fields.

Expand Down
4 changes: 2 additions & 2 deletions ethtxmanager/ethtxmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (c *Client) getTxNonce(ctx context.Context, from common.Address) (uint64, e
}

// Add a transaction to be sent and monitored
func (c *Client) Add(ctx context.Context, to *common.Address, forcedNonce *uint64, value *big.Int, data []byte, sidecar *types.BlobTxSidecar) (common.Hash, error) {
func (c *Client) Add(ctx context.Context, to *common.Address, forcedNonce *uint64, value *big.Int, data []byte, gasOffset uint64, sidecar *types.BlobTxSidecar) (common.Hash, error) {
var nonce uint64
var err error

Expand Down Expand Up @@ -285,7 +285,7 @@ func (c *Client) Add(ctx context.Context, to *common.Address, forcedNonce *uint6
mTx := monitoredTx{
ID: id, From: c.from, To: to,
Nonce: nonce, Value: value, Data: data,
Gas: gas, GasPrice: gasPrice,
Gas: gas, GasPrice: gasPrice, GasOffset: gasOffset,
BlobSidecar: sidecar,
BlobGas: tx.BlobGas(),
BlobGasPrice: blobFeeCap, GasTipCap: gasTipCap,
Expand Down
2 changes: 1 addition & 1 deletion ethtxmanager/monitoredtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (mTx monitoredTx) Tx() *types.Transaction {
Data: mTx.Data,
GasFeeCap: uint256.MustFromBig(mTx.GasPrice),
GasTipCap: uint256.MustFromBig(mTx.GasTipCap),
Gas: mTx.Gas,
Gas: mTx.Gas + mTx.GasOffset,
BlobFeeCap: uint256.MustFromBig(mTx.BlobGasPrice),
BlobHashes: mTx.BlobSidecar.BlobHashes(),
Sidecar: mTx.BlobSidecar,
Expand Down
4 changes: 2 additions & 2 deletions test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func main() {
}

func sendTransaction(ctx context.Context, ethtxmanager *ethtxmanager.Client, nonce uint64) common.Hash {
id, err := ethtxmanager.Add(ctx, &to0, &nonce, big.NewInt(1), []byte{byte(rand.Intn(256)), byte(rand.Intn(256)), byte(rand.Intn(256))}, nil)
id, err := ethtxmanager.Add(ctx, &to0, &nonce, big.NewInt(1), []byte{byte(rand.Intn(256)), byte(rand.Intn(256)), byte(rand.Intn(256))}, 0, nil)
if err != nil {
log.Errorf("Error sending transaction: %s", err)
} else {
Expand All @@ -130,7 +130,7 @@ func sendBlobTransaction(ctx context.Context, ethtxmanager *ethtxmanager.Client,

// data := []byte{228, 103, 97, 196} // pol method
data := []byte{}
id, err := ethtxmanager.Add(ctx, &to0, &nonce, big.NewInt(0), data, blobSidecar)
id, err := ethtxmanager.Add(ctx, &to0, &nonce, big.NewInt(0), data, 0, blobSidecar)
if err != nil {
log.Errorf("Error sending Blob transaction: %s", err)
} else {
Expand Down

0 comments on commit 9b73f0b

Please sign in to comment.