Skip to content

Conversation

@Hecate2
Copy link
Contributor

@Hecate2 Hecate2 commented Nov 10, 2021

…on testnet

namespace NeoBurger
{
[ManifestExtra("Author", "NEOBURGER")]
[ManifestExtra("Email", "developer@neo.org")]

This comment was marked as resolved.

StorageMap proposal_id_map = new(Storage.CurrentContext, new byte[] { PREFIX_PROPOSAL });
ProposalAttributesStruct proposal_attributes = new();
proposal_attributes.id = 0;
proposal_id_map.PutObject((ByteString)(BigInteger)0, proposal_attributes);

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        public void PutObject(ByteString key, object value);
        public void PutObject(byte[] key, object value);

and 2 converts is necessary if use a fixed integer as key. An alternative way can be

proposal_id_map.PutObject(proposal_attributes.id, proposal_attributes);

proposal_id_map.PutObject((ByteString)(BigInteger)0, proposal_attributes);
}

public static BigInteger NewProposal(UInt160 provider, BigInteger proposal_id, UInt160 scripthash, string method, ByteString[] args)

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CallingscriptHash may be a native contract, instead of the actual caller

Storage.Put(Storage.CurrentContext, new byte[] { PREFIX_PROPOSAL_LATEST_ID }, (ByteString)proposal_id);

ProposalAttributesStruct proposal_attributes = new();
proposal_attributes.id = proposal_id;

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

judgement is made at https://github.com/Hecate2/code/blob/13414e510e422e7ae76204f8d1cf8b8a951ad98a/NeoBurgerTestnetVote.cs#L71 which says

((ProposalAttributesStruct)proposal_id_map.GetObject((ByteString)(proposal_id - 1))).id != proposal_id - 1

and proposal_id as 0 leads to exception.
It's even OK if proposal_id is really set as 0, because the TEE would ignore the 0-proposal

ExecutionEngine.Assert(Runtime.CheckWitness(from));
StorageMap delegate_map = new(Storage.CurrentContext, PREFIX_DELEGATE);
if (to == UInt160.Zero || to == from)
delegate_map.Delete(from);

This comment was marked as resolved.

Copy link
Contributor Author

@Hecate2 Hecate2 Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping as zero adds difficulty for collecting delegation relationship information. This contract will be deployed on testnet, where GAS consumption is not a problem.

This comment was marked as resolved.

@Hecate2 Hecate2 force-pushed the BurgerGovTestnetVote branch from 8f4877c to 7aa0132 Compare December 22, 2021 09:02
@bugerhunter
Copy link

IMO, put the delegation relationship on mainnet would be better.

  1. If testnet is down and all data are wept, we may keep the delegation relationship.
  2. We'll do a snapshot for voters' NoBug count and delegation relationship for voting result. Put the relationship on mainnet would make it accountable and durable.

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

Successfully merging this pull request may close these issues.

3 participants