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

Check for Blocks before Contract Start and Adding Format Script #108

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

amessbee
Copy link
Contributor

@amessbee amessbee commented Jan 1, 2025

potentially closes: #27

@amessbee amessbee self-assigned this Jan 1, 2025
@amessbee amessbee force-pushed the ms/check-chain-status-before-contract-start branch from aecdd7c to e8a1e17 Compare January 3, 2025 14:57
@amessbee amessbee marked this pull request as ready for review January 7, 2025 05:10
@amessbee amessbee force-pushed the ms/check-chain-status-before-contract-start branch from e8a1e17 to e5904f6 Compare January 8, 2025 08:13
@amessbee amessbee requested a review from dckc January 8, 2025 08:26
@amessbee
Copy link
Contributor Author

amessbee commented Jan 8, 2025

@dckc does this work to fix #27 ?

.gitignore Outdated
@@ -39,3 +39,4 @@ videos

# contract tx
contract/,tx.json
contract/start-offer-up-plan.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive-by? put it in a separate commit, perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes :) - sure, will do.

local required_patterns=3 # Number of block patterns we want to see

while IFS= read -r line; do
echo "$line" # Show the log output
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider showing just 1 dot (.) instead

if [[ $line =~ "block-manager: block "[0-9]+" commit" ]]; then
((count++))
if [ $count -ge $required_patterns ]; then
return 0 # Success
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps show the whole line at this point; i.e. give evidence in the form of a timestamp and block number that things are running.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so rather than 150 lines of agd output in the ci log we would see...

Run yarn start:contract
Waiting for blockchain to start........(~150 dots)...
agd-1  | 2025-01-08T08:20:28.543Z block-manager: block 1227 commit
Blockchain is running and producing blocks...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@amessbee amessbee requested a review from dckc January 9, 2025 06:20
Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like the dots all on the same line.

I suppose it's not critical, though.

contract/scripts/wait-for-chain.sh Outdated Show resolved Hide resolved
contract/scripts/wait-for-chain.sh Show resolved Hide resolved
@amessbee amessbee force-pushed the ms/check-chain-status-before-contract-start branch from 15c610a to 60b9b18 Compare January 9, 2025 10:56
@amessbee amessbee merged commit f551a3e into main Jan 9, 2025
3 checks passed
@amessbee amessbee deleted the ms/check-chain-status-before-contract-start branch January 9, 2025 11:39
@dckc
Copy link
Member

dckc commented Jan 9, 2025

yay! much nicer DX!

Run yarn start:contract
Waiting for blockchain to start...
..............................................................................................
agd-1  | 2025-01-09T11:03:[4](https://github.com/Agoric/dapp-offer-up/actions/runs/12688514812/job/35365216310#step:8:5)5.545Z block-manager: block 1227 commit
Blockchain is running and producing blocks...

-- ci log

echo "Blockchain is running and producing blocks..."
exit 0
else
echo "Failed to detect blockchain activity\n Run yarn start:docker to start the blockchain first!"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops... I should have checked this part; it doesn't seem to work for me. If I do yarn start:contract before yarn start:docker, I get:

$ yarn start:contract
Waiting for blockchain to start...
............
agd-1  | 2024-12-13T14:50:03.351Z block-manager: block 44932 commit
Blockchain is running and producing blocks...
service "agd" is not running

maybe that won't affect 1st time users
perhaps it's because I have stuff in my docker logs from an earlier run

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work fine for me:

Waiting for blockchain to start...
Failed to detect blockchain activity\n Run yarn start:docker to start the blockchain first!

Although newline character is not treated as such due to missing -e I suppose. If I am going create a PR just for -e, I am going treat myself with red color added to the above line too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test that the chain is available before using it
2 participants