[BUG] Failed to retrieve the stamp contract status from arweave.net. #419
This commit is contained in:
@@ -22,7 +22,8 @@ export const WARP_TAGS = {
|
|||||||
SEQUENCER_OWNER: 'Sequencer-Owner',
|
SEQUENCER_OWNER: 'Sequencer-Owner',
|
||||||
SEQUENCER_MILLIS: 'Sequencer-Mills',
|
SEQUENCER_MILLIS: 'Sequencer-Mills',
|
||||||
SEQUENCER_SORT_KEY: 'Sequencer-Sort-Key',
|
SEQUENCER_SORT_KEY: 'Sequencer-Sort-Key',
|
||||||
SEQUENCER_LAST_SORT_KEY: 'Sequencer-Last-Sort-Key',
|
SEQUENCER_PREV_SORT_KEY: 'Sequencer-Prev-Sort-Key',
|
||||||
|
SEQUENCER_LAST_SORT_KEY: 'Sequencer-Last-Sort-Key', // deprecated
|
||||||
SEQUENCER_TX_ID: 'Sequencer-Tx-Id',
|
SEQUENCER_TX_ID: 'Sequencer-Tx-Id',
|
||||||
SEQUENCER_BLOCK_HEIGHT: 'Sequencer-Block-Height',
|
SEQUENCER_BLOCK_HEIGHT: 'Sequencer-Block-Height',
|
||||||
SEQUENCER_BLOCK_ID: 'Sequencer-Block-Id',
|
SEQUENCER_BLOCK_ID: 'Sequencer-Block-Id',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Arweave from 'arweave';
|
import Arweave from 'arweave';
|
||||||
import { SMART_WEAVE_TAGS } from '../../KnownTags';
|
import { SMART_WEAVE_TAGS, WARP_TAGS, WarpTags } from '../../KnownTags';
|
||||||
import { GQLEdgeInterface, GQLNodeInterface } from '../../../legacy/gqlResult';
|
import { GQLEdgeInterface, GQLNodeInterface } from '../../../legacy/gqlResult';
|
||||||
import { Benchmark } from '../../../logging/Benchmark';
|
import { Benchmark } from '../../../logging/Benchmark';
|
||||||
import { LoggerFactory } from '../../../logging/LoggerFactory';
|
import { LoggerFactory } from '../../../logging/LoggerFactory';
|
||||||
@@ -7,11 +7,10 @@ import { ArweaveWrapper } from '../../../utils/ArweaveWrapper';
|
|||||||
import { GW_TYPE, InteractionsLoader } from '../InteractionsLoader';
|
import { GW_TYPE, InteractionsLoader } from '../InteractionsLoader';
|
||||||
import { InteractionsSorter } from '../InteractionsSorter';
|
import { InteractionsSorter } from '../InteractionsSorter';
|
||||||
import { EvaluationOptions } from '../StateEvaluator';
|
import { EvaluationOptions } from '../StateEvaluator';
|
||||||
import { LexicographicalInteractionsSorter } from './LexicographicalInteractionsSorter';
|
import { defaultArweaveMs, LexicographicalInteractionsSorter } from './LexicographicalInteractionsSorter';
|
||||||
import { Warp, WarpEnvironment } from '../../Warp';
|
import { Warp, WarpEnvironment } from '../../Warp';
|
||||||
import { Tag } from 'utils/types/arweave-types';
|
import { Tag } from 'utils/types/arweave-types';
|
||||||
import { ArweaveGQLTxsFetcher } from './ArweaveGQLTxsFetcher';
|
import { ArweaveGQLTxsFetcher } from './ArweaveGQLTxsFetcher';
|
||||||
import { WarpTags, WARP_TAGS } from '../../KnownTags';
|
|
||||||
import { safeParseInt } from '../../../utils/utils';
|
import { safeParseInt } from '../../../utils/utils';
|
||||||
import { VrfPluginFunctions, WarpPlugin } from '../../WarpPlugin';
|
import { VrfPluginFunctions, WarpPlugin } from '../../WarpPlugin';
|
||||||
import { TagsParser } from './TagsParser';
|
import { TagsParser } from './TagsParser';
|
||||||
@@ -40,6 +39,9 @@ export interface GqlReqVariables {
|
|||||||
after?: string;
|
after?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// a height from which the last sort key value is being set by the sequencer
|
||||||
|
const LAST_SORT_KEY_MIN_HEIGHT = 1057409;
|
||||||
|
|
||||||
export class ArweaveGatewayBundledInteractionLoader implements InteractionsLoader {
|
export class ArweaveGatewayBundledInteractionLoader implements InteractionsLoader {
|
||||||
private readonly logger = LoggerFactory.INST.create(ArweaveGatewayBundledInteractionLoader.name);
|
private readonly logger = LoggerFactory.INST.create(ArweaveGatewayBundledInteractionLoader.name);
|
||||||
|
|
||||||
@@ -73,6 +75,10 @@ export class ArweaveGatewayBundledInteractionLoader implements InteractionsLoade
|
|||||||
{
|
{
|
||||||
name: SMART_WEAVE_TAGS.CONTRACT_TX_ID,
|
name: SMART_WEAVE_TAGS.CONTRACT_TX_ID,
|
||||||
values: [contractId]
|
values: [contractId]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: WARP_TAGS.SEQUENCER,
|
||||||
|
values: ['RedStone']
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
blockFilter: {
|
blockFilter: {
|
||||||
@@ -131,8 +137,21 @@ export class ArweaveGatewayBundledInteractionLoader implements InteractionsLoade
|
|||||||
const prevInteraction = allInteractions[index - 1];
|
const prevInteraction = allInteractions[index - 1];
|
||||||
const nextInteraction = allInteractions[index];
|
const nextInteraction = allInteractions[index];
|
||||||
|
|
||||||
if (prevInteraction.node.sortKey !== nextInteraction.node.lastSortKey) {
|
this.logger.debug(`prev: ${prevInteraction.node.id} | current: ${nextInteraction.node.id}`);
|
||||||
throw Error(
|
|
||||||
|
if (nextInteraction.node.block.height <= LAST_SORT_KEY_MIN_HEIGHT) {
|
||||||
|
return interaction;
|
||||||
|
}
|
||||||
|
if (nextInteraction.node.lastSortKey?.split(',')[1] === defaultArweaveMs) {
|
||||||
|
// cannot verify this one
|
||||||
|
return interaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
prevInteraction.node.source === 'redstone-sequencer' &&
|
||||||
|
prevInteraction.node.sortKey !== nextInteraction.node.lastSortKey
|
||||||
|
) {
|
||||||
|
this.logger.warn(
|
||||||
`Interaction loading error: interaction ${nextInteraction.node.id} lastSortKey is not pointing on prev interaction ${prevInteraction.node.id}`
|
`Interaction loading error: interaction ${nextInteraction.node.id} lastSortKey is not pointing on prev interaction ${prevInteraction.node.id}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -157,20 +176,26 @@ export class ArweaveGatewayBundledInteractionLoader implements InteractionsLoade
|
|||||||
|
|
||||||
private attachSequencerDataToInteraction(interaction: GQLEdgeInterface): GQLEdgeInterface {
|
private attachSequencerDataToInteraction(interaction: GQLEdgeInterface): GQLEdgeInterface {
|
||||||
const extractTag = (tagName: WarpTags) => interaction.node.tags.find((tag: Tag) => tag.name === tagName)?.value;
|
const extractTag = (tagName: WarpTags) => interaction.node.tags.find((tag: Tag) => tag.name === tagName)?.value;
|
||||||
|
|
||||||
|
const sequencerTxId = extractTag(WARP_TAGS.SEQUENCER_TX_ID);
|
||||||
|
|
||||||
const sequencerOwner = extractTag(WARP_TAGS.SEQUENCER_OWNER);
|
const sequencerOwner = extractTag(WARP_TAGS.SEQUENCER_OWNER);
|
||||||
const sequencerBlockId = extractTag(WARP_TAGS.SEQUENCER_BLOCK_ID);
|
const sequencerBlockId = extractTag(WARP_TAGS.SEQUENCER_BLOCK_ID);
|
||||||
const sequencerBlockHeight = extractTag(WARP_TAGS.SEQUENCER_BLOCK_HEIGHT);
|
const sequencerBlockHeight = extractTag(WARP_TAGS.SEQUENCER_BLOCK_HEIGHT);
|
||||||
const sequencerLastSortKey = extractTag(WARP_TAGS.SEQUENCER_LAST_SORT_KEY);
|
const sequencerLastSortKey =
|
||||||
|
extractTag(WARP_TAGS.SEQUENCER_PREV_SORT_KEY) || extractTag(WARP_TAGS.SEQUENCER_LAST_SORT_KEY);
|
||||||
const sequencerSortKey = extractTag(WARP_TAGS.SEQUENCER_SORT_KEY);
|
const sequencerSortKey = extractTag(WARP_TAGS.SEQUENCER_SORT_KEY);
|
||||||
const sequencerTxId = extractTag(WARP_TAGS.SEQUENCER_TX_ID);
|
|
||||||
// this field was added in sequencer from 15.03.2023
|
// this field was added in sequencer from 15.03.2023
|
||||||
const sequencerBlockTimestamp = extractTag(WARP_TAGS.SEQUENCER_BLOCK_TIMESTAMP);
|
const sequencerBlockTimestamp = extractTag(WARP_TAGS.SEQUENCER_BLOCK_TIMESTAMP);
|
||||||
|
|
||||||
|
const parsedBlockHeight = safeParseInt(sequencerBlockHeight);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!sequencerOwner ||
|
!sequencerOwner ||
|
||||||
!sequencerBlockId ||
|
!sequencerBlockId ||
|
||||||
!sequencerBlockHeight ||
|
!sequencerBlockHeight ||
|
||||||
!sequencerLastSortKey ||
|
// note: old sequencer transactions do not have last sort key set
|
||||||
|
(!sequencerLastSortKey && parsedBlockHeight > LAST_SORT_KEY_MIN_HEIGHT) ||
|
||||||
!sequencerTxId ||
|
!sequencerTxId ||
|
||||||
!sequencerSortKey
|
!sequencerSortKey
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { InteractionsSorter } from '../InteractionsSorter';
|
|||||||
// note: this (i.e. padding to 13 digits) should be safe between years ~1966 and ~2286
|
// note: this (i.e. padding to 13 digits) should be safe between years ~1966 and ~2286
|
||||||
const firstSortKeyMs = ''.padEnd(13, '0');
|
const firstSortKeyMs = ''.padEnd(13, '0');
|
||||||
const lastSortKeyMs = ''.padEnd(13, '9');
|
const lastSortKeyMs = ''.padEnd(13, '9');
|
||||||
const defaultArweaveMs = ''.padEnd(13, '0');
|
export const defaultArweaveMs = ''.padEnd(13, '0');
|
||||||
|
|
||||||
export const sortingFirst = ''.padEnd(64, '0');
|
export const sortingFirst = ''.padEnd(64, '0');
|
||||||
export const sortingLast = ''.padEnd(64, 'z');
|
export const sortingLast = ''.padEnd(64, 'z');
|
||||||
|
|||||||
47
tools/stamp_state.ts
Normal file
47
tools/stamp_state.ts
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
import Arweave from 'arweave';
|
||||||
|
import {
|
||||||
|
ArweaveGatewayBundledContractDefinitionLoader,
|
||||||
|
ArweaveGatewayBundledInteractionLoader,
|
||||||
|
defaultCacheOptions,
|
||||||
|
WarpFactory
|
||||||
|
} from '../src';
|
||||||
|
|
||||||
|
const arweave = Arweave.init({
|
||||||
|
host: 'arweave.net',
|
||||||
|
port: 443,
|
||||||
|
protocol: 'https',
|
||||||
|
timeout: 200000
|
||||||
|
});
|
||||||
|
|
||||||
|
const arContractLoader = new ArweaveGatewayBundledContractDefinitionLoader('mainnet');
|
||||||
|
const arInteractionLoader = new ArweaveGatewayBundledInteractionLoader(arweave, 'mainnet');
|
||||||
|
const contractId = 'TlqASNDLA1Uh8yFiH-BzR_1FDag4s735F3PoUFEv2Mo';
|
||||||
|
const warp = WarpFactory.custom(
|
||||||
|
arweave,
|
||||||
|
{
|
||||||
|
...defaultCacheOptions,
|
||||||
|
inMemory: true
|
||||||
|
},
|
||||||
|
'mainnet'
|
||||||
|
)
|
||||||
|
.useArweaveGateway()
|
||||||
|
.setInteractionsLoader(arInteractionLoader)
|
||||||
|
.setDefinitionLoader(arContractLoader)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
const c = warp.contract(contractId).setEvaluationOptions({
|
||||||
|
allowBigInt: true,
|
||||||
|
unsafeClient: 'skip'
|
||||||
|
});
|
||||||
|
|
||||||
|
async function getState() {
|
||||||
|
try {
|
||||||
|
const { sortKey, cachedValue } = await c.readState();
|
||||||
|
console.log(sortKey, cachedValue.errorMessages, cachedValue.state, cachedValue.validity);
|
||||||
|
} catch (error) {
|
||||||
|
console.log('readState error:', error, 'contractId:', contractId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getState();
|
||||||
14
tools/wallet.js
Normal file
14
tools/wallet.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
const Arweave = require("arweave");
|
||||||
|
|
||||||
|
const arweave = Arweave.init({
|
||||||
|
host: "arweave.net",
|
||||||
|
port: 443,
|
||||||
|
protocol: "https",
|
||||||
|
});
|
||||||
|
const wallet = arweave.wallets.generate()
|
||||||
|
.then(w => {
|
||||||
|
arweave.wallets.jwkToAddress(w).then((address) => {
|
||||||
|
console.log(address);
|
||||||
|
//1seRanklLU_1VTGkEk7P0xAwMJfA7owA1JHW5KyZKlY
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user