Skip to content

David/staging2 #570

New issue

Have a question about this project? Sign up for a free account to open an issue and contact its maintainers and the community.

By clicking “Sign up for ”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on ? Sign in to your account

Merged
merged 8 commits into from
Mar 17, 2022
Merged
Changes from 1 commit
Commits
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
PrevPrevious commit
Merge branch 'master' into david/staging2
  • Loading branch information
@druiz0992
druiz0992 authoredMar 14, 2022
commit ab26bd3e1bcff6e2824fad060ff28c3dfb5d366b
40 changes: 26 additions & 14 deletions nightfall-optimist/src/services/block-assembler.mjs
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,18 +73,30 @@ export async function conditionalMakeBlock(proposer) {
// transaction. If not, we must wait until either we have enough (hooray)
// or we're no-longer the proposer (boo).
if (proposer.isMe) {
if ((await numberOfUnprocessedTransactions()) >= TRANSACTIONS_PER_BLOCK) {
const { block, transactions } = await makeBlock(proposer.address);
logger.info(`Block Assembler - New Block created, ${JSON.stringify(block, null, 2)}`);
// propose this block to the Shield contract here
const unsignedProposeBlockTransaction = await (
await waitForContract(STATE_CONTRACT_NAME)
).methods
.proposeBlock(
Block.buildSolidityStruct(block),
transactions.map(t => Transaction.buildSolidityStruct(t)),
)
.encodeABI();
const unprocessedTransactions = await numberOfUnprocessedTransactions();
if (unprocessedTransactions >= TRANSACTIONS_PER_BLOCK) {
const { blockList, transactionsList } = await makeBlock(
proposer.address,
unprocessedTransactions,
);

const unsignedProposeBlockTransactionList = [];

for (let i = 0; i < blockList.length; i++) {
const block = blockList[i];
const transactions = transactionsList[i];
logger.info(`Block Assembler - New Block created, ${JSON.stringify(block, null, 2)}`);
// propose this block to the Shield contract here
const unsignedProposeBlockTransaction = await (
await waitForContract(STATE_CONTRACT_NAME)
).methods
.proposeBlock(
Block.buildSolidityStruct(block),
transactions.map(t => Transaction.buildSolidityStruct(t)),
)
.encodeABI();
unsignedProposeBlockTransactionList.push(unsignedProposeBlockTransaction);
}
// TODO - check ws readyState is OPEN => CLOSED .WebSocket.OPEN(1), CONNECTING(0), CLOSING(2), CLOSED(3)
// before sending Poposed block. If not Open, try to open it
if (ws) {
Expand All@@ -96,9 +108,9 @@ export async function conditionalMakeBlock(proposer) {
transactionsList,
}),
);
logger.debug('Send unsigned block-assembler transaction to ws client');
logger.debug('Send unsigned block-assembler transactions to ws client');
}
// remove the transactiosn from the mempool so we don't keep making new
// remove the transactions from the mempool so we don't keep making new
// blocks with them
const transactionHashes = blockList.reduce(
(transactionHashList, block) => transactionHashList.concat(block.transactionHashes),
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.