wearekickback / contracts Goto Github PK
View Code? Open in Web Editor NEWKickback contracts
License: MIT License
Kickback contracts
License: MIT License
GIVEN a user has 10DAI on their wallet
AND the user has 10ETH on their wallet
AND the user manually do `token.apprve(10DAI)`
WHEN kickback frontend sends 10ETH when RSVPing (due to a bug/caching)
THEN ETH sent on the smartcontract gets stack forever and no way to recover.
https://kickback.events/event/0x600ef4d29c8b18e320ef17b4ca31323a5af6b87f
https://etherscan.io/address/0x600ef4d29c8b18e320ef17b4ca31323a5af6b87f
When a user reported that it sees "RSVP - 10 ETH" instead of "RSVP 10 DAI" on the DAI based event. We still don't know why the frontend was showing the message but when I just checked the smartcode for the possible impact, I discovered the vulnerability,.
None.
All the user who have RSVPed did RSVP properly so no ETH in the contract at this moment.
We stopped RSVP by lowering the cap so no new RSVP will be allowed unless we change the cap.
Minor inconvenience to the user as we have to cancel the event and the user has to re-register in the newly deployed contract.
In addition to simply upgrading, these also need to be done.
_beforeTokenTransfer
instead of overriding transferFrom
Conference
) has its own NFT contractConference
constructorDeployer
and can be changed by groupAdmin
. (Refer to changeClearFee for the similar implementation).Please make sure to write tests to cover at least these scenarios.
ownerOf(tokenId)
returns the registrant address.isRegistered/isAttended/isPaid
returns the info about the recipient (if this ended up causing too much attack vector, we may make the token not transferrable ).withdraw
and clearAndSend
to receive the payoutJust downloaded and followed the steps.
What could cause test to fail?
From ganache-cli
Transaction: 0x1f625d8fd078caac43c816ba1cc635c1bcc3a0c747b7ca7a7e5c9dd608e85018
Contract created: 0x201e119207151e6d15fd89e9a77f472526e4b819
Gas usage: 6721975
Block Number: 4
Block Time: Wed Dec 04 2019 11:26:29 GMT+0100 (West Africa Standard Time)
Runtime Error: invalid opcode
Contract: ETH Conference
on registration
1) tokenAddress is empty
> No events were emitted
on changeName
2) "before each" hook for "owner can rename the event"
on changeDeposit
3) "before each" hook for "owner can change the deposit"
on setLimitOfParticipants
4) "before each" hook for "does not allow to register more than the limit"
on creation
✓ name cannot be empty
✓ deposit cannot be empty
✓ limitOfParticipants cannot be empty
✓ coolingPeriod cannot be empty
✓ ownerAddress cannot be empty
✓ cannot set empty address as an owner (6721975 gas)
5) can set config values
> No events were emitted
on registration
6) "before each" hook for "increments registered"
on failed registration
7) "before each" hook for "cannot be registered if wrong amount of deposit is sent"
finalize using attendee bitmap
8) "before each" hook for "can be called by owner"
empty events
9) "before each" hook for "nothing to withdraw if no one registered"
on cancel
10) "before each" hook for "cannot cancel if non owner calls"
on withdraw
11) "before each" hook for "cannot withdraw twice"
on clear
12) "before each" hook for "cooling period can be set"
Contract: Deployer
13) "before each" hook for "does not accept ETH"
Contract: ERC20 Conference
on changeName
14) "before each" hook for "owner can rename the event"
Contract: NPM exports
✓ exports contracts
✓ exports valid events
Contract: GroupAdmin
on new
15) "before each" hook for "owner is admin"
Contract: ETH Conference - stress tests
on big party
finalize large party using attendee bitmaps
16) requires valid input to succeed
> No events were emitted
success modes
17) "before each" hook for "correctly updates attendee records - p1, p2, p256, p257, p298, p299"
·-----------------------------------------------|----------------------------·
| Gas · Block limit: 6721975 gas │
························|·······················|·····························
| Methods · 1 gwei/gas · 146.47 usd/eth │
·············|··········|·······|·······|·······|·············|···············
| Contract · Method · Min · Max · Avg · # calls · usd (avg) │
·------------|----------|-------|-------|-------|-------------|--------------·
8 passing (30s)
17 failing
Contract: ETH Conference
on registration
tokenAddress is empty:
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at Context.createConference (test/conference.js:43:36)
at Context._callee4$ (test/conference.js:120:27)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/conference.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/conference.js:3:437
at new Promise ()
at Context. (test/conference.js:3:99)
Contract: ETH Conference
on registration
on changeName
"before each" hook for "owner can rename the event":
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at createConference (test/conference.js:43:36)
at Context._callee2$ (test/behaviors/conference.behavior.js:74:22)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/behaviors/conference.behavior.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conference.behavior.js:3:437
at new Promise ()
at Context. (test/behaviors/conference.behavior.js:3:99)
at processImmediate (internal/timers.js:443:21)
at process.topLevelDomainCallback (domain.js:136:23)
Contract: ETH Conference
on registration
on changeDeposit
"before each" hook for "owner can change the deposit":
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at createConference (test/conference.js:43:36)
at Context._callee6$ (test/behaviors/conference.behavior.js:168:22)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/behaviors/conference.behavior.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conference.behavior.js:3:437
at new Promise ()
at Context. (test/behaviors/conference.behavior.js:3:99)
at processImmediate (internal/timers.js:443:21)
at process.topLevelDomainCallback (domain.js:136:23)
Contract: ETH Conference
on registration
on setLimitOfParticipants
"before each" hook for "does not allow to register more than the limit":
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at createConference (test/conference.js:43:36)
at Context._callee10$ (test/behaviors/conference.behavior.js:263:22)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/behaviors/conference.behavior.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conference.behavior.js:3:437
at new Promise ()
at Context. (test/behaviors/conference.behavior.js:3:99)
at processImmediate (internal/timers.js:443:21)
at process.topLevelDomainCallback (domain.js:136:23)
Contract: ETH Conference
on registration
on creation
can set config values:
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at createConference (test/conference.js:43:36)
at Context._callee15$ (test/behaviors/conference.behavior.js:403:22)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/behaviors/conference.behavior.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conference.behavior.js:3:437
at new Promise ()
at Context. (test/behaviors/conference.behavior.js:3:99)
at processImmediate (internal/timers.js:443:21)
at process.topLevelDomainCallback (domain.js:136:23)
Contract: ETH Conference
on registration
on registration
"before each" hook for "increments registered":
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at createConference (test/conference.js:43:36)
at Context._callee16$ (test/behaviors/conference.behavior.js:453:22)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/behaviors/conference.behavior.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conference.behavior.js:3:437
at new Promise ()
at Context. (test/behaviors/conference.behavior.js:3:99)
at processImmediate (internal/timers.js:443:21)
at process.topLevelDomainCallback (domain.js:136:23)
Contract: ETH Conference
on registration
on failed registration
"before each" hook for "cannot be registered if wrong amount of deposit is sent":
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at createConference (test/conference.js:43:36)
at Context._callee21$ (test/behaviors/conference.behavior.js:577:22)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/behaviors/conference.behavior.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conference.behavior.js:3:437
at new Promise ()
at Context. (test/behaviors/conference.behavior.js:3:99)
at processImmediate (internal/timers.js:443:21)
at process.topLevelDomainCallback (domain.js:136:23)
Contract: ETH Conference
on registration
finalize using attendee bitmap
"before each" hook for "can be called by owner":
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at createConference (test/conference.js:43:36)
at Context._callee24$ (test/behaviors/conference.behavior.js:679:22)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/behaviors/conference.behavior.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conference.behavior.js:3:437
at new Promise ()
at Context. (test/behaviors/conference.behavior.js:3:99)
at processImmediate (internal/timers.js:443:21)
at process.topLevelDomainCallback (domain.js:136:23)
Contract: ETH Conference
on registration
empty events
"before each" hook for "nothing to withdraw if no one registered":
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at createConference (test/conference.js:43:36)
at Context._callee36$ (test/behaviors/conference.behavior.js:1047:22)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/behaviors/conference.behavior.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conference.behavior.js:3:437
at new Promise ()
at Context. (test/behaviors/conference.behavior.js:3:99)
at processImmediate (internal/timers.js:443:21)
at process.topLevelDomainCallback (domain.js:136:23)
Contract: ETH Conference
on registration
on cancel
"before each" hook for "cannot cancel if non owner calls":
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at createConference (test/conference.js:43:36)
at Context._callee39$ (test/behaviors/conference.behavior.js:1146:22)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/behaviors/conference.behavior.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conference.behavior.js:3:437
at new Promise ()
at Context. (test/behaviors/conference.behavior.js:3:99)
at processImmediate (internal/timers.js:443:21)
at process.topLevelDomainCallback (domain.js:136:23)
Contract: ETH Conference
on registration
on withdraw
"before each" hook for "cannot withdraw twice":
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at createConference (test/conference.js:43:36)
at Context._callee44$ (test/behaviors/conference.behavior.js:1393:22)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/behaviors/conference.behavior.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conference.behavior.js:3:437
at new Promise ()
at Context. (test/behaviors/conference.behavior.js:3:99)
at processImmediate (internal/timers.js:443:21)
at process.topLevelDomainCallback (domain.js:136:23)
Contract: ETH Conference
on registration
on clear
"before each" hook for "cooling period can be set":
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at createConference (test/conference.js:43:36)
at Context._callee48$ (test/behaviors/conference.behavior.js:1531:22)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/behaviors/conference.behavior.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conference.behavior.js:3:437
at new Promise ()
at Context. (test/behaviors/conference.behavior.js:3:99)
at processImmediate (internal/timers.js:443:21)
at process.topLevelDomainCallback (domain.js:136:23)
Contract: Deployer
"before each" hook for "does not accept ETH":
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at _callee$ (test/deployer.js:38:32)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/deployer.js:9:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/deployer.js:9:361
at processTicksAndRejections (internal/process/task_queues.js:86:5)
Contract: ERC20 Conference
"before each" hook for "owner can rename the event":
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at Context._callee3$ (test/erc20_conference.js:28:29)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/erc20_conference.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/erc20_conference.js:3:437
at new Promise ()
at Context. (test/erc20_conference.js:3:99)
at web3.eth.getBlockNumber.then.result (node_modules/truffle/build/webpack:/packages/core/lib/testing/testrunner.js:161:1)
at processTicksAndRejections (internal/process/task_queues.js:86:5)
Contract: GroupAdmin
"before each" hook for "owner is admin":
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at Context._callee$ (test/group_admin.js:25:46)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/group_admin.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/group_admin.js:3:437
at new Promise ()
at Context. (test/group_admin.js:3:99)
at web3.eth.getBlockNumber.then.result (node_modules/truffle/build/webpack:/packages/core/lib/testing/testrunner.js:161:1)
at processTicksAndRejections (internal/process/task_queues.js:86:5)
Contract: ETH Conference - stress tests
on big party
finalize large party using attendee bitmaps
requires valid input to succeed:
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at createConference (test/stress.js:42:36)
at Context._callee2$ (test/behaviors/conferenceFinalize.behavior.js:65:34)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/behaviors/conferenceFinalize.behavior.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conferenceFinalize.behavior.js:3:437
at new Promise ()
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conferenceFinalize.behavior.js:3:99
at createConferenceAndRegisterParticipants (test/behaviors/conferenceFinalize.behavior.js:102:32)
at Suite._callee4$ (test/behaviors/conferenceFinalize.behavior.js:120:22)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/behaviors/conferenceFinalize.behavior.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conferenceFinalize.behavior.js:3:437
at new Promise ()
at Context. (test/behaviors/conferenceFinalize.behavior.js:3:99)
Contract: ETH Conference - stress tests
on big party
finalize large party using attendee bitmaps
success modes
"before each" hook for "correctly updates attendee records - p1, p2, p256, p257, p298, p299":
Error: Returned error: VM Exception while processing transaction: invalid opcode
at PromiEvent (node_modules/truffle/build/webpack:/packages/contract/lib/promievent.js:9:1)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:224:1
at Function.new (node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:34:1)
at createConference (test/stress.js:42:36)
at Context._callee2$ (test/behaviors/conferenceFinalize.behavior.js:65:34)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/behaviors/conferenceFinalize.behavior.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conferenceFinalize.behavior.js:3:437
at new Promise ()
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conferenceFinalize.behavior.js:3:99
at createConferenceAndRegisterParticipants (test/behaviors/conferenceFinalize.behavior.js:102:32)
at Suite._callee5$ (test/behaviors/conferenceFinalize.behavior.js:149:24)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (test/behaviors/conferenceFinalize.behavior.js:3:191)
at /home/eka/buildtool/job/amhello/gitcoin/contracts/test/behaviors/conferenceFinalize.behavior.js:3:437
at new Promise ()
at Context. (test/behaviors/conferenceFinalize.behavior.js:3:99)
at processImmediate (internal/timers.js:443:21)
at process.topLevelDomainCallback (domain.js:136:23)
error Command failed with exit code 17.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 17.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Currently organiser can only make binary decision about participant and everybody either receives the same payout or 0.
This is achieved by passing bitmap of attendance information at finalise
as follows.
function finalize(uint256[] calldata _maps)
By packing all attendance information as a bitmap of uint256, it can handle up to 256 people's attendance information into 1 uint256 slot.
This makes sense in binary result such as meetups, but less flexible for long running challenges.
In addition to pass bitmap where 1 bit represents 1/0 for a participant, allow it to pass bitmap where 8 bit represents 0-255 or 4 bit represents 0-15. By doing so, 8 bit can store up to 32 participant and 4 bit can handle up to 64 participants.
function finalize(uint256[] calldata _maps, uint _type)
_type
is unum of 1/4/8payoutAmount(address)
address
so that it returns unique payout amount per each participant.300 DAI
Currently all participants have to withdraw the commitment they staked manually and this is one of the biggest flows in our overall user experience therefore we now send back to users manually which is quite painful.
The challenge is to add the following function into our smart contract to automate the process.
clearAndSend(num) afterCoolingPeriod
which allows anyone to batch send the remaining taking some fees (eg: x % of deposit ).
Example
Given user 0x001 .. 0x100 has not withdrawn after cooling period
And payout is 10 DAI and fee is 1 DAI per attendee . (10%)
When user 0x200 calls clearAndSend(10)
Then user 0x001 .. 0x010 receives 9 DAI each and 0x200 receives 10 DAI
When user 0x200 calls clearAndSend(20)
Then user 0x011 .. 0x030 receives 9 DAI each and 0x200 receives 20 DAI
When user 0x200 calls clearAndSend()
Then user 0x031 .. 0x100 receives 9 DAI each and 0x200 receives 70 DAI
The first high quality code with good test coverage submission wins
TBD
200 DAI
We are considering to add donation feature. .
To support it, add "sendAndWithdraw(addresses[], values[])" which works like withdraw
but it also allows to send to external addresses.
TBD
TBD
At Kickback, we send a list of participants who were checked in as a bitmap to save gas cost.
eg: when 300 people RSVPed and i1, i2, i256, i257, i298, i299 attended, we send bitmap of 2 bytes containing the following.
finalise([110, 11000000000000000000000000000000000000000011])
NOTE: Bitmap starts from right to left so 110 is 0, 1, 1
For more info, please refer to our test.
At the last EthLondon hackathon, we had a dozen of reports from participants who could not withdraw despite marked as "checked in" because their transactions got reverted with message 'Fail with error 'event still active or you did not attend''
After our analysis, it turned out isAttended(address)
that the logic to return whether the user has attended or not does not match by one row after 123rd participant.
The column C(bitmap) is derived from the bitmap info sent at finalisation at etherscan
Input data
0xe17e082b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000f7fdffffdadbfaffefffb57ff87dbddd2f797ef7dfbfcfceff4df
Hex f7fdffffdadbfaffefffb57ff87dbddd2f797ef7dfbfcfceff4df
=> Bin 11110111111111011111111111111111110110101101101111111010111111111110111111111111101101010111111111111000011111011011110111011101001011110111100101111110111101111101111110111111110011111100111011111111010011011111
then you reverse the order.
The column D(isAttended
) is derived by calling the function for each address
function isAttended(address _addr) public view returns (bool){
if (!isRegistered(_addr) || !ended) {
return false;
}
// check the attendance maps
else {
Participant storage p = participants[_addr];
uint256 pIndex = p.index - 1;
uint256 map = attendanceMaps[uint256(pIndex / 256)];
return (0 < (map & (2 ** (pIndex % 256))));
}
}
We suspect that the bug is either in our smart contract or js library to encode/decode the bitmap.
Now that Kickback is on Polygon, we can make use of their rich ecosystem by integrating with lending platforms such as Aave.
I have done something similar for Chai (tokenisation of DAI DSR)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.