Skip to content

Commit 4926267

Browse files
authored
Merge pull request #3626 from AElfProject/dev
TransactionResult optimization
2 parents 39398fa + 9d567e4 commit 4926267

File tree

30 files changed

+425
-29
lines changed

30 files changed

+425
-29
lines changed

.github/workflows/sonarqube.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
with:
1616
dotnet-version: '8.0'
1717
- name: Create temporary global.json
18-
run: echo '{"sdk":{"version":"8.0.303"}}' > ./global.json
18+
run: echo '{"sdk":{"version":"8.0.*"}}' > ./global.json
1919
- name: Set up JDK 17
2020
uses: actions/setup-java@v1
2121
with:

azure-pipelines.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ jobs:
4040
parts: 3
4141
n: 2
4242
codecoverage: true
43-
- template: templates/build-template-macos.yml
44-
parameters:
45-
parts: 3
46-
n: 3
47-
codecoverage: true
43+
# - template: templates/build-template-macos.yml
44+
# parameters:
45+
# parts: 3
46+
# n: 3
47+
# codecoverage: true
4848

contract/AElf.Contracts.Consensus.AEDPoS/AEDPoSContract_ProcessConsensusInformation.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,12 @@ private void ProcessNextRound(NextRoundInput input)
127127
{
128128
var minersCount = GetMinersCount(nextRound);
129129
if (minersCount != 0 && State.ElectionContract.Value != null)
130+
{
130131
State.ElectionContract.UpdateMinersCount.Send(new UpdateMinersCountInput
131132
{
132133
MinersCount = minersCount
133134
});
135+
}
134136
}
135137
}
136138

contract/AElf.Contracts.MultiToken/TokenContract_Actions.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,35 @@ public override Int32Value GetMaxBatchApproveCount(Empty input)
691691
};
692692
}
693693

694+
public override Empty ExtendSeedExpirationTime(ExtendSeedExpirationTimeInput input)
695+
{
696+
var tokenInfo = GetTokenInfo(input.Symbol);
697+
if (tokenInfo == null)
698+
{
699+
throw new AssertionException("Seed NFT does not exist.");
700+
}
701+
702+
Assert(tokenInfo.Owner == Context.Sender, "Sender is not Seed NFT owner.");
703+
var oldExpireTimeLong = 0L;
704+
if (tokenInfo.ExternalInfo.Value.TryGetValue(TokenContractConstants.SeedExpireTimeExternalInfoKey,
705+
out var oldExpireTime))
706+
{
707+
long.TryParse(oldExpireTime, out oldExpireTimeLong);
708+
}
709+
710+
tokenInfo.ExternalInfo.Value[TokenContractConstants.SeedExpireTimeExternalInfoKey] =
711+
input.ExpirationTime.ToString();
712+
State.TokenInfos[input.Symbol] = tokenInfo;
713+
Context.Fire(new SeedExpirationTimeUpdated
714+
{
715+
ChainId = tokenInfo.IssueChainId,
716+
Symbol = input.Symbol,
717+
OldExpirationTime = oldExpireTimeLong,
718+
NewExpirationTime = input.ExpirationTime
719+
});
720+
return new Empty();
721+
}
722+
694723
private int GetMaxBatchApproveCount()
695724
{
696725
return State.MaxBatchApproveCount.Value == 0

contract/AElf.Contracts.MultiToken/TokenContract_Helper.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,16 @@ private Address ExtractTokenContractAddress(ByteString bytes)
215215
private void AssertCrossChainTransaction(Transaction originalTransaction, Address validAddress,
216216
params string[] validMethodNames)
217217
{
218-
var validateResult = validMethodNames.Contains(originalTransaction.MethodName)
218+
var validateResult = validMethodNames.Contains(MaybeRecoverInlineTransactionFunctionName(originalTransaction.MethodName))
219219
&& originalTransaction.To == validAddress;
220220
Assert(validateResult, "Invalid transaction.");
221221
}
222+
223+
private static string MaybeRecoverInlineTransactionFunctionName(string methodName)
224+
{
225+
var parts = methodName.Split('.');
226+
return parts.Length > 1 ? parts[^2] : methodName;
227+
}
222228

223229
private void RegisterTokenInfo(TokenInfo tokenInfo)
224230
{

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "8.0.x"
3+
"version": "8.0.*"
44
}
55
}

protobuf/inline_transaction.proto

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
syntax = "proto3";
2+
3+
option csharp_namespace = "AElf.Types";
4+
5+
6+
import "aelf/core.proto";
7+
import "aelf/options.proto";
8+
9+
service InlineTransaction {
10+
}
11+
12+
message InlineTransactionCreated {
13+
option (aelf.is_event) = true;
14+
aelf.Transaction transaction = 1 [(aelf.is_indexed) = true];
15+
}

protobuf/test_virtual_address_contract.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ service VirtualAddressContract {
1414
option (aelf.base) = "acs1.proto";
1515

1616
rpc VirtualAddressVote(VirtualAddressVoteInput) returns (google.protobuf.Empty);
17+
rpc VirtualAddressVoteWithInline(VirtualAddressVoteWithCountInput) returns (google.protobuf.Empty);
1718
rpc VirtualAddressWithdraw(aelf.Hash) returns (google.protobuf.Empty);
1819
rpc VirtualAddressChangeVotingOption(VirtualAddressChangeVotingOptionInput) returns (google.protobuf.Empty);
1920
rpc VirtualAddressClaimProfit(VirtualAddressClaimProfitInput) returns (google.protobuf.Empty);
@@ -32,6 +33,11 @@ message VirtualAddressVoteInput {
3233
aelf.Hash token = 4;
3334
}
3435

36+
message VirtualAddressVoteWithCountInput {
37+
VirtualAddressVoteInput vote_input = 1; // Existing input type
38+
int32 count = 2; // Additional count input
39+
}
40+
3541
message VirtualAddressChangeVotingOptionInput {
3642
bool is_reset = 1;
3743
aelf.Hash vote_id = 2;

protobuf/token_contract_impl.proto

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ service TokenContractImpl {
182182
rpc GetMaxBatchApproveCount (google.protobuf.Empty) returns (google.protobuf.Int32Value) {
183183

184184
}
185+
186+
rpc ExtendSeedExpirationTime (ExtendSeedExpirationTimeInput) returns (google.protobuf.Empty) {
187+
}
185188
}
186189

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

445448
message SetTokenIssuerAndOwnerModificationEnabledInput{
446449
bool enabled = 1;
450+
}
451+
452+
message ExtendSeedExpirationTimeInput {
453+
string symbol = 1;
454+
int64 expiration_time = 2;
455+
}
456+
457+
message SeedExpirationTimeUpdated {
458+
option (aelf.is_event) = true;
459+
int32 chain_id = 1;
460+
string symbol = 2;
461+
int64 old_expiration_time = 3;
462+
int64 new_expiration_time = 4;
447463
}

protobuf/virtual_transaction.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ message VirtualTransactionCreated {
1717
string method_name = 4 [(aelf.is_indexed) = true];
1818
bytes params = 5;
1919
aelf.Address signatory = 6 [(aelf.is_indexed) = true];
20-
}
20+
}

0 commit comments

Comments
 (0)