-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into candidate-peers
- Loading branch information
Showing
23 changed files
with
367 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ jobs: | |
timeout-minutes: 35 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache Cargo Registry and Target Directory | ||
uses: actions/[email protected] | ||
|
@@ -46,10 +46,10 @@ jobs: | |
run: sudo apt-get install -y protobuf-compiler | ||
|
||
- name: Set up Just | ||
uses: extractions/setup-just@v1 | ||
uses: extractions/setup-just@v2 | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v3 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: .tool-versions | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache Cargo Registry and Target Directory | ||
uses: actions/[email protected] | ||
|
@@ -56,7 +56,7 @@ jobs: | |
run: sudo apt-get install -y protobuf-compiler | ||
|
||
- name: Set up Just | ||
uses: extractions/setup-just@v1 | ||
uses: extractions/setup-just@v2 | ||
|
||
- name: Set up Test Dependencies | ||
if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache Cargo Registry and Target Directory | ||
uses: actions/[email protected] | ||
|
@@ -51,7 +51,7 @@ jobs: | |
run: sudo apt-get install -y protobuf-compiler | ||
|
||
- name: Set up Just | ||
uses: extractions/setup-just@v1 | ||
uses: extractions/setup-just@v2 | ||
|
||
- name: Test docs | ||
run: just test-doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache Cargo Registry and Target Directory | ||
uses: actions/[email protected] | ||
|
@@ -49,7 +49,7 @@ jobs: | |
run: sudo apt-get install -y protobuf-compiler | ||
|
||
- name: Set up Just | ||
uses: extractions/setup-just@v1 | ||
uses: extractions/setup-just@v2 | ||
|
||
- name: Generate docs | ||
run: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache Cargo Registry and Target Directory | ||
uses: actions/[email protected] | ||
|
@@ -63,10 +63,10 @@ jobs: | |
run: sudo apt-get install -y protobuf-compiler | ||
|
||
- name: Set up Just | ||
uses: extractions/setup-just@v1 | ||
uses: extractions/setup-just@v2 | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v3 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: .tool-versions | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache Cargo Registry and Target Directory | ||
uses: actions/[email protected] | ||
|
@@ -63,10 +63,10 @@ jobs: | |
run: sudo apt-get install -y protobuf-compiler | ||
|
||
- name: Set up Just | ||
uses: extractions/setup-just@v1 | ||
uses: extractions/setup-just@v2 | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v3 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: .tool-versions | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache Cargo Registry and Target Directory | ||
uses: actions/[email protected] | ||
|
@@ -63,10 +63,10 @@ jobs: | |
run: sudo apt-get install -y protobuf-compiler | ||
|
||
- name: Set up Just | ||
uses: extractions/setup-just@v1 | ||
uses: extractions/setup-just@v2 | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v3 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: .tool-versions | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache Cargo Registry and Target Directory | ||
uses: actions/[email protected] | ||
|
@@ -59,7 +59,7 @@ jobs: | |
run: sudo apt-get install -y protobuf-compiler | ||
|
||
- name: Set up Just | ||
uses: extractions/setup-just@v1 | ||
uses: extractions/setup-just@v2 | ||
|
||
- name: Integration tests | ||
run: just test-int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache Cargo Registry and Target Directory | ||
uses: actions/[email protected] | ||
|
@@ -57,7 +57,7 @@ jobs: | |
run: sudo apt-get install -y protobuf-compiler | ||
|
||
- name: Set up Just | ||
uses: extractions/setup-just@v1 | ||
uses: extractions/setup-just@v2 | ||
|
||
- name: Just lint-check | ||
run: just lint-check -2024-01-01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache Cargo Registry and Target Directory | ||
uses: actions/[email protected] | ||
|
@@ -58,7 +58,7 @@ jobs: | |
run: sudo apt-get install -y protobuf-compiler | ||
|
||
- name: Set up Just | ||
uses: extractions/setup-just@v1 | ||
uses: extractions/setup-just@v2 | ||
|
||
- name: Unit tests | ||
run: just test-unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
contract TestContractDenseStorage { | ||
|
||
struct Record { | ||
uint16 field16; | ||
uint16 reserve; | ||
uint32 field32; | ||
uint64 field64; | ||
uint128 field128; | ||
} | ||
|
||
mapping(address => Record) public records; | ||
|
||
/// @dev Changes fields of the record for an account. | ||
/// @param changeOfField16 The value to change of the appropriate fields of the record. | ||
/// @param changeOfField32 The value to change of the appropriate fields of the record. | ||
/// @param changeOfField64 The value to change of the appropriate fields of the record. | ||
/// @param changeOfField128 The value to change of the appropriate fields of the record. | ||
function change( | ||
address account, | ||
int256 changeOfField16, | ||
int256 changeOfField32, | ||
int256 changeOfField64, | ||
int256 changeOfField128 | ||
) public { | ||
Record storage record = records[account]; | ||
|
||
record.field16 = uint16(uint256(int256(uint256(record.field16)) + changeOfField16)); | ||
record.field32 = uint32(uint256(int256(uint256(record.field32)) + changeOfField32)); | ||
record.field64 = uint64(uint256(int256(uint256(record.field64)) + changeOfField64)); | ||
record.field128 = uint128(uint256(int256(uint256(record.field128)) + changeOfField128)); | ||
} | ||
|
||
/// @dev Sets the exact field values of the record for an an account. | ||
/// @param newRecord The new content of the record for the account. | ||
function set(address account, Record calldata newRecord) public { | ||
records[account] = newRecord; | ||
} | ||
|
||
/// @dev Gets the record of an account. | ||
/// @return The record of the account. | ||
function get(address account) public view returns (Record memory) { | ||
return records[account]; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
e2e/test/automine/e2e-tx-parallel-contract-dense-storage.abm.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Account, ALICE, BOB, randomAccounts } from "../helpers/account"; | ||
import { deployTestContractDenseStorage, sendRawTransactions, } from "../helpers/rpc"; | ||
import { | ||
AccountRecord, | ||
applyRecordChange, | ||
compareRecords, | ||
defineRecordChange, | ||
initialRecord, | ||
inverseRecordChange, | ||
prepareSignedTxOfRecordChange | ||
} from "../helpers/contract-dense-storage"; | ||
|
||
describe("Transaction: parallel for the 'TestContractDenseStorage' contract", async () => { | ||
it("Parallel transactions execute properly when no reverts are expected", async () => { | ||
const contract = await deployTestContractDenseStorage(); | ||
|
||
const expectedRecords: Record<string, AccountRecord> = {}; | ||
expectedRecords[ALICE.address] = { ...initialRecord }; | ||
expectedRecords[BOB.address] = { ...initialRecord }; | ||
|
||
// Set initial records | ||
await contract.set(ALICE.address, expectedRecords[ALICE.address]); | ||
await contract.set(BOB.address, expectedRecords[BOB.address]); | ||
|
||
|
||
// Prepare a pair of transactions: one for Alice and another for Bob | ||
const txCountPerUser = 32; | ||
const senders: Account[] = randomAccounts(txCountPerUser * 2); | ||
const signedTxs: string[] = []; | ||
for (let txIndexPerUser = 0; txIndexPerUser < txCountPerUser; ++txIndexPerUser) { | ||
const recordChange1 = defineRecordChange(txIndexPerUser); | ||
const recordChange2 = inverseRecordChange(recordChange1); | ||
applyRecordChange(expectedRecords[ALICE.address], recordChange1); | ||
applyRecordChange(expectedRecords[BOB.address], recordChange2); | ||
|
||
const sender1 = senders[txIndexPerUser * 2]; | ||
const sender2 = senders[txIndexPerUser * 2 + 1]; | ||
const signTx1: string = await prepareSignedTxOfRecordChange(contract, sender1, ALICE, recordChange1); | ||
const signTx2: string = await prepareSignedTxOfRecordChange(contract, sender2, BOB, recordChange2); | ||
|
||
signedTxs.push(signTx1); | ||
signedTxs.push(signTx2); | ||
} | ||
|
||
// Send transactions in parallel | ||
await sendRawTransactions(signedTxs); | ||
|
||
// Verify | ||
compareRecords(await contract.get(ALICE.address), expectedRecords[ALICE.address]); | ||
compareRecords(await contract.get(BOB.address), expectedRecords[BOB.address]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.