Skip to content

Blockscout integration #2511

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

Merged
merged 12 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from 10 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
37 changes: 22 additions & 15 deletions toolbox/src/toolbox/Nodes/AvalanchegoDocker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import { RadioGroup } from "../../components/RadioGroup";
import { Success } from "../../components/Success";


const debugConfigBase64 = (chainId: string) => {
const debugConfig = {
export const nodeConfigBase64 = (chainId: string, debugEnabled: boolean, pruningEnabled: boolean) => {
const vmConfig = debugEnabled ? {
"pruning-enabled": pruningEnabled,
"log-level": "debug",
"warp-api-enabled": true,
"eth-apis": [
Expand All @@ -42,21 +43,21 @@ const debugConfigBase64 = (chainId: string) => {
"debug-file-tracer",
"debug-handler"
]
} : {
"pruning-enabled": pruningEnabled,
}

// First encode the inner config object
const debugConfigEncoded = btoa(JSON.stringify(debugConfig));
const vmConfigEncoded = btoa(JSON.stringify(vmConfig));

const configMap: Record<string, { Config: string, Upgrade: any }> = {}
configMap[chainId] = { Config: debugConfigEncoded, Upgrade: null }

console.log('configMap', configMap);
configMap[chainId] = { Config: vmConfigEncoded, Upgrade: null }

return btoa(JSON.stringify(configMap))
}


const generateDockerCommand = (subnets: string[], isRPC: boolean, networkID: number, debugChainId?: string) => {
const generateDockerCommand = (subnets: string[], isRPC: boolean, networkID: number, chainId: string, debugEnabled: boolean = false, pruningEnabled: boolean = false) => {
const env: Record<string, string> = {
AVAGO_PARTIAL_SYNC_PRIMARY_NETWORK: "true",
AVAGO_PUBLIC_IP_RESOLUTION_SERVICE: "opendns",
Expand All @@ -80,9 +81,7 @@ const generateDockerCommand = (subnets: string[], isRPC: boolean, networkID: num
env.AVAGO_HTTP_ALLOWED_HOSTS = "\"*\"";
}

if (debugChainId) {
env.AVAGO_CHAIN_CONFIG_CONTENT = debugConfigBase64(debugChainId);
}
env.AVAGO_CHAIN_CONFIG_CONTENT = nodeConfigBase64(chainId, debugEnabled, pruningEnabled);

const chunks = [
"docker run -it -d",
Expand Down Expand Up @@ -135,7 +134,7 @@ ${domain}/ext/bc/${chainID}/rpc`
}
}

const dockerInstallInstructions: Record<string, string> = {
export const dockerInstallInstructions: Record<string, string> = {
'Ubuntu/Debian': `sudo apt-get update && \\
sudo apt-get install -y docker.io && \\
sudo usermod -aG docker $USER && \\
Expand Down Expand Up @@ -164,7 +163,7 @@ docker run -it --rm hello-world
`,
} as const;

type OS = keyof typeof dockerInstallInstructions;
export type OS = keyof typeof dockerInstallInstructions;

export default function AvalanchegoDocker() {
const [chainId, setChainId] = useState("");
Expand All @@ -174,20 +173,21 @@ export default function AvalanchegoDocker() {
const [nodeRunningMode, setNodeRunningMode] = useState("server");
const [domain, setDomain] = useState("");
const [enableDebugTrace, setEnableDebugTrace] = useState<boolean>(false);
const [pruningEnabled, setPruningEnabled] = useState<boolean>(true);
const [subnetIdError, setSubnetIdError] = useState<string | null>(null);
const [isAddChainModalOpen, setIsAddChainModalOpen] = useState<boolean>(false);
const [chainAddedToWallet, setChainAddedToWallet] = useState<string | null>(null);

const { avalancheNetworkID } = useWalletStore();
const { addL1 } = useL1ListStore()();

useEffect(() => {
try {
setRpcCommand(generateDockerCommand([subnetId], isRPC, avalancheNetworkID, enableDebugTrace ? chainId : undefined));
setRpcCommand(generateDockerCommand([subnetId], isRPC, avalancheNetworkID, chainId, enableDebugTrace, pruningEnabled));
} catch (error) {
setRpcCommand((error as Error).message);
}
}, [subnetId, isRPC, avalancheNetworkID, enableDebugTrace, chainId]);
}, [subnetId, isRPC, avalancheNetworkID, enableDebugTrace, chainId, pruningEnabled]);

useEffect(() => {
if (!isRPC) {
Expand Down Expand Up @@ -217,6 +217,7 @@ export default function AvalanchegoDocker() {
setNodeRunningMode("server");
setDomain("");
setEnableDebugTrace(false);
setPruningEnabled(true);
setSubnetIdError(null);
setIsAddChainModalOpen(false);
};
Expand Down Expand Up @@ -315,6 +316,12 @@ export default function AvalanchegoDocker() {
checked={enableDebugTrace}
onChange={setEnableDebugTrace}
/>}

{isRPC && <Checkbox
label="Enable Archive Mode (pruning will be disabled)"
checked={!pruningEnabled}
onChange={checked => setPruningEnabled(!checked)}
/>}
</Step>
{nodeRunningMode === "server" && (<Step>
<h3 className="text-xl font-bold mb-4">Port Configuration</h3>
Expand Down
Loading