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

Regarding the release PR for aelf project version 1.12.0 #3630

Merged
merged 100 commits into from
Jan 8, 2025
Merged
Changes from 20 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
955096c
Add whitelist solution
chopin-fan Sep 3, 2024
47595fc
Resolve issue of compilation and running, and add unit-test
chopin-fan Sep 3, 2024
53f389c
Revert appsettings.json
chopin-fan Sep 4, 2024
a57f39e
feat(zkp): Add methods required for supporting zkp verification over …
gldeng Sep 4, 2024
b66e60c
Change version to 8.0.402 in sonarqube.yaml
chopin-fan Sep 29, 2024
6469d74
Change version of sdk
chopin-fan Sep 29, 2024
00d0b6e
Change version of sdk
chopin-fan Sep 29, 2024
77e2d11
Add sources
chopin-fan Sep 29, 2024
7c9c674
Merge branch 'dev' into feature/whitelist-to-sdk
chopin-fan Sep 29, 2024
8838901
Merge branch 'dev' into feature/whitelist-to-sdk
chopin-fan Oct 3, 2024
0c5cf13
Change versions and add whitelist
chopin-fan Oct 8, 2024
8262cd9
Merge remote-tracking branch 'origin/feature/whitelist-to-sdk' into f…
chopin-fan Oct 8, 2024
4e5b3aa
Remove poseidon and groth16 in IWhitelistProvider.cs
chopin-fan Oct 8, 2024
aa43d7b
Add config for auto-publishing
chopin-fan Nov 7, 2024
534f24b
Now some of inline txs will have their own tx id via layered method n…
eanzhao Nov 9, 2024
46e54c5
Improve layered method name.
eanzhao Nov 9, 2024
be03fce
Put inline txs to block body.
eanzhao Nov 9, 2024
8291fb1
Fix block sync issue.
eanzhao Nov 11, 2024
1ac0435
1. Remove useless comments
chopin-fan Nov 12, 2024
0b3ab87
Cancel inline event log
chopin-fan Nov 12, 2024
8626f56
extend seed expiration time
JimAelf Nov 12, 2024
54fb07d
extend SEED expiration time
JimAelf Nov 13, 2024
1e7c987
transaction result status optimization, clear return the expired desc…
JimAelf Nov 13, 2024
8ec60e3
Fixed GetTransactionResultAsync: compare BestChainHeight with RefBloc…
eanzhao Nov 14, 2024
daaec05
optimize the result of transaction result
JimAelf Nov 14, 2024
1ad4d46
support zk
chopin-fan Nov 14, 2024
8c4234a
Resolve unit test issue
chopin-fan Nov 15, 2024
e1ccdb9
Resolve Verification Failure Issue
chopin-fan Nov 15, 2024
9df0b20
Resolve the difficulty of creating inline transactions by eventlog du…
chopin-fan Nov 15, 2024
5dd5ac8
Rename method name
chopin-fan Nov 15, 2024
6d433e5
Add unit-test for zk supporting
chopin-fan Nov 18, 2024
c876944
Clean up unused code and optimize the code
chopin-fan Nov 18, 2024
60b637d
Update the sdk version
chopin-fan Nov 18, 2024
d416275
Temporarily remove the unit test; it will be added back later
chopin-fan Nov 19, 2024
8299f35
Temporarily remove the unit test; it will be added back later
chopin-fan Nov 19, 2024
3067232
Modify config in azure-pipelines.yml
chopin-fan Nov 19, 2024
69ec7e8
Modify config in azure-pipelines.yml
chopin-fan Nov 19, 2024
c045573
set a the Error message to the output to infer that the transaction w…
JimAelf Nov 19, 2024
18763ee
Modify config in azure-pipelines.yml
chopin-fan Nov 19, 2024
52efae9
set a the Error message to the output to infer that the transaction w…
JimAelf Nov 19, 2024
de45a0f
set a the Error message to the output to infer that the transaction w…
JimAelf Nov 19, 2024
60cb378
If transaction satus is "NOT_EXIST", and the lag of the refblock is b…
JimAelf Nov 19, 2024
1b7c212
handle the Sonar build problem
JimAelf Nov 19, 2024
c53dbf7
handle the Sonar build problem
JimAelf Nov 19, 2024
af79e90
Fix tx expired error message.
eanzhao Nov 20, 2024
1404c3e
Add new event: SeedExpirationTimeUpdated
eanzhao Nov 20, 2024
d1a71ef
CallCount revert to 15000
chopin-fan Nov 23, 2024
6ea81f8
Merge pull request #3621 from AElfProject/feature/transaction-result-…
JimAelf Nov 25, 2024
e617a69
The Status is obsolete. Use StatusV2 instead
JimAelf Nov 25, 2024
d1658fd
The Status is obsolete. Use StatusV2 instead
JimAelf Nov 25, 2024
0f4b2c4
The Status is obsolete in this version. Use StatusV2 instead
JimAelf Nov 25, 2024
f16179d
Merge branch 'dev' into feature/inline-tx-id
chopin-fan Nov 25, 2024
b3a138c
Add unit-test for cross-aa
chopin-fan Nov 26, 2024
b498ff5
Add unit test
chopin-fan Nov 26, 2024
c84faaa
Remove unused unit test
chopin-fan Nov 26, 2024
cec89b7
unit test done
JimAelf Nov 26, 2024
2e1522e
unit test done
JimAelf Nov 26, 2024
85e9efd
Merge pull request #3620 from AElfProject/feature/inline-tx-id
JimAelf Nov 26, 2024
67ea4aa
Tune Get_TransactionResultV2_Expired_Testf and fixed tx.statusv2 issues.
eanzhao Nov 27, 2024
39398fa
Will return new status if pending txs already expired.
eanzhao Nov 27, 2024
d594e53
Merge branch 'dev' into feature/whitelist-to-sdk
chopin-fan Nov 27, 2024
f21fc2d
Merge pull request #3625 from AElfProject/feature/transaction-result-…
JimAelf Dec 3, 2024
9d567e4
Merge pull request #3624 from AElfProject/feature/extend-seed-expirat…
JimAelf Dec 3, 2024
4926267
Merge pull request #3626 from AElfProject/dev
JimAelf Dec 4, 2024
c4a291c
TransactionResult optimization, add a new method GetTransactionResult…
JimAelf Dec 4, 2024
dc42b74
Merge pull request #3627 from AElfProject/feature/transaction-result-…
JimAelf Dec 4, 2024
a74faf0
Remove inline transaction modification because of the early publishme…
JimAelf Dec 5, 2024
2a62de2
update StatusV2 to StatusWithBVP
JimAelf Dec 7, 2024
187d3ed
Merge pull request #3628 from AElfProject/feature/transaction-result-…
JimAelf Dec 7, 2024
d38683f
Remove publish config in main and side project
chopin-fan Dec 12, 2024
187a4c5
Merge branch 'dev' into feature/whitelist-to-sdk
chopin-fan Dec 12, 2024
29143a2
token contract add inline transaction modification
JimAelf Dec 14, 2024
94abd2a
Merge branch 'dev' into feature/whitelist-to-sdk
chopin-fan Dec 14, 2024
71c5095
Merge pull request #3614 from AElfProject/feature/whitelist-to-sdk
JimAelf Dec 14, 2024
6008ea5
Revert code
chopin-fan Dec 17, 2024
77ed70a
try to skip issue that node can not produce
chopin-fan Dec 18, 2024
3340791
Remove TriggerConsensusEventAsync
chopin-fan Dec 18, 2024
a584079
Add TriggerConsensusEventAsync for image
chopin-fan Dec 18, 2024
6bf28b9
remove TriggerConsensusEventAsync
chopin-fan Dec 18, 2024
745b326
add TriggerConsensusEventAsync
chopin-fan Dec 18, 2024
3222d1c
Add log
chopin-fan Dec 18, 2024
c522ab9
Add log
chopin-fan Dec 19, 2024
692c6b2
1. Remove log and resolve issue
chopin-fan Dec 19, 2024
b8fb0d8
Remove unused code
chopin-fan Dec 20, 2024
586a98a
Remove cross-aa code
chopin-fan Dec 23, 2024
ff58f36
Adjust the implementation of zk function
chopin-fan Dec 24, 2024
4d02f27
Adjust implementation of ZK function
chopin-fan Dec 25, 2024
230fceb
Adjust impletation of zk function
chopin-fan Dec 26, 2024
c124761
Adjust to static method
chopin-fan Dec 27, 2024
a2ef9a6
Add WhitelistCryptographyHelpers whitelist method
chopin-fan Dec 27, 2024
c752104
Adjust zk code
chopin-fan Dec 29, 2024
3383c90
remove priveteAssets
chopin-fan Dec 30, 2024
ee4801f
adjust version of Nethereum.Web3
chopin-fan Dec 30, 2024
a2e3579
remove unused code
chopin-fan Dec 30, 2024
7b1eb9b
Add unit test
chopin-fan Jan 1, 2025
b4804c6
Merge branch 'master' into release/1.12.2
chopin-fan Jan 1, 2025
99e57c9
Change method name to TransactionResultWithBVP
chopin-fan Jan 2, 2025
453d96b
Merge remote-tracking branch 'origin/release/1.12.2' into release/1.12.2
chopin-fan Jan 2, 2025
03ede96
Remove inline_transaction.proto
chopin-fan Jan 3, 2025
3688493
Remove poseidong
chopin-fan Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions contract/AElf.Contracts.MultiToken/TokenContract_Actions.cs
Original file line number Diff line number Diff line change
@@ -691,6 +691,35 @@ public override Int32Value GetMaxBatchApproveCount(Empty input)
};
}

public override Empty ExtendSeedExpirationTime(ExtendSeedExpirationTimeInput input)
{
var tokenInfo = GetTokenInfo(input.Symbol);
if (tokenInfo == null)
{
throw new AssertionException("Seed NFT does not exist.");
}

Assert(tokenInfo.Owner == Context.Sender, "Sender is not Seed NFT owner.");
var oldExpireTimeLong = 0L;
if (tokenInfo.ExternalInfo.Value.TryGetValue(TokenContractConstants.SeedExpireTimeExternalInfoKey,
out var oldExpireTime))
{
long.TryParse(oldExpireTime, out oldExpireTimeLong);
}

tokenInfo.ExternalInfo.Value[TokenContractConstants.SeedExpireTimeExternalInfoKey] =
input.ExpirationTime.ToString();
State.TokenInfos[input.Symbol] = tokenInfo;
Context.Fire(new SeedExpirationTimeUpdated
{
ChainId = tokenInfo.IssueChainId,
Symbol = input.Symbol,
OldExpirationTime = oldExpireTimeLong,
NewExpirationTime = input.ExpirationTime
});
return new Empty();
}

private int GetMaxBatchApproveCount()
{
return State.MaxBatchApproveCount.Value == 0
8 changes: 1 addition & 7 deletions contract/AElf.Contracts.MultiToken/TokenContract_Helper.cs
Original file line number Diff line number Diff line change
@@ -215,16 +215,10 @@ private Address ExtractTokenContractAddress(ByteString bytes)
private void AssertCrossChainTransaction(Transaction originalTransaction, Address validAddress,
params string[] validMethodNames)
{
var validateResult = validMethodNames.Contains(MaybeRecoverInlineTransactionFunctionName(originalTransaction.MethodName))
var validateResult = validMethodNames.Contains(originalTransaction.MethodName)
&& originalTransaction.To == validAddress;
Assert(validateResult, "Invalid transaction.");
}

private static string MaybeRecoverInlineTransactionFunctionName(string methodName)
{
var parts = methodName.Split('.');
return parts.Length > 1 ? parts[^2] : methodName;
}

private void RegisterTokenInfo(TokenInfo tokenInfo)
{
2 changes: 2 additions & 0 deletions protobuf/aelf/core.proto
Original file line number Diff line number Diff line change
@@ -59,6 +59,8 @@ enum TransactionResultStatus {
PENDING_VALIDATION = 5;
// Transaction validation failed.
NODE_VALIDATION_FAILED = 6;
// Transaction is expired
EXPIRED = 7;
}

message TransactionResult {
16 changes: 16 additions & 0 deletions protobuf/token_contract_impl.proto
Original file line number Diff line number Diff line change
@@ -182,6 +182,9 @@ service TokenContractImpl {
rpc GetMaxBatchApproveCount (google.protobuf.Empty) returns (google.protobuf.Int32Value) {

}

rpc ExtendSeedExpirationTime (ExtendSeedExpirationTimeInput) returns (google.protobuf.Empty) {
}
}

message AdvanceResourceTokenInput {
@@ -444,4 +447,17 @@ message ModifyTokenIssuerAndOwnerInput {

message SetTokenIssuerAndOwnerModificationEnabledInput{
bool enabled = 1;
}

message ExtendSeedExpirationTimeInput {
string symbol = 1;
int64 expiration_time = 2;
}

message SeedExpirationTimeUpdated {
option (aelf.is_event) = true;
int32 chain_id = 1;
string symbol = 2;
int64 old_expiration_time = 3;
int64 new_expiration_time = 4;
}
5 changes: 5 additions & 0 deletions src/AElf.WebApp.Application.Chain/Dto/TransactionResultDto.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
using System;

namespace AElf.WebApp.Application.Chain.Dto;

public class TransactionResultDto
{
public string TransactionId { get; set; }

[Obsolete("The Status is obsolete. Use StatusWithBVP instead.")]
public string Status { get; set; }

public string StatusWithBVP { get; set; }

public LogEventDto[] Logs { get; set; }

Original file line number Diff line number Diff line change
@@ -24,6 +24,8 @@ namespace AElf.WebApp.Application.Chain;
public interface ITransactionResultAppService
{
Task<TransactionResultDto> GetTransactionResultAsync(string transactionId);

Task<TransactionResultDto> GetTransactionResultV2Async(string transactionId);

Task<List<TransactionResultDto>> GetTransactionResultsAsync(string blockHash, int offset = 0,
int limit = 10);
@@ -118,16 +120,72 @@ await _transactionResultProxyService.InvalidTransactionResultService.GetInvalidT
return output;
}
}
return output;
}
/// <summary>
/// Get the current status of a transaction, available since V1.12.0
/// </summary>
/// <param name="transactionId">transaction id</param>
/// <returns></returns>
public async Task<TransactionResultDto> GetTransactionResultV2Async(string transactionId)
{
Hash transactionIdHash;
try
{
transactionIdHash = Hash.LoadFromHex(transactionId);
}
catch
{
throw new UserFriendlyException(Error.Message[Error.InvalidTransactionId],
Error.InvalidTransactionId.ToString());
}

var transactionResult = await GetTransactionResultAsync(transactionIdHash);
var output = _objectMapper.GetMapper()
.Map<TransactionResult, TransactionResultDto>(transactionResult,
opt => opt.Items[TransactionProfile.ErrorTrace] = _webAppOptions.IsDebugMode);
output.StatusWithBVP = output.Status;

var transaction = await _transactionManager.GetTransactionAsync(transactionResult.TransactionId);
output.Transaction = _objectMapper.Map<Transaction, TransactionDto>(transaction);
output.TransactionSize = transaction?.CalculateSize() ?? 0;

var chain = await _blockchainService.GetChainAsync();
if (chain.BestChainHeight - output.Transaction.RefBlockNumber > KernelConstants.ReferenceBlockValidPeriod
&& transactionResult.Status == TransactionResultStatus.NotExisted)
if (transactionResult.Status == TransactionResultStatus.Pending &&
chain.BestChainHeight - output.Transaction?.RefBlockNumber > KernelConstants.ReferenceBlockValidPeriod)
{
// set a the Error message to the output to infer that the transaction will never succeed.
var error = "The transaction is already expired, and it will never succeed.";
output.Error = TransactionErrorResolver.TakeErrorMessage(error, _webAppOptions.IsDebugMode);
output.StatusWithBVP = TransactionResultStatus.Expired.ToString().ToUpper();
return output;
}

if (transactionResult.Status != TransactionResultStatus.NotExisted)
{
await FormatTransactionParamsAsync(output.Transaction, transaction.Params);
return output;
}

var validationStatus = _transactionResultStatusCacheProvider.GetTransactionResultStatus(transactionIdHash);
if (validationStatus != null)
{
output.StatusWithBVP = validationStatus.TransactionResultStatus.ToString().ToUpper();
output.Error =
TransactionErrorResolver.TakeErrorMessage(validationStatus.Error, _webAppOptions.IsDebugMode);
return output;
}

if (_transactionOptions.StoreInvalidTransactionResultEnabled)
{
var failedTransactionResult =
await _transactionResultProxyService.InvalidTransactionResultService.GetInvalidTransactionResultAsync(
transactionIdHash);
if (failedTransactionResult != null)
{
output.StatusWithBVP = failedTransactionResult.Status.ToString().ToUpper();
output.Error = failedTransactionResult.Error;
return output;
}
}

return output;
}

11 changes: 11 additions & 0 deletions test/AElf.Contracts.MultiToken.Tests/BVT/TokenApplicationTests.cs
Original file line number Diff line number Diff line change
@@ -1893,4 +1893,15 @@ public async Task TokenIssuerAndOwnerModification_Test()
result.TransactionResult.Error.ShouldContain("Set token issuer and owner disabled.");

}

[Theory]
[InlineData("SEED-0", 1731927992000)]
public async Task ExtendSeedExpirationTime_Test(string symbol, long expirationTime)
{
ExtendSeedExpirationTimeInput input = new ExtendSeedExpirationTimeInput();
input.Symbol = symbol;
input.ExpirationTime = expirationTime;

await TokenContractStub.ExtendSeedExpirationTime.CallAsync(input);
}
}
Original file line number Diff line number Diff line change
@@ -240,4 +240,7 @@ internal async Task<IExecutionResult<Empty>> CreateMutiTokenWithExceptionAsync(
await CreateSeedNftAsync(stub, createInput);
return await stub.Create.SendWithExceptionAsync(createInput);
}



}
Original file line number Diff line number Diff line change
@@ -685,6 +685,37 @@ public async Task Get_TransactionResult_Success_Test()
response.BlockNumber.ShouldBe(block.Height);
response.BlockHash.ShouldBe(block.GetHash().ToHex());
}

[Fact]
public async Task Get_TransactionResultV2_Expired_Test()
{
// Generate a transaction
var transaction = await _osTestHelper.GenerateTransferTransaction();

// Push chain height to be ref_block_number + at least 512
await MineSomeBlocks(520);
var transactionHex = transaction.GetHash().ToHex();

// Broadcast expired transaction
await _osTestHelper.BroadcastTransactions(new List<Transaction> { transaction });

// Check transaction status
var response = await GetResponseAsObjectAsync<TransactionResultDto>(
$"/api/blockChain/transactionResultV2?transactionId={transactionHex}");
response.StatusWithBVP.ShouldBe(TransactionResultStatus.Expired.ToString().ToUpper());
}

private async Task MineSomeBlocks(int blockNumber)
{
var heightBefore = (await _osTestHelper.GetChainContextAsync()).BlockHeight;
for (var i = 0; i < blockNumber; i++)
{
await _osTestHelper.MinedOneBlock();
}

var heightAfter = (await _osTestHelper.GetChainContextAsync()).BlockHeight;
heightAfter.ShouldBe(heightBefore + blockNumber);
}

[Fact]
public async Task Get_Failed_TransactionResult_Success_Test()
Loading