-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add frxUSD/sfrxUSD granite fork code change
- Loading branch information
Showing
18 changed files
with
405 additions
and
138 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Release docker image | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: Version to publish (will be the docker tag) | ||
required: true | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
tags: ghcr.io/fraxfinance/fraxtal-op-geth:${{ inputs.version }} | ||
platforms: linux/amd64,linux/arm64 | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
build-args: | | ||
COMMIT=${{ github.sha }} | ||
VERSION=${{ inputs.version }} | ||
BUILDNUM=${{ github.run_number }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package misc | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/consensus/misc/frxusd" | ||
"github.com/ethereum/go-ethereum/core/vm" | ||
"github.com/ethereum/go-ethereum/params" | ||
) | ||
|
||
func EnsureFrxUSD(c *params.ChainConfig, timestamp uint64, db vm.StateDB) { | ||
if !c.IsOptimism() || c.GraniteTime == nil || *c.GraniteTime != timestamp { | ||
return | ||
} | ||
|
||
switch c.ChainID.Uint64() { | ||
case 2521: | ||
frxusd.RunDevnetMigration(c, timestamp, db) | ||
case 2522: | ||
frxusd.RunTestnetMigration(c, timestamp, db) | ||
default: | ||
frxusd.RunMainnetMigration(c, timestamp, db) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package frxusd | ||
|
||
import "github.com/ethereum/go-ethereum/common" | ||
|
||
var frxUSDMigrationProxyCodeAddress = common.HexToAddress("0xfc0000000000000000000000000000000000000a") | ||
var frxUSDProxyAdminAddress = common.HexToAddress("0xfc0000000000000000000000000000000000000a") | ||
var frxUSDProxyAdminSlot = common.HexToHash("0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103") | ||
var frxUSDProxyImplementationSlot = common.HexToHash("0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc") | ||
|
||
var frxUSDAddress = common.HexToAddress("0xfc00000000000000000000000000000000000001") | ||
var frxUSDImplementationAddress = common.HexToAddress("0xfcc0d30000000000000000000000000000000001") | ||
var frxUSDNameBytes = common.HexToHash("0x4672617820555344000000000000000000000000000000000000000000000010") // Frax USD | ||
var frxUSDSymbolBytes = common.HexToHash("0x667278555344000000000000000000000000000000000000000000000000000c") // frxUSD | ||
var frxUSDL1Token = common.FromHex("0xCAcd6fd266aF91b8AeD52aCCc382b4e165586E29") | ||
|
||
var sfrxUSDAddress = common.HexToAddress("0xfc00000000000000000000000000000000000008") | ||
var sfrxUSDImplementationAddress = common.HexToAddress("0xfcc0d30000000000000000000000000000000008") | ||
var sfrxUSDNameBytes = common.HexToHash("0x5374616b6564204672617820555344000000000000000000000000000000001e") // Staked Frax USD | ||
var sfrxUSDSymbolBytes = common.HexToHash("0x736672785553440000000000000000000000000000000000000000000000000e") // sfrxUSD | ||
var sfrxUSDL1Token = common.FromHex("0xcf62F905562626CfcDD2261162a51fd02Fc9c5b6") | ||
|
||
var frxUSDL1TokenReplacementIndexes = []uint{2137, 6850, 7218} | ||
var sfrxUSDL1TokenReplacementIndexes = []uint{2137, 6850, 7218} | ||
|
||
var testnetFrxUSDL1TokenReplacementIndexes = []uint{2137, 6962, 7330} | ||
|
||
var devnetFrxUSDL1TokenReplacementIndexes = []uint{693, 1303} | ||
var devnetSfrxUSDL1TokenReplacementIndexes = []uint{693, 1303} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package frxusd | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/core/vm" | ||
"github.com/ethereum/go-ethereum/log" | ||
"github.com/ethereum/go-ethereum/params" | ||
) | ||
|
||
func RunDevnetMigration(c *params.ChainConfig, timestamp uint64, db vm.StateDB) { | ||
log.Info("Getting frxUSD/sfrxUSD proxy code", "address", frxUSDMigrationProxyCodeAddress) | ||
proxyCode := db.GetCode(frxUSDMigrationProxyCodeAddress) | ||
log.Info("Moving frxUSD implementation", "from", frxUSDAddress, "to", frxUSDImplementationAddress) | ||
frxUSDImplementationCode := db.GetCode(frxUSDAddress) | ||
for _, i := range devnetFrxUSDL1TokenReplacementIndexes { | ||
copy(frxUSDImplementationCode[i:], frxUSDL1Token) | ||
} | ||
db.SetCode(frxUSDImplementationAddress, frxUSDImplementationCode) | ||
log.Info("Setting frxUSD proxy", "address", frxUSDAddress) | ||
db.SetCode(frxUSDAddress, proxyCode) | ||
log.Info("Setting frxUSD storage variables", "address", frxUSDAddress) | ||
db.SetState(frxUSDAddress, frxUSDProxyAdminSlot, common.BytesToHash(common.LeftPadBytes(frxUSDProxyAdminAddress.Bytes(), common.HashLength))) | ||
db.SetState(frxUSDAddress, frxUSDProxyImplementationSlot, common.BytesToHash(common.LeftPadBytes(frxUSDImplementationAddress.Bytes(), common.HashLength))) | ||
db.SetState(frxUSDAddress, common.HexToHash("0x03"), frxUSDNameBytes) | ||
db.SetState(frxUSDAddress, common.HexToHash("0x04"), frxUSDSymbolBytes) | ||
db.SetState(frxUSDAddress, common.HexToHash("0x04"), frxUSDSymbolBytes) | ||
|
||
log.Info("Moving sfrxUSD implementation", "from", sfrxUSDAddress, "to", sfrxUSDImplementationAddress) | ||
sfrxUSDImplementationCode := db.GetCode(sfrxUSDAddress) | ||
for _, i := range devnetSfrxUSDL1TokenReplacementIndexes { | ||
copy(sfrxUSDImplementationCode[i:], sfrxUSDL1Token) | ||
} | ||
db.SetCode(sfrxUSDImplementationAddress, sfrxUSDImplementationCode) | ||
log.Info("Setting sfrxUSD proxy", "address", frxUSDAddress) | ||
db.SetCode(sfrxUSDAddress, proxyCode) | ||
log.Info("Setting sfrxUSD proxy and storage", "address", sfrxUSDAddress) | ||
db.SetState(sfrxUSDAddress, frxUSDProxyAdminSlot, common.BytesToHash(common.LeftPadBytes(frxUSDProxyAdminAddress.Bytes(), common.HashLength))) | ||
db.SetState(sfrxUSDAddress, frxUSDProxyImplementationSlot, common.BytesToHash(common.LeftPadBytes(sfrxUSDImplementationAddress.Bytes(), common.HashLength))) | ||
db.SetState(sfrxUSDAddress, common.HexToHash("0x03"), sfrxUSDNameBytes) | ||
db.SetState(sfrxUSDAddress, common.HexToHash("0x04"), sfrxUSDSymbolBytes) | ||
} |
Oops, something went wrong.