-
Notifications
You must be signed in to change notification settings - Fork 4
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
NeoBurgerTestnetVote.cs which records proposals, delegates and votes on testnet #5
base: main
Are you sure you want to change the base?
Conversation
NeoBurgerTestnetVote.cs
Outdated
namespace NeoBurger | ||
{ | ||
[ManifestExtra("Author", "NEOBURGER")] | ||
[ManifestExtra("Email", "[email protected]")] |
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.
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);
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.
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.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
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.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
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.
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