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

fix: debug eviction issue #254

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 19 additions & 0 deletions frontend/components/Main/MainHeader/AgentButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ const AgentNotRunningButton = () => {
// Must have a wallet to start the agent
if (!wallets?.[0]) return;

console.log(wallets);

// Paused to stop overlapping service poll while wallet is created or service is built
setIsServicePollingPaused(true);

Expand All @@ -122,6 +124,8 @@ const AgentNotRunningButton = () => {
// Mock "DEPLOYING" status (service polling will update this once resumed)
setServiceStatus(DeploymentStatus.DEPLOYING);

console.log('before master safe: ', masterSafeAddress);

// Create master safe if it doesn't exist
try {
if (!masterSafeAddress) {
Expand All @@ -136,6 +140,7 @@ const AgentNotRunningButton = () => {
return;
}

console.log('before create / deploy: ');
// Then create / deploy the service
try {
await ServicesService.createService({
Expand All @@ -151,6 +156,7 @@ const AgentNotRunningButton = () => {
return;
}

console.log('before minimum staked amount required: ');
// Show success notification based on whether there was a service prior to starting
try {
if (!service) {
Expand All @@ -168,6 +174,8 @@ const AgentNotRunningButton = () => {
showNotification?.('Error while showing "running" notification');
}

console.log('before setting services ');

// Can assume successful deployment
// resume polling, optimistically update service status (poll will update, if needed)
setIsServicePollingPaused(false);
Expand Down Expand Up @@ -196,6 +204,8 @@ const AgentNotRunningButton = () => {
return safeOlasBalanceWithStaked >= requiredOlas;
}

console.log({ isEligibleForStaking, isAgentEvicted });

// case if agent is evicted and user has met the staking criteria
if (isEligibleForStaking && isAgentEvicted) return true;

Expand Down Expand Up @@ -258,6 +268,15 @@ export const AgentButton = () => {
return <AgentNotRunningButton />;
}

console.log('inside useMemo for start button');
console.log({
hasInitialLoaded,
serviceStatus,
isEligibleForStaking,
isAgentEvicted,
service,
});

return (
<Button type="primary" size="large" disabled>
Error, contact us!
Expand Down
12 changes: 10 additions & 2 deletions frontend/context/ServicesProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,16 @@ export const ServicesProvider = ({ children }: PropsWithChildren) => {

const updateServiceStatus = useCallback(async () => {
if (!services?.[0]) return;
const serviceStatus = await ServicesService.getDeployment(services[0].hash);
setServiceStatus(serviceStatus.status);
try {
const serviceStatus = await ServicesService.getDeployment(
services[0].hash,
);
setServiceStatus(serviceStatus.status);
} catch (e) {
message.error(
'Service status could not be deployed, please contact support',
);
}
}, [services]);

// Update service state
Expand Down
7 changes: 7 additions & 0 deletions frontend/hooks/useStakingContractInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ export const useStakingContractInfo = () => {
hasEnoughRewardsAndSlots &&
(isAgentEvicted ? isServiceStakedForMinimumDuration : true);

console.log({
serviceStakingStartTime,
minimumStakingDuration,
isEligibleForStaking,
isAgentEvicted,
});

return {
hasEnoughServiceSlots,
isEligibleForStaking,
Expand Down
2 changes: 2 additions & 0 deletions frontend/service/Autonolas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ const getStakingContractInfo = async (
): Promise<StakingContractInfo | undefined> => {
if (!serviceId) return;

console.log('serviceId: ', serviceId);

const contractCalls = [
serviceStakingTokenMechUsageContract.availableRewards(),
serviceStakingTokenMechUsageContract.maxNumServices(),
Expand Down
Loading