Commit 03eec5f6 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge branch 'develop' into dependabot/npm_and_yarn/wagmi/core-1.3.9

parents 435a9851 1b713d7c
---
'@eth-optimism/web3.js-plugin': patch
---
Update code exmaples in README
...@@ -321,11 +321,3 @@ pull_request_rules: ...@@ -321,11 +321,3 @@ pull_request_rules:
label: label:
add: add:
- M-ci - M-ci
- name: Add M-bot label for bots
conditions:
- 'author=(github-actions|dependabot|)'
- '#label<5'
actions:
label:
add:
- M-bot
...@@ -88,6 +88,7 @@ type MetricsConfig struct { ...@@ -88,6 +88,7 @@ type MetricsConfig struct {
// LoadConfig loads the `indexer.toml` config file from a given path // LoadConfig loads the `indexer.toml` config file from a given path
func LoadConfig(logger geth_log.Logger, path string) (Config, error) { func LoadConfig(logger geth_log.Logger, path string) (Config, error) {
logger.Info("Loading config file", "path", path)
var conf Config var conf Config
data, err := os.ReadFile(path) data, err := os.ReadFile(path)
...@@ -97,6 +98,8 @@ func LoadConfig(logger geth_log.Logger, path string) (Config, error) { ...@@ -97,6 +98,8 @@ func LoadConfig(logger geth_log.Logger, path string) (Config, error) {
data = []byte(os.ExpandEnv(string(data))) data = []byte(os.ExpandEnv(string(data)))
logger.Debug("Decoding config file", "data", string(data))
if _, err := toml.Decode(string(data), &conf); err != nil { if _, err := toml.Decode(string(data), &conf); err != nil {
logger.Info("Failed to decode config file", "message", err) logger.Info("Failed to decode config file", "message", err)
return conf, err return conf, err
......
...@@ -131,9 +131,9 @@ func (s *SyncClient) eventLoop() { ...@@ -131,9 +131,9 @@ func (s *SyncClient) eventLoop() {
s.log.Info("Starting sync client event loop") s.log.Info("Starting sync client event loop")
backoffStrategy := &backoff.ExponentialStrategy{ backoffStrategy := &backoff.ExponentialStrategy{
Min: 1000, Min: 1000 * time.Millisecond,
Max: 20_000, Max: 20_000 * time.Millisecond,
MaxJitter: 250, MaxJitter: 250 * time.Millisecond,
} }
for { for {
......
...@@ -16,35 +16,34 @@ type Strategy interface { ...@@ -16,35 +16,34 @@ type Strategy interface {
// ExponentialStrategy performs exponential backoff. The exponential backoff // ExponentialStrategy performs exponential backoff. The exponential backoff
// function is min(e.Min + (2^attempt * 1000) + randBetween(0, e.MaxJitter), e.Max) // function is min(e.Min + (2^attempt * 1000) + randBetween(0, e.MaxJitter), e.Max)
type ExponentialStrategy struct { type ExponentialStrategy struct {
// Min is the minimum amount of time to wait between attempts in ms. // Min is the minimum amount of time to wait between attempts.
Min float64 Min time.Duration
// Max is the maximum amount of time to wait between attempts in ms. // Max is the maximum amount of time to wait between attempts.
Max float64 Max time.Duration
// MaxJitter is the maximum amount of random jitter to insert between // MaxJitter is the maximum amount of random jitter to insert between attempts.
// attempts in ms. MaxJitter time.Duration
MaxJitter int
} }
func (e *ExponentialStrategy) Duration(attempt int) time.Duration { func (e *ExponentialStrategy) Duration(attempt int) time.Duration {
var jitter int var jitter time.Duration
if e.MaxJitter > 0 { if e.MaxJitter > 0 {
jitter = rand.Intn(e.MaxJitter) jitter = time.Duration(rand.Int63n(e.MaxJitter.Nanoseconds()))
} }
dur := e.Min + (math.Pow(2, float64(attempt)) * 1000) dur := e.Min + time.Duration(int(math.Pow(2, float64(attempt))*1000))*time.Millisecond
dur += float64(jitter) dur += jitter
if dur > e.Max { if dur > e.Max {
return time.Millisecond * time.Duration(e.Max) return e.Max
} }
return time.Millisecond * time.Duration(dur) return dur
} }
func Exponential() Strategy { func Exponential() Strategy {
return &ExponentialStrategy{ return &ExponentialStrategy{
Max: 10000, Max: time.Duration(10000 * time.Millisecond),
MaxJitter: 250, MaxJitter: time.Duration(250 * time.Millisecond),
} }
} }
......
...@@ -9,13 +9,13 @@ import ( ...@@ -9,13 +9,13 @@ import (
func TestExponential(t *testing.T) { func TestExponential(t *testing.T) {
strategy := &ExponentialStrategy{ strategy := &ExponentialStrategy{
Min: 3000, Min: 3000 * time.Millisecond,
Max: 10000, Max: 10000 * time.Millisecond,
MaxJitter: 0, MaxJitter: 0,
} }
durations := []int{4, 5, 7, 10, 10} durations := []time.Duration{4, 5, 7, 10, 10}
for i, dur := range durations { for i, dur := range durations {
require.Equal(t, time.Millisecond*time.Duration(dur*1000), strategy.Duration(i)) require.Equal(t, dur*time.Second, strategy.Duration(i))
} }
} }
...@@ -11,7 +11,7 @@ export const logLevels = [ ...@@ -11,7 +11,7 @@ export const logLevels = [
'error', 'error',
'fatal', 'fatal',
] as const ] as const
export type LogLevel = typeof logLevels[number] export type LogLevel = (typeof logLevels)[number]
export interface LoggerOptions { export interface LoggerOptions {
name: string name: string
......
# @eth-optimism/web3.js-plugin # @eth-optimism/web3.js-plugin
## 0.1.2
### Patch Changes
- [#6873](https://github.com/ethereum-optimism/optimism/pull/6873) [`fdab6caa7`](https://github.com/ethereum-optimism/optimism/commit/fdab6caa7e6684b08882d2a766ccd727068c2b2f) Thanks [@spacesailor24](https://github.com/spacesailor24)! - Update code exmaples in README
## 0.1.1 ## 0.1.1
### Patch Changes ### Patch Changes
......
{ {
"name": "@eth-optimism/web3.js-plugin", "name": "@eth-optimism/web3.js-plugin",
"version": "0.1.1", "version": "0.1.2",
"description": "A Web3.js plugin for doing OP-Chain gas estimation", "description": "A Web3.js plugin for doing OP-Chain gas estimation",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
......
...@@ -77,7 +77,7 @@ importers: ...@@ -77,7 +77,7 @@ importers:
version: 1.2.3(eslint@8.47.0) version: 1.2.3(eslint@8.47.0)
eslint-plugin-prettier: eslint-plugin-prettier:
specifier: ^4.0.0 specifier: ^4.0.0
version: 4.0.0(eslint-config-prettier@8.3.0)(eslint@8.47.0)(prettier@2.8.1) version: 4.0.0(eslint-config-prettier@8.3.0)(eslint@8.47.0)(prettier@2.8.8)
eslint-plugin-promise: eslint-plugin-promise:
specifier: ^5.1.0 specifier: ^5.1.0
version: 5.2.0(eslint@8.47.0) version: 5.2.0(eslint@8.47.0)
...@@ -119,10 +119,10 @@ importers: ...@@ -119,10 +119,10 @@ importers:
version: 6.4.7 version: 6.4.7
prettier: prettier:
specifier: ^2.8.0 specifier: ^2.8.0
version: 2.8.1 version: 2.8.8
prettier-plugin-solidity: prettier-plugin-solidity:
specifier: ^1.0.0-beta.13 specifier: ^1.0.0-beta.13
version: 1.0.0-beta.18(prettier@2.8.1) version: 1.0.0-beta.18(prettier@2.8.8)
rimraf: rimraf:
specifier: ^5.0.1 specifier: ^5.0.1
version: 5.0.1 version: 5.0.1
...@@ -1012,7 +1012,7 @@ packages: ...@@ -1012,7 +1012,7 @@ packages:
fs-extra: 7.0.1 fs-extra: 7.0.1
lodash.startcase: 4.4.0 lodash.startcase: 4.4.0
outdent: 0.5.0 outdent: 0.5.0
prettier: 2.8.1 prettier: 2.8.8
resolve-from: 5.0.0 resolve-from: 5.0.0
semver: 5.7.2 semver: 5.7.2
dev: false dev: false
...@@ -1198,7 +1198,7 @@ packages: ...@@ -1198,7 +1198,7 @@ packages:
'@changesets/types': 5.2.1 '@changesets/types': 5.2.1
fs-extra: 7.0.1 fs-extra: 7.0.1
human-id: 1.0.2 human-id: 1.0.2
prettier: 2.8.1 prettier: 2.8.8
dev: false dev: false
/@codechecks/client@0.1.11(typescript@5.1.6): /@codechecks/client@0.1.11(typescript@5.1.6):
...@@ -8366,7 +8366,7 @@ packages: ...@@ -8366,7 +8366,7 @@ packages:
eslint: 8.47.0 eslint: 8.47.0
dev: true dev: true
/eslint-plugin-prettier@4.0.0(eslint-config-prettier@8.3.0)(eslint@8.47.0)(prettier@2.8.1): /eslint-plugin-prettier@4.0.0(eslint-config-prettier@8.3.0)(eslint@8.47.0)(prettier@2.8.8):
resolution: {integrity: sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==} resolution: {integrity: sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==}
engines: {node: '>=6.0.0'} engines: {node: '>=6.0.0'}
peerDependencies: peerDependencies:
...@@ -8379,7 +8379,7 @@ packages: ...@@ -8379,7 +8379,7 @@ packages:
dependencies: dependencies:
eslint: 8.47.0 eslint: 8.47.0
eslint-config-prettier: 8.3.0(eslint@8.47.0) eslint-config-prettier: 8.3.0(eslint@8.47.0)
prettier: 2.8.1 prettier: 2.8.8
prettier-linter-helpers: 1.0.0 prettier-linter-helpers: 1.0.0
dev: true dev: true
...@@ -13768,7 +13768,7 @@ packages: ...@@ -13768,7 +13768,7 @@ packages:
fast-diff: 1.2.0 fast-diff: 1.2.0
dev: true dev: true
/prettier-plugin-solidity@1.0.0-beta.18(prettier@2.8.1): /prettier-plugin-solidity@1.0.0-beta.18(prettier@2.8.8):
resolution: {integrity: sha512-ezWdsG/jIeClmYBzg8V9Voy8jujt+VxWF8OS3Vld+C3c+3cPVib8D9l8ahTod7O5Df1anK9zo+WiiS5wb1mLmg==} resolution: {integrity: sha512-ezWdsG/jIeClmYBzg8V9Voy8jujt+VxWF8OS3Vld+C3c+3cPVib8D9l8ahTod7O5Df1anK9zo+WiiS5wb1mLmg==}
engines: {node: '>=12'} engines: {node: '>=12'}
peerDependencies: peerDependencies:
...@@ -13777,22 +13777,16 @@ packages: ...@@ -13777,22 +13777,16 @@ packages:
'@solidity-parser/parser': 0.13.2 '@solidity-parser/parser': 0.13.2
emoji-regex: 9.2.2 emoji-regex: 9.2.2
escape-string-regexp: 4.0.0 escape-string-regexp: 4.0.0
prettier: 2.8.1 prettier: 2.8.8
semver: 7.5.3 semver: 7.5.3
solidity-comments-extractor: 0.0.7 solidity-comments-extractor: 0.0.7
string-width: 4.2.3 string-width: 4.2.3
dev: true dev: true
/prettier@2.8.1:
resolution: {integrity: sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==}
engines: {node: '>=10.13.0'}
hasBin: true
/prettier@2.8.8: /prettier@2.8.8:
resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==}
engines: {node: '>=10.13.0'} engines: {node: '>=10.13.0'}
hasBin: true hasBin: true
dev: true
/pretty-format@27.5.1: /pretty-format@27.5.1:
resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==} resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment