You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When signing a transaction it’s actually a subset of the fields: from/to and the target method as well as the parameter that were given. It also contains the reference block number and prefix.
Bloom filter for transaction logs. A transaction log event can be defined in the contract and stored in the bloom filter after the transaction is executed. Through this filter, we can quickly search for and determine whether a log exists in the transaction result.
The execution result of the transaction does not exist.
PENDING
1
The transaction is in the transaction pool waiting to be packaged.
FAILED
2
Transaction execution failed.
MINED
3
The transaction was successfully executed and successfully packaged into a block.
CONFLICT
4
When executed in parallel, there are conflicts with other transactions.
PENDING_VALIDATION
5
The transaction is waiting for validation.
NODE_VALIDATION_FAILED
6
Transaction validation failed.
Usage
AElf uses the key-value database to store data. For the data generated during the contract execution, a mechanism called State Path is used to determine the key of the data.
Assuming that the address of the Token contract is Nmjj7noTpMqZ522j76SDsFLhiKkThv1u3d4TxqJMD8v89tWmE. If you want to know the balance of the address 2EM5uV6bSJh6xJfZTUa1pZpYsYcCUAdPvZvFUJzMDJEx3rbioz, you can directly use this key to access redis / ssdb to get its value.
On AElf, the implementation of parallel transaction execution is also based on the key , developers need to provide a method may access to the StatePath, then the corresponding transactions will be properly grouped before executing: if the two methods do not access the same StatePath, then you can safely place them in different groups.
Attention: The transaction will be canceled and labeled to “can not be groupped” when the StatePath mismatchs the method.
If you are interested in the logic, you can view the code ITransactionGrouper, as well as IParallelTransactionExecutingService .
Implementation
Token contract, as an example, the core logic of method Transfer is to modify the balance of address. It accesses the balances property mentioned above twice.
At this point, we need to notify ITransactionGrouper via the GetResourceInfo method of the key of the ELF balance of address A and address B:
You can construct two transactions, and the transactions are passed directly to an implementation instance of ITransactionGrouper, and the GroupAsync method is used to see whether the two transactions are parallel.
We prepare two stubs that implement the ACS2 contract with different addresses to simulate the Transfer:
You can refer to the implementation of the MultiToken contract for GetResourceInfo. Noting that for the ResourceInfo provided by the method Transfer, you need to consider charging a transaction fee in addition to the two keys mentioned in this article.