Skip to content

Commit

Permalink
chore(lib): validate inputs before locking (#2148)
Browse files Browse the repository at this point in the history
The PR #2140 introduced a
locking around a cache. Some parts of the critical section seem
unrelated to the locking and can be done before without changing the
read semantics (because this check happened after the cache read
before).

issue: none
  • Loading branch information
chmllr authored Oct 14, 2024
1 parent a782d51 commit a722aa0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/contracts/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ var (

// GetAddresses returns the contract addresses for the given network.
func GetAddresses(ctx context.Context, network netconf.ID) (Addresses, error) {
ver, err := version(ctx, network)
if err != nil {
return Addresses{}, err
}

addrsCache.mu.Lock()
defer addrsCache.mu.Unlock()

Expand All @@ -122,11 +127,6 @@ func GetAddresses(ctx context.Context, network netconf.ID) (Addresses, error) {
return addrs, nil
}

ver, err := version(ctx, network)
if err != nil {
return Addresses{}, err
}

addrs = Addresses{
Create3Factory: create3Factory(network),
AVS: avs(network),
Expand Down

0 comments on commit a722aa0

Please sign in to comment.