Skip to content

Instantly share code, notes, and snippets.

@makoto
Created May 1, 2018 20:12
Show Gist options
  • Save makoto/74603ae7279729baa29370cb30a15217 to your computer and use it in GitHub Desktop.
Save makoto/74603ae7279729baa29370cb30a15217 to your computer and use it in GitHub Desktop.
[~/work/blockparty/contracts - (master)] $ myth -x Conference.sol
==== Dependence on predictable environment variable ====
Type: Warning
Contract: Ownable
Function name: clear()
PC address: 5567
In the function `clear()` the following predictable state variables are used to determine Ether recipient:
- block.timestamp
--------------------
In file: Conference.sol:161
owner.transfer(leftOver)
--------------------
==== Exception state ====
Type: Informational
Contract: Ownable
Function name: _function_0x05f203d9
PC address: 3130
A reachable exception (opcode 0xfe) has been detected. This can be caused by type errors, division by zero, out-of-bounds array access, or assert violations. This is acceptable in most situations. Note however that `assert()` should only be used to check invariants. Use `require()` for regular input checking.
--------------------
In file: GroupAdmin.sol:28
oldAdmins[i]
--------------------
==== Exception state ====
Type: Informational
Contract: Ownable
Function name: _function_0x14bfd6d0
PC address: 3995
A reachable exception (opcode 0xfe) has been detected. This can be caused by type errors, division by zero, out-of-bounds array access, or assert violations. This is acceptable in most situations. Note however that `assert()` should only be used to check invariants. Use `require()` for regular input checking.
--------------------
In file: GroupAdmin.sol:11
address[] public admins
--------------------
==== Integer Overflow ====
Type: Warning
Contract: Ownable
Function name: _function_0x05f203d9
PC address: 9032
A possible integer overflow exists in the function `_function_0x05f203d9`.
The addition or multiplication may result in a value higher than the maximum representable integer.
--------------------
In file: Conference.sol:6
contract Conference is Destructible, GroupAdmin {
string public name;
uint256 public deposit;
uint public limitOfParticipants;
uint public registered;
uint public attended;
bool public ended;
bool public cancelled;
uint public endedAt;
uint public coolingPeriod;
uint256 public payoutAmount;
string public encryption;
mapping (address => Participant) public participants;
mapping (uint => address) public participantsIndex;
bool paid;
struct Participant {
string participantName;
address addr;
bool attended;
bool paid;
}
event RegisterEvent(address addr, string participantName, string _encryption);
event AttendEvent(address addr);
event PaybackEvent(uint256 _payout);
event WithdrawEvent(address addr, uint256 _payout);
event CancelEvent();
event ClearEvent(address addr, uint256 leftOver);
/* Modifiers */
modifier onlyActive {
require(!ended);
_;
}
modifier onlyEnded {
require(ended);
_;
}
/* Public functions */
constructor (
string _name,
uint256 _deposit,
uint _limitOfParticipants,
uint _coolingPeriod,
string _encryption
) public {
if(bytes(_name).length != 0){
name = _name;
}else{
name = 'Test';
}
if(_deposit != 0){
deposit = _deposit;
}else{
deposit = 0.02 ether;
}
if(_limitOfParticipants !=0){
limitOfParticipants = _limitOfParticipants;
}else{
limitOfParticipants = 20;
}
if (_coolingPeriod != 0) {
coolingPeriod = _coolingPeriod;
} else {
coolingPeriod = 1 weeks;
}
if (bytes(_encryption).length != 0) {
encryption = _encryption;
}
}
function registerWithEncryption(string _participant, string _encrypted) external payable onlyActive{
registerInternal(_participant);
emit RegisterEvent(msg.sender, _participant, _encrypted);
}
function register(string _participant) external payable onlyActive{
registerInternal(_participant);
emit RegisterEvent(msg.sender, _participant, '');
}
function registerInternal(string _participant) internal {
require(msg.value == deposit);
require(registered < limitOfParticipants);
require(!isRegistered(msg.sender));
registered++;
participantsIndex[registered] = msg.sender;
participants[msg.sender] = Participant(_participant, msg.sender, false, false);
}
function withdraw() external onlyEnded{
require(payoutAmount > 0);
Participant participant = participants[msg.sender];
require(participant.addr == msg.sender);
require(cancelled || participant.attended);
require(participant.paid == false);
participant.paid = true;
participant.addr.transfer(payoutAmount);
emit WithdrawEvent(msg.sender, payoutAmount);
}
/* Constants */
function totalBalance() constant public returns (uint256){
return address(this).balance;
}
function isRegistered(address _addr) constant public returns (bool){
return participants[_addr].addr != address(0);
}
function isAttended(address _addr) constant public returns (bool){
return isRegistered(_addr) && participants[_addr].attended;
}
function isPaid(address _addr) constant public returns (bool){
return isRegistered(_addr) && participants[_addr].paid;
}
function payout() constant public returns(uint256){
if (attended == 0) return 0;
return uint(totalBalance()) / uint(attended);
}
/* Admin only functions */
function payback() external onlyOwner onlyActive{
payoutAmount = payout();
ended = true;
endedAt = now;
emit PaybackEvent(payoutAmount);
}
function cancel() external onlyOwner onlyActive{
payoutAmount = deposit;
cancelled = true;
ended = true;
endedAt = now;
emit CancelEvent();
}
/* return the remaining of balance if there are any unclaimed after cooling period */
function clear() external onlyOwner onlyEnded{
require(now > endedAt + coolingPeriod);
uint leftOver = totalBalance();
owner.transfer(leftOver);
emit ClearEvent(owner, leftOver);
}
function setLimitOfParticipants(uint _limitOfParticipants) external onlyOwner onlyActive{
limitOfParticipants = _limitOfParticipants;
}
function attend(address[] _addresses) external onlyAdmin onlyActive{
for(uint i=0;i<_addresses.length;i++){
address _addr = _addresses[i];
require(isRegistered(_addr));
require(!isAttended(_addr));
emit AttendEvent(_addr);
participants[_addr].attended = true;
attended++;
}
}
}
--------------------
==== Integer Overflow ====
Type: Warning
Contract: Ownable
Function name: clear()
PC address: 5463
A possible integer overflow exists in the function `clear()`.
The addition or multiplication may result in a value higher than the maximum representable integer.
--------------------
In file: Conference.sol:159
endedAt + coolingPeriod
--------------------
==== Integer Overflow ====
Type: Warning
Contract: Ownable
Function name: register(string)
PC address: 9149
A possible integer overflow exists in the function `register(string)`.
The addition or multiplication may result in a value higher than the maximum representable integer.
--------------------
In file: Conference.sol:6
contract Conference is Destructible, GroupAdmin {
string public name;
uint256 public deposit;
uint public limitOfParticipants;
uint public registered;
uint public attended;
bool public ended;
bool public cancelled;
uint public endedAt;
uint public coolingPeriod;
uint256 public payoutAmount;
string public encryption;
mapping (address => Participant) public participants;
mapping (uint => address) public participantsIndex;
bool paid;
struct Participant {
string participantName;
address addr;
bool attended;
bool paid;
}
event RegisterEvent(address addr, string participantName, string _encryption);
event AttendEvent(address addr);
event PaybackEvent(uint256 _payout);
event WithdrawEvent(address addr, uint256 _payout);
event CancelEvent();
event ClearEvent(address addr, uint256 leftOver);
/* Modifiers */
modifier onlyActive {
require(!ended);
_;
}
modifier onlyEnded {
require(ended);
_;
}
/* Public functions */
constructor (
string _name,
uint256 _deposit,
uint _limitOfParticipants,
uint _coolingPeriod,
string _encryption
) public {
if(bytes(_name).length != 0){
name = _name;
}else{
name = 'Test';
}
if(_deposit != 0){
deposit = _deposit;
}else{
deposit = 0.02 ether;
}
if(_limitOfParticipants !=0){
limitOfParticipants = _limitOfParticipants;
}else{
limitOfParticipants = 20;
}
if (_coolingPeriod != 0) {
coolingPeriod = _coolingPeriod;
} else {
coolingPeriod = 1 weeks;
}
if (bytes(_encryption).length != 0) {
encryption = _encryption;
}
}
function registerWithEncryption(string _participant, string _encrypted) external payable onlyActive{
registerInternal(_participant);
emit RegisterEvent(msg.sender, _participant, _encrypted);
}
function register(string _participant) external payable onlyActive{
registerInternal(_participant);
emit RegisterEvent(msg.sender, _participant, '');
}
function registerInternal(string _participant) internal {
require(msg.value == deposit);
require(registered < limitOfParticipants);
require(!isRegistered(msg.sender));
registered++;
participantsIndex[registered] = msg.sender;
participants[msg.sender] = Participant(_participant, msg.sender, false, false);
}
function withdraw() external onlyEnded{
require(payoutAmount > 0);
Participant participant = participants[msg.sender];
require(participant.addr == msg.sender);
require(cancelled || participant.attended);
require(participant.paid == false);
participant.paid = true;
participant.addr.transfer(payoutAmount);
emit WithdrawEvent(msg.sender, payoutAmount);
}
/* Constants */
function totalBalance() constant public returns (uint256){
return address(this).balance;
}
function isRegistered(address _addr) constant public returns (bool){
return participants[_addr].addr != address(0);
}
function isAttended(address _addr) constant public returns (bool){
return isRegistered(_addr) && participants[_addr].attended;
}
function isPaid(address _addr) constant public returns (bool){
return isRegistered(_addr) && participants[_addr].paid;
}
function payout() constant public returns(uint256){
if (attended == 0) return 0;
return uint(totalBalance()) / uint(attended);
}
/* Admin only functions */
function payback() external onlyOwner onlyActive{
payoutAmount = payout();
ended = true;
endedAt = now;
emit PaybackEvent(payoutAmount);
}
function cancel() external onlyOwner onlyActive{
payoutAmount = deposit;
cancelled = true;
ended = true;
endedAt = now;
emit CancelEvent();
}
/* return the remaining of balance if there are any unclaimed after cooling period */
function clear() external onlyOwner onlyEnded{
require(now > endedAt + coolingPeriod);
uint leftOver = totalBalance();
owner.transfer(leftOver);
emit ClearEvent(owner, leftOver);
}
function setLimitOfParticipants(uint _limitOfParticipants) external onlyOwner onlyActive{
limitOfParticipants = _limitOfParticipants;
}
function attend(address[] _addresses) external onlyAdmin onlyActive{
for(uint i=0;i<_addresses.length;i++){
address _addr = _addresses[i];
require(isRegistered(_addr));
require(!isAttended(_addr));
emit AttendEvent(_addr);
participants[_addr].attended = true;
attended++;
}
}
}
--------------------
==== Integer Overflow ====
Type: Warning
Contract: Ownable
Function name: register(string)
PC address: 9107
A possible integer overflow exists in the function `register(string)`.
The addition or multiplication may result in a value higher than the maximum representable integer.
--------------------
In file: Conference.sol:6
contract Conference is Destructible, GroupAdmin {
string public name;
uint256 public deposit;
uint public limitOfParticipants;
uint public registered;
uint public attended;
bool public ended;
bool public cancelled;
uint public endedAt;
uint public coolingPeriod;
uint256 public payoutAmount;
string public encryption;
mapping (address => Participant) public participants;
mapping (uint => address) public participantsIndex;
bool paid;
struct Participant {
string participantName;
address addr;
bool attended;
bool paid;
}
event RegisterEvent(address addr, string participantName, string _encryption);
event AttendEvent(address addr);
event PaybackEvent(uint256 _payout);
event WithdrawEvent(address addr, uint256 _payout);
event CancelEvent();
event ClearEvent(address addr, uint256 leftOver);
/* Modifiers */
modifier onlyActive {
require(!ended);
_;
}
modifier onlyEnded {
require(ended);
_;
}
/* Public functions */
constructor (
string _name,
uint256 _deposit,
uint _limitOfParticipants,
uint _coolingPeriod,
string _encryption
) public {
if(bytes(_name).length != 0){
name = _name;
}else{
name = 'Test';
}
if(_deposit != 0){
deposit = _deposit;
}else{
deposit = 0.02 ether;
}
if(_limitOfParticipants !=0){
limitOfParticipants = _limitOfParticipants;
}else{
limitOfParticipants = 20;
}
if (_coolingPeriod != 0) {
coolingPeriod = _coolingPeriod;
} else {
coolingPeriod = 1 weeks;
}
if (bytes(_encryption).length != 0) {
encryption = _encryption;
}
}
function registerWithEncryption(string _participant, string _encrypted) external payable onlyActive{
registerInternal(_participant);
emit RegisterEvent(msg.sender, _participant, _encrypted);
}
function register(string _participant) external payable onlyActive{
registerInternal(_participant);
emit RegisterEvent(msg.sender, _participant, '');
}
function registerInternal(string _participant) internal {
require(msg.value == deposit);
require(registered < limitOfParticipants);
require(!isRegistered(msg.sender));
registered++;
participantsIndex[registered] = msg.sender;
participants[msg.sender] = Participant(_participant, msg.sender, false, false);
}
function withdraw() external onlyEnded{
require(payoutAmount > 0);
Participant participant = participants[msg.sender];
require(participant.addr == msg.sender);
require(cancelled || participant.attended);
require(participant.paid == false);
participant.paid = true;
participant.addr.transfer(payoutAmount);
emit WithdrawEvent(msg.sender, payoutAmount);
}
/* Constants */
function totalBalance() constant public returns (uint256){
return address(this).balance;
}
function isRegistered(address _addr) constant public returns (bool){
return participants[_addr].addr != address(0);
}
function isAttended(address _addr) constant public returns (bool){
return isRegistered(_addr) && participants[_addr].attended;
}
function isPaid(address _addr) constant public returns (bool){
return isRegistered(_addr) && participants[_addr].paid;
}
function payout() constant public returns(uint256){
if (attended == 0) return 0;
return uint(totalBalance()) / uint(attended);
}
/* Admin only functions */
function payback() external onlyOwner onlyActive{
payoutAmount = payout();
ended = true;
endedAt = now;
emit PaybackEvent(payoutAmount);
}
function cancel() external onlyOwner onlyActive{
payoutAmount = deposit;
cancelled = true;
ended = true;
endedAt = now;
emit CancelEvent();
}
/* return the remaining of balance if there are any unclaimed after cooling period */
function clear() external onlyOwner onlyEnded{
require(now > endedAt + coolingPeriod);
uint leftOver = totalBalance();
owner.transfer(leftOver);
emit ClearEvent(owner, leftOver);
}
function setLimitOfParticipants(uint _limitOfParticipants) external onlyOwner onlyActive{
limitOfParticipants = _limitOfParticipants;
}
function attend(address[] _addresses) external onlyAdmin onlyActive{
for(uint i=0;i<_addresses.length;i++){
address _addr = _addresses[i];
require(isRegistered(_addr));
require(!isAttended(_addr));
emit AttendEvent(_addr);
participants[_addr].attended = true;
attended++;
}
}
}
--------------------
==== Integer Overflow ====
Type: Warning
Contract: Ownable
Function name: registerWithEncryption(string,string)
PC address: 5771
A possible integer overflow exists in the function `registerWithEncryption(string,string)`.
The addition or multiplication may result in a value higher than the maximum representable integer.
--------------------
In file: Conference.sol:87
registerInternal(_participant)
--------------------
==== Integer Overflow ====
Type: Warning
Contract: Ownable
Function name: register(string)
PC address: 7891
A possible integer overflow exists in the function `register(string)`.
The addition or multiplication may result in a value higher than the maximum representable integer.
--------------------
In file: Conference.sol:92
registerInternal(_participant)
--------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment