Skip to content

Commit

Permalink
chore: deprecate blockTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Feb 25, 2025
1 parent fee1402 commit a9388c4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/fast-usdc/src/cli/operator-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ export const addOperatorCommands = (
.requiredOption('--recipientAddress <string>', 'bech32 address', String)
.requiredOption('--blockHash <0xhex>', 'hex hash', parseHex)
.requiredOption('--blockNumber <number>', 'number', parseNat)
.requiredOption('--blockTimestamp <number>', 'number', parseNat)
.requiredOption('--chainId <string>', 'chain id', Number)
.requiredOption('--amount <number>', 'number', parseNat)
.requiredOption('--forwardingAddress <string>', 'bech32 address', String)
.requiredOption('--sender <string>', 'Ethereum address initiating', String)
.requiredOption('--txHash <0xhexo>', 'hex hash', parseHex)
.option('--blockTimestamp <number>', 'number', parseNat, 0n)
.option('--offerId <string>', 'Offer id', String, `operatorAttest-${now()}`)
.action(async opts => {
const {
Expand Down
11 changes: 5 additions & 6 deletions packages/fast-usdc/src/exos/status-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,13 @@ export const prepareStatusManager = (
* Transactions seen *ever* by the contract.
*
* Note that like all durable stores, this MapStore is kept in IAVL. It stores
* the `blockTimestamp` so that later we can prune old transactions.
* the `blockNumber` so that later we can prune old transactions.
*
* Note that `blockTimestamp` can drift between chains. Fortunately all CCTP
* chains use the same Unix epoch and won't drift more than minutes apart,
* which is more than enough precision for pruning old transaction.
* Note that `blockNumber` is per source chain.
*
* @type {MapStore<EvmHash, NatValue>}
*/
// TODO make prunable https://github.com/Agoric/agoric-sdk/issues/11050
const seenTxs = zone.mapStore('SeenTxs', {
keyShape: M.string(),
valueShape: M.nat(),
Expand Down Expand Up @@ -165,7 +164,7 @@ export const prepareStatusManager = (
if (seenTxs.has(txHash)) {
throw makeError(`Transaction already seen: ${q(txHash)}`);
}
seenTxs.init(txHash, evidence.blockTimestamp);
seenTxs.init(txHash, evidence.blockNumber);

appendToStoredArray(
pendingSettleTxs,
Expand Down Expand Up @@ -310,7 +309,7 @@ export const prepareStatusManager = (
if (seenTxs.has(txHash)) {
throw makeError(`Transaction already seen: ${q(txHash)}`);
}
seenTxs.init(txHash, evidence.blockTimestamp);
seenTxs.init(txHash, evidence.blockNumber);
publishEvidence(txHash, evidence);
},

Expand Down
2 changes: 2 additions & 0 deletions packages/fast-usdc/src/type-guards.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export const CctpTxEvidenceShape = {
},
blockHash: EvmHashShape,
blockNumber: M.nat(),
/** @deprecated this value is ignored; infer from blockNumber instead */
// maintained because we can't change the type guard in the running vat
blockTimestamp: M.nat(),
chainId: M.number(),
tx: {
Expand Down
7 changes: 2 additions & 5 deletions packages/fast-usdc/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,9 @@ export interface CctpTxEvidence {
/** height of blockHash on the source chain */
blockNumber: bigint;
/**
* Seconds since Unix epoch. Not all CCTP source chains update time the same
* way but they all use Unix epoch and thus are approximately equal. (Within
* minutes apart.)
* @deprecated too expensive to poll so we rely on blockNumber instead
*/
blockTimestamp: bigint;
//
blockTimestamp?: bigint;
/**
* [Domain of values](https://chainid.network/) per [EIP-155](https://eips.ethereum.org/EIPS/eip-155)
* (We don't have [CCTP `domain`](https://developers.circle.com/stablecoins/supported-domains) )
Expand Down
18 changes: 9 additions & 9 deletions packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -3061,15 +3061,15 @@ Generated by [AVA](https://avajs.dev).
PendingSettleTxs: {},
PoolAccount: 'Vow',
SeenTxs: {
'0x000001': 1632340000n,
'0x0000010': 1632340000n,
'0x000002': 1632340000n,
'0x000003': 1632340000n,
'0x000004': 1632340000n,
'0x000005': 1632340000n,
'0x000006': 1632340000n,
'0x000007': 1632340000n,
'0x000008': 1632340000n,
'0x000001': 21037664n,
'0x0000010': 21037673n,
'0x000002': 21037665n,
'0x000003': 21037666n,
'0x000004': 21037667n,
'0x000005': 21037668n,
'0x000006': 21037669n,
'0x000007': 21037670n,
'0x000008': 21037671n,
},
SettleAccount: 'Vow',
StoredCompletedTxs: [
Expand Down
Binary file not shown.

0 comments on commit a9388c4

Please sign in to comment.