Skip to content

Commit 000ad3f

Browse files
committed
Add option to disable auto update mastercopies configuration on startup
1 parent a4428ab commit 000ad3f

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

config/settings/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
# https://docs.djangoproject.com/en/3.2/ref/settings/#force-script-name
5050
FORCE_SCRIPT_NAME = env("FORCE_SCRIPT_NAME", default=None)
5151

52+
# SETUP SERVICE COMMAND
53+
FORCE_SETUP_SAFE_CONTRACTS = env("FORCE_SETUP_SAFE_CONTRACTS", default=True)
54+
5255
# SSO
5356
SSO_ENABLED = False
5457

@@ -658,9 +661,6 @@
658661
EVENTS_QUEUE_POOL_CONNECTIONS_LIMIT = env.int(
659662
"EVENTS_QUEUE_POOL_CONNECTIONS_LIMIT", default=0
660663
)
661-
662-
# Events
663-
# ------------------------------------------------------------------------------
664664
DISABLE_SERVICE_EVENTS = env.bool(
665665
"DISABLE_SERVICE_EVENTS", default=False
666666
) # Increases indexing speed for initial sync by disabling sending events to the queue

safe_transaction_service/history/management/commands/setup_service.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,19 @@ def handle(self, *args, **options):
183183
self.stdout.write(
184184
self.style.SUCCESS(f"Task {task.name} was already created")
185185
)
186+
self._setup_safe_contracts()
186187

188+
def _setup_safe_contracts(self):
187189
self.stdout.write(self.style.SUCCESS("Setting up Safe Contract Addresses"))
188190
ethereum_client = get_auto_ethereum_client()
189191
ethereum_network = ethereum_client.get_network()
190192
if ethereum_network in MASTER_COPIES:
191193
self.stdout.write(
192194
self.style.SUCCESS(f"Setting up {ethereum_network.name} safe addresses")
193195
)
194-
self._setup_safe_singleton_addresses(MASTER_COPIES[ethereum_network])
196+
self._setup_safe_singleton_addresses(
197+
MASTER_COPIES[ethereum_network], settings.FORCE_SETUP_SAFE_CONTRACTS
198+
)
195199

196200
else:
197201
self.stdout.write(
@@ -226,7 +230,9 @@ def handle(self, *args, **options):
226230
)
227231

228232
def _setup_safe_singleton_addresses(
229-
self, safe_singleton_addresses: Sequence[tuple[str, int, str]]
233+
self,
234+
safe_singleton_addresses: Sequence[tuple[str, int, str]],
235+
force_setup_safe_contracts: bool = True,
230236
):
231237
for address, initial_block_number, version in safe_singleton_addresses:
232238
safe_singleton_address, _ = SafeMasterCopy.objects.get_or_create(
@@ -238,7 +244,7 @@ def _setup_safe_singleton_addresses(
238244
"l2": version.endswith("+L2"),
239245
},
240246
)
241-
if (
247+
if force_setup_safe_contracts and (
242248
safe_singleton_address.version != version
243249
or safe_singleton_address.initial_block_number != initial_block_number
244250
):

0 commit comments

Comments
 (0)