Skip to content
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

Effect Network contracts V2 #117

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7c9d7ec
eos: Update to antelope CDT 3.1.0
jeisses Jul 29, 2023
14922d3
force: Remove batch qualifications and merkle proofs
jeisses Jul 29, 2023
6022fc7
force: Implement new reservation system (wip)
jeisses Jul 29, 2023
7affb0e
force: Move task expiration time to campaign level
jeisses Jul 30, 2023
a6bb02a
force: Implement new task submission system
jeisses Jul 30, 2023
759184a
force: Remove `last_task_done` argument form `reservetask`
jeisses Jul 30, 2023
fe00152
force: Add campaign data structures for nft qualifications
jeisses Aug 3, 2023
83bd525
force: Add AtomicAsset qualifications
jeisses Aug 9, 2023
7697adb
force: Add e2e tests for AtomicAsset NFTs
jeisses Aug 9, 2023
2c2ca64
force: Remove old qualification system
jeisses Aug 9, 2023
ad2933d
force: Remove old config table and its migration
jeisses Aug 9, 2023
11374d2
force: Remove task merkle root for batches
jeisses Aug 10, 2023
5136802
force: Fix broken e2e test
jeisses Aug 11, 2023
8de4070
force: Allow updating of the settings table
jeisses Aug 11, 2023
951bb7e
force: Allow deleting batches and remove old task reclaiming methods
jeisses Aug 11, 2023
8b5cf4a
force: Implement pausing of campaigns
jeisses Aug 11, 2023
3729a35
ci: Update guix manifest to support docker builds
jeisses Oct 11, 2023
8f80ce3
ci: Update tasks deployment script to V2
jeisses Oct 11, 2023
ffe9b44
force: Add helper action to clear all data on testnet
jeisses Oct 11, 2023
eebf7ad
force: Fix alignment of reservation and submission IDs
jeisses Oct 11, 2023
f7c28c7
force: Fix issue where user reserves more tasks than cmpaign size
jeisses Oct 11, 2023
83e54a0
force: Fix bug in task reservation indexing using acctaskidx
jeisses Nov 8, 2023
caef169
task: Add script that adds n consecutive DAO cycles to the table
jeisses Nov 20, 2023
2de763f
task: Adjust default automatic power up quantity
jeisses Nov 20, 2023
6a291b8
force: Move from vtransfer to transfer in publishbatch
jeisses Jan 27, 2024
caab823
force: Fix transfering of the network fee in publishbatch
jeisses Jan 28, 2024
f39eccb
task: Add helper task to fix a misconfigured feepool cycle
jeisses Feb 29, 2024
6a81e7e
force: Remove support for pub key vaccounts
jeisses Apr 5, 2024
bdabbf4
force: Fix tests by removing pub key vaccount scenarios
jeisses Apr 6, 2024
d8ec9bb
dao: Fix tests to match latest nodeos version
jeisses Apr 6, 2024
cc99c77
force: Remove deprecated method serialization structs
jeisses Apr 11, 2024
eb7e016
force: Remove `tasks_done` field from `batch` table
jeisses Apr 11, 2024
48ccceb
force: Add `total_submissions` field to `campaign` table
jeisses Apr 11, 2024
6811f75
task: Add Make targets for running tests and deploying to testnet
jeisses Apr 11, 2024
f029a15
force: Add a type indicator to the submission's `data` field
jeisses Apr 20, 2024
90796d8
force: Remove unused payer from submittask
jeisses May 4, 2024
e884792
force: Allow users to work ahead of the campaigns active batch
jeisses May 14, 2024
a3fbb80
force: Remove unused `content` field from `submission` table
jeisses May 17, 2024
79361a4
force: Store `batch_id` as `uint32` in submission and reservation
jeisses May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
build
*.abi
*.wasm
!tests/*.wasm
!tests/*.abi
node_modules
.idea/
.vscode/
Expand Down
19 changes: 11 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
EOS_CC ?= eosio-cpp
ABI_CC ?= eosio-abigen
EOS_CC ?= cdt-cpp

SKIP_CONTRACTS := $(wildcard contracts/swap/*.cpp contracts/taskproxy/*.cpp)

SRC = $(filter-out $(SKIP_CONTRACTS), $(wildcard contracts/*/*.cpp))
WASM = $(SRC:.cpp=.wasm)
ABI = $(WASM:.wasm=.abi)

all: $(WASM) $(ABI)
all: $(WASM)

%.wasm: %.cpp %.hpp $(%-shared.hpp)
%.abi %.wasm: %.cpp %.hpp $(%-shared.hpp)
$(EOS_CC) -o $@ $<

%.abi: %.cpp
$(ABI_CC) -contract=$(basename $(^F)) -output $@ $^

.PHONY: serve-docs clean

clean:
rm -f $(WASM) $(ABI)
Expand All @@ -25,3 +20,11 @@ serve-docs:

build-docs:
jekyll b -s docs

test-contracts:
npm run lumo e2e.force

deploy-testnet:
bb deploy jungle4

.PHONY: serve-docs clean test-contracts deploy-testnet
3 changes: 2 additions & 1 deletion bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
init effect/init
process-cycle effect/process-cycle
deploy-mainnet effect/msig-deploy
atp effect/make-atp}}
atp effect/make-atp
create-n-cycles effect/create-n-cycles}}
519 changes: 519 additions & 0 deletions contracts/force/atomicdata.hpp

Large diffs are not rendered by default.

129 changes: 129 additions & 0 deletions contracts/force/base58.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Copyright (c) 2014-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

//(Slightly modified for the needs of our eosio contract)

#include <string>
#include <vector>

/** All alphanumeric characters except for "0", "I", "O", and "l" */
static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
static const int8_t mapBase58[256] = {
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8,-1,-1,-1,-1,-1,-1,
-1, 9,10,11,12,13,14,15, 16,-1,17,18,19,20,21,-1,
22,23,24,25,26,27,28,29, 30,31,32,-1,-1,-1,-1,-1,
-1,33,34,35,36,37,38,39, 40,41,42,43,-1,44,45,46,
47,48,49,50,51,52,53,54, 55,56,57,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
};


std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend)
{
// Skip & count leading zeroes.
int zeroes = 0;
int length = 0;
while (pbegin != pend && *pbegin == 0) {
pbegin++;
zeroes++;
}
// Allocate enough space in big-endian base58 representation.
int size = (pend - pbegin) * 138 / 100 + 1; // log(256) / log(58), rounded up.
std::vector<unsigned char> b58(size);
// Process the bytes.
while (pbegin != pend) {
int carry = *pbegin;
int i = 0;
// Apply "b58 = b58 * 256 + ch".
for (std::vector<unsigned char>::reverse_iterator it = b58.rbegin(); (carry != 0 || i < length) && (it != b58.rend()); it++, i++) {
carry += 256 * (*it);
*it = carry % 58;
carry /= 58;
}

assert(carry == 0);
length = i;
pbegin++;
}
// Skip leading zeroes in base58 result.
std::vector<unsigned char>::iterator it = b58.begin() + (size - length);
while (it != b58.end() && *it == 0)
it++;
// Translate the result into a string.
std::string str;
str.reserve(zeroes + (b58.end() - it));
str.assign(zeroes, '1');
while (it != b58.end())
str += pszBase58[*(it++)];
return str;
}

std::string EncodeBase58(const std::vector<unsigned char>& vch)
{
return EncodeBase58(vch.data(), vch.data() + vch.size());
}


//Removed the max return length.
bool DecodeBase58(const char* psz, std::vector<unsigned char>& vch)
{
// Skip leading spaces.
while (*psz && isspace(*psz))
psz++;
// Skip and count leading '1's.
int zeroes = 0;
int length = 0;
while (*psz == '1') {
zeroes++;
psz++;
}
// Allocate enough space in big-endian base256 representation.
int size = strlen(psz) * 733 /1000 + 1; // log(58) / log(256), rounded up.
std::vector<unsigned char> b256(size);
// Process the characters.
static_assert(sizeof(mapBase58)/sizeof(mapBase58[0]) == 256, "mapBase58.size() should be 256"); // guarantee not out of range
while (*psz && !isspace(*psz)) {
// Decode base58 character
int carry = mapBase58[(uint8_t)*psz];
if (carry == -1) // Invalid b58 character
return false;
int i = 0;
for (std::vector<unsigned char>::reverse_iterator it = b256.rbegin(); (carry != 0 || i < length) && (it != b256.rend()); ++it, ++i) {
carry += 58 * (*it);
*it = carry % 256;
carry /= 256;
}
assert(carry == 0);
length = i;
psz++;
}
// Skip trailing spaces.
while (isspace(*psz))
psz++;
if (*psz != 0)
return false;
// Skip leading zeroes in b256.
std::vector<unsigned char>::iterator it = b256.begin() + (size - length);
// Copy result into output vector.
vch.reserve(zeroes + (b256.end() - it));
vch.assign(zeroes, 0x00);
while (it != b256.end())
vch.push_back(*(it++));
return true;
}

bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet)
{
return DecodeBase58(str.c_str(), vchRet);
}