Skip to content

SIP-167 Introduces an L2 governance bridge #1402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 107 commits into from
Nov 23, 2021
Merged

Conversation

eternauta1337
Copy link
Contributor

@eternauta1337 eternauta1337 commented Jul 12, 2021

Overview

This is an implementation of SIP 167 "L2 Bridged Governance".

The basic idea is to own the system contracts on L2 via a contract, that is controlled from L1. This L2 owner contract only responds to transactions relayed from its L1 counterpart, which in turn only responds to the L1 owner.

L2 contract: OwnerRelayOnOptimism.sol
L1 counterpart: OwnerRelayOnEthereum.sol

Thus, L2 system contracts need to nominate OwnerRelayOnOptimism as their new owner. This effectively makes OwnerRelayOnOptimism the owner of the L2 instance 😮

The L1 owner (the pDAO) will then be able to use OwnerRelayOnEthereum to relay arbitrary messages to OwnerRelayOnOptimism, which will accept the messages as long as the L1 tx originator was effectively the OwnerRelayOnEthereum. It will then forward these messages to any contract on L2, with owner access.

E.g. changing a SystemSetting on L2, via this owner relay:

  • Optimistic etherscan is used to get the encoded calldata for changing the setting on L2 (or the CLI can be used as well).
  • A call to OwnerRelayOnEthereum.initiateRelay(SystemSettings address on L2, encoded calldata) is staged in the pDAO
  • The pDAO signs and executes the tx
  • 5-8 minutes later, the tx will be relayed to L2
  • OwnerRelayOnEthereum.finalizeRelay(...) will be called by Optimism's messenger, pass all checks, and change the owner protected setting. Yay 🎉

Batching

Similarly, txs can be relayed in batches via OwnerRelayOnEtherem.initiateRelayBatch(...) and OwnerRelayOnOptimisim.finalizeRelayBatch(...). This is handy for when the pDAO needs to relay multiple txs at once, like for example when accepting ownership after all contracts on L2 have nominated OwnerRelayOnOptimism as their new owner.

Gas limits on L1 and L2

Both OwnerRelayOnEthereum.initiateRelay(...) and OwnerRelayOnEthereum.initiateBatchRelay(...) accept a crossDomainGasLimit parameter, which ultimately determines the gas limit of the L2 relayed transaction. If the value used is zero, the default system setting will be used (currently 8m gas).

In practice, we've found that accepting ownership on more than 25 contracts runs out of gas on L2 if the crossDomainGasLimit is 8m.

Temporary fallback mechanism

Since this is a novel mechanism controlling a very critical aspect of the system on L2, a temporary fallback mechanism on L2 is implemented: OwnerRelayOnOptimism.directRelay(...).

This allows an EOA to directly control the contract owner on L2, but this functionality expires after a certain amount of time. The EOA that has access to this functionality and the amount of time it lasts for has to be set on contract deployment and cannot be changed.

Ownership control in the new contracts is as follows:

  • OwnerRelayOnEthereum => Owned => The pDAO
  • OwnerRelayOnOptimism => TemporarilyOwned => an EOA

New settings and defaults

Adds SystemSettings.CROSS_DOMAIN_RELAY_GAS_LIMIT.

Adds default values in index.js for

  • TEMP_OWNER_DEFAULT_DURATION: 60 days
  • CROSS_DOMAIN_RELAY_GAS_LIMIT: 8000000

New scripts

connect-bridge.js is updated to also connect the owner relay contracts.

nominate-relay.js is added, similar to nominate.js but specialized for the relay. This should NOT be used to nominate all contracts to OwnerRelayOnOptimism when the current owner is an EOA, but when the current owner is the relay, and a new relay or EOA is to be nominated.

owner-relay.js is added, similar to owner.js but specialized for the relay. This should be used to (a) accept owner ship for OwnerRelayOnOptimism after nomination, or to stage owner actions to the pDAO multisig.

Tests

New unit tests:

  • OwnerRelayOnEthereum.js
  • OwnerRelayOnOptimism.js
  • TemporarilyOwned.js
  • SystemSettings.js (partial addition)

New integration tests:

  • relay.integration.js - dual test changing an L2 SystemSetting from L1
  • relayBatch.integration.js - dual test changing ownership of all L2 contracts and accepting it via L1
  • directRelay.l2.integration.js - L2 test on the temporary fallback mechanism

Deployment runsheet

To deploy this feature in production, contracts need to be deployed both on mainnet and optimistic-mainnet networks, and the contracts then need to be connected (i.e. each instance needs to know of the addresses of its counterparts in the opposite network).

L1 deployment:

  • Deploy OwnerRelayOnEthereum and SystemSettings

L2 deployment

  • Deploy OwnerRelayOnOptimism

Connection

  • On L1, Stage AddressResolver.importAddresses("ovm:OwnerRelayOnOptimism", address) and execute it on the pDAO.
  • On L1, call OwnerRelayOnEthereum.rebuildCache()
  • On L2, run AddressResolver.importAddresses("base:OwnerRelayOnEthereum", address).
  • On L1, call OwnerRelayOnOptimism.rebuildCache()

Ownership transfer on L2

  • Use nominate.js on L2 (with --use-ovm) to nominate all L2 contracts to the deployed address of OwnerRelayOnOptimism. Note that nominate-relay.js is only needed in the future, after ownership is the relay and not an EOA.
  • Accept L2 relay ownership by OwnerRelayOnOptimism using the bridge. Use the new command owner-relay. It will use OwnerRelayOnEthereum.initiateRelayBatch and will be done via an EOA if you are on a test network or staging a transaction on Gnosis Safe if you are deploying for mainnet. This should be repeated at least twice (until you confirm there's no more contracts pending) since it's a batch execution with a limit in the number of contracts per batch to prevent a revert due to exceeding the gas limit.
  • Verify OwnerRelayOnOptimism is the owner of the contracts on L2.

Command examples

Connect the relay contracts (only works on instances owned by EOAs, i.e. testnets)

In this example we deployed a brand new system on kovan (#1467).

node publish connect-bridge \
    --l1-network kovan \
    --l2-network kovan \
    --l1-provider-url https://kovan.infura.io/v3/1xxxxxxba1 \
    --l2-provider-url https://kovan.optimism.io/ \
    --l1-deployment-path ./publish/deployed/kovan-test \
    --l2-deployment-path ./publish/deployed/kovan-test-ovm \
    --l1-private-key 0x479xxxxxxxxxxxda0 \
    --l2-private-key 0x479xxxxxxxxxxxda0 \
    --l1-messenger 0x4361d0F75A0186C05f971c566dC6bEa5957483fD \
    --l2-messenger 0x4200000000000000000000000000000000000007 \
    --l1-gas-price 2 \
    --l1-gas-limit 8000000 --dry-run

Nominate OwnerRelayOnOptimism

Using the nominate command set the --new-owner to the OwnerRelayOnOptimism address.

node publish nominate --network kovan --deployment-path ./publish/deployed/kovan-test-o
vm  --new-owner 0x41e5175CD6eB75a96b50D9935a6E534A5B1559B2 --use-ovm --provider-url https://kovan.optimism.io

Accept L2 relay ownership by OwnerRelayOnOptimism using the bridge

In this case it was necessary to run this twice, to cover all the contracts. Note that before running the second time you should confirm the first batch succeeded.
You can use https://kovan-optimistic.etherscan.io/txsEnqueued (or https://optimistic.etherscan.io/txsEnqueued for mainnet) to check if the transaction was sent to L2 by Optimism network.

node publish  owner-relay \
    --l1-network kovan \
    --l2-network kovan \
    --l1-deployment-path ./publish/deployed/kovan-test \
    --l2-deployment-path ./publish/deployed/kovan-test-ovm \
    --l1-provider-url https://kovan.infura.io/v3/1xxxxxxba1 \
    --l2-provider-url https://kovan.optimism.io/ \
    --l1-private-key 0x479xxxxxxxxxxxda0 \
    --gas-price 2 \
    --gas-limit 8000000

This example was run using a EOA on L1 to accept ownership via Relay on L2. In case a Gnosis Safe is used as owner on L1, the command should include the flag --is-contract in the same way as it's done with node publish owner command.

Change ownership on L2 (back to EOA or other OwnerRelayOnOptimism)

In case something went wrong, there are two alternatives to regain ownership of the L2 contracts. One using the relay itself or another, that is only available for a period of time, directly using OwnerRelayOnOptimism with the designated temporary owner.

Using the Relay
Once the relay is configured, OwnerRelayOnOptimism will be the owner of all L2 contracts. You can change it to a new owner (a new contract or an EOA) using the new command nominate-relay to nominate a new owner in batches for all L2 contracts.
An example of how to use this new contract can be seen here:

node publish  nominate-relay \
    --l1-network kovan \
    --l2-network kovan \
    --l1-deployment-path ./publish/deployed/kovan-test \
    --l2-deployment-path ./publish/deployed/kovan-test-ovm \
    --l1-provider-url https://kovan.infura.io/v3/1xxxxxxba1 \
    --l2-provider-url https://kovan.optimism.io/ \
    --l1-private-key 0x479xxxxxxxxxxxda0 \
    --gas-price 2 \
    --gas-limit 8000000 \
    --new-owner 0x23e78AaC93254a858c1bA7F6fE92468fE367B3f1

The same note mentioned on owner-relay using an EOA or Gnosis Safe on L1 are valid here, you can set the same parameters like --is-contract to indicate the command to stage a transaction instead of executing it as an EOA.

Using the temporary owner
In order to nominate a new owner and there was something wrong setting up the relay, you can use the temporary owner to act on that situation using the function OwnerRelayOnOptimism.directRelay(address target, bytes calldata payload)

@codecov
Copy link

codecov bot commented Jul 12, 2021

Codecov Report

Merging #1402 (31dbf74) into develop (682a2ef) will increase coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1402      +/-   ##
===========================================
+ Coverage    95.58%   95.67%   +0.08%     
===========================================
  Files           79       82       +3     
  Lines         1882     1917      +35     
  Branches       586      598      +12     
===========================================
+ Hits          1799     1834      +35     
  Misses          83       83              
Impacted Files Coverage Δ
contracts/SynthetixBridgeEscrow.sol 100.00% <ø> (ø)
contracts/MixinSystemSettings.sol 100.00% <100.00%> (ø)
contracts/OwnerRelayOnEthereum.sol 100.00% <100.00%> (ø)
contracts/OwnerRelayOnOptimism.sol 100.00% <100.00%> (ø)
contracts/TemporarilyOwned.sol 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 682a2ef...31dbf74. Read the comment docs.

@jjgonecrypto jjgonecrypto self-requested a review November 23, 2021 21:31
@jjgonecrypto jjgonecrypto merged commit 9f38d1a into develop Nov 23, 2021
@jjgonecrypto jjgonecrypto deleted the governance-bridge branch November 23, 2021 21:32
jacko125 added a commit that referenced this pull request Mar 13, 2022
* Futures closure fee (#1417)

* kovan-ovm-futures (refactored) (#1400)

* Add confirmation and liquidation booleans to futures position data. (#1424)

* add missing chainlink feeds to kovan-ovm-futures

* re-run deployment with correct network set

* Add global futures settings to data contract. (#1431)

* Futures markets respect fee reclamation. (#1436)

* Futures markets respect fee reclamation.

* Check necessity of reclamation on reclaim value rather than number of entries settled.

* Fix merge history for futures-implementation (#1445)

* Alioth release (#1263)

* Remove bridge migrator (#1257)

* Skips multicollateral prod tests if max debt has been reached (#1259)

* SIP-136: MultiCollateral/CollateralEth debt is not excluded correctly from debt calculations (#1243)

* SIP-112: EtherWrapper (#1178)

* Deploy 2.45 to kovan (#1260)

* Prepublish step

* 2.45.0-alpha

* set mint fee and burn fee per sccp 100

Co-authored-by: Alejandro Santander <Palebluedot@gmail.com>
Co-authored-by: Synthetix Team <team@synthetix.io>
Co-authored-by: Jackson C <jackosmacko@gmail.com>

* Introducing new integration tests in CI (#1287)

* Introducing integration tests in CI

* Improved integration tests in CI and removed redundant prod tests

* Bugfix on integration test task

* More verbose on deployer error

* Refactoring of Exchanger.sol to reduce size on OVM (#1291)

* Minor fix for integration tests (#1295)

* Clean state on dual integration tests plus slightly better exchange tests

* Minor fix to integration tests

* Disable some exchanging integration tests for now

* Extra prod tests (#1299)

* Add issuance prod tests

* Add erc20 behavior

* Tweaks on incoming integration tests

* Minor fix to integrationt ests

Co-authored-by: Alejandro Santander <Palebluedot@gmail.com>

* Audit feedback and spring cleaning (#1300)

* Port more integration tests (#1288)

* Basic integration tests for L2 deposits

* Basic integration tests for L2 deposits

* Polish deposit integration tests

* Progress porting withdrawal integration tests

* Working withdrawals in new integration tests

* Using watcher tool more

* Unify action and actionTo in integration tests

* Progress porting integration tests

* Remove comment

* Implemented exchanges in new integration tests

* Bugfix in integrationt est task

* Basic forking in integration tests

* Include fork tests in CI

* Minor fixes for prod tests

* port migrateEscrow test to integration dual

* Fix CI

* Fix CI

Co-authored-by: Leonardo Massazza <lmassazza+github@gmail.com>
Co-authored-by: Yannis <i.stamelakos@gmail.com>

* Better way to get SNX in integration tests (#1303)

* Better way to get SNX

* 2192

* Introduces forking via integration tests (#1307)

* Introduces forking with integration tests

* Compile and deploy on fork tests

* Fix old ovm prod tests

* Replace web3 with ethers in deployment (#1271)

* add wrapper object to hold web3 and ethers

* Replace web3-utils with ethers

* - replace web3.utils with ethers counterpart
- create account with ethers instead of web3

* corrections to failed tests

* propagate Deploy changes fix (test:publish green)

* document the provider addition to Deployer

* document the provider addition to Deployer

* fix require

* fix require

* Clean install

* Update to develop

Co-authored-by: Alejandro Santander <Palebluedot@gmail.com>

* Updates optimism dependencies (#1308)

* Updated optimism deps

* Update usage of dep in code

* Add hardhat-ethers dep required by smock

* Add await in unit test

* Removed @gas-skip (#1309)

* Updated optimism deps

* Update usage of dep in code

* Add hardhat-ethers dep required by smock

* Removed @gas-skip

* Add await in unit test

* Disables prod tests from CI (#1311)

* Reordering the deploy script for sanity (#1304)

* Add integration tests for settle and claim (#1310)

* Support settlements in exchanging behavior

* Testing claims in integration tests

* Address PR feedback, increase timeouts, improve test for forking

* Bigger tolerance for debt comparison

* Approve bridge tokens during bootstrap

* Add SynthsUSD integration (L1 and L2) tests (#1312)

* Add support to SynthsUSD in L1 and L2 integration tests

* Add support to SynthsUSD in L1 and L2 integration tests

* style fixes

Co-authored-by: Alejandro Santander <Palebluedot@gmail.com>

* Port migrateEscrow and depositAndMigrateEscrow tests  (#1306)

* ported. Some tests still failing

* wip

* migrateEscrow test ported

* accept multiples hashes in watchers

* Reduce migrateEscrow dual test to dual scope

* ported depositAndMigrateEscrow test

* update test wording

Co-authored-by: Alejandro Santander <Palebluedot@gmail.com>

* Migration for bulk staking reward upgrade (#1301)

* Deleted everything related to prod tests (#1315)

* Adds ether wrapper integration tests (#1319)

* Basic integration tests for ether wrapper

* Fix timeout in integration tests

* Abstract eth wrapper behavior in integration tests

* Support ether wrapper integration tests in mainnet forks

* Pin ops to a particular commit that is known to work in CI

* Processed Leo's feeedback on PR

* Enables separate folder compilation for integration tests (#1322)

* Enables separate folder compilation for integration tests

* Clean install

* Merge all integration test tasks into one (#1323)

* Remove web3 from the deploy script test (#1328)

* Progress removing web3 from test for deploy script

* Progress removing web3 from test for deploy script

* Almost done removing web3 from deploy tests

* Add optimism scripts to run Optmism via hardhat (#1324)

* Add optimism scripts to npm

* fix variable naming

* Add harhat task to build and start ops

* remove ops scripts from packages.json

* - check status to run the right steps
- order jobs
- cleanup messages

* Update circleCI

* change docker command to test on circleCI

* keep chain atached and add detach option

* Tweak CI for integration tests

* Keep ops start task open

Co-authored-by: Alejandro Santander <Palebluedot@gmail.com>

* Unpins the usage of the Optimism ops tool and starts managing L2 gas (#1331)

* Removes web3 from nominate script (#1332)

* Progress removing web3 from nominate script

* Applies nominate test to L2

* Ported nominate script to ethers

* Fix

* Removed web3 from settle script (#1334)

* Removed web3 from extract-staking-balances (#1335)

* Remove web3

* Remove wallet (only read from contracts)

* Removes web3 from the owner script (#1336)

* Using owner script in integration tests

* Removed web3 from owner script

* Manually setting isContract in owner script

* Add caching of docker layers on integration tests job (#1333)

* remove docker prune from ops tasks

* add cache for optimism build on integration-tests job

* add a check to execute deployments tests only if a deployment.json file changed (#1339)

* Removes web3 from the purge script (#1341)

* Support forks in purge-synths script

* Extract performTransactionalStep version for ethers

* Rename function to deprecate

* Minor fix

* Remove web3 from remove-fee-periods (#1342)

* wip commit

* wip commit

* wip

* wip

* Remove log line from script

* remove empty comment

* Add gas reporting job parallelization on CI (#1305)

* add task for merging gas reports files on CI

* add parallelized gas reports to unit tests

* update codechecks unit-test-gas-report name

* remove optimizer flag from unit tests

* remove test:gas script from package.json

* remove web3 references (#1344)

* SIP-150 Fix excluded debt calculation for partial snapshots. (#1340)

* SIP-145 Emit the proper cached debt number when debt snapshots are taken. (#1325)

* remove web3 from migrate-binary-option-markets (#1345)

* Fixing nominate to work locally and ethers fix (#1354)

* Introduces fast forwarding in L2 integration tests (#1343)

* Basic fast forwarding in L2 integration tests

* Replaced 'ignore' utils with fast forwarding in integration tests

* Clean install

* Undo changes to package lock file

* Pin ops version

* Avoid redundant heartbeats

* Fix and improve integration tests

* Add comment to test

* Update ops image

* Clear ops cache in CI

* Update watchers dep

* Hotfix for Optimism watchers

* Clean install

* Update to hardhat 2.3.x

* Clear ops tool cache

* Unpin ops

* Update ops cache

* Attach ops output

* Debugging Optimism messenger watchers

* Listen to interactions with messenger on blocks

* Keep withdraw tests open

* Implementing a completely patched ops watcher

* Tidy ups

* remove only in tests

* Disabled ops cache

* Restored ops caching

* Quiet

* Bugfix

* Debug optimism in l2 standalone integration tests

* Cleanups

* Adds integration tests for opening and closing a loan (#1330)

* Resolves conflict

* Updates ignore waiting period to new pattern

* Deploy EmptyEtherWrapper (#1349)

* EmptyEtherWrapper

* deploy EmptyEtherWrapper

* ignore EmptyEtherWrapper for coverage

* Use simple synths in local-ovm

* Bugfix on ops tool task

Co-authored-by: Alejandro Santander <Palebluedot@gmail.com>

* remove web3 from checkAggregatorPrices (#1353)

Co-authored-by: Alejandro Santander <Palebluedot@gmail.com>

* Unify wallet creation and ensure .address is always present (#1357)

Co-authored-by: Alejandro Santander <Palebluedot@gmail.com>

* Support for testnet forking (#1359)

* Allow private key overrides in local and fork mode (#1360)

* Fix for SupplySchedule - must use the ERC20 proxy (#1338)

* Adding new synth suspension reason for index rebalancing and using testnet checksum address

* SCCP-98 DEFI rebalance (#1364)

* Prepublish step

* 2.45.3

* Refresh ops cache (#1368)

* Upgrading etherscan links to optimistic explorer when required (#1369)

* Ethers overrides gasLimit, not gas (#1366)

* Adds documentation for integration tests (#1367)

* Add documentation for integration tests

* Update integration tests README

* Updating releases for Alnitak (#1363)

* Remove web3 from persist-tokens. (#1352)

* remove from persist-tokens. Missing one command

* WIP Commit (to stage the branch). Need to replace SetContenthash with our own implementation

* wip

* Remove web3 dependency (setContenthash doesn't work)

* Remove commented out code and useless interaction

Co-authored-by: Alejandro Santander <Palebluedot@gmail.com>

* Incorporate synthetix-cli interactive-ui as a `npx hardhat interact` task (#1365)

* add interactive ui hardhat task

* update pacakge-lock with a clean install

* Minor tidy ups

* Remove redundant utils

Co-authored-by: Alejandro <palebluedot@gmail.com>

* Adding solidity output to deploy script (#1313)

* Simplify conditional logic of generate solidity (#1378)

* Alnitak release kovan (#1379)

* Prepublish step

* 2.46.0-alpha

* Adding EtherWrapper for L2 to deploy empty and SystemSettings for Etherwrapper settings (#1380)

* Alnitak release kovan optimism (#1381)

* Prepublish step

* 2.46.0-alpha-ovm

* Fixing local dev to properly only deploy WETH the first time (#1384)

* Removing 145 and 150 from Alnitak (#1386)

* Fix fork-tests to work and surface errors correctly (#1385)

* OVM gas limit fixes (#1382)

* Mainnet deploy of Alnitak contracts and migration (#1383)

* Prepublish step

* 2.46.0

* Alnitak release optimism (#1390)

* Prepublish step

* 2.46.0-ovm

* Fixes integration tests on CI (#1392)

* Makes l2 standalone integration tests pass

* Refresh ops tool cache in CI

* Possible fix to hardhat ops task

* Undo bad fix, but with small tidy up

* Try to build ops image manually

* Update CI build

* Small bugfix on ci

* Another attempt at building ops tool on ci

* Undo all changes to CI

* Disabled ops tool in CI

* Disable ops tool build

* Showing a different name while integration tests are simplified

* Pins a newer ops tool version

* Re-enable ops-tool in CI (#1395)

* use docker 20.10.6 in CI

* duh...

* fix bootstrap.js issue on dual

Co-authored-by: Alejandro Santander <Palebluedot@gmail.com>
Co-authored-by: Synthetix Team <team@synthetix.io>
Co-authored-by: Jackson C <jackosmacko@gmail.com>
Co-authored-by: Justin J. Moses <justinjmoses@gmail.com>
Co-authored-by: justin j. moses <justin@synthetix.io>
Co-authored-by: Yannis <i.stamelakos@gmail.com>
Co-authored-by: Leonardo Massazza <lmassazza+github@gmail.com>
Co-authored-by: Matías Lescano <mjlescano@users.noreply.github.com>
Co-authored-by: Anton Jurisevic <zyzek@users.noreply.github.com>
Co-authored-by: David Goldberg <gberg1@users.noreply.github.com>

* Futures order slippage (#1446)

* add maxSlippage to submitOrder

This will be used to calculate an upper/lower bound for the price upon an order being confirmed.

* add slippage to calls

* failing test for confirmOrder slippage

* passing test for confirmOrder slippage

* fix some tests

* * fix/simplify slippage calc
* fix tests

* fix test

* convert slippage param to price bounds (min, max)

* fix tests

* test order min/max price in data contract

* canConfirmOrder respects max market size constraints + error management + order size/status (#1430)

* Futures: Market deployment and management scripts (#1440)

* add futures-markets.json to deploy configs

* load futures market settings from config

* remove FUTURES_ASSETS config var

* fix

* add futures-markets.json to deploy configs

* load futures market settings from config

* remove FUTURES_ASSETS config var

* fix

* wip

* wip2

* restore

* * modify publish script test to work with OVM
* add test for futures markets being added

* fix: use only hardhat for L2 tests

* publish script working for local-ovm

* add optimism folder to eslintignore file (#1406)

* restore publish script to original l1-only design

My original design was too complex for not much benefit, since most of the tests were skipped anyways.

* add l2 publish script test, as separate block below

This is a much cleaner diff that'll enable me to get this work out quicker.

* lint

* remove publish test block

I'll reintegrate this in another PR.

Co-authored-by: Matías Lescano <mjlescano@users.noreply.github.com>

* Richer Futures position and margin events (#1456)

* Futures documentation (#1460)

* Dead code cleanup. (#1462)

* Position ID, PositionOpened, PositionClosed added (#1461)

* Position ID, PositionOpened, PositionClosed added

* removed useless positionId variable

* PR fixes

* removing PositionOpened & positionClosed

* Adding new status to futures market interface

* test debug

* tests added

* Futures spot trades (#1477)

* Futures position details (#1479)

* Futures accessible margin (#1484)

* emit sizeDelta with PositionModified event (#1485)

* emit sizeDelta with PositionModified event

* fix

* sizeDelta -> tradeSize

This is clearer for liquidation flows

* Deploy kovan-ovm-futures v0.4.0 (Alpha) (#1487)

* remove price update constraint from order flow

* prepare-deploy

* add FuturesMarketSettings to releases

* deploy kovan-ovm-futures v0.2.0

* fixes

* unignore deployment.json

* add FuturesMarketSettings to releases

* prepare-deploy

* deploy kovan-ovm-futures v0.3.0

* Futures position details (#1479)

* Futures accessible margin (#1484)

* emit sizeDelta with PositionModified event

* emit sizeDelta with PositionModified event (#1485)

* emit sizeDelta with PositionModified event

* fix

* sizeDelta -> tradeSize

This is clearer for liquidation flows

* deploy kovan-ovm-futures v0.4.0

* test that npmignore will include deployment.json

NPM ignores files listed in gitignore which is a problem.

https://stackoverflow.com/questions/24942161/does-npm-ignore-files-listed-in-gitignore

Co-authored-by: Anton Jurisevic <zyzek@users.noreply.github.com>

* Fix futures position id management + tests. (#1492)

* fix slither crashing in CI and local (#1519)

 fix slither crashing in ci and local

#1519

* Adding gnosis safe multisend functionality to owner (#1513)

* Adding safe functionality from the gnosis SDK to the owner command
* Updating nominate command to use owner actions when not the owner

* SIP-135 Cleanup (#1522)

* Prepping for the Sargas (2.50) release to OVM (#1526)

* Sargas to be OVM only with 135, 142 and 174
* Adding missing SIP-140 from list

* Fixing settle for ethers (#1509)

* Reduce gas usage for opening loans (#1529)

* Print deploy param object value (#1534)

* add slither code check github integration (#1523)

* Refactor exceedsDebtLimit check (#1539)

* Removing unneeded kovan contracts (#1538)

* ci: lavamoat integration (#1517)

* CI: add codeql (#1544)

* Adds block tag parameter to interact task (#1528) (#1536)

* ci: slither github actions improvements (#1543)

* Removing integrationProxy from Proxyable  (#1521)

* up maxMarketValue

* Fix prepare deploy (#1548)

* Document debt cache (#1533)

* * conceptually document this function
* iterate on a simplified construction

* rewrite doc for current version, sans changes to logic

* document debt cache

* Updating packages for audits and temporarily disabling the audit check (#1553)

* redeploy again

* ci: fail audit on critical severity (#1557)

Signed-off-by: Jakub Mucha <jakub.mucha@icloud.com>

* ci: update docker containers to node@14.18 (#1558)

* chore: name entry added to lockfile in recent npm version
* ci: update docker containers to node@14.18

* Futures: merge develop (#1547)

* Update proportional skew funding calculation to use maxMarketValue an… (#1556)

* Update proportional skew funding calculation to use maxMarketValue and also cap maxMarketValue

* update funding rate skew tests and IFuturesMarket interface

* Futures min skew scale (#1561)

* use minSkewScale to control starting funding rate

* enable skipped tests

* increase testnet minSkewScale

* add test for minSkewScale regime transition

Co-authored-by: Arthur Deygin <29574203+artdgn@users.noreply.github.com>

* add verified details for some (not all) contracts

* only run if CollateralShort exists

* * Move "sources" into "sips"
* Add additional sources to SIP-80

* fix: disable WETH deployment on L2

* deploy kovan-ovm-futures v0.5.0

* add whitelist for transfering externstateToken (#1565)

* add whitelist for transfering externstateToken

* update require statement

* enable limited transfers on kovan-ovm-futures

* introduce LimitedTransferSynth, a clone of Synth with limited transfers according to whitelist
* polymorphic approach to deploying LimitedTransferSynth

Co-authored-by: liamzebedee <liamzebedee@yahoo.com.au>

* prepare-deploy kovan-ovm-futures v0.5.1

* prepare-deploy 0.5.2

We need to replace Issuer as the synths are being added there, not in Synthetix

* prepare-deploy 0.5.3

hack: deploy SynthRedeemer so we can get out-the-door

* deploy 0.5.3

* revert changes

* Deploy kovan-ovm-futures v0.5.0 (#1566)

* add verified details for some (not all) contracts

* only run if CollateralShort exists

* * Move "sources" into "sips"
* Add additional sources to SIP-80

* fix: disable WETH deployment on L2

* deploy kovan-ovm-futures v0.5.0

* prepare-deploy kovan-ovm-futures v0.5.1

* prepare-deploy 0.5.2

We need to replace Issuer as the synths are being added there, not in Synthetix

* prepare-deploy 0.5.3

hack: deploy SynthRedeemer so we can get out-the-door

* deploy 0.5.3

* revert changes

* add missing deployments to config.json so verify picks them up

* verified

* prepare-deploy 0.5.4

* deploy SynthsETH and SynthsUSD

* During deployment, ensure deprecated synths from Wezen have cache updated (#1564)

* Update configure loans interactionDelay (#1568)

* update deployer to support EIP-1559 (#1504)

* update deployer to support EIP-1559

updates `--gas-price` to be replaced with `--max-fee-per-gas` which specifies the maximum base fee paid on a transaction. Additionally, deployer may also specify `--max-priority-fee-per-gas` to specify a mining tip (default: 1 gwei)

If the network does not support 1559, the `gasPrice` is automatically determined by ethers.

For EIP-1559 support, ethers.js needed to be upgraded to 5.4.6

Co-authored-by: jj <jj@og.snxdao.io>

* futures listen to system and synth suspensions (#1530)

* Deploy kovan-ovm-futures v0.6.0 (#1570)

* log error here for better info

* upgrade deployer for OVM 2.0

* fix: update gas price

* prepare-deploy 0.6.0

* fix: rm WETH deploy

* fix url's to etherscan

* SIP-187 fix partial synth updates and debt cache updates (#1551)

* fix partial synth updates and debt cache updates

* Remove require check that cachedSum < Debt as excluded Debt can cause this to fail. Update calc of delta in new synths changed.

* * revert max market value to higher amount
* fix network key in deployment.json

* remove gasPrice overrides from simulate-deploy (#1573)

* Exchange rates circuit breaker refactor (#1540)

* SIP-182 Wrapper Factory (#1489)

Co-authored-by: Lecky <leckylao@gmail.com>
Co-authored-by: Mark Barrasso <4982406+barrasso@users.noreply.github.com>

* SIP-182 Audit feedback - allowance in constructor (#1584)

* Fix param spam during deployment (#1587)

* add missing data in position modified events (#1580)

* add expalantion about releases.json in readme (#1569)

Co-authored-by: Liam Zebedee <liamzebedee@yahoo.com.au>
Co-authored-by: jj <jj@og.snxdao.io>

* ci: use node 16 (LTS) (#1588)

* ci: use node@16

* ci: use new cache key

* chore: "name" missing in package-lock.json

* ci: generated new config

* chore: use node@16 by default

Signed-off-by: Jakub Mucha <jakub.mucha@icloud.com>

* Removing inverse synths (#1592)

* Ensuring SCCP-139 feeds are persisted to future ExchangeRates contracts (#1593)

* Futures rename parameters (#1595)

* Deploy kovan-ovm-futures v0.7.0 (#1589)

* log error here for better info

* upgrade deployer for OVM 2.0

* fix: load source for LegacyOwned

LegacyOwned is contained within legacy/

* remove ovm-specific logic around compilerversion metadata

Code is now compiled using the regular solc.

* update gas price again

* prepare-deploy

* deploy kovan-ovm-futures v0.7.0

* rm WrapperFactory from config

I copied these changes hackily across from develop. This snuck through

* contracts verified

* deploy kovan-ovm-futures v0.7.0 again

For some reason, LimitedTransferSynth wasn't deployed for SynthsUSD the first time

* update ops node

* use the optimismCommit in task-ops.js as a cache key

* Skip shorts integration tests when cannot open loans (#1597)

* Add default private key for local-ovm deploys (#1455)

* add default private key for local-ovm deploys

* fix: add useOvm

* Update ops node commit to working version in `develop`

* SIP-120: TWAP Exchange Function (#1127)

* Adding 6 more potential releases

* Helper script to distribute SNX/sUSD to accounts on kovan-futures-ovm (#1554)

* commit empty deployment.json for local-ovm so resolve will work

* move local-ovm network down

* iterate on local helper for bootstrapping

* working script to bootstrap local l2 account (aka snx-brrr)

* local script now supports specifying provider/snx-network/owner account

* use ensureBalance to get testnet SNX/sUSD for accounts

* refactoring: balances script

* log error here for better info

* upgrade deployer for OVM 2.0

* fix: update gas price

* prepare-deploy 0.6.0

* fix: rm WETH deploy

* update local dist script with whitelist

* revert

* rename file to match task

* Futures liquidation fee update (#1594)

* adding market debt explanation comments

* Fixing owner script to not submit multiple accept for dupe contracts

* Upgrading to OVM 2.0 (or the destruction of useless code) (#1598)

* Minor fixes for release history

* SIP-167 Introduces an L2 governance bridge (#1402)

* Removing mistake

* Fixes from menkalinan (#1608)

* Owner batch fixing
* Adding L2 owner

* Update OVM bytecode (#1613)

* Move debt snapshot to beforeEach block (#1616)

* Fix duplicate fee reporting on WrapperFactory (#1617)

* SIP-194 Fix Liquidations on L2 (#1621)

* Fix broken unit test (#1622)

* Futures next price mechanism (#1609)

* Futures remove closure fee and rounding (#1610)

* reduce storage variables sizes for gas savings (#1614)

* Ensuring job-compile size check matches build command (#1628)

* refactor views into mixin to reduce clutter (#1615)

* rename circuit breaker contracts (#1629)

* Adding exchange gas usage output

* Adding gas output to synth issue, burn and claim in int tests

* SIP-188: Add sETHBTC synth (#1618)

* add tests for debt cache when markets

* SIP-195: L2 CollateralEth Loans (#1632)

* Sip 196 remove internal oracle (#1636)

* Fix contracts compiling after merge

* Remove LimitedTransferSynth

* add liquidation tests in integration (#1625)

* use new `hardhat-interact` package instead of builtin (#1612)

* fix liquidations fork test fail (#1646)

* SIP-193 Reduce size for SystemSettings (#1627)

* Implement interface funcs for BaseDebtCache, EmptyCollateralManager, IExchanger interface cleanup

* Update configuration of loan and system settings (#1637)

* SIP-200: Fix FeePool Rewards Distribution (#1650)

* migration script helper allows deployment and staging of migration script call (#1652)

this should make releases a little easier and make it easier to utilize the migration script functionality of the deployer.

* deploy futures to kovan-ovm-futures and update configuration scripts

* fix shadowing in empty futures market

* fix circuit breaker tests

* remove deprecated setLastExchangeRateForSynth

* update fund local accounts script

* fix atomic exchange circuit breaker tests

* fix market settings and manager tests

* SIP-184 Dynamic Fees (#1649)

* fix status script and fund local accounts

* Take debt snapshot before funding local accounts (#1657)

* fix aggregators usage in futures, setup fixes

* fix futures market test setup

* fix futures market data tests

* fix next price test setup

* fix system settings tests

* fix integration tests failing to setup markets

* fix market debt calculation during setup

* Deploy SNX/ETH and sUSD/DAI staking rewards on OVM (#1653)

* remove old RewardEscrow from deployment.json for ovm environments (#1658)

* Update kovan-ovm/feeds.json for OCR (#1659)

* verify deployment

* fix market settings tests

* fix futures market tests

* Update feeds.json for kovan ovm with new OCR proxies (#1664)

* Optimism Forking with Hardhat (#1656)


Co-authored-by: jj <jj@og.snxdao.io>

* Remove legacy deployment config from kovan-ovm (#1665)

* Upgrade Gnosis SDK (#1655)

* SIPS 196, 193, 184 - audit fixes, full version (#1661)

* Futures merge 184 (#1672)

* fix breaker merge test

* fix test lints (#1607)

* fix test lints

sometimes the dual tests fail due to race condition built into the tests

in addition, a better event is now being used for monitoring transaction relay status.

Withdrawal tests still don't work because the transaction is not relayed on the L1 side,
I'm guessing because the user has to call `finalize` transaction somehow. Not sure who to talk to if we want to get those tests working.

* fix lints

* uncomment

Co-authored-by: Mark Barrasso <4982406+barrasso@users.noreply.github.com>
Co-authored-by: jj <jj@og.snxdao.io>

* try fix dual itnegration tests

* update migration script to also stage nominations (#1670)

* update migration script to also stage nominations

also the owner can now run migration, instead of the deployer, which is way better for getting stuff done

* fix lints

* re-add legacy onlyDeploy function for older migrations

* add verify step

* use performTransactionalStep

* add signer

* cleanup verify step and additional logging for clarity

* another attempt to fix dual integration tests

* Revert "another attempt to fix dual integration tests"

This reverts commit 64de1c2.

* Revert "try fix dual itnegration tests"

This reverts commit 8d0f088.

* Removing redundant ExchangeRatesWithInversePricing

* Ensuring fork tests do compile (#1679)

* Futures dynamic fee (#1673)

* Sip 185 debt shares (#1601)

* Fix the validate deployment CI run (#1680)

* Removing the redundant owner param from migrations (#1681)

* Collecting Test Metadata in CI (#1683)

* SIP-209 Update feeRateForExchange function signature (#1686)

* Also fix test-coverage in CI

* Updating task-node to properly manage the provider

* Futures size reduction (#1682)

* address preliminary audit comments (#1691)

* Futures pausing (#1692)

* Basic npm audit fix (#1693)

* Updating mainnet-ovm feeds to new chainlink OCR (#1645)

* add moar releases (#1698)

* Fixing ABI anomaly for kovan-ovm for exchangeWithVirtual

* AIP-202 - Upgrade supply schedule to use target ratio inflation amount (#1700)

* Fixing lint

* Updating mainnet-ovm feeds to new chainlink OCR (#1645)

* add moar releases (#1698)

* Polaris release 2.61 to mainnet ovm (#1699)

* SIP-199 sSOL to Optimism
* SCCP-163 OCR feeds on Optimism

* Prepublish step

* 2.61.0

* Fixing ABI anomaly for kovan-ovm for exchangeWithVirtual

* Fixing ABI anomaly for kovan-ovm for exchangeWithVirtual

* 2.61.1

* AIP-202 - Upgrade supply schedule to use target ratio inflation amount (#1700)

* Hamal release v2.62 mainnet (#1706)

* SIP-202 Target Staking Ratio

* Prepublish step

* 2.62.0

* Fixing lint

* deploy new futuresMarkets with dynamic fees to kovan-ovm-futures

* verify

* add ovm etherscan key support (#1703)

* address minor audit issues

* deploy systemStatus

* release exchangeRates

* dual integration test fix attempt

* Futures single market pausing (#1711)

* Futures support multiple markets for same asset (#1713)

* Futures volume source fee methods (#1714)

* update releases json

* revert unrelated contract changes

* fix fork tests (#1717)

* Debtcache import excluded debt entries (#1716)

* SIP-165 Debt Orcale (#1694)

Impl for 165

From a code perspective, this entails:

    FeePool and Issuer are changed to use the chainlink oracle instead of DebtCache and SynthetixDebtShare directly
    FeePool now closes its fee period across networks (using optimism relay call) to allow for synchronized sharing of close parameters between networks
    For testing and initial deployment, a dummy oracles SingleNetworkAggregatorDebtRatio and SingleNetworkAggregatorIssuedSynths are utilized to retrieve debt values for this network, meaning most unit tests can work exactly the same as before.

Notes:

    The SC has indicated that inflation should be divided evenly between networks based on amount of debt shares on each network, so this has been implemented. Also, fees will remain on the network they originate from for the time being
    Dual Integration test was added to verify fee pool closure
    Tests were removed from DebtCache because the functionality is no longer used within the system, but the actual code from solidity was not removed because there is no need to include DebtCache in an update. Doing so would require more migration complexity and it would be better if we could avoid that, so no changes have been made to DebtCache for the time being.

The release process for this SIP is 2 steps:

    First, we will release as usual with the included SingleNetworkAggregators, which will preserve current functionality while enabling for us to start reading from an oracle interface for debt info
    Second, we will use the pdao to change the AddressResolver setting for the two aggregators to be the chainlink provided ones, which will effectively complete the debt synthethsis and enable synth fungibility

* diphda part 1

* diphda part 2

* diphda optimism part 1

* diphda ovm part 2

Co-authored-by: Anton Jurisevic <zyzek@users.noreply.github.com>
Co-authored-by: Liam Zebedeee <liamzebedee@yahoo.com.au>
Co-authored-by: Alejandro Santander <Palebluedot@gmail.com>
Co-authored-by: Synthetix Team <team@synthetix.io>
Co-authored-by: Jackson C <jackosmacko@gmail.com>
Co-authored-by: Justin J. Moses <justinjmoses@gmail.com>
Co-authored-by: justin j. moses <justin@synthetix.io>
Co-authored-by: Yannis <i.stamelakos@gmail.com>
Co-authored-by: Leonardo Massazza <lmassazza+github@gmail.com>
Co-authored-by: Matías Lescano <mjlescano@users.noreply.github.com>
Co-authored-by: David Goldberg <gberg1@users.noreply.github.com>
Co-authored-by: Clément BALESTRAT <clement.balestrat@gmail.com>
Co-authored-by: Mark Barrasso <4982406+barrasso@users.noreply.github.com>
Co-authored-by: Jakub Mucha <jakub.mucha@icloud.com>
Co-authored-by: jj <jj@og.snxdao.io>
Co-authored-by: dbeal <git@dbeal.dev>
Co-authored-by: Lecky <leckylao@gmail.com>
Co-authored-by: Brett Sun <qisheng.brett.sun@gmail.com>
Co-authored-by: Joey <5688912+bachstatter@users.noreply.github.com>
Co-authored-by: Noah Litvin <335975+noahlitvin@users.noreply.github.com>
Co-authored-by: dbeal <git@danb.email>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants