Skip to content

Commit d2e6cf5

Browse files
committed
fix(erc721): rework to relay pattern (no re-key), keep diagnostics
Signed-off-by: ValentinVPK <valentin.krumov@limechain.tech>
1 parent 6b58bb8 commit d2e6cf5

3 files changed

Lines changed: 65 additions & 168 deletions

File tree

.github/workflows/test-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ permissions:
2929
jobs:
3030
acceptance-workflow:
3131
runs-on: hl-contr-lin-lg
32-
timeout-minutes: 45
32+
timeout-minutes: 15 # TEMPORARY (v0.77 iteration) — restore to 45 before merge
3333
strategy:
3434
fail-fast: false
3535

.github/workflows/tests.yml

Lines changed: 8 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
name: Tests CI
22

3+
# =============================================================================
4+
# TEMPORARY — v0.77 fix iteration only. REVERT BEFORE MERGE.
5+
# Reduced to a single suite so each push runs one ~5-min job instead of 14
6+
# suites (most hanging to the job cap) on a serialized runner pool. The full
7+
# 14-suite job list + PublishResults lives in git history; restore it before
8+
# this PR is merged. To iterate a different suite, change `testfilter` below.
9+
# =============================================================================
10+
311
on:
412
pull_request:
513
branches: [main, release/**]
@@ -21,125 +29,8 @@ defaults:
2129
shell: bash
2230

2331
jobs:
24-
ERC20Contract:
25-
name: ERC20 Contract Test Suite
26-
uses: ./.github/workflows/test-workflow.yml
27-
with:
28-
testfilter: ERC20
29-
3032
ERC721Contract:
3133
name: ERC721 Contract Test Suite
3234
uses: ./.github/workflows/test-workflow.yml
3335
with:
3436
testfilter: ERC721
35-
36-
TokenCreateContract:
37-
name: Token Create Test Suite
38-
uses: ./.github/workflows/test-workflow.yml
39-
with:
40-
testfilter: TokenCreateContract
41-
42-
TokenQueryContract:
43-
name: Token Query Test Suite
44-
uses: ./.github/workflows/test-workflow.yml
45-
with:
46-
testfilter: TokenQueryContract
47-
48-
TokenManagmentContract:
49-
name: Token Managment Test Suite
50-
uses: ./.github/workflows/test-workflow.yml
51-
with:
52-
testfilter: TokenManagmentContract
53-
54-
TokenTransferContract:
55-
name: Token Transfer Test Suite
56-
uses: ./.github/workflows/test-workflow.yml
57-
with:
58-
testfilter: TokenTransferContract
59-
60-
HIP755:
61-
name: HIP755 Test Suite
62-
uses: ./.github/workflows/test-workflow.yml
63-
with:
64-
testfilter: HIP755
65-
66-
HIP1215:
67-
name: HIP1215 Test Suite
68-
uses: ./.github/workflows/test-workflow.yml
69-
with:
70-
testfilter: HIP1215
71-
72-
HRC:
73-
name: HRC Test Suite
74-
uses: ./.github/workflows/test-workflow.yml
75-
with:
76-
testfilter: HRC
77-
78-
PrngSystemContract:
79-
name: PrngSystemContract Test Suite
80-
uses: ./.github/workflows/test-workflow.yml
81-
with:
82-
testfilter: PrngSystemContract
83-
84-
HederaAccountService:
85-
name: HederaAccountService Test Suite
86-
uses: ./.github/workflows/test-workflow.yml
87-
with:
88-
testfilter: HAS
89-
90-
HIP904Batch1:
91-
name: HIP904 Contract Test Suite Batch 1
92-
uses: ./.github/workflows/test-workflow.yml
93-
with:
94-
testfilter: HIP904Batch1
95-
96-
HIP904Batch2:
97-
name: HIP904 Contract Test Suite Batch 2
98-
uses: ./.github/workflows/test-workflow.yml
99-
with:
100-
testfilter: HIP904Batch2
101-
102-
HIP904Batch3:
103-
name: HIP904 Contract Test Suite Batch 3
104-
uses: ./.github/workflows/test-workflow.yml
105-
with:
106-
testfilter: HIP904Batch3
107-
108-
PublishResults:
109-
name: Publish Results
110-
if: ${{ !cancelled() }}
111-
needs:
112-
- ERC20Contract
113-
- ERC721Contract
114-
- TokenCreateContract
115-
- TokenQueryContract
116-
- TokenManagmentContract
117-
- TokenTransferContract
118-
- HIP755
119-
- HIP1215
120-
- HRC
121-
- PrngSystemContract
122-
- HederaAccountService
123-
- HIP904Batch1
124-
- HIP904Batch2
125-
- HIP904Batch3
126-
127-
runs-on: hl-contr-lin-md
128-
steps:
129-
- name: Harden Runner
130-
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
131-
with:
132-
egress-policy: audit
133-
134-
- name: Download Test Reports
135-
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
136-
with:
137-
pattern: Test Results (*)
138-
merge-multiple: true
139-
140-
- name: Publish Test Report
141-
uses: step-security/publish-unit-test-result-action@681100d67b09305624c089873f12c545ee7cbc24 # v2.23.0
142-
with:
143-
check_name: Test Results
144-
json_thousands_separator: ','
145-
junit_files: 'test-*.xml'

test/token-service/erc-721/ERC721Contract.js

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,63 +9,75 @@ import utils from '../utils';
99

1010
describe('ERC721Contract Test Suite', function () {
1111
let tokenCreateContract;
12-
let tokenTransferContract;
1312
let tokenAddress;
1413
let erc721Contract;
1514
let mintedTokenSerialNumber;
1615
let nftInitialOwnerAddress;
1716
let signers, firstWallet, secondWallet;
1817

1918
before(async function () {
19+
this.timeout(180000); // [diag] bound the hook so a hang flushes instead of eating the 45m job cap
20+
const step = async (label, fn) => {
21+
console.log('[diag] erc721c: ' + label);
22+
try {
23+
return await fn();
24+
} catch (err) {
25+
utils.logRelayError('erc721c:' + label, err);
26+
throw err;
27+
}
28+
};
2029
signers = await ethers.getSigners();
21-
tokenCreateContract = await utils.deployTokenCreateContract();
22-
tokenTransferContract = await utils.deployTokenTransferContract();
23-
await hapi.updateAccountKeys([
24-
await tokenCreateContract.getAddress(),
25-
await tokenTransferContract.getAddress(),
26-
]);
27-
erc721Contract = await utils.deployERC721Contract();
28-
tokenAddress = await utils.createNonFungibleToken(
29-
tokenCreateContract,
30-
signers[0].address,
30+
firstWallet = signers[0];
31+
secondWallet = signers[1];
32+
tokenCreateContract = await step('deployTokenCreateContract', () =>
33+
utils.deployTokenCreateContract(),
3134
);
32-
await hapi.updateTokenKeys(tokenAddress, [
33-
await tokenCreateContract.getAddress(),
34-
await tokenTransferContract.getAddress(),
35-
]);
36-
mintedTokenSerialNumber = await utils.mintNFT(
37-
tokenCreateContract,
38-
tokenAddress,
35+
erc721Contract = await step('deployERC721Contract', () =>
36+
utils.deployERC721Contract(),
3937
);
40-
await utils.associateToken(
41-
tokenCreateContract,
42-
tokenAddress,
43-
Constants.Contract.TokenCreateContract,
38+
const erc721Addr = await erc721Contract.getAddress();
39+
// Relay model: no account re-keying. The token is precompile-created (so the
40+
// contract can read its ERC721 facade) with firstWallet — the tx sender — as
41+
// treasury, which its own signature authorizes, and the NFT is minted
42+
// straight to it. So no re-key and no separate transfer to seed ownership.
43+
tokenAddress = await step('createNonFungibleToken', () =>
44+
utils.createNonFungibleToken(tokenCreateContract, firstWallet.address),
4445
);
45-
await utils.grantTokenKyc(tokenCreateContract, tokenAddress);
46-
firstWallet = signers[0];
47-
secondWallet = signers[1];
48-
49-
await tokenCreateContract.associateTokenPublic(
50-
await erc721Contract.getAddress(),
51-
tokenAddress,
52-
Constants.GAS_LIMIT_1_000_000,
46+
mintedTokenSerialNumber = await step('mintNFT', () =>
47+
utils.mintNFT(tokenCreateContract, tokenAddress),
5348
);
54-
55-
await tokenCreateContract.grantTokenKycPublic(
56-
tokenAddress,
57-
await erc721Contract.getAddress(),
58-
Constants.GAS_LIMIT_1_000_000,
49+
// Receivers must be associated + KYC-granted (treasury firstWallet is
50+
// exempt). secondWallet self-associates with its own key; the contract holds
51+
// the inherited KYC key so it grants KYC without the target signing.
52+
await step('associate secondWallet', () =>
53+
hapi.associateWithSigner(
54+
utils.getHardhatSignerPrivateKeyByIndex(1),
55+
tokenAddress,
56+
),
5957
);
60-
61-
await tokenTransferContract.transferNFTPublic(
62-
tokenAddress,
63-
await tokenCreateContract.getAddress(),
64-
signers[0].address,
65-
mintedTokenSerialNumber,
66-
Constants.GAS_LIMIT_1_000_000,
58+
await step('grantKyc secondWallet', () =>
59+
tokenCreateContract.grantTokenKycPublic(
60+
tokenAddress,
61+
secondWallet.address,
62+
Constants.GAS_LIMIT_1_000_000,
63+
),
64+
);
65+
await step('associate erc721Contract', () =>
66+
tokenCreateContract.associateTokenPublic(
67+
erc721Addr,
68+
tokenAddress,
69+
Constants.GAS_LIMIT_1_000_000,
70+
),
6771
);
68-
nftInitialOwnerAddress = signers[0].address;
72+
await step('grantKyc erc721Contract', () =>
73+
tokenCreateContract.grantTokenKycPublic(
74+
tokenAddress,
75+
erc721Addr,
76+
Constants.GAS_LIMIT_1_000_000,
77+
),
78+
);
79+
nftInitialOwnerAddress = firstWallet.address;
80+
console.log('[diag] erc721c: before DONE');
6981
});
7082

7183
after(function () {
@@ -225,16 +237,10 @@ describe('ERC721Contract Test Suite', function () {
225237
let serialNumber;
226238

227239
before(async function () {
240+
// Minted straight to the treasury (firstWallet), so no transfer needed.
228241
serialNumber = await utils.mintNFT(tokenCreateContract, tokenAddress, [
229242
'0x02',
230243
]);
231-
await tokenTransferContract.transferNFTPublic(
232-
tokenAddress,
233-
await tokenCreateContract.getAddress(),
234-
signers[0].address,
235-
serialNumber,
236-
Constants.GAS_LIMIT_1_000_000,
237-
);
238244
});
239245

240246
it('should NOT be able to execute approve', async function () {

0 commit comments

Comments
 (0)