NeoBurgerTestnetVote.cs which records proposals, delegates and votes on testnet#5
NeoBurgerTestnetVote.cs which records proposals, delegates and votes on testnet#5Hecate2 wants to merge 15 commits intoneoburger:mainfrom
Conversation
NeoBurgerTestnetVote.cs
Outdated
| namespace NeoBurger | ||
| { | ||
| [ManifestExtra("Author", "NEOBURGER")] | ||
| [ManifestExtra("Email", "developer@neo.org")] |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| 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.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
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);
NeoBurgerTestnetVote.cs
Outdated
| 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.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
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.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
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 - 1and 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.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
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.
This comment was marked as resolved.
Sorry, something went wrong.
8f4877c to
7aa0132
Compare
|
IMO, put the delegation relationship on mainnet would be better.
|
…on testnet