Skip to content
This repository was archived by the owner on Apr 23, 2024. It is now read-only.

Commit 2fd0e54

Browse files
committed
remove deposit token allow list
1 parent 559b8a9 commit 2fd0e54

File tree

7 files changed

+2
-460
lines changed

7 files changed

+2
-460
lines changed

solidity-go/bridge.go

+1-196
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

solidity/contracts/Bridge.sol

+1-45
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ struct SetPausedRequest {
4747
uint256 expiration; // unix timestamp of when the transaction should expire
4848
}
4949

50-
// SetDepositAllowedRequest is the payload for the setDepositAllowed() transaction.
51-
struct SetDepositAllowedRequest {
52-
address token; // token to be enabled / disabled
53-
bool allowed; // true if depsits are allowed otherwise false
54-
uint256 nonce; // used to make each transaction unique for replay prevention
55-
uint256 expiration; // unix timestamp of when the transaction should expire
56-
}
57-
5850
// RegisterStellarAssetRequest is the payload for the registerStellarAsset() transaction.
5951
// The three fields define a new ERC20 token which represents the ethereum equivalent of
6052
// a Stellar asset.
@@ -71,8 +63,6 @@ uint8 constant PAUSE_WITHDRAWALS = 1 << 1;
7163
// bitwise flag representing the state where no withdrawals or deposits are allowed on the bridge
7264
uint8 constant PAUSE_DEPOSITS_AND_WITHDRAWALS = PAUSE_DEPOSITS | PAUSE_WITHDRAWALS;
7365

74-
// SET_DEPOSIT_ALLOWED is used to distinguish setDepositAllowed() signatures from signatures for other bridge functions.
75-
bytes32 constant SET_DEPOSIT_ALLOWED = keccak256("setDepositAllowed");
7666
// SET_PAUSED_ID is used to distinguish setPaused() signatures from signatures for other bridge functions.
7767
bytes32 constant SET_PAUSED_ID = keccak256("setPaused");
7868
// REGISTER_STELLAR_ASSET_ID is used to distinguish registerStellarAsset() signatures from signatures for other bridge functions.
@@ -89,10 +79,7 @@ contract Bridge is Auth, ReentrancyGuard {
8979
event SetPaused(uint8 value);
9080

9181
// to create a Bridge instance you need to provide the validator set configuration
92-
constructor(address[] memory _signers, uint8 _minThreshold) Auth(_signers, _minThreshold) {
93-
emit SetDepositAllowed(address(0x0), true);
94-
depositAllowed[address(0x0)] = true;
95-
}
82+
constructor(address[] memory _signers, uint8 _minThreshold) Auth(_signers, _minThreshold) {}
9683

9784
// Deposit is emitted whenever ERC20 tokens (or ETH) are deposited on the bridge.
9885
// The Deposit event initiates a Ethereum -> Stellar transfer.
@@ -123,13 +110,6 @@ contract Bridge is Auth, ReentrancyGuard {
123110
// created by the bridge.
124111
mapping(address => bool) public isStellarAsset;
125112

126-
// depositAllowed identifies whether an ERC20 token is can be deposited on
127-
// the bridge.
128-
mapping(address => bool) public depositAllowed;
129-
130-
// SetPaused is emitted whenever the paused state of the bridge changes
131-
event SetDepositAllowed(address token, bool allowed);
132-
133113
// depositERC20() deposits ERC20 tokens to the bridge and starts a ERC20 -> Stellar
134114
// transfer. If deposits are disabled this function will fail.
135115
function depositERC20(
@@ -140,7 +120,6 @@ contract Bridge is Auth, ReentrancyGuard {
140120
require((paused & PAUSE_DEPOSITS) == 0, "deposits are paused");
141121
require(amount > 0, "deposit amount is zero");
142122
require(token != address(0x0), "invalid token address");
143-
require(depositAllowed[token], "deposits not allowed for token");
144123

145124
emit Deposit(token, msg.sender, destination, amount);
146125

@@ -163,7 +142,6 @@ contract Bridge is Auth, ReentrancyGuard {
163142
// depositETH() deposits ETH to the bridge and starts a ETH -> Stellar
164143
// transfer. If deposits are disabled this function will fail.
165144
function depositETH(uint256 destination) external payable {
166-
require(depositAllowed[address(0)], "eth deposits are not allowed");
167145
require((paused & PAUSE_DEPOSITS) == 0, "deposits are paused");
168146
require(msg.value > 0, "deposit amount is zero");
169147
emit Deposit(address(0), msg.sender, destination, msg.value);
@@ -247,26 +225,6 @@ contract Bridge is Auth, ReentrancyGuard {
247225
paused = request.value;
248226
}
249227

250-
// setDepositAllowed() will enable or disable deposits for a specific token.
251-
// setDepositAllowed() must be authorized by the bridge validators otherwise the transaction
252-
// will fail. Replay prevention is implemented by storing the request hash in the
253-
// fulfilledrequests set.
254-
function setDepositAllowed(
255-
SetDepositAllowedRequest memory request,
256-
bytes[] calldata signatures,
257-
uint8[] calldata indexes
258-
) external {
259-
bytes32 requestHash = keccak256(abi.encode(domainSeparator, SET_DEPOSIT_ALLOWED, request));
260-
// ensure the same setPaused() transaction cannot be used more than once
261-
verifyRequest(requestHash, requestHash, request.expiration, signatures, indexes);
262-
emit SetDepositAllowed(request.token, request.allowed);
263-
if (request.allowed) {
264-
depositAllowed[request.token] = true;
265-
} else {
266-
delete(depositAllowed[request.token]);
267-
}
268-
}
269-
270228
// registerStellarAsset() will creates an ERC20 token to represent a stellar asset.
271229
// registerStellarAsset() must be authorized by the bridge validators otherwise the transaction
272230
// will fail. Replay prevention is impemented by creating the ERC20 via the CREATE2 opcode (see
@@ -303,8 +261,6 @@ contract Bridge is Auth, ReentrancyGuard {
303261
);
304262

305263
emit RegisterStellarAsset(asset);
306-
emit SetDepositAllowed(asset, true);
307264
isStellarAsset[asset] = true;
308-
depositAllowed[asset] = true;
309265
}
310266
}

solidity/test/bridge.js

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ describe("Deploy Bridge", function() {
1313
for(let i = 0; i < 20; i++) {
1414
expect(await bridge.signers(i)).to.equal(addresses[i]);
1515
}
16-
expect(await bridge.depositAllowed("0x0000000000000000000000000000000000000000")).to.be.true;
1716
await expect(bridge.signers(20)).to.be.reverted;
1817
});
1918

solidity/test/erc20.js

-35
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const { ethers } = require("hardhat");
33
const { PAUSE_DEPOSITS, PAUSE_NOTHING, PAUSE_WITHDRAWALS_AND_DEPOSITS, setPaused, nextPauseNonce, PAUSE_WITHDRAWALS } = require("./paused");
44
const { updateSigners } = require("./updateSigners");
55
const { validTimestamp, expiredTimestamp } = require("./util");
6-
const { setDepositAllowed } = require("./setDepositAllowed");
76

87
async function withdrawERC20(bridge, token, signers, id, domainSeparator, expiration, recipient, amount) {
98
const request = [id, expiration, recipient, token.address, amount];
@@ -37,7 +36,6 @@ describe("Deposit & Withdraw ERC20", function() {
3736
token = await ERC20.deploy("Test Token", "TEST", 18);
3837
await token.mint(sender.address, ethers.utils.parseEther("100.0"));
3938
await token.approve(bridge.address, ethers.utils.parseEther("300.0"));
40-
await setDepositAllowed(bridge, signers, domainSeparator, token.address, true, 0, validTimestamp());
4139
});
4240

4341
it("deposits of 0 are rejected", async function() {
@@ -60,44 +58,11 @@ describe("Deposit & Withdraw ERC20", function() {
6058
await feeToken.mint(sender.address, ethers.utils.parseEther("100.0"));
6159
await feeToken.approve(bridge.address, ethers.utils.parseEther("300.0"));
6260

63-
await setDepositAllowed(bridge, signers, domainSeparator, feeToken.address, true, 1, validTimestamp());
64-
expect(await bridge.depositAllowed(feeToken.address)).to.be.true;
65-
6661
await expect(bridge.depositERC20(
6762
feeToken.address, 1, ethers.utils.parseEther("1.0")
6863
)).to.be.revertedWith("received amount not equal to expected amount");
6964
});
7065

71-
it("block deposits for a specific ERC20 token", async function() {
72-
const blockedToken = await ERC20.deploy("Blocked Test Token", "BLOCKED", 18);
73-
await blockedToken.mint(sender.address, ethers.utils.parseEther("100.0"));
74-
await blockedToken.approve(bridge.address, ethers.utils.parseEther("300.0"));
75-
76-
expect(await bridge.depositAllowed(blockedToken.address)).to.be.false;
77-
await expect(bridge.depositERC20(
78-
blockedToken.address, 1, ethers.utils.parseEther("1.0")
79-
)).to.be.revertedWith("deposits not allowed for token");
80-
81-
await setDepositAllowed(bridge, signers, domainSeparator, blockedToken.address, true, 1, validTimestamp());
82-
expect(await bridge.depositAllowed(blockedToken.address)).to.be.true;
83-
84-
const before = await token.balanceOf(bridge.address);
85-
86-
await bridge.depositERC20(
87-
blockedToken.address, 1, ethers.utils.parseEther("1.0")
88-
);
89-
90-
const after = await blockedToken.balanceOf(bridge.address);
91-
expect(after.sub(before)).to.equal(ethers.utils.parseEther("1.0"));
92-
93-
await setDepositAllowed(bridge, signers, domainSeparator, blockedToken.address, false, 2, validTimestamp());
94-
95-
expect(await bridge.depositAllowed(blockedToken.address)).to.be.false;
96-
await expect(bridge.depositERC20(
97-
blockedToken.address, 1, ethers.utils.parseEther("1.0")
98-
)).to.be.revertedWith("deposits not allowed for token");
99-
});
100-
10166
it("cannot deposit more tokens than current balance", async function() {
10267
await expect(bridge.depositERC20(
10368
token.address, 1, ethers.utils.parseEther("200")

solidity/test/eth.js

-29
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const { ethers, waffle } = require("hardhat");
33
const { PAUSE_DEPOSITS, PAUSE_NOTHING, PAUSE_WITHDRAWALS_AND_DEPOSITS, setPaused, nextPauseNonce, PAUSE_WITHDRAWALS } = require("./paused");
44
const { updateSigners } = require("./updateSigners");
55
const { validTimestamp, expiredTimestamp } = require("./util");
6-
const { setDepositAllowed } = require("./setDepositAllowed");
76

87
describe("Deposit & Withdraw ETH", function() {
98
let signers;
@@ -31,34 +30,6 @@ describe("Deposit & Withdraw ETH", function() {
3130
await expect(bridge.depositETH(1, {value: 0})).to.be.revertedWith("deposit amount is zero");
3231
});
3332

34-
it("block deposits of ETH", async function() {
35-
const ERC20 = await ethers.getContractFactory("StellarAsset");
36-
const token = await ERC20.deploy("Blocked Test Token", "BLOCKED", 18);
37-
await token.mint(sender.address, ethers.utils.parseEther("100.0"));
38-
await token.approve(bridge.address, ethers.utils.parseEther("300.0"));
39-
40-
await setDepositAllowed(bridge, signers, domainSeparator, token.address, true, 0, validTimestamp());
41-
expect(await bridge.depositAllowed(token.address)).to.be.true;
42-
43-
const ethAddress = "0x0000000000000000000000000000000000000000";
44-
await setDepositAllowed(bridge, signers, domainSeparator, ethAddress, false, 1, validTimestamp());
45-
expect(await bridge.depositAllowed(ethAddress)).to.be.false;
46-
47-
const before = await token.balanceOf(bridge.address);
48-
49-
await bridge.depositERC20(
50-
token.address, 1, ethers.utils.parseEther("1.0")
51-
);
52-
53-
const after = await token.balanceOf(bridge.address);
54-
expect(after.sub(before)).to.equal(ethers.utils.parseEther("1.0"));
55-
56-
await expect(bridge.depositETH(1, {value: ethers.utils.parseEther("1.0")})).to.be.revertedWith("eth deposits are not allowed");
57-
58-
await setDepositAllowed(bridge, signers, domainSeparator, ethAddress, true, 2, validTimestamp());
59-
expect(await bridge.depositAllowed(ethAddress)).to.be.true;
60-
});
61-
6233
it("deposits are rejected when bridge is paused", async function() {
6334
await setPaused(bridge, signers, domainSeparator, PAUSE_DEPOSITS, nextPauseNonce(), validTimestamp());
6435
await expect(bridge.depositETH(1, {value: ethers.utils.parseEther("1.0")})).to.be.revertedWith("deposits are paused");

solidity/test/registerStellarAsset.js

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ describe("registerStellarAsset", function() {
4949
expect(await wrappedXLM.name()).to.be.eql("Stellar Lumens");
5050
expect(await wrappedXLM.symbol()).to.be.eql("XLM");
5151
expect(await bridge.isStellarAsset(wrappedXLM.address)).to.be.true;
52-
expect(await bridge.depositAllowed(wrappedXLM.address)).to.be.true;
5352
});
5453

5554
it("rejects duplicate transactions", async function() {

solidity/test/setDepositAllowed.js

-153
This file was deleted.

0 commit comments

Comments
 (0)