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

Crowdsale participation amounts may be off by 100000000 #249

Closed
dexX7 opened this issue Sep 19, 2015 · 0 comments
Closed

Crowdsale participation amounts may be off by 100000000 #249

dexX7 opened this issue Sep 19, 2015 · 0 comments

Comments

@dexX7
Copy link
Member

dexX7 commented Sep 19, 2015

CMPTransaction::logicHelper_CrowdsaleParticipation:

if (!isPropertyDivisible(property)) { // <-- the tokens "invested"
    nValue = nValue * 1e8; // <--  modifies nValue!
}

The adjusted amount for crowdsale participations with indivisble tokens is not stored in a new variable, but modifies the value of the transaction.

As result, crowdsale participations may look much larger than they actually are. This is not consensus affecting, as far as I can see right now.

Example:

Given is a crowdsale without bonus, where 1 indivisible token is granted for each unit invested. The tokens to be invested are also indivisible, i.e. 1 token invested = 1 token granted.

It follows a purchase with 1 token:

omni_gettransaction fc2e547b7426111da6fe04007dfac08a2ca996241d2bc48e05a17aee3fc2b05a
{
  "txid": "fc2e547b7426111da6fe04007dfac08a2ca996241d2bc48e05a17aee3fc2b05a",
  "fee": "0.00010000",
  "sendingaddress": "mmHRSSG5dovbNnbTMgE6QTrLoMErXnZ3w8",
  "referenceaddress": "n4JaFhZXkSu59RoZLbzu3PMUdsEtkhPMFU",
  "ismine": true,
  "version": 0,
  "type_int": 0,
  "type": "Crowdsale Purchase",
  "propertyid": 3,
  "divisible": false,
  "amount": "1",
  "purchasedpropertyid": 4,
  "purchasedpropertyname": "Test",
  "purchasedpropertydivisible": false,
  "purchasedtokens": "1", // <--- 1 sent!
  "issuertokens": "0",
  "valid": true,
  "blockhash": "4d863fbd3b232cb96fc7dc88822a1947e4778d652dd19f387834bd1b733a34dc",
  "blocktime": 1442692142,
  "block": 107,
  "confirmations": 1
}
{
  "propertyid": 4,
  "name": "Test",
  "active": true,
  "issuer": "n4JaFhZXkSu59RoZLbzu3PMUdsEtkhPMFU",
  "propertyiddesired": 3,
  "tokensperunit": "1",
  "earlybonus": 0,
  "percenttoissuer": 0,
  "starttime": 1442692142,
  "deadline": 7731414000,
  "tokensissued": "1",
  "addedissuertokens": "0",
  "amountraised": "100000000", // <--- only 1 sent, off by a factor of 100000000
  "participanttransactions": [{
    "txid": "fc2e547b7426111da6fe04007dfac08a2ca996241d2bc48e05a17aee3fc2b05a",
    "amountsent": "100000000", // <--- only 1 sent, off by a factor of 100000000
    "participanttokens": "1",
    "issuertokens": "0"
  }]
}

The total can also overflow, if there are multiple participations:

{
  "propertyid": 4,
  "name": "Test",
  "active": true,
  "issuer": "miSc8q3BtXUX4AXebpxqkJuxJAFvsaXpxn",
  "propertyiddesired": 3,
  "tokensperunit": "1",
  "earlybonus": 0,
  "percenttoissuer": 0,
  "starttime": 1442693274,
  "deadline": 7731414000,
  "amountraised": "-219103232", // <--- should be 368934881472
  "tokensissued": "368934881472",
  "addedissuertokens": "0",
  "participanttransactions": [{
    "txid": "3770ead708178fd1072dc4d90e711417dfe4cc003b7edd26846db0d05485a3d3",
    "amountsent": "9223372036800000000", // <--- should be 92233720368
    "participanttokens": "92233720368",
    "issuertokens": "0"
  }, {
    "txid": "5e8f786d7d97adef1334afa5a4bcd726bcc8e9fc3a0cdcf3d2e968e6b45d6a2b",
    "amountsent": "9223372036800000000", // <--- should be 92233720368
    "participanttokens": "92233720368",
    "issuertokens": "0"
  }, {
    "txid": "f57d2fee2178f49ffe96b6a2ba2b0a899b20c21804ef46745f7751ed98384dde",
    "amountsent": "9223372036800000000", // <--- should be 92233720368
    "participanttokens": "92233720368",
    "issuertokens": "0"
  }, {
    "txid": "8127b30eeb61716c526b9672162e2414ea4d219876961b0bf663dd0d9aceea4f",
    "amountsent": "9223372036800000000", // <--- should be 92233720368
    "participanttokens": "92233720368",
    "issuertokens": "0"
  }]
}

Note: even though this is seemingly an RPC issue, the underlying cause should be addressed on the core level.

Related: #247, #248

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant