sepolia deploy
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 36s Details

This commit is contained in:
Ladd Hoffman 2024-04-16 16:50:09 -05:00
parent 1989b20ed5
commit 4e0f00ff2a
15 changed files with 274 additions and 155 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -6,9 +6,9 @@
"Proposals": "0x050C420Cc4995B41217Eba1B54B82Fd5687e9139"
},
"sepolia": {
"DAO": "0x58c41E768aCA55B39b5dC0618c0D0bE3f5519943",
"Work1": "0x6cEca2BB849c2a00786A05ed4fC64D08905724Cc",
"Onboarding": "0x4b3906a6356F387bF5dd26FD34B072d20Cd40a7b",
"Proposals": "0x3E1A6EE8D24Ba7D1392104B8652Bb0D2BDF127EE"
"DAO": "0x4079D97F7dfd15AB758F0dedEdB15c86Ea3AD8eB",
"Work1": "0x027B534DE68704754886951a1C5f0F6640aA38B0",
"Onboarding": "0x0CB593989FDdC0439840CCe484eD550f333e963a",
"Proposals": "0xA31C8ef8506Edc02772522671562F1520FD963B5"
}
}

View File

@ -1,6 +1,7 @@
API_URL="https://demo.dgov.io/api"
CA_PATH=
SEPOLIA_PRIVATE_KEY=
MAINNET_PRIVATE_KEY=
ETHERSCAN_API_KEY=
WORK1_PRICE="0.001"
ONBOARDING_PRICE="0.001"

View File

@ -6,9 +6,9 @@
"Proposals": "0x050C420Cc4995B41217Eba1B54B82Fd5687e9139"
},
"sepolia": {
"DAO": "0x58c41E768aCA55B39b5dC0618c0D0bE3f5519943",
"Work1": "0x6cEca2BB849c2a00786A05ed4fC64D08905724Cc",
"Onboarding": "0x4b3906a6356F387bF5dd26FD34B072d20Cd40a7b",
"Proposals": "0x3E1A6EE8D24Ba7D1392104B8652Bb0D2BDF127EE"
"DAO": "0x4079D97F7dfd15AB758F0dedEdB15c86Ea3AD8eB",
"Work1": "0x027B534DE68704754886951a1C5f0F6640aA38B0",
"Onboarding": "0x0CB593989FDdC0439840CCe484eD550f333e963a",
"Proposals": "0xA31C8ef8506Edc02772522671562F1520FD963B5"
}
}

View File

@ -148,11 +148,21 @@ contract Forum is Reputation {
} else {
// Prevent reputation from being reduced below zero
if (int(post.reputation) + amount >= 0) {
_update(post.author, address(this), uint(-amount));
if (balanceOf(post.author) >= uint(-amount)) {
_update(post.author, address(this), uint(-amount));
} else {
// Author has already lost some REP gained from this post.
// That means other DAO members have earned it for policing.
// We need to refund the difference here to ensure accurate bookkeeping
refundToInbound = amount + int(balanceOf(post.author));
_update(post.author, address(this), balanceOf(post.author));
}
post.reputation -= uint(-amount);
} else {
refundToInbound = int(post.reputation) + amount;
if (balanceOf(post.author) < post.reputation) {
if (balanceOf(post.author) >= post.reputation) {
_update(post.author, address(this), post.reputation);
} else {
// If author has already lost reputation that was gained from this post,
// that means other DAO members gained it through policing.
// We have to increase the magnitude of the amount we're "refunding", which is expressed as a negative number.
@ -163,8 +173,6 @@ contract Forum is Reputation {
post.reputation - balanceOf(post.author)
);
_update(post.author, address(this), balanceOf(post.author));
} else {
_update(post.author, address(this), post.reputation);
}
post.reputation = 0;
}

View File

@ -227,36 +227,44 @@ contract ValidationPools is Reputation, Forum {
// Here we assume a stakeForAuthor ratio of 0.5
// TODO: Make stakeForAuthor an adjustable parameter
totalRewards += pool.minted / 2;
uint reward = ((((totalRewards * pool.minted) / 2) /
amountFromWinners) * pool.params.bindingPercent) / 100;
totalAllocated += reward;
// Include the losign portion of the VP initial stake
// Issue rewards to the winners
for (uint i = 0; i < pool.stakeCount; i++) {
s = pool.stakes[i];
if (
pool.params.redistributeLosingStakes &&
votePasses == s.inFavor
) {
// Winning stake
uint reward = (((totalRewards * s.amount) /
amountFromWinners) * pool.params.bindingPercent) / 100;
totalAllocated += reward;
_update(address(this), s.sender, reward);
}
}
// Due to rounding, there may be some excess REP. Award it to the author.
uint remainder = totalRewards - totalAllocated;
// Transfer REP to the forum instead of to the author directly
_onValidatePost(pool.postIndex, pool.minted / 2 + reward);
_onValidatePost(pool.postIndex, pool.minted / 2 + remainder);
} else {
// If vote does not pass, divide the losing stake among the winners
totalRewards += pool.minted;
}
// Include the losign portion of the VP initial stake
// Issue rewards to the winners
for (uint i = 0; i < pool.stakeCount; i++) {
s = pool.stakes[i];
if (
pool.params.redistributeLosingStakes && votePasses == s.inFavor
) {
// Winning stake
uint reward = (((totalRewards * s.amount) / amountFromWinners) *
pool.params.bindingPercent) / 100;
totalAllocated += reward;
_update(address(this), s.sender, reward);
for (uint i = 0; i < pool.stakeCount; i++) {
s = pool.stakes[i];
if (
pool.params.redistributeLosingStakes &&
votePasses == s.inFavor
) {
// Winning stake
uint reward = (((totalRewards * s.amount) /
(amountFromWinners - pool.minted / 2)) *
pool.params.bindingPercent) / 100;
totalAllocated += reward;
_update(address(this), s.sender, reward);
}
}
}
// Due to rounding, some reward may be left over. Let's give it to the author.
uint remainder = totalRewards - totalAllocated;
if (remainder > 0) {
_update(address(this), post.author, remainder);
}
// Distribute fee proportionately among all reputation holders
for (uint i = 0; i < memberCount; i++) {
address member = members[i];

View File

@ -16,6 +16,10 @@ module.exports = {
url: `https://sepolia.infura.io/v3/${process.env.INFURA_API_KEY}`,
accounts: [process.env.SEPOLIA_PRIVATE_KEY],
},
mainnet: {
url: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
accounts: [process.env.MAINNET_PRIVATE_KEY],
},
},
etherscan: {
apiKey: {

View File

@ -9,6 +9,7 @@
"automatic-staking-sepolia": "API_URL='https://demo.dgov.io/api' CA_PATH='' hardhat run --network sepolia scripts/automatic-staking.js",
"deploy-local": "hardhat run --network localhost scripts/deploy.js",
"deploy-sepolia": "hardhat run --network sepolia scripts/deploy.js",
"deploy-dao-mainnet": "hardhat run --network mainnet scripts/deploy-dao.js",
"deploy-work-contracts-local": "hardhat run --network localhost scripts/deploy-work-contracts.js",
"deploy-work-contracts-sepolia": "hardhat run --network sepolia scripts/deploy-work-contracts.js",
"verify-sepolia": "hardhat run --network sepolia scripts/verify.js"

View File

@ -0,0 +1,10 @@
const deployContract = require('./util/deploy-contract');
async function main() {
await deployContract('DAO', [], true);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});

View File

@ -3,7 +3,7 @@ const deployContract = require('./util/deploy-contract');
const deployDAOContract = require('./util/deploy-dao-contract');
async function main() {
await deployContract('DAO');
await deployContract('DAO', [], true);
await deployDAOContract('Proposals');
await deployWorkContract('Work1');
await deployWorkContract('Onboarding');

View File

@ -8,13 +8,13 @@ require('dotenv').config();
const network = process.env.HARDHAT_NETWORK;
const deployContract = async (name, args = []) => {
const deployContract = async (name, args = [], isCore = false) => {
const contract = await ethers.deployContract(name, args);
await contract.waitForDeployment();
console.log(`${name} deployed to ${contract.target}`);
contractAddresses[network][name] = contract.target;
const from = `./artifacts/contracts/${name}.sol/${name}.json`;
const from = `./artifacts/contracts/${isCore ? 'core/' : ''}${name}.sol/${name}.json`;
const to = `../client/src/assets/${name}.json`;
fs.copyFileSync(from, to);
console.log(`Copied ${fs.realpathSync(from)} to ${fs.realpathSync(to)}`);

View File

@ -156,8 +156,8 @@ describe('Forum', () => {
await time.increase(POOL_DURATION + 1);
await dao.evaluateOutcome(2);
expect(await dao.balanceOf(account1)).to.equal(133);
expect(await dao.balanceOf(account2)).to.equal(34);
expect(await dao.balanceOf(account3)).to.equal(133);
expect(await dao.balanceOf(account2)).to.equal(33);
expect(await dao.balanceOf(account3)).to.equal(134);
});
it('should limit effects of negative references on prior positive references', async () => {
@ -234,48 +234,82 @@ describe('Forum', () => {
expect(await dao.totalSupply()).to.equal(50);
});
it('handles the case where an author has already lost reputation gained from a later-downvoted post', async () => {
await dao.addPost(account1, 'content-id', []);
await initiateValidationPool({ postIndex: 0 });
await dao.evaluateOutcome(0);
expect(await dao.balanceOf(account1)).to.equal(100);
expect(await dao.totalSupply()).to.equal(100);
expect((await dao.posts(0)).reputation).to.equal(100);
describe('negative citation of a post, the author having already staked and lost reputation', async () => {
beforeEach(async () => {
await dao.addPost(account1, 'content-id', []);
await initiateValidationPool({ postIndex: 0 });
await dao.evaluateOutcome(0);
expect(await dao.balanceOf(account1)).to.equal(100);
expect(await dao.totalSupply()).to.equal(100);
expect((await dao.posts(0)).reputation).to.equal(100);
await dao.addPost(account2, 'second-content-id', []);
await initiateValidationPool({ postIndex: 1 });
await time.increase(POOL_DURATION + 1);
await dao.evaluateOutcome(1);
expect(await dao.balanceOf(account1)).to.equal(100);
expect(await dao.balanceOf(account2)).to.equal(100);
expect(await dao.totalSupply()).to.equal(200);
expect((await dao.posts(0)).reputation).to.equal(100);
expect((await dao.posts(1)).reputation).to.equal(100);
await dao.addPost(account2, 'second-content-id', []);
await initiateValidationPool({ postIndex: 1 });
await time.increase(POOL_DURATION + 1);
await dao.evaluateOutcome(1);
expect(await dao.balanceOf(account1)).to.equal(100);
expect(await dao.balanceOf(account2)).to.equal(100);
expect(await dao.totalSupply()).to.equal(200);
expect((await dao.posts(0)).reputation).to.equal(100);
expect((await dao.posts(1)).reputation).to.equal(100);
// account1 stakes and loses
await initiateValidationPool({ postIndex: 1 });
await dao.stakeOnValidationPool(2, 50, true);
await dao.connect(account2).stakeOnValidationPool(2, 60, false);
await time.increase(POOL_DURATION + 1);
await dao.evaluateOutcome(2);
expect(await dao.balanceOf(account1)).to.equal(50);
expect(await dao.balanceOf(account2)).to.equal(250);
expect(await dao.totalSupply()).to.equal(300);
expect((await dao.posts(0)).reputation).to.equal(100);
expect((await dao.posts(1)).reputation).to.equal(100);
// account1 stakes and loses
await initiateValidationPool({ postIndex: 1 });
await dao.stakeOnValidationPool(2, 50, true);
await dao.connect(account2).stakeOnValidationPool(2, 60, false);
await time.increase(POOL_DURATION + 1);
await dao.evaluateOutcome(2);
expect(await dao.balanceOf(account1)).to.equal(50);
expect(await dao.balanceOf(account2)).to.equal(250);
expect(await dao.totalSupply()).to.equal(300);
expect((await dao.posts(0)).reputation).to.equal(100);
expect((await dao.posts(1)).reputation).to.equal(100);
});
// account1's post is later negatively referenced
await dao.addPost(account3, 'third-content-id', [{ weightPercent: -100, targetPostIndex: 0 }]);
await initiateValidationPool({ postIndex: 2, fee: 200 });
await time.increase(POOL_DURATION + 1);
await dao.evaluateOutcome(3);
expect(await dao.balanceOf(account1)).to.equal(0);
expect(await dao.balanceOf(account2)).to.equal(250);
expect(await dao.balanceOf(account3)).to.equal(250);
expect(await dao.totalSupply()).to.equal(500);
expect((await dao.posts(0)).reputation).to.equal(0);
expect((await dao.posts(1)).reputation).to.equal(100);
expect((await dao.posts(2)).reputation).to.equal(250);
it('author and post rep can be completely destroyed', async () => {
// account1's post is later strongly negatively referenced
await dao.addPost(account3, 'third-content-id', [{ weightPercent: -100, targetPostIndex: 0 }]);
await initiateValidationPool({ postIndex: 2, fee: 200 });
await time.increase(POOL_DURATION + 1);
await dao.evaluateOutcome(3);
expect(await dao.balanceOf(account1)).to.equal(0);
expect(await dao.balanceOf(account2)).to.equal(250);
expect(await dao.balanceOf(account3)).to.equal(250);
expect(await dao.totalSupply()).to.equal(500);
expect((await dao.posts(0)).reputation).to.equal(0);
expect((await dao.posts(1)).reputation).to.equal(100);
expect((await dao.posts(2)).reputation).to.equal(250);
});
it('author rep can be destroyed while some post rep remains', async () => {
// account1's post is later strongly negatively referenced
await dao.addPost(account3, 'third-content-id', [{ weightPercent: -100, targetPostIndex: 0 }]);
await initiateValidationPool({ postIndex: 2, fee: 70 });
await time.increase(POOL_DURATION + 1);
await dao.evaluateOutcome(3);
expect(await dao.totalSupply()).to.equal(370);
expect(await dao.balanceOf(account1)).to.equal(0);
expect(await dao.balanceOf(account2)).to.equal(250);
expect(await dao.balanceOf(account3)).to.equal(120);
expect((await dao.posts(0)).reputation).to.equal(30);
expect((await dao.posts(1)).reputation).to.equal(100);
expect((await dao.posts(2)).reputation).to.equal(120);
});
it('author rep can be destroyed while some post rep remains (odd amount)', async () => {
// account1's post is later strongly negatively referenced
await dao.addPost(account3, 'third-content-id', [{ weightPercent: -100, targetPostIndex: 0 }]);
await initiateValidationPool({ postIndex: 2, fee: 75 });
await time.increase(POOL_DURATION + 1);
await dao.evaluateOutcome(3);
expect(await dao.totalSupply()).to.equal(375);
expect(await dao.balanceOf(account1)).to.equal(0);
expect(await dao.balanceOf(account2)).to.equal(250);
expect(await dao.balanceOf(account3)).to.equal(124);
expect((await dao.posts(0)).reputation).to.equal(26);
expect((await dao.posts(1)).reputation).to.equal(100);
expect((await dao.posts(2)).reputation).to.equal(124);
});
});
});
});