Skip to content

Commit eced75c

Browse files
Merge pull request #14 from rarimo/reg-request/add-gas-multiplier
Add GasLimitMultiplier
2 parents b7ddb01 + d90e600 commit eced75c

4 files changed

Lines changed: 10 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ config.*.yaml
44
docs/node_modules
55
docs/web_deploy
66
vendor/
7+
.DS_Store

config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ network:
55
private_key: ""
66
vault_address: "https://127.0.0.1:8200"
77
vault_mount_path: "secret_data"
8+
gas_limit_multiplier: 1.2
9+
810
whitelist:
911
- 0x123...123
1012
- 0x123...123

internal/config/network.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type RelayerConfig struct {
4343
PrivateKey *ecdsa.PrivateKey
4444
WhiteList whitelist
4545
nonce uint64
46+
GasLimitMultiplier float64
4647

4748
mut *sync.Mutex
4849
}
@@ -59,7 +60,10 @@ func (e *ethereum) RelayerConfig() *RelayerConfig {
5960
VaultAddress string `fig:"vault_address"`
6061
VaultMountPath string `fig:"vault_mount_path"`
6162
WhiteList []string `fig:"whitelist"`
62-
}{}
63+
GasLimitMultiplier float64 `fig:"gas_limit_multiplier"`
64+
}{
65+
GasLimitMultiplier: 1.2,
66+
}
6367
err := figure.
6468
Out(&networkConfig).
6569
With(figure.EthereumHooks).
@@ -97,6 +101,7 @@ func (e *ethereum) RelayerConfig() *RelayerConfig {
97101

98102
result.WhiteList[address] = struct{}{}
99103
}
104+
result.GasLimitMultiplier = networkConfig.GasLimitMultiplier
100105

101106
result.mut = &sync.Mutex{}
102107
return &result

internal/service/handlers/registration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ func confGas(r *http.Request, txd *txData, receiver *common.Address) (err error)
128128
if err != nil {
129129
return fmt.Errorf("failed to estimate gas: %w", err)
130130
}
131+
txd.gas = uint64(float64(txd.gas) * RelayerConfig(r).GasLimitMultiplier)
131132

132133
return nil
133134
}

0 commit comments

Comments
 (0)