Skip to content

Commit

Permalink
Fix MergeSethAndEvmNetworkConfigs for Anvil and Geth networks (#984)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcl committed Jun 11, 2024
1 parent 5eea86e commit 5064fc0
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions utils/seth/seth.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,24 +147,29 @@ func MergeSethAndEvmNetworkConfigs(evmNetwork blockchain.EVMNetwork, sethConfig

var sethNetwork *pkg_seth.Network

for _, conf := range sethConfig.Networks {
if evmNetwork.Simulated {
if conf.Name == pkg_seth.GETH || conf.Name == pkg_seth.ANVIL {
conf.PrivateKeys = evmNetwork.PrivateKeys
if len(conf.URLs) == 0 {
conf.URLs = evmNetwork.URLs
}
// important since Besu doesn't support EIP-1559, but other EVM clients do
conf.EIP1559DynamicFees = evmNetwork.SupportsEIP1559

// might be needed for cases, when node is incapable of estimating gas limit (e.g. Geth < v1.10.0)
if evmNetwork.DefaultGasLimit != 0 {
conf.GasLimit = evmNetwork.DefaultGasLimit
}
mergeSimulatedNetworks := func(evmNetwork blockchain.EVMNetwork, sethNetwork pkg_seth.Network) *pkg_seth.Network {
sethNetwork.PrivateKeys = evmNetwork.PrivateKeys
if len(sethNetwork.URLs) == 0 {
sethNetwork.URLs = evmNetwork.URLs
}
// important since Besu doesn't support EIP-1559, but other EVM clients do
sethNetwork.EIP1559DynamicFees = evmNetwork.SupportsEIP1559
// might be needed for cases, when node is incapable of estimating gas limit (e.g. Geth < v1.10.0)
if evmNetwork.DefaultGasLimit != 0 {
sethNetwork.GasLimit = evmNetwork.DefaultGasLimit
}
return &sethNetwork
}

sethNetwork = conf
break
}
for _, conf := range sethConfig.Networks {
if evmNetwork.Simulated && evmNetwork.Name == pkg_seth.ANVIL && conf.Name == pkg_seth.ANVIL {
// Merge Anvil network
sethNetwork = mergeSimulatedNetworks(evmNetwork, *conf)
break
} else if evmNetwork.Simulated && conf.Name == pkg_seth.GETH {
// Merge all other simulated Geth networks
sethNetwork = mergeSimulatedNetworks(evmNetwork, *conf)
break
} else if strings.EqualFold(conf.Name, fmt.Sprint(evmNetwork.Name)) {
conf.PrivateKeys = evmNetwork.PrivateKeys
if len(conf.URLs) == 0 {
Expand Down

0 comments on commit 5064fc0

Please sign in to comment.