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

Cloned token state is not locked when cloned with current or future block number #42

Open
rudolfix opened this issue Oct 27, 2017 · 0 comments

Comments

@rudolfix
Copy link

When token is cloned at block number that is current block (the default option) in createCloneToken

if (_snapshotBlock == 0) _snapshotBlock = block.number;

or with future block number, it should not be possible to change state (that is balances and total supply) of the cloned token. Allowing that will easily lead to inconsistencies when state changes in cloned token partially "shadow" changes in parent. Example

we are at block 100, parent token state is {owner1 balance: 100, owner2 balance :10, totalSupply:110}, token is cloned at block 110.

at block 110 two operations happen
clone.destroyTokens(owner1, 1)
parent.transfer(owner2, 10, {from: owner1}

which will result in following state of cloned token (at block 110 and future blocks)
owner1 balance: 99 (shadows parent token)
owner2 balance: 20 (taken from parent token as there is no value stored for owner2 in the clone)
totalSupply: 109 (shadows parent token)

at this point balances sum to 119 but totalSupply is 109

solution would be to revert on any calls to destroyTokens and generateTokens that happen before and at the block at which clone is created as doTransfer function already does.

changing the default clone _snapshotBlock to

if (_snapshotBlock == 0) _snapshotBlock = block.number - 1;

would also be advisable as parent state at block.number - 1 is already immutable. cloning at current block is basically cloning at unknown parent state (which may be changed before but also after the clone transaction)

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

No branches or pull requests

1 participant