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

feat(ao): use IO/AO contract from ar.io/sdk #40

Merged
merged 21 commits into from
Jun 11, 2024
Merged

Conversation

dtfiedler
Copy link
Collaborator

@dtfiedler dtfiedler commented Jun 5, 2024

This includes fetching prescribed names and epoch information directly from the contract rather than computing them internally (PE-6259).

Logs:

info: Using wallet 1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo {"timestamp":"2024-06-11T16:31:29.892Z"}
info: Loading key file... {"keyFile":"./wallets/1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo.json","timestamp":"2024-06-11T16:31:29.895Z"}
info: Key file loaded {"keyFile":"./wallets/1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo.json","timestamp":"2024-06-11T16:31:29.896Z"}
info: Using process GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc to fetch contract information {"processId":"GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc","timestamp":"2024-06-11T16:31:29.911Z"}
info: Generating report... {"timestamp":"2024-06-11T16:31:29.941Z"}
info: Listening on port 4000 {"timestamp":"2024-06-11T16:31:29.949Z"}
info: Fetched epoch params {"class":"ContractEpochSource","endTimestamp":1718150400000,"epochIndex":19885,"startHeight":1442178,"startTimestamp":1718064000000,"timestamp":"2024-06-11T16:31:31.044Z"}
info: Report generated in 21223ms {"timestamp":"2024-06-11T16:31:51.164Z"}
info: Report cached {"timestamp":"2024-06-11T16:31:51.166Z"}
info: Getting observers from contract state... {"timestamp":"2024-06-11T16:31:51.166Z"}
info: Retrieved 13 observers from contract state {"timestamp":"2024-06-11T16:31:51.832Z"}
info: Saving report... {"class":"PipelineReportSink","epochIndex":19885,"epochStartHeight":1442178,"epochStartTimestamp":1718064000000,"timestamp":"2024-06-11T16:31:52.432Z"}
info: Saving report using FsReportStore... {"class":"PipelineReportSink","epochIndex":19885,"epochStartHeight":1442178,"epochStartTimestamp":1718064000000,"timestamp":"2024-06-11T16:31:52.432Z"}
info: Using previously saved report {"class":"FsReportStore","epochIndex":19885,"epochStartHeight":1442178,"epochStartTimestamp":1718064000000,"timestamp":"2024-06-11T16:31:52.433Z"}
info: Report saved using FsReportStore {"class":"PipelineReportSink","epochIndex":19885,"epochStartHeight":1442178,"epochStartTimestamp":1718064000000,"timestamp":"2024-06-11T16:31:52.433Z"}
info: Saving report using TurboReportSink... {"class":"PipelineReportSink","epochIndex":19885,"epochStartHeight":1442178,"epochStartTimestamp":1718064000000,"timestamp":"2024-06-11T16:31:52.433Z"}
info: Report already saved, skipping upload {"class":"TurboReportSink","epochIndex":19885,"epochStartHeight":1442178,"epochStartTimestamp":1718064000000,"timestamp":"2024-06-11T16:31:52.717Z"}
info: Report saved using TurboReportSink {"class":"PipelineReportSink","epochIndex":19885,"epochStartHeight":1442178,"epochStartTimestamp":1718064000000,"reportTxId":"ekhAZcWztsh2pvialVYwnPCDY8oaXwx_CJgMdgWPYgc","timestamp":"2024-06-11T16:31:52.717Z"}
info: Saving report using ContractReportSink... {"class":"PipelineReportSink","epochIndex":19885,"epochStartHeight":1442178,"epochStartTimestamp":1718064000000,"timestamp":"2024-06-11T16:31:52.717Z"}
info: Saving observation interactions... {"timestamp":"2024-06-11T16:31:53.070Z"}
info: Observation interactions saved {"interactionIds":["DzaOu1L8PmM1TX9eh9sEpkPBQygBbaI4-Zupgcaa8iE"],"timestamp":"2024-06-11T16:31:53.725Z"}
info: Report saved using ContractReportSink {"class":"PipelineReportSink","epochIndex":19885,"epochStartHeight":1442178,"epochStartTimestamp":1718064000000,"interactionTxIds":["DzaOu1L8PmM1TX9eh9sEpkPBQygBbaI4-Zupgcaa8iE"],"reportTxId":"ekhAZcWztsh2pvialVYwnPCDY8oaXwx_CJgMdgWPYgc","timestamp":"2024-06-11T16:31:53.725Z"}

Report

{
    "formatVersion": 2,
    "observerAddress": "1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo",
    "epochIndex": 19885,
    "epochStartTimestamp": 1718064000000,
    "epochStartHeight": 1442178,
    "epochEndTimestamp": 1718150400000,
    "generatedAt": 1718123240,
    "gatewayAssessments": {
        "permaweb.name": {
            "ownershipAssessment": {
                "expectedWallets": [
                    "M0WP8KSzCvKpzC-HPF1WcddLgGaL9J4DGi76iMnhrN4"
                ],
                "observedWallet": null,
                "failureReason": "certificate has expired",
                "pass": false
            },
            "arnsAssessments": {
                "prescribedNames": {
                    "ar-io": {
                        "assessedAt": 1718123228,
                        "expectedId": null,
                        "resolvedId": null,
                        "expectedDataHash": null,
                        "resolvedDataHash": null,
                        "failureReason": "certificate has expired",
                        "pass": false
                    },
                    "chicapowa": {
                        "assessedAt": 1718123228,
                        "expectedId": null,
                        "resolvedId": null,
                        "expectedDataHash": null,
                        "resolvedDataHash": null,
                        "failureReason": "certificate has expired",
                        "pass": false
                    },
                    "paulsan": {
                        "assessedAt": 1718123228,
                        "expectedId": null,
                        "resolvedId": null,
                        "expectedDataHash": null,
                        "resolvedDataHash": null,
                        "failureReason": "certificate has expired",
                        "pass": false
                    },
                    "perma-user-gi": {
                        "assessedAt": 1718123228,
                        "expectedId": null,
                        "resolvedId": null,
                        "expectedDataHash": null,
                        "resolvedDataHash": null,
                        "failureReason": "certificate has expired",
                        "pass": false
                    },
                    "permabuy": {
                        "assessedAt": 1718123228,
                        "expectedId": null,
                        "resolvedId": null,
                        "expectedDataHash": null,
                        "resolvedDataHash": null,
                        "failureReason": "certificate has expired",
                        "pass": false
                    }
                },
                "chosenNames": {
                    "somenewdomain": {
                        "assessedAt": 1718123228,
                        "expectedId": null,
                        "resolvedId": null,
                        "expectedDataHash": null,
                        "resolvedDataHash": null,
                        "failureReason": "certificate has expired",
                        "pass": false
                    },
                    "fixyfixfix4": {
                        "assessedAt": 1718123228,
                        "expectedId": null,
                        "resolvedId": null,
                        "expectedDataHash": null,
                        "resolvedDataHash": null,
                        "failureReason": "certificate has expired",
                        "pass": false
                    },
                    "jiggyhunt": {
                        "assessedAt": 1718123229,
                        "expectedId": null,
                        "resolvedId": null,
                        "expectedDataHash": null,
                        "resolvedDataHash": null,
                        "failureReason": "certificate has expired",
                        "pass": false
                    },
                    "giggitygiggitygoo": {
                        "assessedAt": 1718123229,
                        "expectedId": null,
                        "resolvedId": null,
                        "expectedDataHash": null,
                        "resolvedDataHash": null,
                        "failureReason": "certificate has expired",
                        "pass": false
                    },
                    "testtickauction": {
                        "assessedAt": 1718123229,
                        "expectedId": null,
                        "resolvedId": null,
                        "expectedDataHash": null,
                        "resolvedDataHash": null,
                        "failureReason": "certificate has expired",
                        "pass": false
                    }
                },
                "pass": false
            },
            "pass": false
        },

Contract:

Using networkContract.getEpoch({ epochIndex: 19885 })

{
   epochIndex = 19885,
   startHeight = 1442178,
   distributions = {  },
   endTimestamp = 1718150400000,
   prescribedObservers = {
    {
       startTimestamp = 1714965191000,
       tenureWeight = 0.19925469393004,
       stake = 192085361673,
       compositeWeight = 3.8273909948595,
       observerAddress = "rweM0QUKbLVHADi2jyAvtOYgQv7lhp61NtX2ftXpANY",
       gatewayAddress = "rweM0QUKbLVHADi2jyAvtOYgQv7lhp61NtX2ftXpANY",
       normalizedCompositeWeight = 0.10157513933699,
       observerRewardRatioWeight = 1.0,
       gatewayRewardRatioWeight = 1.0,
       stakeWeight = 19.2085361673
    },
    {
       startTimestamp = 1714965191000,
       tenureWeight = 0.19925469393004,
       stake = 192095361673,
       compositeWeight = 3.8275902495534,
       observerAddress = "PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM",
       gatewayAddress = "PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM",
       normalizedCompositeWeight = 0.10158042735781,
       observerRewardRatioWeight = 1.0,
       gatewayRewardRatioWeight = 1.0,
       stakeWeight = 19.2095361673
    },
    {
       startTimestamp = 1714965191000,
       tenureWeight = 0.19925469393004,
       stake = 192085361673,
       compositeWeight = 3.8273909948595,
       observerAddress = "7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk",
       gatewayAddress = "7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk",
       normalizedCompositeWeight = 0.10157513933699,
       observerRewardRatioWeight = 1.0,
       gatewayRewardRatioWeight = 1.0,
       stakeWeight = 19.2085361673
    },
    {
       startTimestamp = 1714965191000,
       tenureWeight = 0.19925469393004,
       stake = 319077446989,
       compositeWeight = 6.3577679039772,
       observerAddress = "M0WP8KSzCvKpzC-HPF1WcddLgGaL9J4DGi76iMnhrN4",
       gatewayAddress = "M0WP8KSzCvKpzC-HPF1WcddLgGaL9J4DGi76iMnhrN4",
       normalizedCompositeWeight = 0.16872881855709,
       observerRewardRatioWeight = 1.0,
       gatewayRewardRatioWeight = 1.0,
       stakeWeight = 31.9077446989
    },
    {
       startTimestamp = 1714965191000,
       tenureWeight = 0.19925469393004,
       stake = 95248000000,
       compositeWeight = 1.8978611087449,
       observerAddress = "1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo",
       gatewayAddress = "1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo",
       normalizedCompositeWeight = 0.050367340786953,
       observerRewardRatioWeight = 1.0,
       gatewayRewardRatioWeight = 1.0,
       stakeWeight = 9.5248
    },
    {
       startTimestamp = 1714965191000,
       tenureWeight = 0.19925469393004,
       stake = 25000000000,
       compositeWeight = 0.4981367348251,
       observerAddress = "wlcEhTQY_qjDKTvTDZsb53aX8wivbOJZKnhLswdueZw",
       gatewayAddress = "wlcEhTQY_qjDKTvTDZsb53aX8wivbOJZKnhLswdueZw",
       normalizedCompositeWeight = 0.01322005207116,
       observerRewardRatioWeight = 1.0,
       gatewayRewardRatioWeight = 1.0,
       stakeWeight = 2.5
    },
    {
       startTimestamp = 1714965191000,
       tenureWeight = 0.19925469393004,
       stake = 10005000000,
       compositeWeight = 0.19935432127701,
       observerAddress = "iKryOeZQMONi2965nKz528htMMN_sBcjlhc-VncoRjA",
       gatewayAddress = "iKryOeZQMONi2965nKz528htMMN_sBcjlhc-VncoRjA",
       normalizedCompositeWeight = 0.0052906648388782,
       observerRewardRatioWeight = 1.0,
       gatewayRewardRatioWeight = 1.0,
       stakeWeight = 1.0005
    },
    {
       startTimestamp = 1717708708412,
       tenureWeight = 0.02284539531893,
       stake = 37279283253,
       compositeWeight = 0.085165996312115,
       observerAddress = "LtV0aSqgK3YI7c5FmfvZd-wG95TJ9sezj_a4syaLMS8",
       gatewayAddress = "LtV0aSqgK3YI7c5FmfvZd-wG95TJ9sezj_a4syaLMS8",
       normalizedCompositeWeight = 0.002260220592512,
       observerRewardRatioWeight = 1.0,
       gatewayRewardRatioWeight = 1.0,
       stakeWeight = 3.7279283253
    },
    {
       startTimestamp = 1714965191000,
       tenureWeight = 0.19925469393004,
       stake = 192085361673,
       compositeWeight = 3.8273909948595,
       observerAddress = "q6zIf3KQRMCW9fytR0YlKG4oqw6Cox4r_bk7mq6JZBM",
       gatewayAddress = "q6zIf3KQRMCW9fytR0YlKG4oqw6Cox4r_bk7mq6JZBM",
       normalizedCompositeWeight = 0.10157513933699,
       observerRewardRatioWeight = 1.0,
       gatewayRewardRatioWeight = 1.0,
       stakeWeight = 19.2085361673
    },
    {
       startTimestamp = 1714965191000,
       tenureWeight = 0.19925469393004,
       stake = 259929836658,
       compositeWeight = 5.1792240046575,
       observerAddress = "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
       gatewayAddress = "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
       normalizedCompositeWeight = 0.13745143901867,
       observerRewardRatioWeight = 1.0,
       gatewayRewardRatioWeight = 1.0,
       stakeWeight = 25.9929836658
    },
    {
       startTimestamp = 1714965191000,
       tenureWeight = 0.19925469393004,
       stake = 192095361673,
       compositeWeight = 3.8275902495534,
       observerAddress = "N4h8M9A9hasa3tF47qQyNvcKjm4APBKuFs7vqUVm-SI",
       gatewayAddress = "N4h8M9A9hasa3tF47qQyNvcKjm4APBKuFs7vqUVm-SI",
       normalizedCompositeWeight = 0.10158042735781,
       observerRewardRatioWeight = 1.0,
       gatewayRewardRatioWeight = 1.0,
       stakeWeight = 19.2095361673
    },
    {
       startTimestamp = 1714965191000,
       tenureWeight = 0.19925469393004,
       stake = 192085361673,
       compositeWeight = 3.8273909948595,
       observerAddress = "9jfM0uzGNc9Mkhjo1ixGoqM7ygSem9wx_EokiVgi0Bs",
       gatewayAddress = "9jfM0uzGNc9Mkhjo1ixGoqM7ygSem9wx_EokiVgi0Bs",
       normalizedCompositeWeight = 0.10157513933699,
       observerRewardRatioWeight = 1.0,
       gatewayRewardRatioWeight = 1.0,
       stakeWeight = 19.2085361673
    },
    {
       startTimestamp = 1714965191000,
       tenureWeight = 0.19925469393004,
       stake = 25000000000,
       compositeWeight = 0.4981367348251,
       observerAddress = "xN_aVln30LmoCffwmk5_kRkcyQZyZWy1o_TNtM_CTm0",
       gatewayAddress = "xN_aVln30LmoCffwmk5_kRkcyQZyZWy1o_TNtM_CTm0",
       normalizedCompositeWeight = 0.01322005207116,
       observerRewardRatioWeight = 1.0,
       gatewayRewardRatioWeight = 1.0,
       stakeWeight = 2.5
    }
   },
   prescribedNames = { "ar-io", "chicapowa", "paulsan", "perma-user-gi", "permabuy" },
   observations = {
     failureSummaries = {
       cF0H0SKdnaDTqWKY9iJKBktTpdEWgb3GnlndE7ABv0Q = { "1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo" },
       rweM0QUKbLVHADi2jyAvtOYgQv7lhp61NtX2ftXpANY = { "1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo" },
       PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM = { "1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo" },
       M0WP8KSzCvKpzC-HPF1WcddLgGaL9J4DGi76iMnhrN4 = { "1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo" },
       q6zIf3KQRMCW9fytR0YlKG4oqw6Cox4r_bk7mq6JZBM = { "1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo" },
       iKryOeZQMONi2965nKz528htMMN_sBcjlhc-VncoRjA = { "1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo" },
       LtV0aSqgK3YI7c5FmfvZd-wG95TJ9sezj_a4syaLMS8 = { "1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo" },
       7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk = { "1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo" },
       N4h8M9A9hasa3tF47qQyNvcKjm4APBKuFs7vqUVm-SI = { "1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo" },
       wlcEhTQY_qjDKTvTDZsb53aX8wivbOJZKnhLswdueZw = { "1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo" },
       xN_aVln30LmoCffwmk5_kRkcyQZyZWy1o_TNtM_CTm0 = { "1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo" }
    },
     reports = {
       1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo = "ekhAZcWztsh2pvialVYwnPCDY8oaXwx_CJgMdgWPYgc"
    }
  },
   distributionTimestamp = 1718152200000,
   startTimestamp = 1718064000000
}

dtfiedler added 5 commits June 5, 2024 13:27
dtfiedler added 3 commits June 7, 2024 06:39
…ntion to avoid collisions. This is to be consistent with previous naming conventions for report filenames, but it is important to note the epochStartHeight is provided by the contract for the epoch and not computed by the observer
GatewayAssessments,
GatewayHostsSource,
ObserverReport,
OwnershipAssessment,
} from './types.js';

const REPORT_FORMAT_VERSION = 1;
export const REPORT_FORMAT_VERSION = 2;
Copy link
Collaborator Author

@dtfiedler dtfiedler Jun 7, 2024

Choose a reason for hiding this comment

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

@djwhitt - is the report format intended to reflect just the assessments? I've changed the top level attributes to include epochStartTimestamp and epochEndTimestamp. We can revert it back to 1 if the bump is not necessary.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, you're doing the right thing. We should bump the version for this.

@dtfiedler dtfiedler marked this pull request as ready for review June 10, 2024 16:15
dtfiedler added 2 commits June 10, 2024 20:40
…contract

Since we are not computing epochs ourselves, we need to fetch the epoch information from the contract when we run a new report. This moves that logic to a class that fetches epoch information on every execution of running a report. It will cache the result until the epoch is over, based on network time rather than local system time.
@dtfiedler dtfiedler requested review from djwhitt and karlprieb and removed request for djwhitt June 11, 2024 15:19
dtfiedler added 7 commits June 11, 2024 09:36
The newer release of arweave 2.7+ shortened the max fork depth to 18 blocks.
It is used for both prescribed and chosen names so keeping it general makes sense.
We were not passing the height around so the choseNames kept returning an empty array
Copy link
Collaborator

@djwhitt djwhitt left a comment

Choose a reason for hiding this comment

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

Nice work! Not much to complain about here. 🙂

}

async getName(height: number, index: number): Promise<string> {
const names = await this.getAllNames(height);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fine for now (basically what we did before I think), but we'll need a more efficient way to do this in a future.

@djwhitt djwhitt merged commit 7de8926 into develop Jun 11, 2024
5 checks passed
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.

2 participants