Skip to content

Commit

Permalink
Merge pull request #78 from smartcontractkit/sish/specify-gas-price
Browse files Browse the repository at this point in the history
Fix: hardcore gas price value for zksync
  • Loading branch information
stackman27 authored Jul 1, 2024
2 parents 01b3edd + e7594b8 commit 3cf83b7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ require (
github.com/sagikazarmark/locafero v0.3.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/smartcontractkit/chain-selectors v1.0.17 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6g
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/smartcontractkit/chain-selectors v1.0.17 h1:otOlYUnutS8oQBEAi9RLQICqZP0Nxy0k8vOZuSMJa4w=
github.com/smartcontractkit/chain-selectors v1.0.17/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY=
Expand Down
23 changes: 19 additions & 4 deletions pkg/timelock/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import (
"context"
"crypto/ecdsa"
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
chainselectors "github.com/smartcontractkit/chain-selectors"
"github.com/smartcontractkit/timelock-worker/pkg/timelock/contract"
)

Expand Down Expand Up @@ -51,13 +53,26 @@ func (tw *Worker) executeCallSchedule(ctx context.Context, c *contract.TimelockT
})
}

chainID, err := tw.ethClient.NetworkID(ctx)
if err != nil {
return nil, err
}

txOpts := &bind.TransactOpts{
From: fromAddress,
Signer: tw.signTx,
Context: ctx,
}

// if chainId is zksync-testnet or mainnet use custom gasPrice to enforce legacy tx
if chainID.Cmp(new(big.Int).SetUint64(chainselectors.ETHEREUM_MAINNET_ZKSYNC_1.EvmChainID)) == 0 || chainID.Cmp(new(big.Int).SetUint64(chainselectors.ETHEREUM_TESTNET_SEPOLIA_ZKSYNC_1.EvmChainID)) == 0 {
txOpts.GasPrice = big.NewInt(1000000000) // gasPrice set to 1 gwei
}

// Execute the tx's with all the computed calls.
// Predecessor and salt are the same for all the tx's.
tx, err := c.ExecuteBatch(
&bind.TransactOpts{
From: fromAddress,
Signer: tw.signTx,
Context: ctx},
txOpts,
calls,
cs[0].Predecessor,
cs[0].Salt)
Expand Down

0 comments on commit 3cf83b7

Please sign in to comment.