forked from TrueCloudLab/frostfs-contract
Compare commits
79 commits
support/v0
...
master
Author | SHA1 | Date | |
---|---|---|---|
a1b61d3949 | |||
f28d918727 | |||
7864fc3c4d | |||
edf3c26047 | |||
f30fb324ff | |||
0dda536d4a | |||
43097d2152 | |||
03d0c10852 | |||
21bfe3ebf0 | |||
e56e8d02ee | |||
20f86e96b2 | |||
5cc34f98e9 | |||
dd5919348d | |||
e2e406932f | |||
501b0c5e3c | |||
8affa716e0 | |||
95fe7781d5 | |||
b76f592095 | |||
5cc810096f | |||
c8b14d1376 | |||
edfab37677 | |||
0ea65ca637 | |||
d890a7eba4 | |||
dacac0b53d | |||
6e9c770142 | |||
09281e3ef3 | |||
9ed3845aa9 | |||
901d5a4083 | |||
e09df69ffe | |||
e834a66117 | |||
5124555f05 | |||
184fcdc5a7 | |||
bab6b619d0 | |||
2be81b1def | |||
ab0a899a28 | |||
0b3ea05f76 | |||
c13c01a5c0 | |||
1777c93c9e | |||
45c3710bd2 | |||
391c1cb5d4 | |||
c6a7820363 | |||
2b1fa53b67 | |||
6e8ae742ae | |||
077823ee84 | |||
36f3d39c40 | |||
bcf22c50a1 | |||
2da0ff5750 | |||
b89c3fd584 | |||
6a19989aa6 | |||
f786040322 | |||
a8029c71cd | |||
8537293e11 | |||
|
e19fe15ed8 | ||
|
8d17306c3c | ||
cbe0f01e08 | |||
b9be2ac036 | |||
d8530284fd | |||
6b13a83736 | |||
d626660c1a | |||
19a8ef2d02 | |||
|
4f3c08f552 | ||
03bff785d2 | |||
1a4fa7e421 | |||
0ba830f48f | |||
4077921794 | |||
0c5723964f | |||
e1cd043248 | |||
9c004cab2e | |||
4052e4873b | |||
a21630c1d7 | |||
402c13a607 | |||
0093e89ad9 | |||
e95c598dfc | |||
|
6c805c1b4e | ||
|
8ca71d22b2 | ||
|
9052ec62d6 | ||
|
beaef7b10d | ||
|
38246cd54f | ||
|
363d2a2a3a |
108 changed files with 11317 additions and 3905 deletions
21
.forgejo/workflows/dco.yml
Normal file
21
.forgejo/workflows/dco.yml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
name: DCO action
|
||||||
|
on: [pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
dco:
|
||||||
|
name: DCO
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '1.20'
|
||||||
|
|
||||||
|
- name: Run commit format checker
|
||||||
|
uses: https://git.frostfs.info/TrueCloudLab/dco-go@v2
|
||||||
|
with:
|
||||||
|
from: 'origin/${{ github.event.pull_request.base.ref }}'
|
21
.forgejo/workflows/tests.yml
Normal file
21
.forgejo/workflows/tests.yml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
name: Tests
|
||||||
|
on: [pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
name: Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go_versions: [ '1.19', '1.20' ]
|
||||||
|
fail-fast: false
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '${{ matrix.go_versions }}'
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: make test
|
45
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
45
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: community, triage, bug
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!--- Provide a general summary of the issue in the Title above -->
|
||||||
|
|
||||||
|
## Expected Behavior
|
||||||
|
<!--- If you're describing a bug, tell us what should happen -->
|
||||||
|
<!--- If you're suggesting a change/improvement, tell us how it should work -->
|
||||||
|
|
||||||
|
## Current Behavior
|
||||||
|
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
|
||||||
|
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
|
||||||
|
|
||||||
|
## Possible Solution
|
||||||
|
<!--- Not obligatory -->
|
||||||
|
<!--- If no reason/fix/additions for the bug can be suggested, -->
|
||||||
|
<!--- uncomment the following phrase: -->
|
||||||
|
|
||||||
|
<!--- No fix can be suggested by a QA engineer. Further solutions shall be up to developers. -->
|
||||||
|
|
||||||
|
## Steps to Reproduce (for bugs)
|
||||||
|
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
|
||||||
|
<!--- reproduce this bug. -->
|
||||||
|
|
||||||
|
1.
|
||||||
|
|
||||||
|
## Context
|
||||||
|
<!--- How has this issue affected you? What are you trying to accomplish? -->
|
||||||
|
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
|
||||||
|
|
||||||
|
## Regression
|
||||||
|
<!-- Is this issue a regression? (Yes / No) -->
|
||||||
|
<!-- If Yes, optionally please include version or commit id or PR# that caused this regression, if you have these details. -->
|
||||||
|
|
||||||
|
## Your Environment
|
||||||
|
<!--- Include as many relevant details about the environment you experienced the bug in -->
|
||||||
|
* Version used:
|
||||||
|
* Server setup and configuration:
|
||||||
|
* Operating System and version (`uname -a`):
|
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
blank_issues_enabled: false
|
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: community, triage
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Is your feature request related to a problem? Please describe.
|
||||||
|
<!--- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
|
||||||
|
|
||||||
|
## Describe the solution you'd like
|
||||||
|
<!--- A clear and concise description of what you want to happen. -->
|
||||||
|
|
||||||
|
## Describe alternatives you've considered
|
||||||
|
<!--- A clear and concise description of any alternative solutions or features you've considered. -->
|
||||||
|
|
||||||
|
## Additional context
|
||||||
|
<!--- Add any other context or screenshots about the feature request here. -->
|
197
.github/logo.svg
vendored
197
.github/logo.svg
vendored
|
@ -1,129 +1,70 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<svg
|
<!-- Generator: Adobe Illustrator 25.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
<svg version="1.1" id="Слой_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
xmlns:cc="http://creativecommons.org/ns#"
|
viewBox="0 0 184.2 51.8" style="enable-background:new 0 0 184.2 51.8;" xml:space="preserve">
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
<style type="text/css">
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
.st0{display:none;}
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
.st1{display:inline;}
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
.st2{fill:#01E397;}
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
.st3{display:inline;fill:#010032;}
|
||||||
sodipodi:docname="logo_fs.svg"
|
.st4{display:inline;fill:#00E599;}
|
||||||
inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
|
.st5{display:inline;fill:#00AF92;}
|
||||||
id="svg57"
|
.st6{fill:#00C3E5;}
|
||||||
version="1.1"
|
</style>
|
||||||
viewBox="0 0 105 25"
|
<g id="Layer_2">
|
||||||
height="25mm"
|
<g id="Layer_1-2" class="st0">
|
||||||
width="105mm">
|
<g class="st1">
|
||||||
<defs
|
<path class="st2" d="M146.6,18.3v7.2h10.9V29h-10.9v10.7h-4V14.8h18v3.5H146.6z"/>
|
||||||
id="defs51">
|
<path class="st2" d="M180,15.7c1.7,0.9,3,2.2,4,3.8l-3,2.7c-0.6-1.3-1.5-2.4-2.6-3.3c-1.3-0.7-2.8-1-4.3-1
|
||||||
<clipPath
|
c-1.4-0.1-2.8,0.3-4,1.1c-0.9,0.5-1.5,1.5-1.4,2.6c0,1,0.5,1.9,1.4,2.4c1.5,0.8,3.2,1.3,4.9,1.5c1.9,0.3,3.7,0.8,5.4,1.6
|
||||||
clipPathUnits="userSpaceOnUse"
|
c1.2,0.5,2.2,1.3,2.9,2.3c0.6,1,1,2.2,0.9,3.4c0,1.4-0.5,2.7-1.3,3.8c-0.9,1.2-2.1,2.1-3.5,2.6c-1.7,0.6-3.4,0.9-5.2,0.8
|
||||||
id="clipPath434">
|
c-5,0-8.6-1.6-10.7-5l2.9-2.8c0.7,1.4,1.8,2.5,3.1,3.3c1.5,0.7,3.1,1.1,4.7,1c1.5,0.1,2.9-0.2,4.2-0.9c0.9-0.5,1.5-1.5,1.5-2.6
|
||||||
<path
|
c0-0.9-0.5-1.8-1.3-2.2c-1.5-0.7-3.1-1.2-4.8-1.5c-1.9-0.3-3.7-0.8-5.5-1.5c-1.2-0.5-2.2-1.4-3-2.4c-0.6-1-1-2.2-0.9-3.4
|
||||||
d="M 0,0 H 1366 V 768 H 0 Z"
|
c0-1.4,0.4-2.7,1.2-3.8c0.8-1.2,2-2.2,3.3-2.8c1.6-0.7,3.4-1.1,5.2-1C176.1,14.3,178.2,14.8,180,15.7z"/>
|
||||||
id="path432" />
|
</g>
|
||||||
</clipPath>
|
<path class="st3" d="M73.3,16.3c1.9,1.9,2.9,4.5,2.7,7.1v15.9h-4V24.8c0-2.6-0.5-4.5-1.6-5.7c-1.2-1.2-2.8-1.8-4.5-1.7
|
||||||
</defs>
|
c-1.3,0-2.5,0.3-3.7,0.8c-1.2,0.7-2.2,1.7-2.9,2.9c-0.8,1.5-1.1,3.2-1.1,4.9v13.3h-4V15.1l3.6,1.5v1.7c0.8-1.5,2.1-2.6,3.6-3.3
|
||||||
<sodipodi:namedview
|
c1.5-0.8,3.2-1.2,4.9-1.1C68.9,13.8,71.3,14.7,73.3,16.3z"/>
|
||||||
inkscape:window-maximized="0"
|
<path class="st3" d="M104.4,28.3H85.6c0.1,2.2,1,4.3,2.5,5.9c1.5,1.4,3.5,2.2,5.6,2.1c1.6,0.1,3.2-0.2,4.6-0.9
|
||||||
inkscape:window-y="0"
|
c1.1-0.6,2-1.6,2.5-2.8l3.3,1.8c-0.9,1.7-2.3,3.1-4,4c-2,1-4.2,1.5-6.4,1.4c-3.7,0-6.7-1.1-8.8-3.4s-3.2-5.5-3.2-9.6s1-7.2,3-9.5
|
||||||
inkscape:window-x="130"
|
s5-3.4,8.7-3.4c2.1-0.1,4.2,0.5,6.1,1.5c1.6,1,3,2.5,3.8,4.2c0.9,1.8,1.3,3.9,1.3,5.9C104.6,26.4,104.6,27.4,104.4,28.3z
|
||||||
inkscape:window-height="1040"
|
M88.1,19.3c-1.4,1.5-2.2,3.4-2.4,5.5h15.1c-0.2-2-1-3.9-2.3-5.5c-1.4-1.3-3.2-2-5.1-1.9C91.5,17.3,89.6,18,88.1,19.3z"/>
|
||||||
inkscape:window-width="1274"
|
<path class="st3" d="M131,17.3c2.2,2.3,3.2,5.5,3.2,9.5s-1,7.3-3.2,9.6s-5.1,3.4-8.8,3.4s-6.7-1.1-8.9-3.4s-3.2-5.5-3.2-9.6
|
||||||
height="50mm"
|
s1.1-7.2,3.2-9.5s5.1-3.4,8.9-3.4S128.9,15,131,17.3z M116.2,19.9c-1.5,2-2.2,4.4-2.1,6.9c-0.2,2.5,0.6,5,2.1,7
|
||||||
units="mm"
|
c1.5,1.7,3.7,2.7,6,2.6c2.3,0.1,4.4-0.9,5.9-2.6c1.5-2,2.3-4.5,2.1-7c0.1-2.5-0.6-4.9-2.1-6.9c-1.5-1.7-3.6-2.7-5.9-2.6
|
||||||
showgrid="false"
|
C119.9,17.2,117.7,18.2,116.2,19.9z"/>
|
||||||
inkscape:document-rotation="0"
|
<polygon class="st4" points="0,9.1 0,43.7 22.5,51.8 22.5,16.9 46.8,7.9 24.8,0 "/>
|
||||||
inkscape:current-layer="layer1"
|
<polygon class="st5" points="24.3,17.9 24.3,36.8 46.8,44.9 46.8,9.6 "/>
|
||||||
inkscape:document-units="mm"
|
</g>
|
||||||
inkscape:cy="344.49897"
|
<g>
|
||||||
inkscape:cx="468.64708"
|
<g>
|
||||||
inkscape:zoom="0.7"
|
<path class="st6" d="M41.6,17.5H28.2v6.9h10.4v3.3H28.2v10.2h-3.9V14.2h17.2V17.5z"/>
|
||||||
inkscape:pageshadow="2"
|
<path class="st6" d="M45.8,37.9v-18h3.3l0.4,3.2c0.5-1.2,1.2-2.1,2.1-2.7c0.9-0.6,2.1-0.9,3.5-0.9c0.4,0,0.7,0,1.1,0.1
|
||||||
inkscape:pageopacity="0.0"
|
c0.4,0.1,0.7,0.2,0.9,0.3l-0.5,3.4c-0.3-0.1-0.6-0.2-0.9-0.2C55.4,23,54.9,23,54.4,23c-0.7,0-1.5,0.2-2.2,0.6
|
||||||
borderopacity="1.0"
|
c-0.7,0.4-1.3,1-1.8,1.8s-0.7,1.8-0.7,3v9.5H45.8z"/>
|
||||||
bordercolor="#666666"
|
<path class="st6" d="M68.6,19.6c1.8,0,3.3,0.4,4.6,1.1c1.3,0.7,2.4,1.8,3.1,3.2s1.1,3.1,1.1,5c0,1.9-0.4,3.6-1.1,5
|
||||||
pagecolor="#ffffff"
|
c-0.8,1.4-1.8,2.5-3.1,3.2c-1.3,0.7-2.9,1.1-4.6,1.1s-3.3-0.4-4.6-1.1c-1.3-0.7-2.4-1.8-3.2-3.2c-0.8-1.4-1.2-3.1-1.2-5
|
||||||
id="base" />
|
c0-1.9,0.4-3.6,1.2-5s1.8-2.5,3.2-3.2C65.3,19.9,66.8,19.6,68.6,19.6z M68.6,22.6c-1.1,0-2,0.2-2.8,0.7c-0.8,0.5-1.3,1.2-1.7,2.1
|
||||||
<metadata
|
s-0.6,2.1-0.6,3.5c0,1.3,0.2,2.5,0.6,3.4s1,1.7,1.7,2.2s1.7,0.7,2.8,0.7c1.1,0,2-0.2,2.7-0.7c0.7-0.5,1.3-1.2,1.7-2.2
|
||||||
id="metadata54">
|
s0.6-2.1,0.6-3.4c0-1.4-0.2-2.5-0.6-3.5s-1-1.6-1.7-2.1C70.6,22.8,69.6,22.6,68.6,22.6z"/>
|
||||||
<rdf:RDF>
|
<path class="st6" d="M89.2,38.3c-1.8,0-3.4-0.3-4.9-1c-1.5-0.7-2.7-1.7-3.5-3l2.7-2.3c0.5,1,1.3,1.8,2.3,2.4
|
||||||
<cc:Work
|
c1,0.6,2.2,0.9,3.6,0.9c1.1,0,2-0.2,2.6-0.6c0.6-0.4,1-0.9,1-1.6c0-0.5-0.2-0.9-0.5-1.2s-0.9-0.6-1.7-0.8l-3.8-0.8
|
||||||
rdf:about="">
|
c-1.9-0.4-3.3-1-4.1-1.9c-0.8-0.9-1.2-1.9-1.2-3.3c0-1,0.3-1.9,0.9-2.7c0.6-0.8,1.4-1.5,2.5-2s2.5-0.8,4-0.8c1.8,0,3.3,0.3,4.6,1
|
||||||
<dc:format>image/svg+xml</dc:format>
|
c1.3,0.6,2.2,1.5,2.9,2.7l-2.7,2.2c-0.5-1-1.1-1.7-2-2.1c-0.9-0.5-1.8-0.7-2.8-0.7c-0.8,0-1.4,0.1-2,0.3c-0.6,0.2-1,0.5-1.3,0.8
|
||||||
<dc:type
|
c-0.3,0.3-0.4,0.7-0.4,1.2c0,0.5,0.2,0.9,0.5,1.3s1,0.6,1.9,0.8l4.1,0.9c1.7,0.3,2.9,0.9,3.7,1.7c0.7,0.8,1.1,1.8,1.1,2.9
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
c0,1.2-0.3,2.2-0.9,3c-0.6,0.9-1.5,1.6-2.6,2C92.1,38.1,90.7,38.3,89.2,38.3z"/>
|
||||||
<dc:title></dc:title>
|
<path class="st6" d="M112.8,19.9v3H99.3v-3H112.8z M106.6,14.6v17.9c0,0.9,0.2,1.5,0.7,1.9c0.5,0.4,1.1,0.6,1.9,0.6
|
||||||
</cc:Work>
|
c0.6,0,1.2-0.1,1.7-0.3c0.5-0.2,0.9-0.5,1.3-0.8l0.9,2.8c-0.6,0.5-1.2,0.9-2,1.1c-0.8,0.3-1.7,0.4-2.7,0.4c-1,0-2-0.2-2.8-0.5
|
||||||
</rdf:RDF>
|
s-1.5-0.9-2-1.6c-0.5-0.8-0.7-1.7-0.8-3V15.7L106.6,14.6z"/>
|
||||||
</metadata>
|
<path d="M137.9,17.5h-13.3v6.9h10.4v3.3h-10.4v10.2h-3.9V14.2h17.2V17.5z"/>
|
||||||
<g
|
<path d="M150.9,13.8c2.1,0,4,0.4,5.5,1.2c1.6,0.8,2.9,2,4,3.5l-2.6,2.5c-0.9-1.4-1.9-2.4-3.1-3c-1.1-0.6-2.5-0.9-4-0.9
|
||||||
id="layer1"
|
c-1.2,0-2.1,0.2-2.8,0.5c-0.7,0.3-1.3,0.7-1.6,1.2c-0.3,0.5-0.5,1.1-0.5,1.7c0,0.7,0.3,1.4,0.8,1.9c0.5,0.6,1.5,1,2.9,1.3
|
||||||
inkscape:groupmode="layer"
|
l4.8,1.1c2.3,0.5,3.9,1.3,4.9,2.3c1,1,1.4,2.3,1.4,3.9c0,1.5-0.4,2.7-1.2,3.8c-0.8,1.1-1.9,1.9-3.3,2.5s-3.1,0.9-5,0.9
|
||||||
inkscape:label="Layer 1">
|
c-1.7,0-3.2-0.2-4.5-0.6c-1.3-0.4-2.5-1-3.5-1.8c-1-0.7-1.8-1.6-2.5-2.6l2.7-2.7c0.5,0.8,1.1,1.6,1.9,2.2
|
||||||
<g
|
c0.8,0.7,1.7,1.2,2.7,1.5c1,0.4,2.2,0.5,3.4,0.5c1.1,0,2.1-0.1,2.9-0.4c0.8-0.3,1.4-0.7,1.8-1.2c0.4-0.5,0.6-1.1,0.6-1.9
|
||||||
id="g424"
|
c0-0.7-0.2-1.3-0.7-1.8c-0.5-0.5-1.3-0.9-2.6-1.2l-5.2-1.2c-1.4-0.3-2.6-0.8-3.6-1.3c-0.9-0.6-1.6-1.3-2.1-2.1s-0.7-1.8-0.7-2.8
|
||||||
transform="matrix(0.35277777,0,0,-0.35277777,63.946468,10.194047)">
|
c0-1.3,0.4-2.6,1.1-3.7c0.7-1.1,1.8-2,3.2-2.6C147.3,14.1,148.9,13.8,150.9,13.8z"/>
|
||||||
<path
|
</g>
|
||||||
d="m 0,0 v -8.093 h 12.287 v -3.94 H 0 V -24.067 H -4.534 V 3.898 H 15.677 V 0 Z"
|
</g>
|
||||||
style="fill:#00e396;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
</g>
|
||||||
id="path426" />
|
|
||||||
</g>
|
|
||||||
<g
|
|
||||||
transform="matrix(0.35277777,0,0,-0.35277777,-315.43002,107.34005)"
|
|
||||||
id="g428">
|
|
||||||
<g
|
|
||||||
id="g430"
|
|
||||||
clip-path="url(#clipPath434)">
|
|
||||||
<g
|
|
||||||
id="g436"
|
|
||||||
transform="translate(1112.874,278.2981)">
|
|
||||||
<path
|
|
||||||
d="M 0,0 C 1.822,-0.932 3.354,-2.359 4.597,-4.28 L 1.165,-7.373 c -0.791,1.695 -1.779,2.924 -2.966,3.686 -1.186,0.763 -2.768,1.145 -4.745,1.145 -1.949,0 -3.461,-0.389 -4.534,-1.166 -1.074,-0.777 -1.61,-1.772 -1.61,-2.987 0,-1.13 0.523,-2.027 1.568,-2.69 1.045,-0.664 2.909,-1.236 5.593,-1.716 2.514,-0.452 4.512,-1.024 5.995,-1.716 1.483,-0.693 2.564,-1.554 3.242,-2.585 0.677,-1.031 1.016,-2.309 1.016,-3.834 0,-1.639 -0.466,-3.079 -1.398,-4.322 -0.932,-1.243 -2.239,-2.197 -3.919,-2.86 -1.681,-0.664 -3.623,-0.996 -5.826,-0.996 -5.678,0 -9.689,1.892 -12.033,5.678 l 3.178,3.178 c 0.903,-1.695 2.068,-2.939 3.495,-3.729 1.426,-0.791 3.199,-1.186 5.318,-1.186 2.005,0 3.58,0.345 4.724,1.038 1.144,0.692 1.716,1.674 1.716,2.945 0,1.017 -0.516,1.835 -1.547,2.457 -1.031,0.621 -2.832,1.172 -5.402,1.653 -2.571,0.479 -4.618,1.073 -6.143,1.779 -1.526,0.706 -2.635,1.582 -3.326,2.627 -0.693,1.045 -1.039,2.316 -1.039,3.813 0,1.582 0.438,3.023 1.314,4.322 0.875,1.299 2.14,2.33 3.792,3.093 1.653,0.763 3.58,1.144 5.783,1.144 C -4.018,1.398 -1.822,0.932 0,0"
|
|
||||||
style="fill:#00e396;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
|
||||||
id="path438" />
|
|
||||||
</g>
|
|
||||||
<g
|
|
||||||
id="g440"
|
|
||||||
transform="translate(993.0239,277.5454)">
|
|
||||||
<path
|
|
||||||
d="m 0,0 c 2.054,-1.831 3.083,-4.465 3.083,-7.902 v -17.935 h -4.484 v 16.366 c 0,2.914 -0.626,5.024 -1.877,6.332 -1.253,1.308 -2.924,1.962 -5.016,1.962 -1.495,0 -2.896,-0.327 -4.204,-0.981 -1.308,-0.654 -2.381,-1.719 -3.222,-3.194 -0.841,-1.477 -1.261,-3.335 -1.261,-5.576 v -14.909 h -4.484 V 1.328 l 4.086,-1.674 0.118,-1.84 c 0.933,1.681 2.222,2.923 3.867,3.727 1.643,0.803 3.493,1.205 5.548,1.205 C -4.671,2.746 -2.055,1.83 0,0"
|
|
||||||
style="fill:#000033;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
|
||||||
id="path442" />
|
|
||||||
</g>
|
|
||||||
<g
|
|
||||||
id="g444"
|
|
||||||
transform="translate(1027.9968,264.0386)">
|
|
||||||
<path
|
|
||||||
d="m 0,0 h -21.128 c 0.261,-2.84 1.205,-5.044 2.83,-6.613 1.625,-1.57 3.727,-2.355 6.305,-2.355 2.054,0 3.763,0.356 5.128,1.065 1.363,0.71 2.288,1.738 2.774,3.083 l 3.755,-1.961 c -1.121,-1.981 -2.616,-3.495 -4.484,-4.54 -1.868,-1.046 -4.259,-1.569 -7.173,-1.569 -4.223,0 -7.538,1.289 -9.948,3.867 -2.41,2.578 -3.615,6.146 -3.615,10.704 0,4.558 1.149,8.127 3.447,10.705 2.298,2.578 5.557,3.867 9.779,3.867 2.615,0 4.876,-0.58 6.782,-1.738 1.905,-1.158 3.343,-2.728 4.315,-4.707 C -0.262,7.827 0.224,5.605 0.224,3.139 0.224,2.092 0.149,1.046 0,0 m -18.298,10.144 c -1.513,-1.457 -2.438,-3.512 -2.775,-6.165 h 16.982 c -0.3,2.615 -1.159,4.661 -2.578,6.137 -1.42,1.476 -3.307,2.214 -5.661,2.214 -2.466,0 -4.455,-0.728 -5.968,-2.186"
|
|
||||||
style="fill:#000033;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
|
||||||
id="path446" />
|
|
||||||
</g>
|
|
||||||
<g
|
|
||||||
id="g448"
|
|
||||||
transform="translate(1057.8818,276.4246)">
|
|
||||||
<path
|
|
||||||
d="m 0,0 c 2.41,-2.578 3.615,-6.147 3.615,-10.705 0,-4.558 -1.205,-8.126 -3.615,-10.704 -2.41,-2.578 -5.726,-3.867 -9.948,-3.867 -4.222,0 -7.537,1.289 -9.947,3.867 -2.41,2.578 -3.615,6.146 -3.615,10.704 0,4.558 1.205,8.127 3.615,10.705 2.41,2.578 5.725,3.867 9.947,3.867 C -5.726,3.867 -2.41,2.578 0,0 m -16.617,-2.858 c -1.607,-1.906 -2.41,-4.522 -2.41,-7.847 0,-3.326 0.803,-5.94 2.41,-7.846 1.607,-1.905 3.83,-2.858 6.669,-2.858 2.839,0 5.063,0.953 6.67,2.858 1.606,1.906 2.41,4.52 2.41,7.846 0,3.325 -0.804,5.941 -2.41,7.847 C -4.885,-0.953 -7.109,0 -9.948,0 c -2.839,0 -5.062,-0.953 -6.669,-2.858"
|
|
||||||
style="fill:#000033;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
|
||||||
id="path450" />
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
<g
|
|
||||||
id="g452"
|
|
||||||
transform="matrix(0.35277777,0,0,-0.35277777,5.8329581,6.5590171)">
|
|
||||||
<path
|
|
||||||
d="m 0,0 0.001,-38.946 25.286,-9.076 V -8.753 L 52.626,1.321 27.815,10.207 Z"
|
|
||||||
style="fill:#00e599;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
|
||||||
id="path454" />
|
|
||||||
</g>
|
|
||||||
<g
|
|
||||||
id="g456"
|
|
||||||
transform="matrix(0.35277777,0,0,-0.35277777,15.479008,10.041927)">
|
|
||||||
<path
|
|
||||||
d="M 0,0 V -21.306 L 25.293,-30.364 25.282,9.347 Z"
|
|
||||||
style="fill:#00b091;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
|
||||||
id="path458" />
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 5.5 KiB |
21
.github/workflows/dco.yml
vendored
21
.github/workflows/dco.yml
vendored
|
@ -1,21 +0,0 @@
|
||||||
name: DCO check
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
commits_check_job:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Commits Check
|
|
||||||
steps:
|
|
||||||
- name: Get PR Commits
|
|
||||||
id: 'get-pr-commits'
|
|
||||||
uses: tim-actions/get-pr-commits@master
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: DCO Check
|
|
||||||
uses: tim-actions/dco@master
|
|
||||||
with:
|
|
||||||
commits: ${{ steps.get-pr-commits.outputs.commits }}
|
|
20
.github/workflows/go.yml
vendored
20
.github/workflows/go.yml
vendored
|
@ -1,20 +0,0 @@
|
||||||
name: Go
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches: [ master ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
|
|
||||||
tests:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Set up Go
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: 1.17
|
|
||||||
|
|
||||||
- name: Test
|
|
||||||
run: go test -v ./...
|
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -4,3 +4,7 @@
|
||||||
config.json
|
config.json
|
||||||
/vendor/
|
/vendor/
|
||||||
.idea
|
.idea
|
||||||
|
/bin/
|
||||||
|
|
||||||
|
# debhelpers
|
||||||
|
**/.debhelper
|
||||||
|
|
29
CHANGELOG.md
29
CHANGELOG.md
|
@ -1,11 +1,38 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
Changelog for NeoFS Contract
|
Changelog for FrostFS Contract
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
### Changed
|
### Changed
|
||||||
|
### Removed
|
||||||
### Updated
|
### Updated
|
||||||
|
### Fixed
|
||||||
|
### Updating from v0.18.0
|
||||||
|
|
||||||
|
## [0.18.0] - 2023-09-14 - Academy of Sciences Glacier
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Documentation for contract storage schema (#21)
|
||||||
|
### Changed
|
||||||
|
- `container.Delete()` now accepts public key along with token (#27)
|
||||||
|
- Allow to check whether container was deleted with `container.DeletionInfo()` (#38)
|
||||||
|
### Removed
|
||||||
|
- `subnet` contract (#20)
|
||||||
|
### Updated
|
||||||
|
### Fixed
|
||||||
|
### Updating from v0.17.0
|
||||||
|
|
||||||
|
## [0.17.0] - 2023-04-13 - Furtwängler
|
||||||
|
|
||||||
|
### Added
|
||||||
|
### Changed
|
||||||
|
### Removed
|
||||||
|
- Notary disabled code from all contracts (#7)
|
||||||
|
|
||||||
|
### Updated
|
||||||
|
- `neo-go` to `v0.99.4`
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
### Updating from v0.16.0
|
### Updating from v0.16.0
|
||||||
|
|
||||||
|
|
59
Makefile
59
Makefile
|
@ -1,23 +1,34 @@
|
||||||
#!/usr/bin/make -f
|
#!/usr/bin/make -f
|
||||||
|
|
||||||
SHELL=bash
|
SHELL=bash
|
||||||
GOBIN ?= $(shell go env GOPATH)/bin
|
# GOBIN is used only to install neo-go and allows to override
|
||||||
|
# the location of written binary.
|
||||||
|
export GOBIN ?= $(shell pwd)/bin
|
||||||
NEOGO ?= $(GOBIN)/cli
|
NEOGO ?= $(GOBIN)/cli
|
||||||
VERSION ?= $(shell git describe --tags --dirty --match "v*" --always --abbrev=8 2>/dev/null || cat VERSION 2>/dev/null || echo "develop")
|
VERSION ?= $(shell git describe --tags --dirty --match "v*" --always --abbrev=8 2>/dev/null || cat VERSION 2>/dev/null || echo "develop")
|
||||||
|
|
||||||
|
|
||||||
|
# .deb package versioning
|
||||||
|
OS_RELEASE = $(shell lsb_release -cs)
|
||||||
|
PKG_VERSION ?= $(shell echo $(VERSION) | sed "s/^v//" | \
|
||||||
|
sed -E "s/(.*)-(g[a-fA-F0-9]{6,8})(.*)/\1\3~\2/" | \
|
||||||
|
sed "s/-/~/")-${OS_RELEASE}
|
||||||
|
|
||||||
.PHONY: all build clean test neo-go
|
.PHONY: all build clean test neo-go
|
||||||
.PHONY: alphabet mainnet morph nns sidechain
|
.PHONY: alphabet mainnet morph nns sidechain
|
||||||
|
.PHONY: debpackage debclean
|
||||||
build: neo-go all
|
build: neo-go all
|
||||||
all: sidechain mainnet
|
all: sidechain mainnet
|
||||||
sidechain: alphabet morph nns
|
sidechain: alphabet morph nns
|
||||||
|
|
||||||
alphabet_sc = alphabet
|
alphabet_sc = alphabet
|
||||||
morph_sc = audit balance container neofsid netmap proxy reputation subnet
|
morph_sc = balance container frostfsid netmap proxy policy
|
||||||
mainnet_sc = neofs processing
|
mainnet_sc = frostfs processing
|
||||||
nns_sc = nns
|
nns_sc = nns
|
||||||
|
all_sc = $(alphabet_sc) $(morph_sc) $(mainnet_sc) $(nns_sc)
|
||||||
|
|
||||||
define sc_template
|
define sc_template
|
||||||
$(2)$(1)/$(1)_contract.nef: $(2)$(1)/$(1)_contract.go
|
$(2)$(1)/$(1)_contract.nef: $(2)$(1)/$(1)_contract.go $(2)$(1)/config.yml
|
||||||
$(NEOGO) contract compile -i $(2)$(1) -c $(if $(2),$(2),$(1)/)config.yml -m $(2)$(1)/config.json -o $(2)$(1)/$(1)_contract.nef
|
$(NEOGO) contract compile -i $(2)$(1) -c $(if $(2),$(2),$(1)/)config.yml -m $(2)$(1)/config.json -o $(2)$(1)/$(1)_contract.nef
|
||||||
|
|
||||||
$(if $(2),$(2)$(1)/$(1)_contract.go: alphabet/alphabet.go alphabet/alphabet.tpl
|
$(if $(2),$(2)$(1)/$(1)_contract.go: alphabet/alphabet.go alphabet/alphabet.tpl
|
||||||
|
@ -39,12 +50,36 @@ neo-go:
|
||||||
@go list -f '{{.Path}}/...@{{.Version}}' -m github.com/nspcc-dev/neo-go \
|
@go list -f '{{.Path}}/...@{{.Version}}' -m github.com/nspcc-dev/neo-go \
|
||||||
| xargs go install -v
|
| xargs go install -v
|
||||||
|
|
||||||
|
generate-wrapper.%:
|
||||||
|
@mkdir -p ./rpcclient/$*
|
||||||
|
@# Note, that bindings file is currently missing: is can be emitted by compiler,
|
||||||
|
@# but this leads to a large amount of code duplication. It can be written by hand,
|
||||||
|
@# in case we need to override the type of some variables.
|
||||||
|
@# --config $*/$*.bindings.yml
|
||||||
|
@# Unfortunately, primitive integer types are not yet supported.
|
||||||
|
$(NEOGO) contract generate-rpcwrapper --manifest=$*/config.json --out ./rpcclient/$*/client.go
|
||||||
|
|
||||||
|
generate-wrappers: build $(foreach sc,$(all_sc),generate-wrapper.$(sc))
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@go test ./tests/...
|
@go test ./tests/...
|
||||||
|
|
||||||
|
# Run all code formatters
|
||||||
|
fmts: fumpt imports
|
||||||
|
|
||||||
|
# Reformat imports
|
||||||
|
imports:
|
||||||
|
@echo "⇒ Processing goimports check"
|
||||||
|
@goimports -w $(all_sc) tests/
|
||||||
|
|
||||||
|
fumpt:
|
||||||
|
@echo "⇒ Processing gofumpt check"
|
||||||
|
@gofumpt -l -w $(all_sc) tests/
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
find . -name '*.nef' -exec rm -rf {} \;
|
find . -name '*.nef' -exec rm -rf {} \;
|
||||||
find . -name 'config.json' -exec rm -rf {} \;
|
find . -name 'config.json' -exec rm -rf {} \;
|
||||||
|
rm -rf ./bin/
|
||||||
|
|
||||||
mr_proper: clean
|
mr_proper: clean
|
||||||
for sc in $(alphabet_sc); do\
|
for sc in $(alphabet_sc); do\
|
||||||
|
@ -52,6 +87,18 @@ mr_proper: clean
|
||||||
done
|
done
|
||||||
|
|
||||||
archive: build
|
archive: build
|
||||||
@tar --transform "s|^./|neofs-contract-$(VERSION)/|" \
|
@tar --transform "s|^./|frostfs-contract-$(VERSION)/|" \
|
||||||
-czf neofs-contract-$(VERSION).tar.gz \
|
-czf frostfs-contract-$(VERSION).tar.gz \
|
||||||
$(shell find . -name '*.nef' -o -name 'config.json')
|
$(shell find . -name '*.nef' -o -name 'config.json')
|
||||||
|
|
||||||
|
# Package for Debian
|
||||||
|
debpackage:
|
||||||
|
dch --package frostfs-contract \
|
||||||
|
--controlmaint \
|
||||||
|
--newversion $(PKG_VERSION) \
|
||||||
|
--distribution $(OS_RELEASE) \
|
||||||
|
"Please see CHANGELOG.md for code changes for $(VERSION)"
|
||||||
|
dpkg-buildpackage --no-sign -b
|
||||||
|
|
||||||
|
debclean:
|
||||||
|
dh clean
|
||||||
|
|
43
README.md
43
README.md
|
@ -1,21 +1,21 @@
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="./.github/logo.svg" width="500px" alt="NeoFS">
|
<img src="./.github/logo.svg" width="500px" alt="FrostFS">
|
||||||
</p>
|
</p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://fs.neo.org">NeoFS</a> related smart contracts.
|
<a href="https://frostfs.info">FrostFS</a> related smart contracts.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Overview
|
# Overview
|
||||||
|
|
||||||
NeoFS-Contract contains all NeoFS related contracts written for
|
FrostFS-Contract contains all FrostFS related contracts written for
|
||||||
[neo-go](https://github.com/nspcc-dev/neo-go) compiler. These contracts
|
[neo-go](https://github.com/nspcc-dev/neo-go) compiler. These contracts
|
||||||
are deployed both in the mainchain and the sidechain.
|
are deployed both in the mainchain and the sidechain.
|
||||||
|
|
||||||
Mainchain contracts:
|
Mainchain contracts:
|
||||||
|
|
||||||
- neofs
|
- frostfs
|
||||||
- processing
|
- processing
|
||||||
|
|
||||||
Sidechain contracts:
|
Sidechain contracts:
|
||||||
|
@ -24,12 +24,11 @@ Sidechain contracts:
|
||||||
- audit
|
- audit
|
||||||
- balance
|
- balance
|
||||||
- container
|
- container
|
||||||
- neofsid
|
- frostfsid
|
||||||
- netmap
|
- netmap
|
||||||
- nns
|
- nns
|
||||||
- proxy
|
- proxy
|
||||||
- reputation
|
- reputation
|
||||||
- subnet
|
|
||||||
|
|
||||||
# Getting started
|
# Getting started
|
||||||
|
|
||||||
|
@ -51,13 +50,12 @@ $ make all
|
||||||
/home/user/go/bin/cli contract compile -i audit -c audit/config.yml -m audit/config.json -o audit/audit_contract.nef
|
/home/user/go/bin/cli contract compile -i audit -c audit/config.yml -m audit/config.json -o audit/audit_contract.nef
|
||||||
/home/user/go/bin/cli contract compile -i balance -c balance/config.yml -m balance/config.json -o balance/balance_contract.nef
|
/home/user/go/bin/cli contract compile -i balance -c balance/config.yml -m balance/config.json -o balance/balance_contract.nef
|
||||||
/home/user/go/bin/cli contract compile -i container -c container/config.yml -m container/config.json -o container/container_contract.nef
|
/home/user/go/bin/cli contract compile -i container -c container/config.yml -m container/config.json -o container/container_contract.nef
|
||||||
/home/user/go/bin/cli contract compile -i neofsid -c neofsid/config.yml -m neofsid/config.json -o neofsid/neofsid_contract.nef
|
/home/user/go/bin/cli contract compile -i frostfsid -c frostfsid/config.yml -m frostfsid/config.json -o frostfsid/frostfsid_contract.nef
|
||||||
/home/user/go/bin/cli contract compile -i netmap -c netmap/config.yml -m netmap/config.json -o netmap/netmap_contract.nef
|
/home/user/go/bin/cli contract compile -i netmap -c netmap/config.yml -m netmap/config.json -o netmap/netmap_contract.nef
|
||||||
/home/user/go/bin/cli contract compile -i proxy -c proxy/config.yml -m proxy/config.json -o proxy/proxy_contract.nef
|
/home/user/go/bin/cli contract compile -i proxy -c proxy/config.yml -m proxy/config.json -o proxy/proxy_contract.nef
|
||||||
/home/user/go/bin/cli contract compile -i reputation -c reputation/config.yml -m reputation/config.json -o reputation/reputation_contract.nef
|
/home/user/go/bin/cli contract compile -i reputation -c reputation/config.yml -m reputation/config.json -o reputation/reputation_contract.nef
|
||||||
/home/user/go/bin/cli contract compile -i subnet -c subnet/config.yml -m subnet/config.json -o subnet/subnet_contract.nef
|
|
||||||
/home/user/go/bin/cli contract compile -i nns -c nns/config.yml -m nns/config.json -o nns/nns_contract.nef
|
/home/user/go/bin/cli contract compile -i nns -c nns/config.yml -m nns/config.json -o nns/nns_contract.nef
|
||||||
/home/user/go/bin/cli contract compile -i neofs -c neofs/config.yml -m neofs/config.json -o neofs/neofs_contract.nef
|
/home/user/go/bin/cli contract compile -i frostfs -c frostfs/config.yml -m frostfs/config.json -o frostfs/frostfs_contract.nef
|
||||||
/home/user/go/bin/cli contract compile -i processing -c processing/config.yml -m processing/config.json -o processing/processing_contract.nef
|
/home/user/go/bin/cli contract compile -i processing -c processing/config.yml -m processing/config.json -o processing/processing_contract.nef
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -69,29 +67,24 @@ $ NEOGO=/home/user/neo-go/bin/neo-go make all
|
||||||
|
|
||||||
Remove compiled files with `make clean` or `make mr_proper` command.
|
Remove compiled files with `make clean` or `make mr_proper` command.
|
||||||
|
|
||||||
|
## Building Debian package
|
||||||
|
|
||||||
|
To build Debian package containing compiled contracts, run `make debpackage`
|
||||||
|
command. Package will install compiled contracts `*_contract.nef` and manifest
|
||||||
|
`config.json` with corresponding directories to `/var/lib/neofs/contract` for
|
||||||
|
further usage.
|
||||||
|
It will download and build neo-go, if needed.
|
||||||
|
|
||||||
|
To clean package-related files, use `make debclean`.
|
||||||
|
|
||||||
# Testing
|
# Testing
|
||||||
Smartcontract tests reside in `tests/` directory. To execute test suite
|
Smartcontract tests reside in `tests/` directory. To execute test suite
|
||||||
after applying changes, simply run `make test`.
|
after applying changes, simply run `make test`.
|
||||||
```
|
```
|
||||||
$ make test
|
$ make test
|
||||||
ok github.com/nspcc-dev/neofs-contract/tests 0.462s
|
ok git.frostfs.info/TrueCloudLab/frostfs-contract/tests 0.462s
|
||||||
```
|
```
|
||||||
|
|
||||||
# NeoFS API compatibility
|
|
||||||
|
|
||||||
| neofs-contract version | supported NeoFS API versions |
|
|
||||||
|:----------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
|
||||||
| v0.9.x | [v2.7.0](https://github.com/nspcc-dev/neofs-api/releases/tag/v2.7.0), [v2.8.0](https://github.com/nspcc-dev/neofs-api/releases/tag/v2.8.0) |
|
|
||||||
| v0.10.x | [v2.7.0](https://github.com/nspcc-dev/neofs-api/releases/tag/v2.7.0), [v2.8.0](https://github.com/nspcc-dev/neofs-api/releases/tag/v2.8.0) |
|
|
||||||
| v0.11.x | [v2.7.0](https://github.com/nspcc-dev/neofs-api/releases/tag/v2.7.0), [v2.8.0](https://github.com/nspcc-dev/neofs-api/releases/tag/v2.8.0), [v2.9.0](https://github.com/nspcc-dev/neofs-api/releases/tag/v2.9.0) |
|
|
||||||
| v0.12.x | [v2.10.0](https://github.com/nspcc-dev/neofs-api/releases/tag/v2.10.0) |
|
|
||||||
| v0.13.x | [v2.11.0](https://github.com/nspcc-dev/neofs-api/releases/tag/v2.11.0) |
|
|
||||||
| v0.14.x | [v2.11.0](https://github.com/nspcc-dev/neofs-api/releases/tag/v2.11.0) |
|
|
||||||
| v0.15.x | [v2.11.0](https://github.com/nspcc-dev/neofs-api/releases/tag/v2.11.0), [v2.12.0](https://github.com/nspcc-dev/neofs-api/releases/tag/v2.12.0) |
|
|
||||||
| v0.15.x | [v2.11.0](https://github.com/nspcc-dev/neofs-api/releases/tag/v2.11.0), [v2.12.0](https://github.com/nspcc-dev/neofs-api/releases/tag/v2.12.0) |
|
|
||||||
| v0.16.x | [v2.14.0](https://github.com/nspcc-dev/neofs-api/releases/tag/v2.14.0) |
|
|
||||||
|
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
This project is licensed under the GPLv3 License - see the
|
This project is licensed under the GPLv3 License - see the
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
v0.16.0
|
v0.18.0
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
package alphabet
|
package alphabet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/crypto"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/gas"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/gas"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/neo"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/neo"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neofs-contract/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -19,37 +18,35 @@ const (
|
||||||
indexKey = "index"
|
indexKey = "index"
|
||||||
totalKey = "threshold"
|
totalKey = "threshold"
|
||||||
nameKey = "name"
|
nameKey = "name"
|
||||||
|
|
||||||
notaryDisabledKey = "notary"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// OnNEP17Payment is a callback for NEP-17 compatible native GAS and NEO
|
// OnNEP17Payment is a callback for NEP-17 compatible native GAS and NEO
|
||||||
// contracts.
|
// contracts.
|
||||||
func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
func OnNEP17Payment(from interop.Hash160, amount int, data any) {
|
||||||
caller := runtime.GetCallingScriptHash()
|
caller := runtime.GetCallingScriptHash()
|
||||||
if !common.BytesEqual(caller, []byte(gas.Hash)) && !common.BytesEqual(caller, []byte(neo.Hash)) {
|
if !common.BytesEqual(caller, []byte(gas.Hash)) && !common.BytesEqual(caller, []byte(neo.Hash)) {
|
||||||
common.AbortWithMessage("alphabet contract accepts GAS and NEO only")
|
common.AbortWithMessage("alphabet contract accepts GAS and NEO only")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
func _deploy(data any, isUpdate bool) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
args := data.([]interface{})
|
args := data.([]any)
|
||||||
common.CheckVersion(args[len(args)-1].(int))
|
common.CheckVersion(args[len(args)-1].(int))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
args := data.(struct {
|
args := data.(struct {
|
||||||
notaryDisabled bool
|
addrNetmap interop.Hash160
|
||||||
addrNetmap interop.Hash160
|
addrProxy interop.Hash160
|
||||||
addrProxy interop.Hash160
|
name string
|
||||||
name string
|
index int
|
||||||
index int
|
total int
|
||||||
total int
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(args.addrNetmap) != interop.Hash160Len || !args.notaryDisabled && len(args.addrProxy) != interop.Hash160Len {
|
if len(args.addrNetmap) != interop.Hash160Len || len(args.addrProxy) != interop.Hash160Len {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,25 +56,17 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
storage.Put(ctx, indexKey, args.index)
|
storage.Put(ctx, indexKey, args.index)
|
||||||
storage.Put(ctx, totalKey, args.total)
|
storage.Put(ctx, totalKey, args.total)
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
|
||||||
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
|
||||||
if args.notaryDisabled {
|
|
||||||
common.InitVote(ctx)
|
|
||||||
runtime.Log(args.name + " notary disabled")
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.Log(args.name + " contract initialized")
|
runtime.Log(args.name + " contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. It can be invoked
|
// Update method updates contract source code and manifest. It can be invoked
|
||||||
// only by committee.
|
// only by committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data any) {
|
||||||
if !common.HasUpdateAccess() {
|
if !common.HasUpdateAccess() {
|
||||||
panic("only committee can update contract")
|
panic("only committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update",
|
management.UpdateWithData(script, manifest, common.AppendVersion(data))
|
||||||
contract.All, script, manifest, common.AppendVersion(data))
|
|
||||||
runtime.Log("alphabet contract updated")
|
runtime.Log("alphabet contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,15 +109,11 @@ func checkPermission(ir []interop.PublicKey) bool {
|
||||||
// and proxy contract. It can be invoked only by an Alphabet node of the Inner Ring.
|
// and proxy contract. It can be invoked only by an Alphabet node of the Inner Ring.
|
||||||
//
|
//
|
||||||
// To produce GAS, an alphabet contract transfers all available NEO from the contract
|
// To produce GAS, an alphabet contract transfers all available NEO from the contract
|
||||||
// account to itself. If notary is enabled, 50% of the GAS in the contract account
|
// account to itself. 50% of the GAS in the contract account
|
||||||
// are transferred to proxy contract. 43.75% of the GAS are equally distributed
|
// are transferred to proxy contract. 43.75% of the GAS are equally distributed
|
||||||
// among all Inner Ring nodes. Remaining 6.25% of the GAS stay in the contract.
|
// among all Inner Ring nodes. Remaining 6.25% of the GAS stay in the contract.
|
||||||
//
|
|
||||||
// If notary is disabled, 87.5% of the GAS are equally distributed among all
|
|
||||||
// Inner Ring nodes. Remaining 12.5% of the GAS stay in the contract.
|
|
||||||
func Emit() {
|
func Emit() {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
alphabet := common.AlphabetNodes()
|
alphabet := common.AlphabetNodes()
|
||||||
if !checkPermission(alphabet) {
|
if !checkPermission(alphabet) {
|
||||||
|
@ -143,32 +128,23 @@ func Emit() {
|
||||||
|
|
||||||
gasBalance := gas.BalanceOf(contractHash)
|
gasBalance := gas.BalanceOf(contractHash)
|
||||||
|
|
||||||
if !notaryDisabled {
|
proxyAddr := storage.Get(ctx, proxyKey).(interop.Hash160)
|
||||||
proxyAddr := storage.Get(ctx, proxyKey).(interop.Hash160)
|
|
||||||
|
|
||||||
proxyGas := gasBalance / 2
|
proxyGas := gasBalance / 2
|
||||||
if proxyGas == 0 {
|
if proxyGas == 0 {
|
||||||
panic("no gas to emit")
|
panic("no gas to emit")
|
||||||
}
|
|
||||||
|
|
||||||
if !gas.Transfer(contractHash, proxyAddr, proxyGas, nil) {
|
|
||||||
runtime.Log("could not transfer GAS to proxy contract")
|
|
||||||
}
|
|
||||||
|
|
||||||
gasBalance -= proxyGas
|
|
||||||
|
|
||||||
runtime.Log("utility token has been emitted to proxy contract")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var innerRing []interop.PublicKey
|
if !gas.Transfer(contractHash, proxyAddr, proxyGas, nil) {
|
||||||
|
runtime.Log("could not transfer GAS to proxy contract")
|
||||||
if notaryDisabled {
|
|
||||||
netmapContract := storage.Get(ctx, netmapKey).(interop.Hash160)
|
|
||||||
innerRing = common.InnerRingNodesFromNetmap(netmapContract)
|
|
||||||
} else {
|
|
||||||
innerRing = common.InnerRingNodes()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gasBalance -= proxyGas
|
||||||
|
|
||||||
|
runtime.Log("utility token has been emitted to proxy contract")
|
||||||
|
|
||||||
|
innerRing := common.InnerRingNodes()
|
||||||
|
|
||||||
gasPerNode := gasBalance * 7 / 8 / len(innerRing)
|
gasPerNode := gasBalance * 7 / 8 / len(innerRing)
|
||||||
|
|
||||||
if gasPerNode != 0 {
|
if gasPerNode != 0 {
|
||||||
|
@ -192,25 +168,10 @@ func Emit() {
|
||||||
// alphabet contracts) should vote for a new committee.
|
// alphabet contracts) should vote for a new committee.
|
||||||
func Vote(epoch int, candidates []interop.PublicKey) {
|
func Vote(epoch int, candidates []interop.PublicKey) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
index := index(ctx)
|
index := index(ctx)
|
||||||
name := name(ctx)
|
name := name(ctx)
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
common.CheckAlphabetWitness()
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = common.AlphabetNodes()
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
panic("invalid invoker")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
curEpoch := currentEpoch(ctx)
|
curEpoch := currentEpoch(ctx)
|
||||||
if epoch != curEpoch {
|
if epoch != curEpoch {
|
||||||
|
@ -220,18 +181,6 @@ func Vote(epoch int, candidates []interop.PublicKey) {
|
||||||
candidate := candidates[index%len(candidates)]
|
candidate := candidates[index%len(candidates)]
|
||||||
address := runtime.GetExecutingScriptHash()
|
address := runtime.GetExecutingScriptHash()
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := voteID(epoch, candidates)
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
ok := neo.Vote(address, candidate)
|
ok := neo.Vote(address, candidate)
|
||||||
if ok {
|
if ok {
|
||||||
runtime.Log(name + ": successfully voted for validator")
|
runtime.Log(name + ": successfully voted for validator")
|
||||||
|
@ -240,21 +189,6 @@ func Vote(epoch int, candidates []interop.PublicKey) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func voteID(epoch interface{}, args []interop.PublicKey) []byte {
|
|
||||||
var (
|
|
||||||
result []byte
|
|
||||||
epochBytes = epoch.([]byte)
|
|
||||||
)
|
|
||||||
|
|
||||||
result = append(result, epochBytes...)
|
|
||||||
|
|
||||||
for i := range args {
|
|
||||||
result = append(result, args[i]...)
|
|
||||||
}
|
|
||||||
|
|
||||||
return crypto.Sha256(result)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Name returns the Glagolitic name of the contract.
|
// Name returns the Glagolitic name of the contract.
|
||||||
func Name() string {
|
func Name() string {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name: "NeoFS Alphabet"
|
name: "Alphabet"
|
||||||
safemethods: ["gas", "neo", "name", "version"]
|
safemethods: ["gas", "neo", "name", "version"]
|
||||||
permissions:
|
permissions:
|
||||||
- methods: ["update", "transfer", "vote"]
|
- methods: ["update", "transfer", "vote"]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Alphabet contract is a contract deployed in NeoFS sidechain.
|
Alphabet contract is a contract deployed in FrostFS sidechain.
|
||||||
|
|
||||||
Alphabet contract is designed to support GAS production and vote for new
|
Alphabet contract is designed to support GAS production and vote for new
|
||||||
validators in the sidechain. NEO token is required to produce GAS and vote for
|
validators in the sidechain. NEO token is required to produce GAS and vote for
|
||||||
|
@ -14,8 +14,18 @@ one of the alphabetical contracts to emit GAS. To vote for a new list of side
|
||||||
chain committee, alphabet nodes of the Inner Ring create multisignature transactions
|
chain committee, alphabet nodes of the Inner Ring create multisignature transactions
|
||||||
for each alphabet contract.
|
for each alphabet contract.
|
||||||
|
|
||||||
Contract notifications
|
# Contract notifications
|
||||||
|
|
||||||
Alphabet contract does not produce notifications to process.
|
Alphabet contract does not produce notifications to process.
|
||||||
|
|
||||||
|
# Contract storage scheme
|
||||||
|
|
||||||
|
| Key | Value | Description |
|
||||||
|
|--------------------|------------|-------------------------------------------------|
|
||||||
|
| `netmapScriptHash` | Hash160 | netmap contract hash |
|
||||||
|
| `proxyScriptHash` | Hash160 | proxy contract hash |
|
||||||
|
| `name` | string | assigned glagolitic letter |
|
||||||
|
| `index` | int | the index of deployed alphabet contract |
|
||||||
|
| `threshold` | int | the total number of deployed alphabet contracts |
|
||||||
*/
|
*/
|
||||||
package alphabet
|
package alphabet
|
||||||
|
|
|
@ -1,239 +0,0 @@
|
||||||
package audit
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/crypto"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
|
||||||
"github.com/nspcc-dev/neofs-contract/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
|
||||||
auditHeader struct {
|
|
||||||
epoch int
|
|
||||||
cid []byte
|
|
||||||
from interop.PublicKey
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// Audit key is a combination of the epoch, the container ID and the public key of the node that
|
|
||||||
// has executed the audit. Together, it shouldn't be more than 64 bytes. We can't shrink
|
|
||||||
// epoch and container ID since we iterate over these values. But we can shrink
|
|
||||||
// public key by using first bytes of the hashed value.
|
|
||||||
|
|
||||||
// V2 format
|
|
||||||
const maxKeySize = 24 // 24 + 32 (container ID length) + 8 (epoch length) = 64
|
|
||||||
|
|
||||||
func (a auditHeader) ID() []byte {
|
|
||||||
var buf interface{} = a.epoch
|
|
||||||
|
|
||||||
hashedKey := crypto.Sha256(a.from)
|
|
||||||
shortedKey := hashedKey[:maxKeySize]
|
|
||||||
|
|
||||||
return append(buf.([]byte), append(a.cid, shortedKey...)...)
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
netmapContractKey = "netmapScriptHash"
|
|
||||||
|
|
||||||
notaryDisabledKey = "notary"
|
|
||||||
)
|
|
||||||
|
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
if isUpdate {
|
|
||||||
args := data.([]interface{})
|
|
||||||
common.CheckVersion(args[len(args)-1].(int))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
args := data.(struct {
|
|
||||||
notaryDisabled bool
|
|
||||||
addrNetmap interop.Hash160
|
|
||||||
})
|
|
||||||
|
|
||||||
if len(args.addrNetmap) != interop.Hash160Len {
|
|
||||||
panic("incorrect length of contract script hash")
|
|
||||||
}
|
|
||||||
|
|
||||||
storage.Put(ctx, netmapContractKey, args.addrNetmap)
|
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
|
||||||
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
|
||||||
if args.notaryDisabled {
|
|
||||||
runtime.Log("audit contract notary disabled")
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.Log("audit contract initialized")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. It can be invoked
|
|
||||||
// only by committee.
|
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
|
||||||
if !common.HasUpdateAccess() {
|
|
||||||
panic("only committee can update contract")
|
|
||||||
}
|
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update",
|
|
||||||
contract.All, script, manifest, common.AppendVersion(data))
|
|
||||||
runtime.Log("audit contract updated")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put method stores a stable marshalled `DataAuditResult` structure. It can be
|
|
||||||
// invoked only by Inner Ring nodes.
|
|
||||||
//
|
|
||||||
// Inner Ring nodes perform audit of containers and produce `DataAuditResult`
|
|
||||||
// structures. They are stored in audit contract and used for settlements
|
|
||||||
// in later epochs.
|
|
||||||
func Put(rawAuditResult []byte) {
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var innerRing []interop.PublicKey
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
netmapContract := storage.Get(ctx, netmapContractKey).(interop.Hash160)
|
|
||||||
innerRing = common.InnerRingNodesFromNetmap(netmapContract)
|
|
||||||
} else {
|
|
||||||
innerRing = common.InnerRingNodes()
|
|
||||||
}
|
|
||||||
|
|
||||||
hdr := newAuditHeader(rawAuditResult)
|
|
||||||
presented := false
|
|
||||||
|
|
||||||
for i := range innerRing {
|
|
||||||
ir := innerRing[i]
|
|
||||||
if common.BytesEqual(ir, hdr.from) {
|
|
||||||
presented = true
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !runtime.CheckWitness(hdr.from) || !presented {
|
|
||||||
panic("put access denied")
|
|
||||||
}
|
|
||||||
|
|
||||||
storage.Put(ctx, hdr.ID(), rawAuditResult)
|
|
||||||
|
|
||||||
runtime.Log("audit: result has been saved")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get method returns a stable marshaled DataAuditResult structure.
|
|
||||||
//
|
|
||||||
// The ID of the DataAuditResult can be obtained from listing methods.
|
|
||||||
func Get(id []byte) []byte {
|
|
||||||
ctx := storage.GetReadOnlyContext()
|
|
||||||
return storage.Get(ctx, id).([]byte)
|
|
||||||
}
|
|
||||||
|
|
||||||
// List method returns a list of all available DataAuditResult IDs from
|
|
||||||
// the contract storage.
|
|
||||||
func List() [][]byte {
|
|
||||||
ctx := storage.GetReadOnlyContext()
|
|
||||||
it := storage.Find(ctx, []byte{}, storage.KeysOnly)
|
|
||||||
|
|
||||||
return list(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListByEpoch method returns a list of DataAuditResult IDs generated during
|
|
||||||
// the specified epoch.
|
|
||||||
func ListByEpoch(epoch int) [][]byte {
|
|
||||||
ctx := storage.GetReadOnlyContext()
|
|
||||||
var buf interface{} = epoch
|
|
||||||
it := storage.Find(ctx, buf.([]byte), storage.KeysOnly)
|
|
||||||
|
|
||||||
return list(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListByCID method returns a list of DataAuditResult IDs generated during
|
|
||||||
// the specified epoch for the specified container.
|
|
||||||
func ListByCID(epoch int, cid []byte) [][]byte {
|
|
||||||
ctx := storage.GetReadOnlyContext()
|
|
||||||
|
|
||||||
var buf interface{} = epoch
|
|
||||||
|
|
||||||
prefix := append(buf.([]byte), cid...)
|
|
||||||
it := storage.Find(ctx, prefix, storage.KeysOnly)
|
|
||||||
|
|
||||||
return list(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListByNode method returns a list of DataAuditResult IDs generated in
|
|
||||||
// the specified epoch for the specified container by the specified Inner Ring node.
|
|
||||||
func ListByNode(epoch int, cid []byte, key interop.PublicKey) [][]byte {
|
|
||||||
ctx := storage.GetReadOnlyContext()
|
|
||||||
hdr := auditHeader{
|
|
||||||
epoch: epoch,
|
|
||||||
cid: cid,
|
|
||||||
from: key,
|
|
||||||
}
|
|
||||||
|
|
||||||
it := storage.Find(ctx, hdr.ID(), storage.KeysOnly)
|
|
||||||
|
|
||||||
return list(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
func list(it iterator.Iterator) [][]byte {
|
|
||||||
var result [][]byte
|
|
||||||
|
|
||||||
ignore := [][]byte{
|
|
||||||
[]byte(netmapContractKey),
|
|
||||||
[]byte(notaryDisabledKey),
|
|
||||||
}
|
|
||||||
|
|
||||||
loop:
|
|
||||||
for iterator.Next(it) {
|
|
||||||
key := iterator.Value(it).([]byte) // iterator MUST BE `storage.KeysOnly`
|
|
||||||
for _, ignoreKey := range ignore {
|
|
||||||
if common.BytesEqual(key, ignoreKey) {
|
|
||||||
continue loop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result = append(result, key)
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// Version returns the version of the contract.
|
|
||||||
func Version() int {
|
|
||||||
return common.Version
|
|
||||||
}
|
|
||||||
|
|
||||||
// readNext reads the length from the first byte, and then reads data (max 127 bytes).
|
|
||||||
func readNext(input []byte) ([]byte, int) {
|
|
||||||
var buf interface{} = input[0]
|
|
||||||
ln := buf.(int)
|
|
||||||
|
|
||||||
return input[1 : 1+ln], 1 + ln
|
|
||||||
}
|
|
||||||
|
|
||||||
func newAuditHeader(input []byte) auditHeader {
|
|
||||||
// V2 format
|
|
||||||
offset := int(input[1])
|
|
||||||
offset = 2 + offset + 1 // version prefix + version len + epoch prefix
|
|
||||||
|
|
||||||
var buf interface{} = input[offset : offset+8] // [ 8 integer bytes ]
|
|
||||||
epoch := buf.(int)
|
|
||||||
|
|
||||||
offset = offset + 8
|
|
||||||
|
|
||||||
// cid is a nested structure with raw bytes
|
|
||||||
// [ cid struct prefix (wireType + len = 2 bytes), cid value wireType (1 byte), ... ]
|
|
||||||
cid, cidOffset := readNext(input[offset+2+1:])
|
|
||||||
|
|
||||||
// key is a raw byte
|
|
||||||
// [ public key wireType (1 byte), ... ]
|
|
||||||
key, _ := readNext(input[offset+2+1+cidOffset+1:])
|
|
||||||
|
|
||||||
return auditHeader{
|
|
||||||
epoch,
|
|
||||||
cid,
|
|
||||||
key,
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
name: "NeoFS Audit"
|
|
||||||
safemethods: ["get", "list", "listByEpoch", "listByCID", "listByNode", "version"]
|
|
||||||
permissions:
|
|
||||||
- methods: ["update"]
|
|
22
audit/doc.go
22
audit/doc.go
|
@ -1,22 +0,0 @@
|
||||||
/*
|
|
||||||
Audit contract is a contract deployed in NeoFS sidechain.
|
|
||||||
|
|
||||||
Inner Ring nodes perform audit of the registered containers during every epoch.
|
|
||||||
If a container contains StorageGroup objects, an Inner Ring node initializes
|
|
||||||
a series of audit checks. Based on the results of these checks, the Inner Ring
|
|
||||||
node creates a DataAuditResult structure for the container. The content of this
|
|
||||||
structure makes it possible to determine which storage nodes have been examined and
|
|
||||||
see the status of these checks. Regarding this information, the container owner is
|
|
||||||
charged for data storage.
|
|
||||||
|
|
||||||
Audit contract is used as a reliable and verifiable storage for all
|
|
||||||
DataAuditResult structures. At the end of data audit routine, Inner Ring
|
|
||||||
nodes send a stable marshaled version of the DataAuditResult structure to the
|
|
||||||
contract. When Alphabet nodes of the Inner Ring perform settlement operations,
|
|
||||||
they make a list and get these AuditResultStructures from the audit contract.
|
|
||||||
|
|
||||||
Contract notifications
|
|
||||||
|
|
||||||
Audit contract does not produce notifications to process.
|
|
||||||
*/
|
|
||||||
package audit
|
|
|
@ -1,14 +1,13 @@
|
||||||
package balance
|
package balance
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neofs-contract/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
@ -22,7 +21,7 @@ type (
|
||||||
CirculationKey string
|
CirculationKey string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Account structure stores metadata of each NeoFS balance account.
|
// Account structure stores metadata of each FrostFS balance account.
|
||||||
Account struct {
|
Account struct {
|
||||||
// Active balance
|
// Active balance
|
||||||
Balance int
|
Balance int
|
||||||
|
@ -32,16 +31,22 @@ type (
|
||||||
// account wasn't burnt.
|
// account wasn't burnt.
|
||||||
Parent []byte
|
Parent []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// account is a stored view of Account with fixed int size
|
||||||
|
account struct {
|
||||||
|
Balance []byte
|
||||||
|
Until []byte
|
||||||
|
Parent []byte
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
symbol = "NEOFS"
|
symbol = "FROSTFS"
|
||||||
decimals = 12
|
decimals = 12
|
||||||
circulation = "MainnetGAS"
|
circulation = "MainnetGAS"
|
||||||
|
|
||||||
netmapContractKey = "netmapScriptHash"
|
netmapContractKey = "netmapScriptHash"
|
||||||
containerContractKey = "containerScriptHash"
|
containerContractKey = "containerScriptHash"
|
||||||
notaryDisabledKey = "notary"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var token Token
|
var token Token
|
||||||
|
@ -58,18 +63,18 @@ func init() {
|
||||||
token = createToken()
|
token = createToken()
|
||||||
}
|
}
|
||||||
|
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
func _deploy(data any, isUpdate bool) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
args := data.([]interface{})
|
args := data.([]any)
|
||||||
common.CheckVersion(args[len(args)-1].(int))
|
common.CheckVersion(args[len(args)-1].(int))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
args := data.(struct {
|
args := data.(struct {
|
||||||
notaryDisabled bool
|
addrNetmap interop.Hash160
|
||||||
addrNetmap interop.Hash160
|
addrContainer interop.Hash160
|
||||||
addrContainer interop.Hash160
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(args.addrNetmap) != interop.Hash160Len || len(args.addrContainer) != interop.Hash160Len {
|
if len(args.addrNetmap) != interop.Hash160Len || len(args.addrContainer) != interop.Hash160Len {
|
||||||
|
@ -79,64 +84,56 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
storage.Put(ctx, netmapContractKey, args.addrNetmap)
|
storage.Put(ctx, netmapContractKey, args.addrNetmap)
|
||||||
storage.Put(ctx, containerContractKey, args.addrContainer)
|
storage.Put(ctx, containerContractKey, args.addrContainer)
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
|
||||||
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
|
||||||
if args.notaryDisabled {
|
|
||||||
common.InitVote(ctx)
|
|
||||||
runtime.Log("balance contract notary disabled")
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.Log("balance contract initialized")
|
runtime.Log("balance contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. It can be invoked
|
// Update method updates contract source code and manifest. It can be invoked
|
||||||
// only by committee.
|
// only by committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data any) {
|
||||||
if !common.HasUpdateAccess() {
|
if !common.HasUpdateAccess() {
|
||||||
panic("only committee can update contract")
|
panic("only committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update",
|
management.UpdateWithData(script, manifest, common.AppendVersion(data))
|
||||||
contract.All, script, manifest, common.AppendVersion(data))
|
|
||||||
runtime.Log("balance contract updated")
|
runtime.Log("balance contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Symbol is a NEP-17 standard method that returns NEOFS token symbol.
|
// Symbol is a NEP-17 standard method that returns FROSTFS token symbol.
|
||||||
func Symbol() string {
|
func Symbol() string {
|
||||||
return token.Symbol
|
return token.Symbol
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decimals is a NEP-17 standard method that returns precision of NeoFS
|
// Decimals is a NEP-17 standard method that returns precision of FrostFS
|
||||||
// balances.
|
// balances.
|
||||||
func Decimals() int {
|
func Decimals() int {
|
||||||
return token.Decimals
|
return token.Decimals
|
||||||
}
|
}
|
||||||
|
|
||||||
// TotalSupply is a NEP-17 standard method that returns total amount of main
|
// TotalSupply is a NEP-17 standard method that returns total amount of main
|
||||||
// chain GAS in NeoFS network.
|
// chain GAS in FrostFS network.
|
||||||
func TotalSupply() int {
|
func TotalSupply() int {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
return token.getSupply(ctx)
|
return token.getSupply(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// BalanceOf is a NEP-17 standard method that returns NeoFS balance of the specified
|
// BalanceOf is a NEP-17 standard method that returns FrostFS balance of the specified
|
||||||
// account.
|
// account.
|
||||||
func BalanceOf(account interop.Hash160) int {
|
func BalanceOf(account interop.Hash160) int {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
return token.balanceOf(ctx, account)
|
return token.balanceOf(ctx, account)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer is a NEP-17 standard method that transfers NeoFS balance from one
|
// Transfer is a NEP-17 standard method that transfers FrostFS balance from one
|
||||||
// account to another. It can be invoked only by the account owner.
|
// account to another. It can be invoked only by the account owner.
|
||||||
//
|
//
|
||||||
// It produces Transfer and TransferX notifications. TransferX notification
|
// It produces Transfer and TransferX notifications. TransferX notification
|
||||||
// will have empty details field.
|
// will have empty details field.
|
||||||
func Transfer(from, to interop.Hash160, amount int, data interface{}) bool {
|
func Transfer(from, to interop.Hash160, amount int, data any) bool {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
return token.transfer(ctx, from, to, amount, false, nil)
|
return token.transfer(ctx, from, to, amount, false, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransferX is a method for NeoFS balance to be transferred from one account to
|
// TransferX is a method for FrostFS balance to be transferred from one account to
|
||||||
// another. It can be invoked by the account owner or by Alphabet nodes.
|
// another. It can be invoked by the account owner or by Alphabet nodes.
|
||||||
//
|
//
|
||||||
// It produces Transfer and TransferX notifications.
|
// It produces Transfer and TransferX notifications.
|
||||||
|
@ -146,42 +143,8 @@ func Transfer(from, to interop.Hash160, amount int, data interface{}) bool {
|
||||||
// Inner Ring with multisignature.
|
// Inner Ring with multisignature.
|
||||||
func TransferX(from, to interop.Hash160, amount int, details []byte) {
|
func TransferX(from, to interop.Hash160, amount int, details []byte) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
common.CheckAlphabetWitness()
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
indirectCall bool
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = common.AlphabetNodes()
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
panic("this method must be invoked from inner ring")
|
|
||||||
}
|
|
||||||
|
|
||||||
indirectCall = common.FromKnownContract(
|
|
||||||
ctx,
|
|
||||||
runtime.GetCallingScriptHash(),
|
|
||||||
containerContractKey,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
if notaryDisabled && !indirectCall {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := common.InvokeID([]interface{}{from, to, amount}, []byte("transfer"))
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
result := token.transfer(ctx, from, to, amount, true, details)
|
result := token.transfer(ctx, from, to, amount, true, details)
|
||||||
if !result {
|
if !result {
|
||||||
|
@ -197,27 +160,12 @@ func TransferX(from, to interop.Hash160, amount int, details []byte) {
|
||||||
// It produces Lock, Transfer and TransferX notifications.
|
// It produces Lock, Transfer and TransferX notifications.
|
||||||
//
|
//
|
||||||
// Lock method is invoked by Alphabet nodes of the Inner Ring when they process
|
// Lock method is invoked by Alphabet nodes of the Inner Ring when they process
|
||||||
// Withdraw notification from NeoFS contract. This should transfer assets
|
// Withdraw notification from FrostFS contract. This should transfer assets
|
||||||
// to a new lock account that won't be used for anything beside Unlock and Burn.
|
// to a new lock account that won't be used for anything beside Unlock and Burn.
|
||||||
func Lock(txDetails []byte, from, to interop.Hash160, amount, until int) {
|
func Lock(txDetails []byte, from, to interop.Hash160, amount, until int) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
common.CheckAlphabetWitness()
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = common.AlphabetNodes()
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
panic("this method must be invoked from inner ring")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
details := common.LockTransferDetails(txDetails)
|
details := common.LockTransferDetails(txDetails)
|
||||||
|
|
||||||
|
@ -227,19 +175,7 @@ func Lock(txDetails []byte, from, to interop.Hash160, amount, until int) {
|
||||||
Parent: from,
|
Parent: from,
|
||||||
}
|
}
|
||||||
|
|
||||||
if notaryDisabled {
|
setAccount(ctx, to, lockAccount)
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := common.InvokeID([]interface{}{txDetails}, []byte("lock"))
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
common.SetSerialized(ctx, to, lockAccount)
|
|
||||||
|
|
||||||
result := token.transfer(ctx, from, to, amount, true, details)
|
result := token.transfer(ctx, from, to, amount, true, details)
|
||||||
if !result {
|
if !result {
|
||||||
|
@ -258,21 +194,8 @@ func Lock(txDetails []byte, from, to interop.Hash160, amount, until int) {
|
||||||
// It produces Transfer and TransferX notifications.
|
// It produces Transfer and TransferX notifications.
|
||||||
func NewEpoch(epochNum int) {
|
func NewEpoch(epochNum int) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
common.CheckAlphabetWitness()
|
||||||
indirectCall := common.FromKnownContract(
|
|
||||||
ctx,
|
|
||||||
runtime.GetCallingScriptHash(),
|
|
||||||
netmapContractKey,
|
|
||||||
)
|
|
||||||
if !indirectCall {
|
|
||||||
panic("this method must be invoked from inner ring")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
it := storage.Find(ctx, []byte{}, storage.KeysOnly)
|
it := storage.Find(ctx, []byte{}, storage.KeysOnly)
|
||||||
for iterator.Next(it) {
|
for iterator.Next(it) {
|
||||||
|
@ -300,43 +223,16 @@ func NewEpoch(epochNum int) {
|
||||||
// It produces Mint, Transfer and TransferX notifications.
|
// It produces Mint, Transfer and TransferX notifications.
|
||||||
//
|
//
|
||||||
// Mint method is invoked by Alphabet nodes of the Inner Ring when they process
|
// Mint method is invoked by Alphabet nodes of the Inner Ring when they process
|
||||||
// Deposit notification from NeoFS contract. Before that, Alphabet nodes should
|
// Deposit notification from FrostFS contract. Before that, Alphabet nodes should
|
||||||
// synchronize precision of mainchain GAS contract and Balance contract.
|
// synchronize precision of mainchain GAS contract and Balance contract.
|
||||||
// Mint increases total supply of NEP-17 compatible NeoFS token.
|
// Mint increases total supply of NEP-17 compatible FrostFS token.
|
||||||
func Mint(to interop.Hash160, amount int, txDetails []byte) {
|
func Mint(to interop.Hash160, amount int, txDetails []byte) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
common.CheckAlphabetWitness()
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = common.AlphabetNodes()
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
panic("this method must be invoked from inner ring")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
details := common.MintTransferDetails(txDetails)
|
details := common.MintTransferDetails(txDetails)
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := common.InvokeID([]interface{}{txDetails}, []byte("mint"))
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
ok := token.transfer(ctx, nil, to, amount, true, details)
|
ok := token.transfer(ctx, nil, to, amount, true, details)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("can't transfer assets")
|
panic("can't transfer assets")
|
||||||
|
@ -355,45 +251,18 @@ func Mint(to interop.Hash160, amount int, txDetails []byte) {
|
||||||
// It produces Burn, Transfer and TransferX notifications.
|
// It produces Burn, Transfer and TransferX notifications.
|
||||||
//
|
//
|
||||||
// Burn method is invoked by Alphabet nodes of the Inner Ring when they process
|
// Burn method is invoked by Alphabet nodes of the Inner Ring when they process
|
||||||
// Cheque notification from NeoFS contract. It means that locked assets have been
|
// Cheque notification from FrostFS contract. It means that locked assets have been
|
||||||
// transferred to the user in the mainchain, therefore the lock account should be destroyed.
|
// transferred to the user in the mainchain, therefore the lock account should be destroyed.
|
||||||
// Before that, Alphabet nodes should synchronize precision of mainchain GAS
|
// Before that, Alphabet nodes should synchronize precision of mainchain GAS
|
||||||
// contract and Balance contract. Burn decreases total supply of NEP-17
|
// contract and Balance contract. Burn decreases total supply of NEP-17
|
||||||
// compatible NeoFS token.
|
// compatible FrostFS token.
|
||||||
func Burn(from interop.Hash160, amount int, txDetails []byte) {
|
func Burn(from interop.Hash160, amount int, txDetails []byte) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
common.CheckAlphabetWitness()
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = common.AlphabetNodes()
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
panic("this method must be invoked from inner ring")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
details := common.BurnTransferDetails(txDetails)
|
details := common.BurnTransferDetails(txDetails)
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := common.InvokeID([]interface{}{txDetails}, []byte("burn"))
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
ok := token.transfer(ctx, from, nil, amount, true, details)
|
ok := token.transfer(ctx, from, nil, amount, true, details)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("can't transfer assets")
|
panic("can't transfer assets")
|
||||||
|
@ -443,14 +312,14 @@ func (t Token) transfer(ctx storage.Context, from, to interop.Hash160, amount in
|
||||||
storage.Delete(ctx, from)
|
storage.Delete(ctx, from)
|
||||||
} else {
|
} else {
|
||||||
amountFrom.Balance = amountFrom.Balance - amount // neo-go#953
|
amountFrom.Balance = amountFrom.Balance - amount // neo-go#953
|
||||||
common.SetSerialized(ctx, from, amountFrom)
|
setAccount(ctx, from, amountFrom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(to) == 20 {
|
if len(to) == 20 {
|
||||||
amountTo := getAccount(ctx, to)
|
amountTo := getAccount(ctx, to)
|
||||||
amountTo.Balance = amountTo.Balance + amount // neo-go#953
|
amountTo.Balance = amountTo.Balance + amount // neo-go#953
|
||||||
common.SetSerialized(ctx, to, amountTo)
|
setAccount(ctx, to, amountTo)
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.Notify("Transfer", from, to, amount)
|
runtime.Notify("Transfer", from, to, amount)
|
||||||
|
@ -461,9 +330,7 @@ func (t Token) transfer(ctx storage.Context, from, to interop.Hash160, amount in
|
||||||
|
|
||||||
// canTransfer returns the amount it can transfer.
|
// canTransfer returns the amount it can transfer.
|
||||||
func (t Token) canTransfer(ctx storage.Context, from, to interop.Hash160, amount int, innerRing bool) (Account, bool) {
|
func (t Token) canTransfer(ctx storage.Context, from, to interop.Hash160, amount int, innerRing bool) (Account, bool) {
|
||||||
var (
|
emptyAcc := Account{}
|
||||||
emptyAcc = Account{}
|
|
||||||
)
|
|
||||||
|
|
||||||
if !innerRing {
|
if !innerRing {
|
||||||
if len(to) != interop.Hash160Len || !isUsableAddress(from) {
|
if len(to) != interop.Hash160Len || !isUsableAddress(from) {
|
||||||
|
@ -501,11 +368,24 @@ func isUsableAddress(addr interop.Hash160) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAccount(ctx storage.Context, key interface{}) Account {
|
func getAccount(ctx storage.Context, key any) Account {
|
||||||
data := storage.Get(ctx, key)
|
data := storage.Get(ctx, key)
|
||||||
if data != nil {
|
if data != nil {
|
||||||
return std.Deserialize(data.([]byte)).(Account)
|
acc := std.Deserialize(data.([]byte)).(account)
|
||||||
|
return Account{
|
||||||
|
Balance: common.FromFixedWidth64(acc.Balance),
|
||||||
|
Until: common.FromFixedWidth64(acc.Until),
|
||||||
|
Parent: acc.Parent,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Account{}
|
return Account{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setAccount(ctx storage.Context, key any, acc Account) {
|
||||||
|
common.SetSerialized(ctx, key, account{
|
||||||
|
Balance: common.ToFixedWidth64(acc.Balance),
|
||||||
|
Until: common.ToFixedWidth64(acc.Until),
|
||||||
|
Parent: acc.Parent,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
name: "NeoFS Balance"
|
name: "Balance"
|
||||||
supportedstandards: ["NEP-17"]
|
supportedstandards: ["NEP-17"]
|
||||||
safemethods: ["balanceOf", "decimals", "symbol", "totalSupply", "version"]
|
safemethods:
|
||||||
|
- "balanceOf"
|
||||||
|
- "decimals"
|
||||||
|
- "symbol"
|
||||||
|
- "totalSupply"
|
||||||
|
- "version"
|
||||||
permissions:
|
permissions:
|
||||||
- methods: ["update"]
|
- methods: ["update"]
|
||||||
events:
|
events:
|
||||||
|
|
101
balance/doc.go
101
balance/doc.go
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
Balance contract is a contract deployed in NeoFS sidechain.
|
Balance contract is a contract deployed in FrostFS sidechain.
|
||||||
|
|
||||||
Balance contract stores all NeoFS account balances. It is a NEP-17 compatible
|
Balance contract stores all FrostFS account balances. It is a NEP-17 compatible
|
||||||
contract, so it can be tracked and controlled by N3 compatible network
|
contract, so it can be tracked and controlled by N3 compatible network
|
||||||
monitors and wallet software.
|
monitors and wallet software.
|
||||||
|
|
||||||
|
@ -10,70 +10,77 @@ data audit settlements or container fee payments. It is inefficient to make such
|
||||||
small payment transactions in the mainchain. To process small transfers, balance
|
small payment transactions in the mainchain. To process small transfers, balance
|
||||||
contract has higher (12) decimal precision than native GAS contract.
|
contract has higher (12) decimal precision than native GAS contract.
|
||||||
|
|
||||||
NeoFS balances are synchronized with mainchain operations. Deposit produces
|
FrostFS balances are synchronized with mainchain operations. Deposit produces
|
||||||
minting of NEOFS tokens in Balance contract. Withdraw locks some NEOFS tokens
|
minting of FROSTFS tokens in Balance contract. Withdraw locks some FROSTFS tokens
|
||||||
in a special lock account. When NeoFS contract transfers GAS assets back to the
|
in a special lock account. When FrostFS contract transfers GAS assets back to the
|
||||||
user, the lock account is destroyed with burn operation.
|
user, the lock account is destroyed with burn operation.
|
||||||
|
|
||||||
Contract notifications
|
# Contract notifications
|
||||||
|
|
||||||
Transfer notification. This is a NEP-17 standard notification.
|
Transfer notification. This is a NEP-17 standard notification.
|
||||||
|
|
||||||
Transfer:
|
Transfer:
|
||||||
- name: from
|
- name: from
|
||||||
type: Hash160
|
type: Hash160
|
||||||
- name: to
|
- name: to
|
||||||
type: Hash160
|
type: Hash160
|
||||||
- name: amount
|
- name: amount
|
||||||
type: Integer
|
type: Integer
|
||||||
|
|
||||||
TransferX notification. This is an enhanced transfer notification with details.
|
TransferX notification. This is an enhanced transfer notification with details.
|
||||||
|
|
||||||
TransferX:
|
TransferX:
|
||||||
- name: from
|
- name: from
|
||||||
type: Hash160
|
type: Hash160
|
||||||
- name: to
|
- name: to
|
||||||
type: Hash160
|
type: Hash160
|
||||||
- name: amount
|
- name: amount
|
||||||
type: Integer
|
type: Integer
|
||||||
- name: details
|
- name: details
|
||||||
type: ByteArray
|
type: ByteArray
|
||||||
|
|
||||||
Lock notification. This notification is produced when a lock account is
|
Lock notification. This notification is produced when a lock account is
|
||||||
created. It contains information about the mainchain transaction that has produced
|
created. It contains information about the mainchain transaction that has produced
|
||||||
the asset lock, the address of the lock account and the NeoFS epoch number until which the
|
the asset lock, the address of the lock account and the FrostFS epoch number until which the
|
||||||
lock account is valid. Alphabet nodes of the Inner Ring catch notification and initialize
|
lock account is valid. Alphabet nodes of the Inner Ring catch notification and initialize
|
||||||
Cheque method invocation of NeoFS contract.
|
Cheque method invocation of FrostFS contract.
|
||||||
|
|
||||||
Lock:
|
Lock:
|
||||||
- name: txID
|
- name: txID
|
||||||
type: ByteArray
|
type: ByteArray
|
||||||
- name: from
|
- name: from
|
||||||
type: Hash160
|
type: Hash160
|
||||||
- name: to
|
- name: to
|
||||||
type: Hash160
|
type: Hash160
|
||||||
- name: amount
|
- name: amount
|
||||||
type: Integer
|
type: Integer
|
||||||
- name: until
|
- name: until
|
||||||
type: Integer
|
type: Integer
|
||||||
|
|
||||||
Mint notification. This notification is produced when user balance is
|
Mint notification. This notification is produced when user balance is
|
||||||
replenished from deposit in the mainchain.
|
replenished from deposit in the mainchain.
|
||||||
|
|
||||||
Mint:
|
Mint:
|
||||||
- name: to
|
- name: to
|
||||||
type: Hash160
|
type: Hash160
|
||||||
- name: amount
|
- name: amount
|
||||||
type: Integer
|
type: Integer
|
||||||
|
|
||||||
|
|
||||||
Burn notification. This notification is produced after user balance is reduced
|
Burn notification. This notification is produced after user balance is reduced
|
||||||
when NeoFS contract has transferred GAS assets back to the user.
|
when FrostFS contract has transferred GAS assets back to the user.
|
||||||
|
|
||||||
Burn:
|
Burn:
|
||||||
- name: from
|
- name: from
|
||||||
type: Hash160
|
type: Hash160
|
||||||
- name: amount
|
- name: amount
|
||||||
type: Integer
|
type: Integer
|
||||||
|
|
||||||
|
# Contract storage scheme
|
||||||
|
|
||||||
|
| Key | Value | Description |
|
||||||
|
|-----------------------|------------|----------------------------------|
|
||||||
|
| `netmapScriptHash` | Hash160 | netmap contract hash |
|
||||||
|
| `containerScriptHash` | Hash160 | container contract hash |
|
||||||
|
| circulationKey | int | the token circulation key value |
|
||||||
*/
|
*/
|
||||||
package balance
|
package balance
|
||||||
|
|
11
common/common.go
Normal file
11
common/common.go
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package common
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BytesEqual compares two slices of bytes by wrapping them into strings,
|
||||||
|
// which is necessary with new util.Equals interop behaviour, see neo-go#1176.
|
||||||
|
func BytesEqual(a []byte, b []byte) bool {
|
||||||
|
return util.Equals(string(a), string(b))
|
||||||
|
}
|
28
common/ir.go
28
common/ir.go
|
@ -6,28 +6,12 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/ledger"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/ledger"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/neo"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/neo"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/roles"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/roles"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type IRNode struct {
|
type IRNode struct {
|
||||||
PublicKey interop.PublicKey
|
PublicKey interop.PublicKey
|
||||||
}
|
}
|
||||||
|
|
||||||
const irListMethod = "innerRingList"
|
|
||||||
|
|
||||||
// InnerRingInvoker returns the public key of the inner ring node that has invoked the contract.
|
|
||||||
// Work around for environments without notary support.
|
|
||||||
func InnerRingInvoker(ir []interop.PublicKey) interop.PublicKey {
|
|
||||||
for i := 0; i < len(ir); i++ {
|
|
||||||
node := ir[i]
|
|
||||||
if runtime.CheckWitness(node) {
|
|
||||||
return node
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// InnerRingNodes return a list of inner ring nodes from state validator role
|
// InnerRingNodes return a list of inner ring nodes from state validator role
|
||||||
// in the sidechain.
|
// in the sidechain.
|
||||||
func InnerRingNodes() []interop.PublicKey {
|
func InnerRingNodes() []interop.PublicKey {
|
||||||
|
@ -35,18 +19,6 @@ func InnerRingNodes() []interop.PublicKey {
|
||||||
return roles.GetDesignatedByRole(roles.NeoFSAlphabet, uint32(blockHeight+1))
|
return roles.GetDesignatedByRole(roles.NeoFSAlphabet, uint32(blockHeight+1))
|
||||||
}
|
}
|
||||||
|
|
||||||
// InnerRingNodesFromNetmap gets a list of inner ring nodes through
|
|
||||||
// calling "innerRingList" method of smart contract.
|
|
||||||
// Work around for environments without notary support.
|
|
||||||
func InnerRingNodesFromNetmap(sc interop.Hash160) []interop.PublicKey {
|
|
||||||
nodes := contract.Call(sc, irListMethod, contract.ReadOnly).([]IRNode)
|
|
||||||
pubs := []interop.PublicKey{}
|
|
||||||
for i := range nodes {
|
|
||||||
pubs = append(pubs, nodes[i].PublicKey)
|
|
||||||
}
|
|
||||||
return pubs
|
|
||||||
}
|
|
||||||
|
|
||||||
// AlphabetNodes returns a list of alphabet nodes from committee in the sidechain.
|
// AlphabetNodes returns a list of alphabet nodes from committee in the sidechain.
|
||||||
func AlphabetNodes() []interop.PublicKey {
|
func AlphabetNodes() []interop.PublicKey {
|
||||||
return neo.GetCommittee()
|
return neo.GetCommittee()
|
||||||
|
|
|
@ -1,21 +1,28 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/interop/convert"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetList(ctx storage.Context, key interface{}) [][]byte {
|
|
||||||
data := storage.Get(ctx, key)
|
|
||||||
if data != nil {
|
|
||||||
return std.Deserialize(data.([]byte)).([][]byte)
|
|
||||||
}
|
|
||||||
|
|
||||||
return [][]byte{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetSerialized serializes data and puts it into contract storage.
|
// SetSerialized serializes data and puts it into contract storage.
|
||||||
func SetSerialized(ctx storage.Context, key interface{}, value interface{}) {
|
func SetSerialized(ctx storage.Context, key any, value interface{}) {
|
||||||
data := std.Serialize(value)
|
data := std.Serialize(value)
|
||||||
storage.Put(ctx, key, data)
|
storage.Put(ctx, key, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ToFixedWidth64 converts x to bytes such that numbers <= math.MaxUint64
|
||||||
|
// have constant with of 9.
|
||||||
|
func ToFixedWidth64(x int) []byte {
|
||||||
|
data := convert.ToBytes(x)
|
||||||
|
if x < 0 || len(data) >= 9 {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
return append(data, make([]byte, 9-len(data))...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromFixedWidth64 is a reverse function for ToFixedWidth64.
|
||||||
|
func FromFixedWidth64(x []byte) int {
|
||||||
|
return convert.ToInteger(x)
|
||||||
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ func LockTransferDetails(txDetails []byte) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
func UnlockTransferDetails(epoch int) []byte {
|
func UnlockTransferDetails(epoch int) []byte {
|
||||||
var buf interface{} = epoch
|
var buf any = epoch
|
||||||
return append(unlockPrefix, buf.([]byte)...)
|
return append(unlockPrefix, buf.([]byte)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,15 +4,15 @@ import "github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
major = 0
|
major = 0
|
||||||
minor = 16
|
minor = 18
|
||||||
patch = 0
|
patch = 0
|
||||||
|
|
||||||
// Versions from which an update should be performed.
|
// Versions from which an update should be performed.
|
||||||
// These should be used in a group (so prevMinor can be equal to minor if there are
|
// These should be used in a group (so prevMinor can be equal to minor if there are
|
||||||
// any migration routines.
|
// any migration routines.
|
||||||
prevMajor = 0
|
prevMajor = 0
|
||||||
prevMinor = 15
|
prevMinor = 16
|
||||||
prevPatch = 4
|
prevPatch = 0
|
||||||
|
|
||||||
Version = major*1_000_000 + minor*1_000 + patch
|
Version = major*1_000_000 + minor*1_000 + patch
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ func CheckVersion(from int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendVersion appends current contract version to the list of deploy arguments.
|
// AppendVersion appends current contract version to the list of deploy arguments.
|
||||||
func AppendVersion(data interface{}) []interface{} {
|
func AppendVersion(data any) []interface{} {
|
||||||
if data == nil {
|
if data == nil {
|
||||||
return []interface{}{Version}
|
return []any{Version}
|
||||||
}
|
}
|
||||||
return append(data.([]interface{}), Version)
|
return append(data.([]any), Version)
|
||||||
}
|
}
|
||||||
|
|
149
common/vote.go
149
common/vote.go
|
@ -1,149 +0,0 @@
|
||||||
package common
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/crypto"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/ledger"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Ballot struct {
|
|
||||||
// ID of the voting decision.
|
|
||||||
ID []byte
|
|
||||||
|
|
||||||
// Public keys of the already voted inner ring nodes.
|
|
||||||
Voters []interop.PublicKey
|
|
||||||
|
|
||||||
// Height of block with the last vote.
|
|
||||||
Height int
|
|
||||||
}
|
|
||||||
|
|
||||||
const voteKey = "ballots"
|
|
||||||
|
|
||||||
const blockDiff = 20 // change base on performance evaluation
|
|
||||||
|
|
||||||
func InitVote(ctx storage.Context) {
|
|
||||||
SetSerialized(ctx, voteKey, []Ballot{})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Vote adds ballot for the decision with a specific 'id' and returns the amount
|
|
||||||
// of unique voters for that decision.
|
|
||||||
func Vote(ctx storage.Context, id, from []byte) int {
|
|
||||||
var (
|
|
||||||
newCandidates []Ballot
|
|
||||||
candidates = getBallots(ctx)
|
|
||||||
found = -1
|
|
||||||
blockHeight = ledger.CurrentIndex()
|
|
||||||
)
|
|
||||||
|
|
||||||
for i := 0; i < len(candidates); i++ {
|
|
||||||
cnd := candidates[i]
|
|
||||||
|
|
||||||
if blockHeight-cnd.Height > blockDiff {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if BytesEqual(cnd.ID, id) {
|
|
||||||
voters := cnd.Voters
|
|
||||||
|
|
||||||
for j := range voters {
|
|
||||||
if BytesEqual(voters[j], from) {
|
|
||||||
return len(voters)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
voters = append(voters, from)
|
|
||||||
cnd = Ballot{ID: id, Voters: voters, Height: blockHeight}
|
|
||||||
found = len(voters)
|
|
||||||
}
|
|
||||||
|
|
||||||
newCandidates = append(newCandidates, cnd)
|
|
||||||
}
|
|
||||||
|
|
||||||
if found < 0 {
|
|
||||||
voters := []interop.PublicKey{from}
|
|
||||||
newCandidates = append(newCandidates, Ballot{
|
|
||||||
ID: id,
|
|
||||||
Voters: voters,
|
|
||||||
Height: blockHeight})
|
|
||||||
found = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
SetSerialized(ctx, voteKey, newCandidates)
|
|
||||||
|
|
||||||
return found
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveVotes clears ballots of the decision that has been accepted by
|
|
||||||
// inner ring nodes.
|
|
||||||
func RemoveVotes(ctx storage.Context, id []byte) {
|
|
||||||
var (
|
|
||||||
candidates = getBallots(ctx)
|
|
||||||
index int
|
|
||||||
)
|
|
||||||
|
|
||||||
for i := 0; i < len(candidates); i++ {
|
|
||||||
cnd := candidates[i]
|
|
||||||
if BytesEqual(cnd.ID, id) {
|
|
||||||
index = i
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
util.Remove(candidates, index)
|
|
||||||
SetSerialized(ctx, voteKey, candidates)
|
|
||||||
}
|
|
||||||
|
|
||||||
// getBallots returns a deserialized slice of vote ballots.
|
|
||||||
func getBallots(ctx storage.Context) []Ballot {
|
|
||||||
data := storage.Get(ctx, voteKey)
|
|
||||||
if data != nil {
|
|
||||||
return std.Deserialize(data.([]byte)).([]Ballot)
|
|
||||||
}
|
|
||||||
|
|
||||||
return []Ballot{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// BytesEqual compares two slices of bytes by wrapping them into strings,
|
|
||||||
// which is necessary with new util.Equals interop behaviour, see neo-go#1176.
|
|
||||||
func BytesEqual(a []byte, b []byte) bool {
|
|
||||||
return util.Equals(string(a), string(b))
|
|
||||||
}
|
|
||||||
|
|
||||||
// InvokeID returns hashed value of prefix and args concatenation. Iy is used to
|
|
||||||
// identify different ballots.
|
|
||||||
func InvokeID(args []interface{}, prefix []byte) []byte {
|
|
||||||
for i := range args {
|
|
||||||
arg := args[i].([]byte)
|
|
||||||
prefix = append(prefix, arg...)
|
|
||||||
}
|
|
||||||
|
|
||||||
return crypto.Sha256(prefix)
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Check if the invocation is made from known container or audit contracts.
|
|
||||||
This is necessary because calls from these contracts require to do transfer
|
|
||||||
without signature collection (1 invoke transfer).
|
|
||||||
|
|
||||||
IR1, IR2, IR3, IR4 -(4 invokes)-> [ Container Contract ] -(1 invoke)-> [ Balance Contract ]
|
|
||||||
|
|
||||||
We can do 1 invoke transfer if:
|
|
||||||
- invokation has happened from inner ring node,
|
|
||||||
- it is indirect invocation from another smart-contract.
|
|
||||||
|
|
||||||
However, there is a possible attack, when a malicious inner ring node creates
|
|
||||||
a malicious smart-contract in the morph chain to do indirect call.
|
|
||||||
|
|
||||||
MaliciousIR -(1 invoke)-> [ Malicious Contract ] -(1 invoke)-> [ Balance Contract ]
|
|
||||||
|
|
||||||
To prevent that, we have to allow 1 invoke transfer from authorised well-known
|
|
||||||
smart-contracts, that will be set up at `Init` method.
|
|
||||||
*/
|
|
||||||
|
|
||||||
func FromKnownContract(ctx storage.Context, caller interop.Hash160, key string) bool {
|
|
||||||
addr := storage.Get(ctx, key).(interop.Hash160)
|
|
||||||
return BytesEqual(caller, addr)
|
|
||||||
}
|
|
|
@ -16,8 +16,8 @@ var (
|
||||||
|
|
||||||
// CheckAlphabetWitness checks witness of the passed caller.
|
// CheckAlphabetWitness checks witness of the passed caller.
|
||||||
// It panics with ErrAlphabetWitnessFailed message on fail.
|
// It panics with ErrAlphabetWitnessFailed message on fail.
|
||||||
func CheckAlphabetWitness(caller []byte) {
|
func CheckAlphabetWitness() {
|
||||||
checkWitnessWithPanic(caller, ErrAlphabetWitnessFailed)
|
checkWitnessWithPanic(AlphabetAddress(), ErrAlphabetWitnessFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckOwnerWitness checks witness of the passed caller.
|
// CheckOwnerWitness checks witness of the passed caller.
|
||||||
|
|
20
commonclient/invoker.go
Normal file
20
commonclient/invoker.go
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package commonclient
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Invoker is a subset of methods provided by struct invoker.Invoker. The subset contains only those
|
||||||
|
// methods that are used by ActorWrapper and clients of the contracts.
|
||||||
|
type Invoker interface {
|
||||||
|
Call(contract util.Uint160, method string, params ...any) (*result.Invoke, error)
|
||||||
|
TraverseIterator(sessionID uuid.UUID, iterator *result.Iterator, num int) ([]stackitem.Item, error)
|
||||||
|
TerminateSession(sessionID uuid.UUID) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the interface is compatible with the invoker.Invoker struct.
|
||||||
|
var _ Invoker = (*invoker.Invoker)(nil)
|
35
commonclient/iterator.go
Normal file
35
commonclient/iterator.go
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package commonclient
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ReadIteratorItems calls method that returns iterator and traverses the iterator until all items are read into array.
|
||||||
|
func ReadIteratorItems(inv Invoker, batchSize int, contract util.Uint160, method string, params ...any) ([]stackitem.Item, error) {
|
||||||
|
if batchSize <= 0 {
|
||||||
|
panic("batch size must be positive")
|
||||||
|
}
|
||||||
|
|
||||||
|
sessionID, iter, err := unwrap.SessionIterator(inv.Call(contract, method, params...))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("unwrap session iterator: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var shouldStop bool
|
||||||
|
res := make([]stackitem.Item, 0, len(iter.Values))
|
||||||
|
for !shouldStop {
|
||||||
|
items, err := inv.TraverseIterator(sessionID, &iter, batchSize)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
res = append(res, items...)
|
||||||
|
shouldStop = len(items) < batchSize
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
63
commonclient/transaction.go
Normal file
63
commonclient/transaction.go
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
package commonclient
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Transaction allows to invoke several contract method at once.
|
||||||
|
type Transaction struct {
|
||||||
|
writer *io.BufBinWriter
|
||||||
|
buffer *io.BufBinWriter
|
||||||
|
contract util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
var ErrTransactionTooLarge = errors.New("transaction/script size limit exceeded")
|
||||||
|
|
||||||
|
// NewTransaction creates new transaction to accumulate contract invocations.
|
||||||
|
func NewTransaction(contractHash util.Uint160) *Transaction {
|
||||||
|
return &Transaction{
|
||||||
|
writer: io.NewBufBinWriter(),
|
||||||
|
buffer: io.NewBufBinWriter(),
|
||||||
|
contract: contractHash,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WrapCall accept methods and arguments to invoke.
|
||||||
|
// Should be used with method on clients like Client.MethodNameCall.
|
||||||
|
func (t Transaction) WrapCall(method string, args []any) error {
|
||||||
|
t.buffer.Reset()
|
||||||
|
emit.AppCall(t.buffer.BinWriter, t.contract, method, callflag.All, args...)
|
||||||
|
|
||||||
|
if t.writer.Len()+t.buffer.Len() > transaction.MaxScriptLength {
|
||||||
|
return ErrTransactionTooLarge
|
||||||
|
}
|
||||||
|
|
||||||
|
t.writer.WriteBytes(t.buffer.Bytes())
|
||||||
|
|
||||||
|
return t.writer.Err
|
||||||
|
}
|
||||||
|
|
||||||
|
// WrapCallErr accept methods, arguments and error to handle and invoke.
|
||||||
|
// Should be used with method on clients like *CallErr.
|
||||||
|
func (t Transaction) WrapCallErr(method string, args []any, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return t.WrapCall(method, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bytes returns the resulting buffer and makes future writes return an error.
|
||||||
|
func (t Transaction) Bytes() ([]byte, error) {
|
||||||
|
if t.writer.Len() > transaction.MaxScriptLength {
|
||||||
|
return nil, ErrTransactionTooLarge
|
||||||
|
}
|
||||||
|
|
||||||
|
return t.writer.Bytes(), nil
|
||||||
|
}
|
|
@ -1,47 +1,35 @@
|
||||||
name: "NeoFS Container"
|
name: "Container"
|
||||||
safemethods: ["count", "get", "owner", "list", "eACL", "getContainerSize", "listContainerSizes", "version"]
|
safemethods:
|
||||||
|
- "count"
|
||||||
|
- "containersOf"
|
||||||
|
- "deletionInfo"
|
||||||
|
- "eACL"
|
||||||
|
- "get"
|
||||||
|
- "getContainerSize"
|
||||||
|
- "iterateContainerSizes"
|
||||||
|
- "list"
|
||||||
|
- "listContainerSizes"
|
||||||
|
- "owner"
|
||||||
|
- "version"
|
||||||
permissions:
|
permissions:
|
||||||
- methods: ["update", "addKey", "transferX",
|
- methods:
|
||||||
"register", "addRecord", "deleteRecords"]
|
- "addRecord"
|
||||||
|
- "deleteRecords"
|
||||||
|
- "register"
|
||||||
|
- "transferX"
|
||||||
|
- "update"
|
||||||
|
|
||||||
events:
|
events:
|
||||||
- name: containerPut
|
|
||||||
parameters:
|
|
||||||
- name: container
|
|
||||||
type: ByteArray
|
|
||||||
- name: signature
|
|
||||||
type: Signature
|
|
||||||
- name: publicKey
|
|
||||||
type: PublicKey
|
|
||||||
- name: token
|
|
||||||
type: ByteArray
|
|
||||||
- name: PutSuccess
|
- name: PutSuccess
|
||||||
parameters:
|
parameters:
|
||||||
- name: containerID
|
- name: containerID
|
||||||
type: Hash256
|
type: Hash256
|
||||||
- name: publicKey
|
- name: publicKey
|
||||||
type: PublicKey
|
type: PublicKey
|
||||||
- name: containerDelete
|
|
||||||
parameters:
|
|
||||||
- name: containerID
|
|
||||||
type: ByteArray
|
|
||||||
- name: signature
|
|
||||||
type: Signature
|
|
||||||
- name: token
|
|
||||||
type: ByteArray
|
|
||||||
- name: DeleteSuccess
|
- name: DeleteSuccess
|
||||||
parameters:
|
parameters:
|
||||||
- name: containerID
|
- name: containerID
|
||||||
type: ByteArray
|
type: ByteArray
|
||||||
- name: setEACL
|
|
||||||
parameters:
|
|
||||||
- name: eACL
|
|
||||||
type: ByteArray
|
|
||||||
- name: signature
|
|
||||||
type: Signature
|
|
||||||
- name: publicKey
|
|
||||||
type: PublicKey
|
|
||||||
- name: token
|
|
||||||
type: ByteArray
|
|
||||||
- name: SetEACLSuccess
|
- name: SetEACLSuccess
|
||||||
parameters:
|
parameters:
|
||||||
- name: containerID
|
- name: containerID
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/convert"
|
"github.com/nspcc-dev/neo-go/pkg/interop/convert"
|
||||||
|
@ -10,7 +11,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neofs-contract/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
@ -44,13 +44,12 @@ type (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
neofsIDContractKey = "identityScriptHash"
|
frostfsIDContractKey = "identityScriptHash"
|
||||||
balanceContractKey = "balanceScriptHash"
|
balanceContractKey = "balanceScriptHash"
|
||||||
netmapContractKey = "netmapScriptHash"
|
netmapContractKey = "netmapScriptHash"
|
||||||
nnsContractKey = "nnsScriptHash"
|
nnsContractKey = "nnsScriptHash"
|
||||||
nnsRootKey = "nnsRoot"
|
nnsRootKey = "nnsRoot"
|
||||||
nnsHasAliasKey = "nnsHasAlias"
|
nnsHasAliasKey = "nnsHasAlias"
|
||||||
notaryDisabledKey = "notary"
|
|
||||||
|
|
||||||
// RegistrationFeeKey is a key in netmap config which contains fee for container registration.
|
// RegistrationFeeKey is a key in netmap config which contains fee for container registration.
|
||||||
RegistrationFeeKey = "ContainerFee"
|
RegistrationFeeKey = "ContainerFee"
|
||||||
|
@ -62,6 +61,9 @@ const (
|
||||||
|
|
||||||
singleEstimatePrefix = "est"
|
singleEstimatePrefix = "est"
|
||||||
estimateKeyPrefix = "cnr"
|
estimateKeyPrefix = "cnr"
|
||||||
|
containerKeyPrefix = 'x'
|
||||||
|
ownerKeyPrefix = 'o'
|
||||||
|
graveKeyPrefix = 'g'
|
||||||
estimatePostfixSize = 10
|
estimatePostfixSize = 10
|
||||||
// CleanupDelta contains the number of the last epochs for which container estimations are present.
|
// CleanupDelta contains the number of the last epochs for which container estimations are present.
|
||||||
CleanupDelta = 3
|
CleanupDelta = 3
|
||||||
|
@ -74,35 +76,53 @@ const (
|
||||||
NotFoundError = "container does not exist"
|
NotFoundError = "container does not exist"
|
||||||
|
|
||||||
// default SOA record field values
|
// default SOA record field values
|
||||||
defaultRefresh = 3600 // 1 hour
|
defaultRefresh = 3600 // 1 hour
|
||||||
defaultRetry = 600 // 10 min
|
defaultRetry = 600 // 10 min
|
||||||
defaultExpire = 604800 // 1 week
|
defaultExpire = 3600 * 24 * 365 * 10 // 10 years
|
||||||
defaultTTL = 3600 // 1 hour
|
defaultTTL = 3600 // 1 hour
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var eACLPrefix = []byte("eACL")
|
||||||
eACLPrefix = []byte("eACL")
|
|
||||||
)
|
|
||||||
|
|
||||||
// OnNEP11Payment is needed for registration with contract as the owner to work.
|
// OnNEP11Payment is needed for registration with contract as the owner to work.
|
||||||
func OnNEP11Payment(a interop.Hash160, b int, c []byte, d interface{}) {
|
func OnNEP11Payment(a interop.Hash160, b int, c []byte, d any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
func _deploy(data any, isUpdate bool) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
args := data.([]interface{})
|
args := data.([]any)
|
||||||
common.CheckVersion(args[len(args)-1].(int))
|
common.CheckVersion(args[len(args)-1].(int))
|
||||||
|
|
||||||
|
it := storage.Find(ctx, []byte{}, storage.None)
|
||||||
|
for iterator.Next(it) {
|
||||||
|
item := iterator.Value(it).(struct {
|
||||||
|
key []byte
|
||||||
|
value []byte
|
||||||
|
})
|
||||||
|
|
||||||
|
// Migrate container.
|
||||||
|
if len(item.key) == containerIDSize {
|
||||||
|
storage.Delete(ctx, item.key)
|
||||||
|
storage.Put(ctx, append([]byte{containerKeyPrefix}, item.key...), item.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Migrate owner-cid map.
|
||||||
|
if len(item.key) == 25 /* owner id size */ +containerIDSize {
|
||||||
|
storage.Delete(ctx, item.key)
|
||||||
|
storage.Put(ctx, append([]byte{ownerKeyPrefix}, item.key...), item.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
args := data.(struct {
|
args := data.(struct {
|
||||||
notaryDisabled bool
|
addrNetmap interop.Hash160
|
||||||
addrNetmap interop.Hash160
|
addrBalance interop.Hash160
|
||||||
addrBalance interop.Hash160
|
addrID interop.Hash160
|
||||||
addrID interop.Hash160
|
addrNNS interop.Hash160
|
||||||
addrNNS interop.Hash160
|
nnsRoot string
|
||||||
nnsRoot string
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(args.addrNetmap) != interop.Hash160Len ||
|
if len(args.addrNetmap) != interop.Hash160Len ||
|
||||||
|
@ -113,17 +133,10 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
storage.Put(ctx, netmapContractKey, args.addrNetmap)
|
storage.Put(ctx, netmapContractKey, args.addrNetmap)
|
||||||
storage.Put(ctx, balanceContractKey, args.addrBalance)
|
storage.Put(ctx, balanceContractKey, args.addrBalance)
|
||||||
storage.Put(ctx, neofsIDContractKey, args.addrID)
|
storage.Put(ctx, frostfsIDContractKey, args.addrID)
|
||||||
storage.Put(ctx, nnsContractKey, args.addrNNS)
|
storage.Put(ctx, nnsContractKey, args.addrNNS)
|
||||||
storage.Put(ctx, nnsRootKey, args.nnsRoot)
|
storage.Put(ctx, nnsRootKey, args.nnsRoot)
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
|
||||||
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
|
||||||
if args.notaryDisabled {
|
|
||||||
common.InitVote(ctx)
|
|
||||||
runtime.Log("container contract notary disabled")
|
|
||||||
}
|
|
||||||
|
|
||||||
// add NNS root for container alias domains
|
// add NNS root for container alias domains
|
||||||
registerNiceNameTLD(args.addrNNS, args.nnsRoot)
|
registerNiceNameTLD(args.addrNNS, args.nnsRoot)
|
||||||
|
|
||||||
|
@ -138,7 +151,7 @@ func registerNiceNameTLD(addrNNS interop.Hash160, nnsRoot string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
res := contract.Call(addrNNS, "register", contract.All,
|
res := contract.Call(addrNNS, "register", contract.All,
|
||||||
nnsRoot, runtime.GetExecutingScriptHash(), "ops@nspcc.ru",
|
nnsRoot, runtime.GetExecutingScriptHash(), "ops@frostfs.info",
|
||||||
defaultRefresh, defaultRetry, defaultExpire, defaultTTL).(bool)
|
defaultRefresh, defaultRetry, defaultExpire, defaultTTL).(bool)
|
||||||
if !res {
|
if !res {
|
||||||
panic("can't register NNS TLD")
|
panic("can't register NNS TLD")
|
||||||
|
@ -147,18 +160,17 @@ func registerNiceNameTLD(addrNNS interop.Hash160, nnsRoot string) {
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. It can be invoked
|
// Update method updates contract source code and manifest. It can be invoked
|
||||||
// by committee only.
|
// by committee only.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data any) {
|
||||||
if !common.HasUpdateAccess() {
|
if !common.HasUpdateAccess() {
|
||||||
panic("only committee can update contract")
|
panic("only committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update",
|
management.UpdateWithData(script, manifest, common.AppendVersion(data))
|
||||||
contract.All, script, manifest, common.AppendVersion(data))
|
|
||||||
runtime.Log("container contract updated")
|
runtime.Log("container contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put method creates a new container if it has been invoked by Alphabet nodes
|
// Put method creates a new container if it has been invoked by Alphabet nodes
|
||||||
// of the Inner Ring. Otherwise, it produces containerPut notification.
|
// of the Inner Ring.
|
||||||
//
|
//
|
||||||
// Container should be a stable marshaled Container structure from API.
|
// Container should be a stable marshaled Container structure from API.
|
||||||
// Signature is a RFC6979 signature of the Container.
|
// Signature is a RFC6979 signature of the Container.
|
||||||
|
@ -173,13 +185,12 @@ func Put(container []byte, signature interop.Signature, publicKey interop.Public
|
||||||
// Note that zone must exist.
|
// Note that zone must exist.
|
||||||
func PutNamed(container []byte, signature interop.Signature,
|
func PutNamed(container []byte, signature interop.Signature,
|
||||||
publicKey interop.PublicKey, token []byte,
|
publicKey interop.PublicKey, token []byte,
|
||||||
name, zone string) {
|
name, zone string,
|
||||||
|
) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
ownerID := ownerFromBinaryContainer(container)
|
ownerID := ownerFromBinaryContainer(container)
|
||||||
containerID := crypto.Sha256(container)
|
containerID := crypto.Sha256(container)
|
||||||
neofsIDContractAddr := storage.Get(ctx, neofsIDContractKey).(interop.Hash160)
|
|
||||||
cnr := Container{
|
cnr := Container{
|
||||||
value: container,
|
value: container,
|
||||||
sig: signature,
|
sig: signature,
|
||||||
|
@ -216,26 +227,7 @@ func PutNamed(container []byte, signature interop.Signature,
|
||||||
panic("insufficient balance to create container")
|
panic("insufficient balance to create container")
|
||||||
}
|
}
|
||||||
|
|
||||||
if notaryDisabled {
|
common.CheckAlphabetWitness()
|
||||||
nodeKey := common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
runtime.Notify("containerPut", container, signature, publicKey, token)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := common.InvokeID([]interface{}{container, signature, publicKey}, []byte("put"))
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
// todo: check if new container with unique container id
|
// todo: check if new container with unique container id
|
||||||
|
|
||||||
details := common.ContainerFeeTransferDetails(containerID)
|
details := common.ContainerFeeTransferDetails(containerID)
|
||||||
|
@ -258,7 +250,7 @@ func PutNamed(container []byte, signature interop.Signature,
|
||||||
if name != "" {
|
if name != "" {
|
||||||
if needRegister {
|
if needRegister {
|
||||||
res := contract.Call(nnsContractAddr, "register", contract.All,
|
res := contract.Call(nnsContractAddr, "register", contract.All,
|
||||||
domain, runtime.GetExecutingScriptHash(), "ops@nspcc.ru",
|
domain, runtime.GetExecutingScriptHash(), "ops@frostfs.info",
|
||||||
defaultRefresh, defaultRetry, defaultExpire, defaultTTL).(bool)
|
defaultRefresh, defaultRetry, defaultExpire, defaultTTL).(bool)
|
||||||
if !res {
|
if !res {
|
||||||
panic("can't register the domain " + domain)
|
panic("can't register the domain " + domain)
|
||||||
|
@ -271,10 +263,6 @@ func PutNamed(container []byte, signature interop.Signature,
|
||||||
storage.Put(ctx, key, domain)
|
storage.Put(ctx, key, domain)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(token) == 0 { // if container created directly without session
|
|
||||||
contract.Call(neofsIDContractAddr, "addKey", contract.All, ownerID, [][]byte{publicKey})
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.Log("added new container")
|
runtime.Log("added new container")
|
||||||
runtime.Notify("PutSuccess", containerID, publicKey)
|
runtime.Notify("PutSuccess", containerID, publicKey)
|
||||||
}
|
}
|
||||||
|
@ -304,44 +292,22 @@ func checkNiceNameAvailable(nnsContractAddr interop.Hash160, domain string) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete method removes a container from the contract storage if it has been
|
// Delete method removes a container from the contract storage if it has been
|
||||||
// invoked by Alphabet nodes of the Inner Ring. Otherwise, it produces
|
// invoked by Alphabet nodes of the Inner Ring.
|
||||||
// containerDelete notification.
|
|
||||||
//
|
//
|
||||||
// Signature is a RFC6979 signature of the container ID.
|
// Signature is a RFC6979 signature of the container ID.
|
||||||
// Token is optional and should be a stable marshaled SessionToken structure from
|
// Token is optional and should be a stable marshaled SessionToken structure from
|
||||||
// API.
|
// API.
|
||||||
//
|
//
|
||||||
// If the container doesn't exist, it panics with NotFoundError.
|
// If the container doesn't exist, it panics with NotFoundError.
|
||||||
func Delete(containerID []byte, signature interop.Signature, token []byte) {
|
func Delete(containerID []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
ownerID := getOwnerByID(ctx, containerID)
|
ownerID := getOwnerByID(ctx, containerID)
|
||||||
if ownerID == nil {
|
if ownerID == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if notaryDisabled {
|
common.CheckAlphabetWitness()
|
||||||
alphabet := common.AlphabetNodes()
|
|
||||||
nodeKey := common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
runtime.Notify("containerDelete", containerID, signature, token)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := common.InvokeID([]interface{}{containerID, signature}, []byte("delete"))
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
key := append([]byte(nnsHasAliasKey), containerID...)
|
key := append([]byte(nnsHasAliasKey), containerID...)
|
||||||
domain := storage.Get(ctx, key).(string)
|
domain := storage.Get(ctx, key).(string)
|
||||||
|
@ -352,7 +318,7 @@ func Delete(containerID []byte, signature interop.Signature, token []byte) {
|
||||||
// and inability to delete a container. We should also check if we own the record in case.
|
// and inability to delete a container. We should also check if we own the record in case.
|
||||||
nnsContractAddr := storage.Get(ctx, nnsContractKey).(interop.Hash160)
|
nnsContractAddr := storage.Get(ctx, nnsContractKey).(interop.Hash160)
|
||||||
res := contract.Call(nnsContractAddr, "getRecords", contract.ReadStates|contract.AllowCall, domain, 16 /* TXT */)
|
res := contract.Call(nnsContractAddr, "getRecords", contract.ReadStates|contract.AllowCall, domain, 16 /* TXT */)
|
||||||
if res != nil && std.Base58Encode(containerID) == string(res.([]interface{})[0].(string)) {
|
if res != nil && std.Base58Encode(containerID) == string(res.([]any)[0].(string)) {
|
||||||
contract.Call(nnsContractAddr, "deleteRecords", contract.All, domain, 16 /* TXT */)
|
contract.Call(nnsContractAddr, "deleteRecords", contract.All, domain, 16 /* TXT */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -361,6 +327,35 @@ func Delete(containerID []byte, signature interop.Signature, token []byte) {
|
||||||
runtime.Notify("DeleteSuccess", containerID)
|
runtime.Notify("DeleteSuccess", containerID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DelInfo struct {
|
||||||
|
Owner []byte
|
||||||
|
Epoch int
|
||||||
|
}
|
||||||
|
|
||||||
|
type delInfo struct {
|
||||||
|
Owner []byte
|
||||||
|
Epoch []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletionInfo method returns container deletion info.
|
||||||
|
// If the container had never existed, NotFoundError is throwed.
|
||||||
|
// It can be used to check whether non-existing container was indeed deleted
|
||||||
|
// or does not yet exist at some height.
|
||||||
|
func DeletionInfo(containerID []byte) DelInfo {
|
||||||
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
graveKey := append([]byte{graveKeyPrefix}, containerID...)
|
||||||
|
data := storage.Get(ctx, graveKey).([]byte)
|
||||||
|
if data == nil {
|
||||||
|
panic(NotFoundError)
|
||||||
|
}
|
||||||
|
|
||||||
|
d := std.Deserialize(data).(delInfo)
|
||||||
|
return DelInfo{
|
||||||
|
Owner: d.Owner,
|
||||||
|
Epoch: common.FromFixedWidth64(d.Epoch),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get method returns a structure that contains a stable marshaled Container structure,
|
// Get method returns a structure that contains a stable marshaled Container structure,
|
||||||
// the signature, the public key of the container creator and a stable marshaled SessionToken
|
// the signature, the public key of the container creator and a stable marshaled SessionToken
|
||||||
// structure if it was provided.
|
// structure if it was provided.
|
||||||
|
@ -391,17 +386,24 @@ func Owner(containerID []byte) []byte {
|
||||||
func Count() int {
|
func Count() int {
|
||||||
count := 0
|
count := 0
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
it := storage.Find(ctx, []byte{}, storage.KeysOnly)
|
it := storage.Find(ctx, []byte{containerKeyPrefix}, storage.KeysOnly)
|
||||||
for iterator.Next(it) {
|
for iterator.Next(it) {
|
||||||
key := iterator.Value(it).([]byte)
|
count++
|
||||||
// V2 format
|
|
||||||
if len(key) == containerIDSize {
|
|
||||||
count++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainersOf iterates over all container IDs owned by the specified owner.
|
||||||
|
// If owner is nil, it iterates over all containers.
|
||||||
|
func ContainersOf(owner []byte) iterator.Iterator {
|
||||||
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
key := []byte{ownerKeyPrefix}
|
||||||
|
if len(owner) != 0 {
|
||||||
|
key = append(key, owner...)
|
||||||
|
}
|
||||||
|
return storage.Find(ctx, key, storage.ValuesOnly)
|
||||||
|
}
|
||||||
|
|
||||||
// List method returns a list of all container IDs owned by the specified owner.
|
// List method returns a list of all container IDs owned by the specified owner.
|
||||||
func List(owner []byte) [][]byte {
|
func List(owner []byte) [][]byte {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
@ -412,7 +414,7 @@ func List(owner []byte) [][]byte {
|
||||||
|
|
||||||
var list [][]byte
|
var list [][]byte
|
||||||
|
|
||||||
it := storage.Find(ctx, owner, storage.ValuesOnly)
|
it := storage.Find(ctx, append([]byte{ownerKeyPrefix}, owner...), storage.ValuesOnly)
|
||||||
for iterator.Next(it) {
|
for iterator.Next(it) {
|
||||||
id := iterator.Value(it).([]byte)
|
id := iterator.Value(it).([]byte)
|
||||||
list = append(list, id)
|
list = append(list, id)
|
||||||
|
@ -422,8 +424,7 @@ func List(owner []byte) [][]byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetEACL method sets a new extended ACL table related to the contract
|
// SetEACL method sets a new extended ACL table related to the contract
|
||||||
// if it was invoked by Alphabet nodes of the Inner Ring. Otherwise, it produces
|
// if it was invoked by Alphabet nodes of the Inner Ring.
|
||||||
// setEACL notification.
|
|
||||||
//
|
//
|
||||||
// EACL should be a stable marshaled EACLTable structure from API.
|
// EACL should be a stable marshaled EACLTable structure from API.
|
||||||
// Signature is a RFC6979 signature of the Container.
|
// Signature is a RFC6979 signature of the Container.
|
||||||
|
@ -434,7 +435,6 @@ func List(owner []byte) [][]byte {
|
||||||
// If the container doesn't exist, it panics with NotFoundError.
|
// If the container doesn't exist, it panics with NotFoundError.
|
||||||
func SetEACL(eACL []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte) {
|
func SetEACL(eACL []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
// V2 format
|
// V2 format
|
||||||
// get container ID
|
// get container ID
|
||||||
|
@ -447,27 +447,7 @@ func SetEACL(eACL []byte, signature interop.Signature, publicKey interop.PublicK
|
||||||
panic(NotFoundError)
|
panic(NotFoundError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if notaryDisabled {
|
common.CheckAlphabetWitness()
|
||||||
alphabet := common.AlphabetNodes()
|
|
||||||
nodeKey := common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
runtime.Notify("setEACL", eACL, signature, publicKey, token)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := common.InvokeID([]interface{}{eACL}, []byte("setEACL"))
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
rule := ExtendedACL{
|
rule := ExtendedACL{
|
||||||
value: eACL,
|
value: eACL,
|
||||||
|
@ -551,11 +531,11 @@ func GetContainerSize(id []byte) containerSizes {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListContainerSizes method returns the IDs of container size estimations
|
// ListContainerSizes method returns the IDs of container size estimations
|
||||||
// that has been registered for the specified epoch.
|
// that have been registered for the specified epoch.
|
||||||
func ListContainerSizes(epoch int) [][]byte {
|
func ListContainerSizes(epoch int) [][]byte {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
var buf interface{} = epoch
|
var buf any = epoch
|
||||||
|
|
||||||
key := []byte(estimateKeyPrefix)
|
key := []byte(estimateKeyPrefix)
|
||||||
key = append(key, buf.([]byte)...)
|
key = append(key, buf.([]byte)...)
|
||||||
|
@ -582,25 +562,25 @@ func ListContainerSizes(epoch int) [][]byte {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IterateContainerSizes method returns iterator over container size estimations
|
||||||
|
// that have been registered for the specified epoch.
|
||||||
|
func IterateContainerSizes(epoch int) iterator.Iterator {
|
||||||
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
|
var buf any = epoch
|
||||||
|
|
||||||
|
key := []byte(estimateKeyPrefix)
|
||||||
|
key = append(key, buf.([]byte)...)
|
||||||
|
|
||||||
|
return storage.Find(ctx, key, storage.DeserializeValues)
|
||||||
|
}
|
||||||
|
|
||||||
// NewEpoch method removes all container size estimations from epoch older than
|
// NewEpoch method removes all container size estimations from epoch older than
|
||||||
// epochNum + 3. It can be invoked only by NewEpoch method of the Netmap contract.
|
// epochNum + 3. It can be invoked only by NewEpoch method of the Netmap contract.
|
||||||
func NewEpoch(epochNum int) {
|
func NewEpoch(epochNum int) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
common.CheckAlphabetWitness()
|
||||||
indirectCall := common.FromKnownContract(
|
|
||||||
ctx,
|
|
||||||
runtime.GetCallingScriptHash(),
|
|
||||||
netmapContractKey,
|
|
||||||
)
|
|
||||||
if !indirectCall {
|
|
||||||
panic("method must be invoked by inner ring")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanupContainers(ctx, epochNum)
|
cleanupContainers(ctx, epochNum)
|
||||||
}
|
}
|
||||||
|
@ -608,36 +588,7 @@ func NewEpoch(epochNum int) {
|
||||||
// StartContainerEstimation method produces StartEstimation notification.
|
// StartContainerEstimation method produces StartEstimation notification.
|
||||||
// It can be invoked only by Alphabet nodes of the Inner Ring.
|
// It can be invoked only by Alphabet nodes of the Inner Ring.
|
||||||
func StartContainerEstimation(epoch int) {
|
func StartContainerEstimation(epoch int) {
|
||||||
ctx := storage.GetContext()
|
common.CheckAlphabetWitness()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = common.AlphabetNodes()
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
panic("method must be invoked by inner ring")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := common.InvokeID([]interface{}{epoch}, []byte("startEstimation"))
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.Notify("StartEstimation", epoch)
|
runtime.Notify("StartEstimation", epoch)
|
||||||
runtime.Log("notification has been produced")
|
runtime.Log("notification has been produced")
|
||||||
|
@ -646,36 +597,7 @@ func StartContainerEstimation(epoch int) {
|
||||||
// StopContainerEstimation method produces StopEstimation notification.
|
// StopContainerEstimation method produces StopEstimation notification.
|
||||||
// It can be invoked only by Alphabet nodes of the Inner Ring.
|
// It can be invoked only by Alphabet nodes of the Inner Ring.
|
||||||
func StopContainerEstimation(epoch int) {
|
func StopContainerEstimation(epoch int) {
|
||||||
ctx := storage.GetContext()
|
common.CheckAlphabetWitness()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = common.AlphabetNodes()
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
panic("method must be invoked by inner ring")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := common.InvokeID([]interface{}{epoch}, []byte("stopEstimation"))
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.Notify("StopEstimation", epoch)
|
runtime.Notify("StopEstimation", epoch)
|
||||||
runtime.Log("notification has been produced")
|
runtime.Log("notification has been produced")
|
||||||
|
@ -687,29 +609,41 @@ func Version() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func addContainer(ctx storage.Context, id, owner []byte, container Container) {
|
func addContainer(ctx storage.Context, id, owner []byte, container Container) {
|
||||||
containerListKey := append(owner, id...)
|
containerListKey := append([]byte{ownerKeyPrefix}, owner...)
|
||||||
|
containerListKey = append(containerListKey, id...)
|
||||||
storage.Put(ctx, containerListKey, id)
|
storage.Put(ctx, containerListKey, id)
|
||||||
|
|
||||||
common.SetSerialized(ctx, id, container)
|
idKey := append([]byte{containerKeyPrefix}, id...)
|
||||||
|
common.SetSerialized(ctx, idKey, container)
|
||||||
|
|
||||||
|
graveKey := append([]byte{graveKeyPrefix}, id...)
|
||||||
|
storage.Delete(ctx, graveKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeContainer(ctx storage.Context, id []byte, owner []byte) {
|
func removeContainer(ctx storage.Context, id []byte, owner []byte) {
|
||||||
containerListKey := append(owner, id...)
|
containerListKey := append([]byte{ownerKeyPrefix}, owner...)
|
||||||
|
containerListKey = append(containerListKey, id...)
|
||||||
storage.Delete(ctx, containerListKey)
|
storage.Delete(ctx, containerListKey)
|
||||||
|
|
||||||
storage.Delete(ctx, id)
|
storage.Delete(ctx, append([]byte{containerKeyPrefix}, id...))
|
||||||
|
|
||||||
|
graveKey := append([]byte{graveKeyPrefix}, id...)
|
||||||
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).(interop.Hash160)
|
||||||
|
epoch := contract.Call(netmapContractAddr, "epoch", contract.ReadOnly).(int)
|
||||||
|
common.SetSerialized(ctx, graveKey, delInfo{
|
||||||
|
Owner: owner,
|
||||||
|
Epoch: common.ToFixedWidth64(epoch),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAllContainers(ctx storage.Context) [][]byte {
|
func getAllContainers(ctx storage.Context) [][]byte {
|
||||||
var list [][]byte
|
var list [][]byte
|
||||||
|
|
||||||
it := storage.Find(ctx, []byte{}, storage.KeysOnly)
|
it := storage.Find(ctx, []byte{containerKeyPrefix}, storage.KeysOnly|storage.RemovePrefix)
|
||||||
for iterator.Next(it) {
|
for iterator.Next(it) {
|
||||||
key := iterator.Value(it).([]byte) // it MUST BE `storage.KeysOnly`
|
key := iterator.Value(it).([]byte) // it MUST BE `storage.KeysOnly`
|
||||||
// V2 format
|
// V2 format
|
||||||
if len(key) == containerIDSize {
|
list = append(list, key)
|
||||||
list = append(list, key)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return list
|
return list
|
||||||
|
@ -726,7 +660,7 @@ func getEACL(ctx storage.Context, cid []byte) ExtendedACL {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getContainer(ctx storage.Context, cid []byte) Container {
|
func getContainer(ctx storage.Context, cid []byte) Container {
|
||||||
data := storage.Get(ctx, cid)
|
data := storage.Get(ctx, append([]byte{containerKeyPrefix}, cid...))
|
||||||
if data != nil {
|
if data != nil {
|
||||||
return std.Deserialize(data.([]byte)).(Container)
|
return std.Deserialize(data.([]byte)).(Container)
|
||||||
}
|
}
|
||||||
|
@ -751,7 +685,7 @@ func ownerFromBinaryContainer(container []byte) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
func estimationKey(epoch int, cid []byte, key interop.PublicKey) []byte {
|
func estimationKey(epoch int, cid []byte, key interop.PublicKey) []byte {
|
||||||
var buf interface{} = epoch
|
var buf any = epoch
|
||||||
|
|
||||||
hash := crypto.Ripemd160(key)
|
hash := crypto.Ripemd160(key)
|
||||||
|
|
||||||
|
@ -829,7 +763,7 @@ func cleanupContainers(ctx storage.Context, epoch int) {
|
||||||
// V2 format
|
// V2 format
|
||||||
nbytes := k[len(estimateKeyPrefix) : len(k)-containerIDSize-estimatePostfixSize]
|
nbytes := k[len(estimateKeyPrefix) : len(k)-containerIDSize-estimatePostfixSize]
|
||||||
|
|
||||||
var n interface{} = nbytes
|
var n any = nbytes
|
||||||
|
|
||||||
if epoch-n.(int) > TotalCleanupDelta {
|
if epoch-n.(int) > TotalCleanupDelta {
|
||||||
storage.Delete(ctx, k)
|
storage.Delete(ctx, k)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Container contract is a contract deployed in NeoFS sidechain.
|
Container contract is a contract deployed in FrostFS sidechain.
|
||||||
|
|
||||||
Container contract stores and manages containers, extended ACLs and container
|
Container contract stores and manages containers, extended ACLs and container
|
||||||
size estimations. Contract does not perform sanity or signature checks of
|
size estimations. Contract does not perform sanity or signature checks of
|
||||||
|
@ -7,62 +7,36 @@ containers or extended ACLs, it is done by Alphabet nodes of the Inner Ring.
|
||||||
Alphabet nodes approve it by invoking the same Put or SetEACL methods with
|
Alphabet nodes approve it by invoking the same Put or SetEACL methods with
|
||||||
the same arguments.
|
the same arguments.
|
||||||
|
|
||||||
Contract notifications
|
# Contract notifications
|
||||||
|
|
||||||
containerPut notification. This notification is produced when a user wants to
|
|
||||||
create a new container. Alphabet nodes of the Inner Ring catch the notification and
|
|
||||||
validate container data, signature and token if present.
|
|
||||||
|
|
||||||
containerPut:
|
|
||||||
- name: container
|
|
||||||
type: ByteArray
|
|
||||||
- name: signature
|
|
||||||
type: Signature
|
|
||||||
- name: publicKey
|
|
||||||
type: PublicKey
|
|
||||||
- name: token
|
|
||||||
type: ByteArray
|
|
||||||
|
|
||||||
containerDelete notification. This notification is produced when a container owner
|
|
||||||
wants to delete a container. Alphabet nodes of the Inner Ring catch the notification
|
|
||||||
and validate container ownership, signature and token if present.
|
|
||||||
|
|
||||||
containerDelete:
|
|
||||||
- name: containerID
|
|
||||||
type: ByteArray
|
|
||||||
- name: signature
|
|
||||||
type: Signature
|
|
||||||
- name: token
|
|
||||||
type: ByteArray
|
|
||||||
|
|
||||||
setEACL notification. This notification is produced when a container owner wants
|
|
||||||
to update an extended ACL of a container. Alphabet nodes of the Inner Ring catch
|
|
||||||
the notification and validate container ownership, signature and token if
|
|
||||||
present.
|
|
||||||
|
|
||||||
setEACL:
|
|
||||||
- name: eACL
|
|
||||||
type: ByteArray
|
|
||||||
- name: signature
|
|
||||||
type: Signature
|
|
||||||
- name: publicKey
|
|
||||||
type: PublicKey
|
|
||||||
- name: token
|
|
||||||
type: ByteArray
|
|
||||||
|
|
||||||
StartEstimation notification. This notification is produced when Storage nodes
|
StartEstimation notification. This notification is produced when Storage nodes
|
||||||
should exchange estimation values of container sizes among other Storage nodes.
|
should exchange estimation values of container sizes among other Storage nodes.
|
||||||
|
|
||||||
StartEstimation:
|
StartEstimation:
|
||||||
- name: epoch
|
- name: epoch
|
||||||
type: Integer
|
type: Integer
|
||||||
|
|
||||||
StopEstimation notification. This notification is produced when Storage nodes
|
StopEstimation notification. This notification is produced when Storage nodes
|
||||||
should calculate average container size based on received estimations and store
|
should calculate average container size based on received estimations and store
|
||||||
it in Container contract.
|
it in Container contract.
|
||||||
|
|
||||||
StopEstimation:
|
StopEstimation:
|
||||||
- name: epoch
|
- name: epoch
|
||||||
type: Integer
|
type: Integer
|
||||||
|
|
||||||
|
# Contract storage scheme
|
||||||
|
|
||||||
|
| Key | Value | Description |
|
||||||
|
|-----------------------------------------------------------------------------------------------------|
|
||||||
|
| `netmapScriptHash` | Hash160 | netmap contract hash |
|
||||||
|
| `balanceScriptHash` | Hash160 | balance contract hash |
|
||||||
|
| `identityScriptHash` | Hash160 | frostfsID contract hash |
|
||||||
|
| `nnsContractKey` | Hash160 | nns contract hash |
|
||||||
|
| `nnsRoot` | string | default value for domain zone |
|
||||||
|
| `cnr` + epoch + containerID + publicKeyHash[:10] | ByteArray | estimated container size |
|
||||||
|
| `est` + containerID + publicKeyHash | ByteArray | serialized epochs array |
|
||||||
|
| `o` + ownerID + containerID | ByteArray | container ID |
|
||||||
|
| `x` + containerID | ByteArray | serialized container struct |
|
||||||
|
| `nnsHasAlias` + containerID | string | domain name |
|
||||||
*/
|
*/
|
||||||
package container
|
package container
|
||||||
|
|
5
debian/changelog
vendored
Normal file
5
debian/changelog
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
frostfs-contract (0.0.0) stable; urgency=medium
|
||||||
|
|
||||||
|
* Initial release
|
||||||
|
|
||||||
|
-- TrueCloudLab <tech@frostfs.info> Wed, 24 Aug 2022 18:29:49 +0300
|
33
debian/control
vendored
Normal file
33
debian/control
vendored
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
Source: frostfs-contract
|
||||||
|
Section: misc
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: FrostFS <tech@frostfs.info>
|
||||||
|
Build-Depends: debhelper-compat (= 13), git, devscripts, neo-go
|
||||||
|
Standards-Version: 4.5.1
|
||||||
|
Homepage: https://fs.neo.org/
|
||||||
|
Vcs-Git: https://git.frostfs.info/TrueCloudLab/frostfs-contract.git
|
||||||
|
Vcs-Browser: https://git.frostfs.info/TrueCloudLab/frostfs-contract
|
||||||
|
|
||||||
|
Package: frostfs-contract
|
||||||
|
Architecture: all
|
||||||
|
Depends: ${misc:Depends}
|
||||||
|
Description: FrostFS-Contract contains all FrostFS related contracts.
|
||||||
|
Contracts are written for neo-go compiler.
|
||||||
|
These contracts are deployed both in the mainchain and the sidechain.
|
||||||
|
.
|
||||||
|
Mainchain contracts:
|
||||||
|
.
|
||||||
|
- frostfs
|
||||||
|
- processing
|
||||||
|
.
|
||||||
|
Sidechain contracts:
|
||||||
|
.
|
||||||
|
- alphabet
|
||||||
|
- audit
|
||||||
|
- balance
|
||||||
|
- container
|
||||||
|
- frostfsid
|
||||||
|
- netmap
|
||||||
|
- nns
|
||||||
|
- proxy
|
||||||
|
- reputation
|
23
debian/copyright
vendored
Normal file
23
debian/copyright
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||||
|
Upstream-Name: frostfs-contract
|
||||||
|
Upstream-Contact: tech@frostfs.info
|
||||||
|
Source: https://git.frostfs.info/TrueCloudLab/frostfs-contract
|
||||||
|
|
||||||
|
Files: *
|
||||||
|
Copyright: 2022 TrueCloudLab (@TrueCloudLab)
|
||||||
|
Copyright: 2018-2022 NeoSPCC (@nspcc-dev)
|
||||||
|
|
||||||
|
License: GPL-3
|
||||||
|
This program is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published
|
||||||
|
by the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program or at /usr/share/common-licenses/GPL-3.
|
||||||
|
If not, see <http://www.gnu.org/licenses/>.
|
1
debian/neofs-contract.docs
vendored
Normal file
1
debian/neofs-contract.docs
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
README*
|
39
debian/postinst.ex
vendored
Normal file
39
debian/postinst.ex
vendored
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# postinst script for frostfs-contract
|
||||||
|
#
|
||||||
|
# see: dh_installdeb(1)
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# summary of how this script can be called:
|
||||||
|
# * <postinst> `configure' <most-recently-configured-version>
|
||||||
|
# * <old-postinst> `abort-upgrade' <new version>
|
||||||
|
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
|
||||||
|
# <new-version>
|
||||||
|
# * <postinst> `abort-remove'
|
||||||
|
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
|
||||||
|
# <failed-install-package> <version> `removing'
|
||||||
|
# <conflicting-package> <version>
|
||||||
|
# for details, see https://www.debian.org/doc/debian-policy/ or
|
||||||
|
# the debian-policy package
|
||||||
|
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
configure)
|
||||||
|
;;
|
||||||
|
|
||||||
|
abort-upgrade|abort-remove|abort-deconfigure)
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "postinst called with unknown argument \`$1'" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# dh_installdeb will replace this with shell code automatically
|
||||||
|
# generated by other debhelper scripts.
|
||||||
|
|
||||||
|
#DEBHELPER#
|
||||||
|
|
||||||
|
exit 0
|
37
debian/postrm.ex
vendored
Normal file
37
debian/postrm.ex
vendored
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# postrm script for frostfs-contract
|
||||||
|
#
|
||||||
|
# see: dh_installdeb(1)
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# summary of how this script can be called:
|
||||||
|
# * <postrm> `remove'
|
||||||
|
# * <postrm> `purge'
|
||||||
|
# * <old-postrm> `upgrade' <new-version>
|
||||||
|
# * <new-postrm> `failed-upgrade' <old-version>
|
||||||
|
# * <new-postrm> `abort-install'
|
||||||
|
# * <new-postrm> `abort-install' <old-version>
|
||||||
|
# * <new-postrm> `abort-upgrade' <old-version>
|
||||||
|
# * <disappearer's-postrm> `disappear' <overwriter>
|
||||||
|
# <overwriter-version>
|
||||||
|
# for details, see https://www.debian.org/doc/debian-policy/ or
|
||||||
|
# the debian-policy package
|
||||||
|
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "postrm called with unknown argument \`$1'" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# dh_installdeb will replace this with shell code automatically
|
||||||
|
# generated by other debhelper scripts.
|
||||||
|
|
||||||
|
#DEBHELPER#
|
||||||
|
|
||||||
|
exit 0
|
35
debian/preinst.ex
vendored
Normal file
35
debian/preinst.ex
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# preinst script for frostfs-contract
|
||||||
|
#
|
||||||
|
# see: dh_installdeb(1)
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# summary of how this script can be called:
|
||||||
|
# * <new-preinst> `install'
|
||||||
|
# * <new-preinst> `install' <old-version>
|
||||||
|
# * <new-preinst> `upgrade' <old-version>
|
||||||
|
# * <old-preinst> `abort-upgrade' <new-version>
|
||||||
|
# for details, see https://www.debian.org/doc/debian-policy/ or
|
||||||
|
# the debian-policy package
|
||||||
|
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
install|upgrade)
|
||||||
|
;;
|
||||||
|
|
||||||
|
abort-upgrade)
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "preinst called with unknown argument \`$1'" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# dh_installdeb will replace this with shell code automatically
|
||||||
|
# generated by other debhelper scripts.
|
||||||
|
|
||||||
|
#DEBHELPER#
|
||||||
|
|
||||||
|
exit 0
|
38
debian/prerm.ex
vendored
Normal file
38
debian/prerm.ex
vendored
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# prerm script for frostfs-contract
|
||||||
|
#
|
||||||
|
# see: dh_installdeb(1)
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# summary of how this script can be called:
|
||||||
|
# * <prerm> `remove'
|
||||||
|
# * <old-prerm> `upgrade' <new-version>
|
||||||
|
# * <new-prerm> `failed-upgrade' <old-version>
|
||||||
|
# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
|
||||||
|
# * <deconfigured's-prerm> `deconfigure' `in-favour'
|
||||||
|
# <package-being-installed> <version> `removing'
|
||||||
|
# <conflicting-package> <version>
|
||||||
|
# for details, see https://www.debian.org/doc/debian-policy/ or
|
||||||
|
# the debian-policy package
|
||||||
|
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
remove|upgrade|deconfigure)
|
||||||
|
;;
|
||||||
|
|
||||||
|
failed-upgrade)
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "prerm called with unknown argument \`$1'" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# dh_installdeb will replace this with shell code automatically
|
||||||
|
# generated by other debhelper scripts.
|
||||||
|
|
||||||
|
#DEBHELPER#
|
||||||
|
|
||||||
|
exit 0
|
20
debian/rules
vendored
Executable file
20
debian/rules
vendored
Executable file
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/make -f
|
||||||
|
|
||||||
|
SERVICE = frostfs-contract
|
||||||
|
export NEOGO ?= $(shell command -v neo-go)
|
||||||
|
|
||||||
|
%:
|
||||||
|
dh $@
|
||||||
|
|
||||||
|
override_dh_auto_build:
|
||||||
|
|
||||||
|
make all
|
||||||
|
|
||||||
|
override_dh_auto_install:
|
||||||
|
install -D -m 0750 -d debian/$(SERVICE)/var/lib/frostfs/contract
|
||||||
|
find . -maxdepth 2 \( -name '*.nef' -o -name 'config.json' \) -exec cp --parents \{\} debian/$(SERVICE)/var/lib/frostfs/contract \;
|
||||||
|
|
||||||
|
override_dh_installchangelogs:
|
||||||
|
dh_installchangelogs -k CHANGELOG.md
|
||||||
|
|
||||||
|
|
1
debian/source/format
vendored
Normal file
1
debian/source/format
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
3.0 (quilt)
|
|
@ -1,5 +1,10 @@
|
||||||
name: "NeoFS"
|
name: "FrostFS"
|
||||||
safemethods: ["alphabetList", "alphabetAddress", "innerRingCandidates", "config", "listConfig", "version"]
|
safemethods:
|
||||||
|
- "alphabetAddress"
|
||||||
|
- "config"
|
||||||
|
- "innerRingCandidates"
|
||||||
|
- "listConfig"
|
||||||
|
- "version"
|
||||||
permissions:
|
permissions:
|
||||||
- methods: ["update", "transfer"]
|
- methods: ["update", "transfer"]
|
||||||
events:
|
events:
|
92
frostfs/doc.go
Normal file
92
frostfs/doc.go
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
FrostFS contract is a contract deployed in FrostFS mainchain.
|
||||||
|
|
||||||
|
FrostFS contract is an entry point to FrostFS users. This contract stores all FrostFS
|
||||||
|
related GAS, registers new Inner Ring candidates and produces notifications
|
||||||
|
to control the sidechain.
|
||||||
|
|
||||||
|
While mainchain committee controls the list of Alphabet nodes in native
|
||||||
|
RoleManagement contract, FrostFS can't change more than 1\3 keys at a time.
|
||||||
|
FrostFS contract contains the actual list of Alphabet nodes in the sidechain.
|
||||||
|
|
||||||
|
Network configuration is also stored in FrostFS contract. All changes in
|
||||||
|
configuration are mirrored in the sidechain with notifications.
|
||||||
|
|
||||||
|
# Contract notifications
|
||||||
|
|
||||||
|
Deposit notification. This notification is produced when user transfers native
|
||||||
|
GAS to the FrostFS contract address. The same amount of FROSTFS token will be
|
||||||
|
minted in Balance contract in the sidechain.
|
||||||
|
|
||||||
|
Deposit:
|
||||||
|
- name: from
|
||||||
|
type: Hash160
|
||||||
|
- name: amount
|
||||||
|
type: Integer
|
||||||
|
- name: receiver
|
||||||
|
type: Hash160
|
||||||
|
- name: txHash
|
||||||
|
type: Hash256
|
||||||
|
|
||||||
|
Withdraw notification. This notification is produced when a user wants to
|
||||||
|
withdraw GAS from the internal FrostFS balance and has paid fee for that.
|
||||||
|
|
||||||
|
Withdraw:
|
||||||
|
- name: user
|
||||||
|
type: Hash160
|
||||||
|
- name: amount
|
||||||
|
type: Integer
|
||||||
|
- name: txHash
|
||||||
|
type: Hash256
|
||||||
|
|
||||||
|
Cheque notification. This notification is produced when FrostFS contract
|
||||||
|
has successfully transferred assets back to the user after withdraw.
|
||||||
|
|
||||||
|
Cheque:
|
||||||
|
- name: id
|
||||||
|
type: ByteArray
|
||||||
|
- name: user
|
||||||
|
type: Hash160
|
||||||
|
- name: amount
|
||||||
|
type: Integer
|
||||||
|
- name: lockAccount
|
||||||
|
type: ByteArray
|
||||||
|
|
||||||
|
Bind notification. This notification is produced when a user wants to bind
|
||||||
|
public keys with the user account (OwnerID). Keys argument is an array of ByteArray.
|
||||||
|
|
||||||
|
Bind:
|
||||||
|
- name: user
|
||||||
|
type: ByteArray
|
||||||
|
- name: keys
|
||||||
|
type: Array
|
||||||
|
|
||||||
|
Unbind notification. This notification is produced when a user wants to unbind
|
||||||
|
public keys with the user account (OwnerID). Keys argument is an array of ByteArray.
|
||||||
|
|
||||||
|
Unbind:
|
||||||
|
- name: user
|
||||||
|
type: ByteArray
|
||||||
|
- name: keys
|
||||||
|
type: Array
|
||||||
|
|
||||||
|
SetConfig notification. This notification is produced when Alphabet nodes update
|
||||||
|
FrostFS network configuration value.
|
||||||
|
|
||||||
|
SetConfig
|
||||||
|
- name: id
|
||||||
|
type: ByteArray
|
||||||
|
- name: key
|
||||||
|
type: ByteArray
|
||||||
|
- name: value
|
||||||
|
type: ByteArray
|
||||||
|
|
||||||
|
# Contract storage scheme
|
||||||
|
|
||||||
|
| Key | Value | Description |
|
||||||
|
|-----------------------------------------------------------------------------|
|
||||||
|
| `processingScriptHash` | Hash160 | processing contract hash |
|
||||||
|
| `candidates` + candidateKey | ByteArray | it flags inner ring candidate |
|
||||||
|
| `config` + postfix | ByteArray | serialized config data |
|
||||||
|
*/
|
||||||
|
package frostfs
|
|
@ -1,10 +1,10 @@
|
||||||
package neofs
|
package frostfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/crypto"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/gas"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/gas"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/ledger"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/ledger"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
|
||||||
|
@ -12,7 +12,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neofs-contract/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
@ -27,9 +26,8 @@ const (
|
||||||
CandidateFeeConfigKey = "InnerRingCandidateFee"
|
CandidateFeeConfigKey = "InnerRingCandidateFee"
|
||||||
withdrawFeeConfigKey = "WithdrawFee"
|
withdrawFeeConfigKey = "WithdrawFee"
|
||||||
|
|
||||||
alphabetKey = "alphabet"
|
alphabetKey = "alphabet"
|
||||||
candidatesKey = "candidates"
|
candidatesKey = "candidates"
|
||||||
notaryDisabledKey = "notary"
|
|
||||||
|
|
||||||
processingContractKey = "processingScriptHash"
|
processingContractKey = "processingScriptHash"
|
||||||
|
|
||||||
|
@ -40,25 +38,22 @@ const (
|
||||||
ignoreDepositNotification = "\x57\x0b"
|
ignoreDepositNotification = "\x57\x0b"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var configPrefix = []byte("config")
|
||||||
configPrefix = []byte("config")
|
|
||||||
)
|
|
||||||
|
|
||||||
// _deploy sets up initial alphabet node keys.
|
// _deploy sets up initial alphabet node keys.
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
func _deploy(data any, isUpdate bool) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
args := data.([]interface{})
|
args := data.([]any)
|
||||||
common.CheckVersion(args[len(args)-1].(int))
|
common.CheckVersion(args[len(args)-1].(int))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
args := data.(struct {
|
args := data.(struct {
|
||||||
notaryDisabled bool
|
addrProc interop.Hash160
|
||||||
addrProc interop.Hash160
|
keys []interop.PublicKey
|
||||||
keys []interop.PublicKey
|
config [][]byte
|
||||||
config [][]byte
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(args.keys) == 0 {
|
if len(args.keys) == 0 {
|
||||||
|
@ -81,13 +76,6 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
storage.Put(ctx, processingContractKey, args.addrProc)
|
storage.Put(ctx, processingContractKey, args.addrProc)
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
|
||||||
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
|
||||||
if args.notaryDisabled {
|
|
||||||
common.InitVote(ctx)
|
|
||||||
runtime.Log("neofs contract notary disabled")
|
|
||||||
}
|
|
||||||
|
|
||||||
ln := len(args.config)
|
ln := len(args.config)
|
||||||
if ln%2 != 0 {
|
if ln%2 != 0 {
|
||||||
panic("bad configuration")
|
panic("bad configuration")
|
||||||
|
@ -100,33 +88,22 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
setConfig(ctx, key, val)
|
setConfig(ctx, key, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.Log("neofs: contract initialized")
|
runtime.Log("frostfs: contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. It can be invoked
|
// Update method updates contract source code and manifest. It can be invoked
|
||||||
// only by sidechain committee.
|
// only by sidechain committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data any) {
|
||||||
blockHeight := ledger.CurrentIndex()
|
blockHeight := ledger.CurrentIndex()
|
||||||
alphabetKeys := roles.GetDesignatedByRole(roles.NeoFSAlphabet, uint32(blockHeight+1))
|
alphabetKeys := roles.GetDesignatedByRole(roles.NeoFSAlphabet, uint32(blockHeight+1))
|
||||||
alphabetCommittee := common.Multiaddress(alphabetKeys, true)
|
alphabetCommittee := common.Multiaddress(alphabetKeys, true)
|
||||||
|
|
||||||
common.CheckAlphabetWitness(alphabetCommittee)
|
if !runtime.CheckWitness(alphabetCommittee) {
|
||||||
|
panic(common.ErrAlphabetWitnessFailed)
|
||||||
contract.Call(interop.Hash160(management.Hash), "update",
|
|
||||||
contract.All, script, manifest, common.AppendVersion(data))
|
|
||||||
runtime.Log("neofs contract updated")
|
|
||||||
}
|
|
||||||
|
|
||||||
// AlphabetList returns an array of alphabet node keys. It is used in sidechain notary
|
|
||||||
// disabled environment.
|
|
||||||
func AlphabetList() []common.IRNode {
|
|
||||||
ctx := storage.GetReadOnlyContext()
|
|
||||||
pubs := getAlphabetNodes(ctx)
|
|
||||||
nodes := []common.IRNode{}
|
|
||||||
for i := range pubs {
|
|
||||||
nodes = append(nodes, common.IRNode{PublicKey: pubs[i]})
|
|
||||||
}
|
}
|
||||||
return nodes
|
|
||||||
|
management.UpdateWithData(script, manifest, common.AppendVersion(data))
|
||||||
|
runtime.Log("frostfs contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
// AlphabetAddress returns 2\3n+1 multisignature address of alphabet nodes.
|
// AlphabetAddress returns 2\3n+1 multisignature address of alphabet nodes.
|
||||||
|
@ -156,43 +133,16 @@ func InnerRingCandidates() []common.IRNode {
|
||||||
// This method does not return fee back to the candidate.
|
// This method does not return fee back to the candidate.
|
||||||
func InnerRingCandidateRemove(key interop.PublicKey) {
|
func InnerRingCandidateRemove(key interop.PublicKey) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
keyOwner := runtime.CheckWitness(key)
|
keyOwner := runtime.CheckWitness(key)
|
||||||
|
|
||||||
if !keyOwner {
|
if !keyOwner {
|
||||||
if notaryDisabled {
|
multiaddr := AlphabetAddress()
|
||||||
alphabet = getAlphabetNodes(ctx)
|
if !runtime.CheckWitness(multiaddr) {
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
panic("this method must be invoked by candidate or alphabet")
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
panic("this method must be invoked by candidate or alphabet")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := AlphabetAddress()
|
|
||||||
if !runtime.CheckWitness(multiaddr) {
|
|
||||||
panic("this method must be invoked by candidate or alphabet")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if notaryDisabled && !keyOwner {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := append(key, []byte("delete")...)
|
|
||||||
hashID := crypto.Sha256(id)
|
|
||||||
|
|
||||||
n := common.Vote(ctx, hashID, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, hashID)
|
|
||||||
}
|
|
||||||
|
|
||||||
prefix := []byte(candidatesKey)
|
prefix := []byte(candidatesKey)
|
||||||
stKey := append(prefix, key...)
|
stKey := append(prefix, key...)
|
||||||
if storage.Get(ctx, stKey) != nil {
|
if storage.Get(ctx, stKey) != nil {
|
||||||
|
@ -205,7 +155,7 @@ func InnerRingCandidateRemove(key interop.PublicKey) {
|
||||||
// It can be invoked only by the candidate itself.
|
// It can be invoked only by the candidate itself.
|
||||||
//
|
//
|
||||||
// This method transfers fee from a candidate to the contract account.
|
// This method transfers fee from a candidate to the contract account.
|
||||||
// Fee value is specified in NeoFS network config with the key InnerRingCandidateFee.
|
// Fee value is specified in FrostFS network config with the key InnerRingCandidateFee.
|
||||||
func InnerRingCandidateAdd(key interop.PublicKey) {
|
func InnerRingCandidateAdd(key interop.PublicKey) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
|
@ -231,9 +181,9 @@ func InnerRingCandidateAdd(key interop.PublicKey) {
|
||||||
|
|
||||||
// OnNEP17Payment is a callback for NEP-17 compatible native GAS contract.
|
// OnNEP17Payment is a callback for NEP-17 compatible native GAS contract.
|
||||||
// It takes no more than 9000.0 GAS. Native GAS has precision 8, and
|
// It takes no more than 9000.0 GAS. Native GAS has precision 8, and
|
||||||
// NeoFS balance contract has precision 12. Values bigger than 9000.0 can
|
// FrostFS balance contract has precision 12. Values bigger than 9000.0 can
|
||||||
// break JSON limits for integers when precision is converted.
|
// break JSON limits for integers when precision is converted.
|
||||||
func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
func OnNEP17Payment(from interop.Hash160, amount int, data any) {
|
||||||
rcv := data.(interop.Hash160)
|
rcv := data.(interop.Hash160)
|
||||||
if common.BytesEqual(rcv, []byte(ignoreDepositNotification)) {
|
if common.BytesEqual(rcv, []byte(ignoreDepositNotification)) {
|
||||||
return
|
return
|
||||||
|
@ -264,13 +214,13 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
||||||
runtime.Notify("Deposit", from, amount, rcv, tx.Hash)
|
runtime.Notify("Deposit", from, amount, rcv, tx.Hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Withdraw initializes gas asset withdraw from NeoFS. It can be invoked only
|
// Withdraw initializes gas asset withdraw from FrostFS. It can be invoked only
|
||||||
// by the specified user.
|
// by the specified user.
|
||||||
//
|
//
|
||||||
// This method produces Withdraw notification to lock assets in the sidechain and
|
// This method produces Withdraw notification to lock assets in the sidechain and
|
||||||
// transfers withdraw fee from a user account to each Alphabet node. If notary
|
// transfers withdraw fee from a user account to each Alphabet node. If notary
|
||||||
// is enabled in the mainchain, fee is transferred to Processing contract.
|
// is enabled in the mainchain, fee is transferred to Processing contract.
|
||||||
// Fee value is specified in NeoFS network config with the key WithdrawFee.
|
// Fee value is specified in FrostFS network config with the key WithdrawFee.
|
||||||
func Withdraw(user interop.Hash160, amount int) {
|
func Withdraw(user interop.Hash160, amount int) {
|
||||||
if !runtime.CheckWitness(user) {
|
if !runtime.CheckWitness(user) {
|
||||||
panic("you should be the owner of the wallet")
|
panic("you should be the owner of the wallet")
|
||||||
|
@ -285,28 +235,15 @@ func Withdraw(user interop.Hash160, amount int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
// transfer fee to proxy contract to pay cheque invocation
|
// transfer fee to proxy contract to pay cheque invocation
|
||||||
fee := getConfig(ctx, withdrawFeeConfigKey).(int)
|
fee := getConfig(ctx, withdrawFeeConfigKey).(int)
|
||||||
|
|
||||||
if notaryDisabled {
|
processingAddr := storage.Get(ctx, processingContractKey).(interop.Hash160)
|
||||||
alphabet := getAlphabetNodes(ctx)
|
|
||||||
for _, node := range alphabet {
|
|
||||||
processingAddr := contract.CreateStandardAccount(node)
|
|
||||||
|
|
||||||
transferred := gas.Transfer(user, processingAddr, fee, []byte{})
|
transferred := gas.Transfer(user, processingAddr, fee, []byte{})
|
||||||
if !transferred {
|
if !transferred {
|
||||||
panic("failed to transfer withdraw fee, aborting")
|
panic("failed to transfer withdraw fee, aborting")
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
processingAddr := storage.Get(ctx, processingContractKey).(interop.Hash160)
|
|
||||||
|
|
||||||
transferred := gas.Transfer(user, processingAddr, fee, []byte{})
|
|
||||||
if !transferred {
|
|
||||||
panic("failed to transfer withdraw fee, aborting")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify alphabet nodes
|
// notify alphabet nodes
|
||||||
|
@ -317,43 +254,15 @@ func Withdraw(user interop.Hash160, amount int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cheque transfers GAS back to the user from the contract account, if assets were
|
// Cheque transfers GAS back to the user from the contract account, if assets were
|
||||||
// successfully locked in NeoFS balance contract. It can be invoked only by
|
// successfully locked in FrostFS balance contract. It can be invoked only by
|
||||||
// Alphabet nodes.
|
// Alphabet nodes.
|
||||||
//
|
//
|
||||||
// This method produces Cheque notification to burn assets in sidechain.
|
// This method produces Cheque notification to burn assets in sidechain.
|
||||||
func Cheque(id []byte, user interop.Hash160, amount int, lockAcc []byte) {
|
func Cheque(id []byte, user interop.Hash160, amount int, lockAcc []byte) {
|
||||||
ctx := storage.GetContext()
|
common.CheckAlphabetWitness()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = getAlphabetNodes(ctx)
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
panic("this method must be invoked by alphabet")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
from := runtime.GetExecutingScriptHash()
|
from := runtime.GetExecutingScriptHash()
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
transferred := gas.Transfer(from, user, amount, nil)
|
transferred := gas.Transfer(from, user, amount, nil)
|
||||||
if !transferred {
|
if !transferred {
|
||||||
panic("failed to transfer funds, aborting")
|
panic("failed to transfer funds, aborting")
|
||||||
|
@ -363,7 +272,7 @@ func Cheque(id []byte, user interop.Hash160, amount int, lockAcc []byte) {
|
||||||
runtime.Notify("Cheque", id, user, amount, lockAcc)
|
runtime.Notify("Cheque", id, user, amount, lockAcc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind method produces notification to bind the specified public keys in NeoFSID
|
// Bind method produces notification to bind the specified public keys in FrostFSID
|
||||||
// contract in the sidechain. It can be invoked only by specified user.
|
// contract in the sidechain. It can be invoked only by specified user.
|
||||||
//
|
//
|
||||||
// This method produces Bind notification. This method panics if keys are not
|
// This method produces Bind notification. This method panics if keys are not
|
||||||
|
@ -383,7 +292,7 @@ func Bind(user []byte, keys []interop.PublicKey) {
|
||||||
runtime.Notify("Bind", user, keys)
|
runtime.Notify("Bind", user, keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unbind method produces notification to unbind the specified public keys in NeoFSID
|
// Unbind method produces notification to unbind the specified public keys in FrostFSID
|
||||||
// contract in the sidechain. It can be invoked only by the specified user.
|
// contract in the sidechain. It can be invoked only by the specified user.
|
||||||
//
|
//
|
||||||
// This method produces Unbind notification. This method panics if keys are not
|
// This method produces Unbind notification. This method panics if keys are not
|
||||||
|
@ -403,102 +312,19 @@ func Unbind(user []byte, keys []interop.PublicKey) {
|
||||||
runtime.Notify("Unbind", user, keys)
|
runtime.Notify("Unbind", user, keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AlphabetUpdate updates a list of alphabet nodes with the provided list of
|
// Config returns configuration value of FrostFS configuration. If the key does
|
||||||
// public keys. It can be invoked only by alphabet nodes.
|
|
||||||
//
|
|
||||||
// This method is used in notary disabled sidechain environment. In this case,
|
|
||||||
// the actual alphabet list should be stored in the NeoFS contract.
|
|
||||||
func AlphabetUpdate(id []byte, args []interop.PublicKey) {
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
if len(args) == 0 {
|
|
||||||
panic("bad arguments")
|
|
||||||
}
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = getAlphabetNodes(ctx)
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
panic("this method must be invoked by alphabet")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
newAlphabet := []interop.PublicKey{}
|
|
||||||
|
|
||||||
for i := 0; i < len(args); i++ {
|
|
||||||
pubKey := args[i]
|
|
||||||
if len(pubKey) != interop.PublicKeyCompressedLen {
|
|
||||||
panic("invalid public key in alphabet list")
|
|
||||||
}
|
|
||||||
|
|
||||||
newAlphabet = append(newAlphabet, pubKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
common.SetSerialized(ctx, alphabetKey, newAlphabet)
|
|
||||||
|
|
||||||
runtime.Notify("AlphabetUpdate", id, newAlphabet)
|
|
||||||
runtime.Log("alphabet list has been updated")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Config returns configuration value of NeoFS configuration. If the key does
|
|
||||||
// not exists, returns nil.
|
// not exists, returns nil.
|
||||||
func Config(key []byte) interface{} {
|
func Config(key []byte) any {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
return getConfig(ctx, key)
|
return getConfig(ctx, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetConfig key-value pair as a NeoFS runtime configuration value. It can be invoked
|
// SetConfig key-value pair as a FrostFS runtime configuration value. It can be invoked
|
||||||
// only by Alphabet nodes.
|
// only by Alphabet nodes.
|
||||||
func SetConfig(id, key, val []byte) {
|
func SetConfig(id, key, val []byte) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
common.CheckAlphabetWitness()
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = getAlphabetNodes(ctx)
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
if len(key) == 0 {
|
|
||||||
panic("this method must be invoked by alphabet")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
setConfig(ctx, key, val)
|
setConfig(ctx, key, val)
|
||||||
|
|
||||||
|
@ -507,7 +333,7 @@ func SetConfig(id, key, val []byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListConfig returns an array of structures that contain a key and a value of all
|
// ListConfig returns an array of structures that contain a key and a value of all
|
||||||
// NeoFS configuration records. Key and value are both byte arrays.
|
// FrostFS configuration records. Key and value are both byte arrays.
|
||||||
func ListConfig() []record {
|
func ListConfig() []record {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
|
@ -542,16 +368,16 @@ func getAlphabetNodes(ctx storage.Context) []interop.PublicKey {
|
||||||
return []interop.PublicKey{}
|
return []interop.PublicKey{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getConfig returns the installed neofs configuration value or nil if it is not set.
|
// getConfig returns the installed frostfs configuration value or nil if it is not set.
|
||||||
func getConfig(ctx storage.Context, key interface{}) interface{} {
|
func getConfig(ctx storage.Context, key any) interface{} {
|
||||||
postfix := key.([]byte)
|
postfix := key.([]byte)
|
||||||
storageKey := append(configPrefix, postfix...)
|
storageKey := append(configPrefix, postfix...)
|
||||||
|
|
||||||
return storage.Get(ctx, storageKey)
|
return storage.Get(ctx, storageKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
// setConfig sets a neofs configuration value in the contract storage.
|
// setConfig sets a frostfs configuration value in the contract storage.
|
||||||
func setConfig(ctx storage.Context, key, val interface{}) {
|
func setConfig(ctx storage.Context, key, val any) {
|
||||||
postfix := key.([]byte)
|
postfix := key.([]byte)
|
||||||
storageKey := append(configPrefix, postfix...)
|
storageKey := append(configPrefix, postfix...)
|
||||||
|
|
880
frostfsid/client/client.go
Normal file
880
frostfsid/client/client.go
Normal file
|
@ -0,0 +1,880 @@
|
||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/commonclient"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/actor"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/vmstate"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
Client struct {
|
||||||
|
act *actor.Actor
|
||||||
|
acc *wallet.Account
|
||||||
|
contract util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
Options struct {
|
||||||
|
// todo add proxy params
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
Subject struct {
|
||||||
|
PrimaryKey *keys.PublicKey
|
||||||
|
AdditionalKeys keys.PublicKeys
|
||||||
|
Namespace string
|
||||||
|
Name string
|
||||||
|
KV map[string]string
|
||||||
|
}
|
||||||
|
|
||||||
|
SubjectExtended struct {
|
||||||
|
PrimaryKey *keys.PublicKey
|
||||||
|
AdditionalKeys keys.PublicKeys
|
||||||
|
Namespace string
|
||||||
|
Name string
|
||||||
|
KV map[string]string
|
||||||
|
Groups []*Group
|
||||||
|
}
|
||||||
|
|
||||||
|
Namespace struct {
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
NamespaceExtended struct {
|
||||||
|
Name string
|
||||||
|
GroupsCount int64
|
||||||
|
SubjectsCount int64
|
||||||
|
}
|
||||||
|
|
||||||
|
Group struct {
|
||||||
|
ID int64
|
||||||
|
Name string
|
||||||
|
Namespace string
|
||||||
|
KV map[string]string
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupExtended struct {
|
||||||
|
ID int64
|
||||||
|
Name string
|
||||||
|
Namespace string
|
||||||
|
KV map[string]string
|
||||||
|
SubjectsCount int64
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
IAMPathKey = "iam-path"
|
||||||
|
IAMARNKey = "iam-arn"
|
||||||
|
IAMCreatedTimeKey = "ctime"
|
||||||
|
IAMModifiedTimeKey = "mtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
const iteratorBatchSize = 100
|
||||||
|
|
||||||
|
const (
|
||||||
|
getAdminMethod = "getAdmin"
|
||||||
|
setAdminMethod = "setAdmin"
|
||||||
|
clearAdminMethod = "clearAdmin"
|
||||||
|
|
||||||
|
versionMethod = "version"
|
||||||
|
|
||||||
|
createSubjectMethod = "createSubject"
|
||||||
|
getSubjectMethod = "getSubject"
|
||||||
|
getSubjectExtendedMethod = "getSubjectExtended"
|
||||||
|
listSubjectsMethod = "listSubjects"
|
||||||
|
addSubjectKeyMethod = "addSubjectKey"
|
||||||
|
removeSubjectKeyMethod = "removeSubjectKey"
|
||||||
|
getSubjectByKeyMethod = "getSubjectByKey"
|
||||||
|
getSubjectKeyByNameMethod = "getSubjectKeyByName"
|
||||||
|
setSubjectKVMethod = "setSubjectKV"
|
||||||
|
setSubjectNameMethod = "setSubjectName"
|
||||||
|
deleteSubjectKVMethod = "deleteSubjectKV"
|
||||||
|
deleteSubjectMethod = "deleteSubject"
|
||||||
|
|
||||||
|
createNamespaceMethod = "createNamespace"
|
||||||
|
getNamespaceMethod = "getNamespace"
|
||||||
|
getNamespaceExtendedMethod = "getNamespaceExtended"
|
||||||
|
listNamespacesMethod = "listNamespaces"
|
||||||
|
addSubjectToNamespaceMethod = "addSubjectToNamespace"
|
||||||
|
removeSubjectFromNamespaceMethod = "removeSubjectFromNamespace"
|
||||||
|
listNamespaceSubjectsMethod = "listNamespaceSubjects"
|
||||||
|
|
||||||
|
createGroupMethod = "createGroup"
|
||||||
|
getGroupMethod = "getGroup"
|
||||||
|
getGroupExtendedMethod = "getGroupExtended"
|
||||||
|
getGroupIDByNameMethod = "getGroupIDByName"
|
||||||
|
setGroupNameMethod = "setGroupName"
|
||||||
|
setGroupKVMethod = "setGroupKV"
|
||||||
|
deleteGroupKVMethod = "deleteGroupKV"
|
||||||
|
listGroupsMethod = "listGroups"
|
||||||
|
addSubjectToGroupMethod = "addSubjectToGroup"
|
||||||
|
removeSubjectFromGroupMethod = "removeSubjectFromGroup"
|
||||||
|
listGroupSubjectsMethod = "listGroupSubjects"
|
||||||
|
deleteGroupMethod = "deleteGroup"
|
||||||
|
)
|
||||||
|
|
||||||
|
// New creates a new Client. Options can be nil.
|
||||||
|
func New(ra actor.RPCActor, acc *wallet.Account, contract util.Uint160, _ *Options) (*Client, error) {
|
||||||
|
act, err := actor.NewSimple(ra, acc)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("init actor: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &Client{
|
||||||
|
act: act,
|
||||||
|
acc: acc,
|
||||||
|
contract: contract,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartTx inits transaction.
|
||||||
|
func (c Client) StartTx() *commonclient.Transaction {
|
||||||
|
return commonclient.NewTransaction(c.contract)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendTx sends provided transaction to blockchain.
|
||||||
|
func (c Client) SendTx(txn *commonclient.Transaction) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
txBytes, err := txn.Bytes()
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint256{}, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.act.SendRun(txBytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version returns version of contract.
|
||||||
|
func (c Client) Version() (int64, error) {
|
||||||
|
return unwrap.Int64(c.act.Call(c.contract, versionMethod))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdmin sets address that can perform write operations on contract.
|
||||||
|
// Must be invoked by committee.
|
||||||
|
func (c Client) SetAdmin(owner util.Uint160) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.SetAdminCall(owner)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdminCall provides args for SetAdmin to use in commonclient.Transaction.
|
||||||
|
func (c Client) SetAdminCall(owner util.Uint160) (method string, args []any) {
|
||||||
|
return setAdminMethod, []any{owner}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearAdmin removes address that can perform write operations on contract.
|
||||||
|
// Must be invoked by committee.
|
||||||
|
func (c Client) ClearAdmin() (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.ClearAdminCall()
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearAdminCall provides args for ClearAdmin to use in commonclient.Transaction.
|
||||||
|
func (c Client) ClearAdminCall() (method string, args []any) {
|
||||||
|
return clearAdminMethod, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAdmin returns address that can perform write operations on contract.
|
||||||
|
// Second return values is true iff admin is set.
|
||||||
|
func (c Client) GetAdmin() (util.Uint160, bool, error) {
|
||||||
|
item, err := unwrap.Item(c.act.Call(c.contract, getAdminMethod))
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, false, err
|
||||||
|
}
|
||||||
|
if item.Value() == nil {
|
||||||
|
return util.Uint160{}, false, nil
|
||||||
|
}
|
||||||
|
bs, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, true, err
|
||||||
|
}
|
||||||
|
u, err := util.Uint160DecodeBytesBE(bs)
|
||||||
|
return u, true, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateSubject creates new subject using public key.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
func (c Client) CreateSubject(key *keys.PublicKey) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.CreateSubjectCall(key)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateSubjectCall provides args for CreateSubject to use in commonclient.Transaction.
|
||||||
|
func (c Client) CreateSubjectCall(key *keys.PublicKey) (method string, args []any) {
|
||||||
|
return createSubjectMethod, []any{key.Bytes()}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSubject gets subject by address.
|
||||||
|
func (c Client) GetSubject(addr util.Uint160) (*Subject, error) {
|
||||||
|
items, err := unwrap.Array(c.act.Call(c.contract, getSubjectMethod, addr))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseSubject(items)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSubjectExtended gets extended subject by address.
|
||||||
|
func (c Client) GetSubjectExtended(addr util.Uint160) (*SubjectExtended, error) {
|
||||||
|
items, err := unwrap.Array(c.act.Call(c.contract, getSubjectExtendedMethod, addr))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseSubjectExtended(items)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListSubjects gets all subjects.
|
||||||
|
func (c Client) ListSubjects() ([]util.Uint160, error) {
|
||||||
|
return unwrapArrayOfUint160(commonclient.ReadIteratorItems(c.act, iteratorBatchSize, c.contract, listSubjectsMethod))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSubjectKey adds extra public key to subject.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
func (c Client) AddSubjectKey(addr util.Uint160, key *keys.PublicKey) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.AddSubjectKeyCall(addr, key)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSubjectKeyCall provides args for AddSubjectKey to use in commonclient.Transaction.
|
||||||
|
func (c Client) AddSubjectKeyCall(addr util.Uint160, key *keys.PublicKey) (method string, args []any) {
|
||||||
|
return addSubjectKeyMethod, []any{addr, key.Bytes()}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveSubjectKey removes extra public key from subject.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
func (c Client) RemoveSubjectKey(addr util.Uint160, key *keys.PublicKey) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.RemoveSubjectKeyCall(addr, key)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveSubjectKeyCall provides args for RemoveSubjectKey to use in commonclient.Transaction.
|
||||||
|
func (c Client) RemoveSubjectKeyCall(addr util.Uint160, key *keys.PublicKey) (method string, args []any) {
|
||||||
|
return removeSubjectKeyMethod, []any{addr, key.Bytes()}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSubjectKV updates subject kv map.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
// You can use some predefined key constants: IAMPathKey, IAMARNKey, IAMCreatedTimeKey, IAMModifiedTimeKey.
|
||||||
|
func (c Client) SetSubjectKV(addr util.Uint160, key, val string) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.SetSubjectKVCall(addr, key, val)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSubjectKVCall provides args for SetSubjectKV to use in commonclient.Transaction.
|
||||||
|
func (c Client) SetSubjectKVCall(addr util.Uint160, key, val string) (method string, args []any) {
|
||||||
|
return setSubjectKVMethod, []any{addr, key, val}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSubjectName updates subject name.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
func (c Client) SetSubjectName(addr util.Uint160, name string) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.SetSubjectNameCall(addr, name)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSubjectNameCall provides args for SetSubjectName to use in commonclient.Transaction.
|
||||||
|
func (c Client) SetSubjectNameCall(addr util.Uint160, name string) (method string, args []any) {
|
||||||
|
return setSubjectNameMethod, []any{addr, name}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteSubjectKV removes subject kv map.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
func (c Client) DeleteSubjectKV(addr util.Uint160, key string) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.DeleteSubjectKVCall(addr, key)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteSubjectKVCall provides args for DeleteSubjectKV to use in commonclient.Transaction.
|
||||||
|
func (c Client) DeleteSubjectKVCall(addr util.Uint160, key string) (method string, args []any) {
|
||||||
|
return deleteSubjectKVMethod, []any{addr, key}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSubjectByKey gets subject by its primary or additional keys.
|
||||||
|
func (c Client) GetSubjectByKey(key *keys.PublicKey) (*Subject, error) {
|
||||||
|
items, err := unwrap.Array(c.act.Call(c.contract, getSubjectByKeyMethod, key.Bytes()))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseSubject(items)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSubjectKeyByName gets subject public key by its name (namespace scope).
|
||||||
|
func (c Client) GetSubjectKeyByName(namespace, subjectName string) (*keys.PublicKey, error) {
|
||||||
|
return unwrap.PublicKey(c.act.Call(c.contract, getSubjectKeyByNameMethod, namespace, subjectName))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteSubject delete subject and removes it from related namespaces and groups.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
func (c Client) DeleteSubject(addr util.Uint160) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.DeleteSubjectCall(addr)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteSubjectCall provides args for DeleteSubject to use in commonclient.Transaction.
|
||||||
|
func (c Client) DeleteSubjectCall(addr util.Uint160) (method string, args []any) {
|
||||||
|
return deleteSubjectMethod, []any{addr}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateNamespace create new namespace.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
func (c Client) CreateNamespace(namespace string) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.CreateNamespaceCall(namespace)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateNamespaceCall provides args for CreateNamespace to use in commonclient.Transaction.
|
||||||
|
func (c Client) CreateNamespaceCall(namespace string) (method string, args []any) {
|
||||||
|
return createNamespaceMethod, []any{namespace}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetNamespace gets namespace.
|
||||||
|
func (c Client) GetNamespace(namespace string) (*Namespace, error) {
|
||||||
|
items, err := unwrap.Array(c.act.Call(c.contract, getNamespaceMethod, namespace))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseNamespace(items)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetNamespaceExtended gets extended namespace.
|
||||||
|
func (c Client) GetNamespaceExtended(namespace string) (*NamespaceExtended, error) {
|
||||||
|
items, err := unwrap.Array(c.act.Call(c.contract, getNamespaceExtendedMethod, namespace))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseNamespaceExtended(items)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListNamespaces gets all namespaces.
|
||||||
|
func (c Client) ListNamespaces() ([]*Namespace, error) {
|
||||||
|
items, err := commonclient.ReadIteratorItems(c.act, iteratorBatchSize, c.contract, listNamespacesMethod)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseNamespaces(items)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSubjectToNamespace adds a subject to namespace.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
func (c Client) AddSubjectToNamespace(addr util.Uint160, namespace string) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.AddSubjectToNamespaceCall(addr, namespace)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSubjectToNamespaceCall provides args for AddSubjectToNamespace to use in commonclient.Transaction.
|
||||||
|
func (c Client) AddSubjectToNamespaceCall(addr util.Uint160, namespace string) (method string, args []any) {
|
||||||
|
return addSubjectToNamespaceMethod, []any{addr, namespace}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveSubjectFromNamespace removes a subject from namespace.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
func (c Client) RemoveSubjectFromNamespace(addr util.Uint160) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.RemoveSubjectFromNamespaceCall(addr)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveSubjectFromNamespaceCall provides args for RemoveSubjectFromNamespace to use in commonclient.Transaction.
|
||||||
|
func (c Client) RemoveSubjectFromNamespaceCall(addr util.Uint160) (method string, args []any) {
|
||||||
|
return removeSubjectFromNamespaceMethod, []any{addr}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListNamespaceSubjects gets all subjects from namespace.
|
||||||
|
func (c Client) ListNamespaceSubjects(namespace string) ([]util.Uint160, error) {
|
||||||
|
return unwrapArrayOfUint160(commonclient.ReadIteratorItems(c.act, iteratorBatchSize, c.contract, listNamespaceSubjectsMethod, namespace))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateGroup creates a new group in specific namespace.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
func (c Client) CreateGroup(namespace, group string) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.CreateGroupCall(namespace, group)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateGroupCall provides args for CreateGroup to use in commonclient.Transaction.
|
||||||
|
func (c Client) CreateGroupCall(namespace, group string) (method string, args []any) {
|
||||||
|
return createGroupMethod, []any{namespace, group}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetGroup gets group.
|
||||||
|
func (c Client) GetGroup(namespace string, groupID int64) (*Group, error) {
|
||||||
|
items, err := unwrap.Array(c.act.Call(c.contract, getGroupMethod, namespace, groupID))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseGroup(items)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetGroupExtended gets extended group.
|
||||||
|
func (c Client) GetGroupExtended(namespace string, groupID int64) (*GroupExtended, error) {
|
||||||
|
items, err := unwrap.Array(c.act.Call(c.contract, getGroupExtendedMethod, namespace, groupID))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseGroupExtended(items)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetGroupName updates subject name.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
func (c Client) SetGroupName(namespace string, groupID int64, name string) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.SetGroupNameCall(namespace, groupID, name)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetGroupNameCall provides args for SetGroupName to use in commonclient.Transaction.
|
||||||
|
func (c Client) SetGroupNameCall(namespace string, groupID int64, name string) (method string, args []any) {
|
||||||
|
return setGroupNameMethod, []any{namespace, groupID, name}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetGroupKV updates group kv map.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
// You can use some predefined key constants: IAMPathKey, IAMARNKey, IAMCreatedTimeKey, IAMModifiedTimeKey.
|
||||||
|
func (c Client) SetGroupKV(namespace string, groupID int64, key, val string) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.SetGroupKVCall(namespace, groupID, key, val)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetGroupKVCall provides args for SetGroupKV to use in commonclient.Transaction.
|
||||||
|
func (c Client) SetGroupKVCall(namespace string, groupID int64, key, val string) (method string, args []any) {
|
||||||
|
return setGroupKVMethod, []any{namespace, groupID, key, val}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteGroupKV removes group kv map.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
func (c Client) DeleteGroupKV(namespace string, groupID int64, key string) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.DeleteGroupKVCall(namespace, groupID, key)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteGroupKVCall provides args for DeleteGroupKV to use in commonclient.Transaction.
|
||||||
|
func (c Client) DeleteGroupKVCall(namespace string, groupID int64, key string) (method string, args []any) {
|
||||||
|
return deleteGroupKVMethod, []any{namespace, groupID, key}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetGroupIDByName gets group id its name (namespace scope).
|
||||||
|
func (c Client) GetGroupIDByName(namespace, groupName string) (int64, error) {
|
||||||
|
return unwrap.Int64(c.act.Call(c.contract, getGroupIDByNameMethod, namespace, groupName))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListGroups gets all groups in specific namespace.
|
||||||
|
func (c Client) ListGroups(namespace string) ([]*Group, error) {
|
||||||
|
items, err := commonclient.ReadIteratorItems(c.act, iteratorBatchSize, c.contract, listGroupsMethod, namespace)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseGroups(items)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSubjectToGroup adds a new subject to group.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
func (c Client) AddSubjectToGroup(addr util.Uint160, groupID int64) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.AddSubjectToGroupCall(addr, groupID)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSubjectToGroupCall provides args for AddSubjectToGroup to use in commonclient.Transaction.
|
||||||
|
func (c Client) AddSubjectToGroupCall(addr util.Uint160, groupID int64) (method string, args []any) {
|
||||||
|
return addSubjectToGroupMethod, []any{addr, groupID}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveSubjectFromGroup removes subject from group.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
func (c Client) RemoveSubjectFromGroup(addr util.Uint160, groupID int64) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.RemoveSubjectFromGroupCall(addr, groupID)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveSubjectFromGroupCall provides args for RemoveSubjectFromGroup to use in commonclient.Transaction.
|
||||||
|
func (c Client) RemoveSubjectFromGroupCall(addr util.Uint160, groupID int64) (method string, args []any) {
|
||||||
|
return removeSubjectFromGroupMethod, []any{addr, groupID}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListGroupSubjects gets all subjects in specific group.
|
||||||
|
func (c Client) ListGroupSubjects(namespace string, groupID int64) ([]util.Uint160, error) {
|
||||||
|
return unwrapArrayOfUint160(commonclient.ReadIteratorItems(c.act, iteratorBatchSize, c.contract, listGroupSubjectsMethod, namespace, groupID))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteGroup deletes group.
|
||||||
|
// Must be invoked by contract owner.
|
||||||
|
func (c Client) DeleteGroup(namespace string, groupID int64) (tx util.Uint256, vub uint32, err error) {
|
||||||
|
method, args := c.DeleteGroupCall(namespace, groupID)
|
||||||
|
return c.act.SendCall(c.contract, method, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteGroupCall provides args for DeleteGroup to use in commonclient.Transaction.
|
||||||
|
func (c Client) DeleteGroupCall(namespace string, groupID int64) (method string, args []any) {
|
||||||
|
return deleteGroupMethod, []any{namespace, groupID}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListNonEmptyNamespaces gets namespaces that contain at least one subject.
|
||||||
|
func (c Client) ListNonEmptyNamespaces() ([]string, error) {
|
||||||
|
namespaces, err := c.ListNamespaces()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []string
|
||||||
|
|
||||||
|
for _, namespace := range namespaces {
|
||||||
|
nsExt, err := c.GetNamespaceExtended(namespace.Name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if nsExt.SubjectsCount > 0 {
|
||||||
|
res = append(res, nsExt.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait invokes underlying wait method on actor.Actor.
|
||||||
|
func (c Client) Wait(tx util.Uint256, vub uint32, err error) (*state.AppExecResult, error) {
|
||||||
|
return c.act.Wait(tx, vub, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseGroupID fetch groupID from stack after creating group method invocation.
|
||||||
|
func (c Client) ParseGroupID(res *state.AppExecResult, err error) (int64, error) {
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return unwrap.Int64(makeResFromAppExec(res))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListNonEmptyGroups gets groups that contain at least one subject.
|
||||||
|
func (c Client) ListNonEmptyGroups(namespace string) ([]string, error) {
|
||||||
|
groups, err := c.ListGroups(namespace)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []string
|
||||||
|
|
||||||
|
for _, group := range groups {
|
||||||
|
groupExt, err := c.GetGroupExtended(namespace, group.ID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if groupExt.SubjectsCount > 0 {
|
||||||
|
res = append(res, groupExt.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func unwrapArrayOfUint160(items []stackitem.Item, err error) ([]util.Uint160, error) {
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return unwrap.ArrayOfUint160(makeValidRes(stackitem.NewArray(items)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeValidRes(item stackitem.Item) (*result.Invoke, error) {
|
||||||
|
return &result.Invoke{
|
||||||
|
Stack: []stackitem.Item{item},
|
||||||
|
State: vmstate.Halt.String(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeResFromAppExec(res *state.AppExecResult) (*result.Invoke, error) {
|
||||||
|
return &result.Invoke{
|
||||||
|
Stack: res.Stack,
|
||||||
|
State: res.VMState.String(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseSubject(structArr []stackitem.Item) (*Subject, error) {
|
||||||
|
if len(structArr) < 5 {
|
||||||
|
return nil, errors.New("invalid response subject struct")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
subj Subject
|
||||||
|
)
|
||||||
|
|
||||||
|
subj.PrimaryKey, err = unwrap.PublicKey(makeValidRes(structArr[0]))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !structArr[1].Equals(stackitem.Null{}) {
|
||||||
|
subj.AdditionalKeys, err = unwrap.ArrayOfPublicKeys(makeValidRes(structArr[1]))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !structArr[2].Equals(stackitem.Null{}) {
|
||||||
|
subj.Namespace, err = unwrap.UTF8String(makeValidRes(structArr[2]))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !structArr[2].Equals(stackitem.Null{}) {
|
||||||
|
subj.Name, err = unwrap.UTF8String(makeValidRes(structArr[3]))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
subj.KV, err = parseMap(structArr[4])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &subj, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseSubjectExtended(structArr []stackitem.Item) (*SubjectExtended, error) {
|
||||||
|
if len(structArr) < 6 {
|
||||||
|
return nil, errors.New("invalid response subject extended struct")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
subj SubjectExtended
|
||||||
|
)
|
||||||
|
|
||||||
|
subj.PrimaryKey, err = unwrap.PublicKey(makeValidRes(structArr[0]))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !structArr[1].Equals(stackitem.Null{}) {
|
||||||
|
subj.AdditionalKeys, err = unwrap.ArrayOfPublicKeys(makeValidRes(structArr[1]))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nsBytes, err := structArr[2].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
subj.Namespace = string(nsBytes)
|
||||||
|
|
||||||
|
nameBytes, err := structArr[3].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
subj.Name = string(nameBytes)
|
||||||
|
|
||||||
|
subj.KV, err = parseMap(structArr[4])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !structArr[5].Equals(stackitem.Null{}) {
|
||||||
|
groupItems, ok := structArr[5].Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("invalid groups field")
|
||||||
|
}
|
||||||
|
|
||||||
|
subj.Groups, err = parseGroups(groupItems)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &subj, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseMap(item stackitem.Item) (map[string]string, error) {
|
||||||
|
if item.Equals(stackitem.Null{}) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
metaMap, err := unwrap.Map(makeValidRes(item))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
meta, ok := metaMap.Value().([]stackitem.MapElement)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("invalid map type")
|
||||||
|
}
|
||||||
|
|
||||||
|
res := make(map[string]string, len(meta))
|
||||||
|
for _, element := range meta {
|
||||||
|
key, err := element.Key.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
val, err := element.Value.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
res[string(key)] = string(val)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseNamespace(structArr []stackitem.Item) (*Namespace, error) {
|
||||||
|
if len(structArr) < 1 {
|
||||||
|
return nil, errors.New("invalid response namespace struct")
|
||||||
|
}
|
||||||
|
|
||||||
|
name, err := structArr[0].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &Namespace{Name: string(name)}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseNamespaceExtended(structArr []stackitem.Item) (*NamespaceExtended, error) {
|
||||||
|
if len(structArr) < 3 {
|
||||||
|
return nil, errors.New("invalid response namespace extended struct")
|
||||||
|
}
|
||||||
|
|
||||||
|
name, err := structArr[0].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
groupCount, err := structArr[1].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
subjectCount, err := structArr[2].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &NamespaceExtended{
|
||||||
|
Name: string(name),
|
||||||
|
GroupsCount: groupCount.Int64(),
|
||||||
|
SubjectsCount: subjectCount.Int64(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseNamespaces(items []stackitem.Item) ([]*Namespace, error) {
|
||||||
|
var err error
|
||||||
|
res := make([]*Namespace, len(items))
|
||||||
|
|
||||||
|
for i := 0; i < len(items); i++ {
|
||||||
|
arr, ok := items[i].Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("invalid namespace type")
|
||||||
|
}
|
||||||
|
res[i], err = parseNamespace(arr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseGroup(structArr []stackitem.Item) (*Group, error) {
|
||||||
|
if len(structArr) < 4 {
|
||||||
|
return nil, errors.New("invalid response group struct")
|
||||||
|
}
|
||||||
|
|
||||||
|
groupID, err := structArr[0].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
name, err := structArr[1].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace, err := structArr[2].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
kvs, err := parseMap(structArr[3])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &Group{
|
||||||
|
ID: groupID.Int64(),
|
||||||
|
Name: string(name),
|
||||||
|
Namespace: string(namespace),
|
||||||
|
KV: kvs,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseGroupExtended(structArr []stackitem.Item) (*GroupExtended, error) {
|
||||||
|
if len(structArr) < 5 {
|
||||||
|
return nil, errors.New("invalid response group extended struct")
|
||||||
|
}
|
||||||
|
|
||||||
|
groupID, err := structArr[0].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
name, err := structArr[1].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace, err := structArr[2].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
kvs, err := parseMap(structArr[3])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
subjectCount, err := structArr[4].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &GroupExtended{
|
||||||
|
ID: groupID.Int64(),
|
||||||
|
Name: string(name),
|
||||||
|
Namespace: string(namespace),
|
||||||
|
KV: kvs,
|
||||||
|
SubjectsCount: subjectCount.Int64(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseGroups(items []stackitem.Item) ([]*Group, error) {
|
||||||
|
var err error
|
||||||
|
res := make([]*Group, len(items))
|
||||||
|
|
||||||
|
for i := 0; i < len(items); i++ {
|
||||||
|
arr, ok := items[i].Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("invalid group type")
|
||||||
|
}
|
||||||
|
res[i], err = parseGroup(arr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
131
frostfsid/config.yml
Normal file
131
frostfsid/config.yml
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
name: "Identity"
|
||||||
|
safemethods:
|
||||||
|
- "getAdmin"
|
||||||
|
- "getGroup"
|
||||||
|
- "getGroupExtended"
|
||||||
|
- "getGroupIDByName"
|
||||||
|
- "getNamespace"
|
||||||
|
- "getNamespaceExtended"
|
||||||
|
- "getSubject"
|
||||||
|
- "getSubjectExtended"
|
||||||
|
- "getSubjectByKey"
|
||||||
|
- "getSubjectKeyByName"
|
||||||
|
- "listGroups"
|
||||||
|
- "listGroupSubjects"
|
||||||
|
- "listNamespaces"
|
||||||
|
- "listNamespaceSubjects"
|
||||||
|
- "listSubjects"
|
||||||
|
- "version"
|
||||||
|
permissions:
|
||||||
|
- methods: ["update"]
|
||||||
|
events:
|
||||||
|
- name: CreateSubject
|
||||||
|
parameters:
|
||||||
|
- name: subjectAddress
|
||||||
|
type: Hash160
|
||||||
|
- name: AddSubjectKey
|
||||||
|
parameters:
|
||||||
|
- name: subjectAddress
|
||||||
|
type: Hash160
|
||||||
|
- name: subjectKey
|
||||||
|
type: PublicKey
|
||||||
|
- name: RemoveSubjectKey
|
||||||
|
parameters:
|
||||||
|
- name: subjectAddress
|
||||||
|
type: Hash160
|
||||||
|
- name: subjectKey
|
||||||
|
type: PublicKey
|
||||||
|
- name: SetSubjectName
|
||||||
|
parameters:
|
||||||
|
- name: subjectAddress
|
||||||
|
type: Hash160
|
||||||
|
- name: name
|
||||||
|
type: String
|
||||||
|
- name: SetSubjectKV
|
||||||
|
parameters:
|
||||||
|
- name: subjectAddress
|
||||||
|
type: Hash160
|
||||||
|
- name: key
|
||||||
|
type: String
|
||||||
|
- name: value
|
||||||
|
type: String
|
||||||
|
- name: DeleteSubjectKV
|
||||||
|
parameters:
|
||||||
|
- name: subjectAddress
|
||||||
|
type: Hash160
|
||||||
|
- name: key
|
||||||
|
type: String
|
||||||
|
- name: DeleteSubject
|
||||||
|
parameters:
|
||||||
|
- name: subjectAddress
|
||||||
|
type: Hash160
|
||||||
|
- name: CreateNamespace
|
||||||
|
parameters:
|
||||||
|
- name: namespace
|
||||||
|
type: String
|
||||||
|
- name: AddSubjectToNamespace
|
||||||
|
parameters:
|
||||||
|
- name: subjectAddress
|
||||||
|
type: Hash160
|
||||||
|
- name: namespace
|
||||||
|
type: String
|
||||||
|
- name: RemoveSubjectFromNamespace
|
||||||
|
parameters:
|
||||||
|
- name: subjectAddress
|
||||||
|
type: Hash160
|
||||||
|
- name: namespace
|
||||||
|
type: String
|
||||||
|
- name: CreateGroup
|
||||||
|
parameters:
|
||||||
|
- name: namespace
|
||||||
|
type: String
|
||||||
|
- name: group
|
||||||
|
type: String
|
||||||
|
- name: SetGroupName
|
||||||
|
parameters:
|
||||||
|
- name: namespace
|
||||||
|
type: String
|
||||||
|
- name: groupID
|
||||||
|
type: Integer
|
||||||
|
- name: name
|
||||||
|
type: String
|
||||||
|
- name: SetGroupKV
|
||||||
|
parameters:
|
||||||
|
- name: namespace
|
||||||
|
type: String
|
||||||
|
- name: groupID
|
||||||
|
type: Integer
|
||||||
|
- name: key
|
||||||
|
type: String
|
||||||
|
- name: value
|
||||||
|
type: String
|
||||||
|
- name: DeleteGroupKV
|
||||||
|
parameters:
|
||||||
|
- name: namespace
|
||||||
|
type: String
|
||||||
|
- name: groupID
|
||||||
|
type: Integer
|
||||||
|
- name: key
|
||||||
|
type: String
|
||||||
|
- name: AddSubjectToGroup
|
||||||
|
parameters:
|
||||||
|
- name: subjectAddress
|
||||||
|
type: Hash160
|
||||||
|
- name: namespace
|
||||||
|
type: String
|
||||||
|
- name: groupID
|
||||||
|
type: Integer
|
||||||
|
- name: RemoveSubjectFromGroup
|
||||||
|
parameters:
|
||||||
|
- name: subjectAddress
|
||||||
|
type: Hash160
|
||||||
|
- name: namespace
|
||||||
|
type: String
|
||||||
|
- name: groupID
|
||||||
|
type: Integer
|
||||||
|
- name: DeleteGroup
|
||||||
|
parameters:
|
||||||
|
- name: namespace
|
||||||
|
type: String
|
||||||
|
- name: groupID
|
||||||
|
type: Integer
|
26
frostfsid/doc.go
Normal file
26
frostfsid/doc.go
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// Package frostfsid
|
||||||
|
/*
|
||||||
|
FrostFSID contract is a contract deployed in FrostFS sidechain.
|
||||||
|
|
||||||
|
# Contract notifications
|
||||||
|
|
||||||
|
FrostFSID contract does not produce notifications to process.
|
||||||
|
|
||||||
|
# Contract storage scheme
|
||||||
|
|
||||||
|
| Key | Value | Description |
|
||||||
|
|------------------------------------------------------------------------------|--------------------------------|-----------------------------------------------|
|
||||||
|
| `o` + [ owner address ] | []byte{1} | contract owners that can invoke write methods |
|
||||||
|
| `s` + [ subject address ] | Serialized Subject structure | subject into |
|
||||||
|
| `a` + [ pk address ] + [ subject address ] | []byte{1} | link extra public keys for subject |
|
||||||
|
| `n` + [ RIPEMD160 of namespace ] | Serialized Namespace structure | namespace info |
|
||||||
|
| `N` + [ RIPEMD160 of namespace ] + [ subject address ] | []byte{1} | subject that belongs to the namespace |
|
||||||
|
| `l` + [ RIPEMD160 of namespace ] + [ RIPEMD160 of subject name ] | Subject public key | subject name to public key index |
|
||||||
|
| `g` + [ RIPEMD160 of namespace ] + [ 8 byte group id ] | Serialized Group structure | group into |
|
||||||
|
| `G` + [ RIPEMD160 of namespace ] + [ 8 byte group id ] + [ subject address ] | []byte{1} | subject that belongs to the group |
|
||||||
|
| `c` | Int | group id counter |
|
||||||
|
| `m` + [ RIPEMD160 of namespace ] + [ RIPEMD160 of subject name ] | Serialized group id int | group name to group id index |
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
package frostfsid
|
1006
frostfsid/frostfsid_contract.go
Normal file
1006
frostfsid/frostfsid_contract.go
Normal file
File diff suppressed because it is too large
Load diff
60
go.mod
60
go.mod
|
@ -1,10 +1,60 @@
|
||||||
module github.com/nspcc-dev/neofs-contract
|
module git.frostfs.info/TrueCloudLab/frostfs-contract
|
||||||
|
|
||||||
go 1.14
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/google/uuid v1.3.0
|
||||||
github.com/mr-tron/base58 v1.2.0
|
github.com/mr-tron/base58 v1.2.0
|
||||||
github.com/nspcc-dev/neo-go v0.99.2
|
github.com/nspcc-dev/neo-go v0.103.0
|
||||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220809123759-3094d3e0c14b
|
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20231020160724-c3955f87d1b5
|
||||||
github.com/stretchr/testify v1.7.0
|
github.com/stretchr/testify v1.8.4
|
||||||
|
go.uber.org/zap v1.26.0
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
|
github.com/bits-and-blooms/bitset v1.8.0 // indirect
|
||||||
|
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||||
|
github.com/consensys/bavard v0.1.13 // indirect
|
||||||
|
github.com/consensys/gnark-crypto v0.12.2-0.20231013160410-1f65e75b6dfb // indirect
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
|
||||||
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
|
github.com/golang/snappy v0.0.1 // indirect
|
||||||
|
github.com/google/go-cmp v0.5.9 // indirect
|
||||||
|
github.com/gorilla/websocket v1.4.2 // indirect
|
||||||
|
github.com/hashicorp/golang-lru v0.6.0 // indirect
|
||||||
|
github.com/holiman/uint256 v1.2.0 // indirect
|
||||||
|
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||||
|
github.com/mmcloughlin/addchain v0.4.0 // indirect
|
||||||
|
github.com/nspcc-dev/dbft v0.0.0-20230515113611-25db6ba61d5c // indirect
|
||||||
|
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22 // indirect
|
||||||
|
github.com/nspcc-dev/neofs-crypto v0.4.0 // indirect
|
||||||
|
github.com/nspcc-dev/rfc6979 v0.2.0 // indirect
|
||||||
|
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
|
||||||
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
github.com/prometheus/client_golang v1.13.0 // indirect
|
||||||
|
github.com/prometheus/client_model v0.2.0 // indirect
|
||||||
|
github.com/prometheus/common v0.37.0 // indirect
|
||||||
|
github.com/prometheus/procfs v0.8.0 // indirect
|
||||||
|
github.com/rogpeppe/go-internal v1.11.0 // indirect
|
||||||
|
github.com/russross/blackfriday/v2 v2.0.1 // indirect
|
||||||
|
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
||||||
|
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954 // indirect
|
||||||
|
github.com/twmb/murmur3 v1.1.5 // indirect
|
||||||
|
github.com/urfave/cli v1.22.5 // indirect
|
||||||
|
go.etcd.io/bbolt v1.3.7 // indirect
|
||||||
|
go.uber.org/multierr v1.10.0 // indirect
|
||||||
|
golang.org/x/crypto v0.14.0 // indirect
|
||||||
|
golang.org/x/mod v0.12.0 // indirect
|
||||||
|
golang.org/x/sync v0.3.0 // indirect
|
||||||
|
golang.org/x/sys v0.13.0 // indirect
|
||||||
|
golang.org/x/term v0.13.0 // indirect
|
||||||
|
golang.org/x/text v0.13.0 // indirect
|
||||||
|
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
|
||||||
|
google.golang.org/protobuf v1.31.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
rsc.io/tmplfunc v0.0.3 // indirect
|
||||||
)
|
)
|
||||||
|
|
260
go.sum
260
go.sum
|
@ -33,80 +33,49 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||||
github.com/CityOfZion/neo-go v0.62.1-pre.0.20191114145240-e740fbe708f8/go.mod h1:MJCkWUBhi9pn/CrYO1Q3P687y2KeahrOPS9BD9LDGb0=
|
|
||||||
github.com/CityOfZion/neo-go v0.70.1-pre.0.20191209120015-fccb0085941e/go.mod h1:0enZl0az8xA6PVkwzEOwPWVJGqlt/GO4hA4kmQ5Xzig=
|
|
||||||
github.com/CityOfZion/neo-go v0.70.1-pre.0.20191212173117-32ac01130d4c/go.mod h1:JtlHfeqLywZLswKIKFnAp+yzezY4Dji9qlfQKB2OD/I=
|
|
||||||
github.com/CityOfZion/neo-go v0.71.1-pre.0.20200129171427-f773ec69fb84/go.mod h1:FLI526IrRWHmcsO+mHsCbj64pJZhwQFTLJZu+A4PGOA=
|
|
||||||
github.com/Workiva/go-datastructures v1.0.50/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA=
|
|
||||||
github.com/abiosoft/ishell v2.0.0+incompatible/go.mod h1:HQR9AqF2R3P4XXpMpI0NAzgHf/aS6+zVXRj14cVk9qg=
|
|
||||||
github.com/abiosoft/ishell/v2 v2.0.2/go.mod h1:E4oTCXfo6QjoCart0QYa5m9w4S+deXs/P/9jA77A9Bs=
|
|
||||||
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db/go.mod h1:rB3B4rKii8V21ydCbIzH5hZiCQE7f5E9SzUb/ZZx530=
|
|
||||||
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
|
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||||
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
|
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20221202181307-76fa05c21b12 h1:npHgfD4Tl2WJS3AJaMUi5ynGDPUBfkg3U3fCzDyXZ+4=
|
||||||
github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
|
|
||||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
|
||||||
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521073959-f0d4d129b7f1/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY=
|
|
||||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
|
||||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
|
||||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||||
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
|
github.com/bits-and-blooms/bitset v1.8.0 h1:FD+XqgOZDUxxZ8hzoBFuV9+cGWY9CslN6d5MS5JVb4c=
|
||||||
github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo=
|
github.com/bits-and-blooms/bitset v1.8.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
|
||||||
github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA=
|
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
|
||||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
|
|
||||||
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o=
|
|
||||||
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
|
|
||||||
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY=
|
|
||||||
github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I=
|
|
||||||
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
|
|
||||||
github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
|
|
||||||
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
|
|
||||||
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
|
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tjxl5dIMyVM=
|
|
||||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
|
||||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
|
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||||
|
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||||
|
github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI=
|
||||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ=
|
||||||
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
|
||||||
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
|
github.com/consensys/gnark-crypto v0.12.2-0.20231013160410-1f65e75b6dfb h1:f0BMgIjhZy4lSRHCXFbQst85f5agZAjtDMixQqBWNpc=
|
||||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
github.com/consensys/gnark-crypto v0.12.2-0.20231013160410-1f65e75b6dfb/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
|
||||||
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
|
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
|
||||||
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
|
||||||
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
|
||||||
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
|
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw=
|
github.com/frankban/quicktest v1.14.5 h1:dfYrrRyLtiqT9GyKXgdh+k4inNeTvmGbuSgZ3lx3GhA=
|
||||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
|
||||||
github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
|
|
||||||
github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:rZfgFAXFS/z/lEd6LJmf9HVZ1LkgYiHx5pHhV5DR16M=
|
|
||||||
github.com/frankban/quicktest v1.14.0/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og=
|
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
|
||||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||||
|
@ -118,9 +87,7 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9
|
||||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||||
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
|
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
|
||||||
github.com/go-redis/redis v6.10.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0=
|
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
@ -133,7 +100,6 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt
|
||||||
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||||
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
||||||
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
|
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
@ -149,12 +115,11 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD
|
||||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
|
||||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||||
|
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
|
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
|
||||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
|
|
||||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
|
@ -166,9 +131,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||||
|
@ -180,28 +144,23 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf
|
||||||
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||||
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
|
||||||
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
|
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
|
||||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
|
github.com/hashicorp/golang-lru v0.6.0 h1:uL2shRDx7RTrOrTCUZEGP/wJUFiUI8QT6E7z5o8jga4=
|
||||||
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
github.com/hashicorp/golang-lru v0.6.0/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||||
github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM=
|
github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM=
|
||||||
github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw=
|
github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||||
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
|
||||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
|
||||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
||||||
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
|
|
||||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
|
||||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
|
@ -209,78 +168,57 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
|
||||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
|
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
|
||||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
|
||||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
|
||||||
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
|
||||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
|
||||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
|
||||||
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
|
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
|
github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY=
|
||||||
|
github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU=
|
||||||
|
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
|
||||||
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
|
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
|
||||||
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
github.com/nspcc-dev/dbft v0.0.0-20191205084618-dacb1a30c254/go.mod h1:w1Ln2aT+dBlPhLnuZhBV+DfPEdS2CHWWLp5JTScY3bw=
|
github.com/nspcc-dev/dbft v0.0.0-20230515113611-25db6ba61d5c h1:uyK5aLbAhrnZtnvobJLN24gGUrlxIJAAFqiWl+liZuo=
|
||||||
github.com/nspcc-dev/dbft v0.0.0-20191209120240-0d6b7568d9ae/go.mod h1:3FjXOoHmA51EGfb5GS/HOv7VdmngNRTssSeQ729dvGY=
|
github.com/nspcc-dev/dbft v0.0.0-20230515113611-25db6ba61d5c/go.mod h1:kjBC9F8L25GR+kIHy/1KgG/KfcoGnVwIiyovgq1uszk=
|
||||||
github.com/nspcc-dev/dbft v0.0.0-20200117124306-478e5cfbf03a/go.mod h1:/YFK+XOxxg0Bfm6P92lY5eDSLYfp06XOdL8KAVgXjVk=
|
|
||||||
github.com/nspcc-dev/dbft v0.0.0-20200219114139-199d286ed6c1/go.mod h1:O0qtn62prQSqizzoagHmuuKoz8QMkU3SzBoKdEvm3aQ=
|
|
||||||
github.com/nspcc-dev/dbft v0.0.0-20210721160347-1b03241391ac/go.mod h1:U8MSnEShH+o5hexfWJdze6uMFJteP0ko7J2frO7Yu1Y=
|
|
||||||
github.com/nspcc-dev/dbft v0.0.0-20220629112714-fd49ca59d354/go.mod h1:U8MSnEShH+o5hexfWJdze6uMFJteP0ko7J2frO7Yu1Y=
|
|
||||||
github.com/nspcc-dev/go-ordered-json v0.0.0-20210915112629-e1b6cce73d02/go.mod h1:79bEUDEviBHJMFV6Iq6in57FEOCMcRhfQnfaf0ETA5U=
|
|
||||||
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22 h1:n4ZaFCKt1pQJd7PXoMJabZWK9ejjbLOVrkl/lOUmshg=
|
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22 h1:n4ZaFCKt1pQJd7PXoMJabZWK9ejjbLOVrkl/lOUmshg=
|
||||||
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22/go.mod h1:79bEUDEviBHJMFV6Iq6in57FEOCMcRhfQnfaf0ETA5U=
|
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22/go.mod h1:79bEUDEviBHJMFV6Iq6in57FEOCMcRhfQnfaf0ETA5U=
|
||||||
github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU=
|
github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y=
|
||||||
github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg=
|
github.com/nspcc-dev/neo-go v0.103.0 h1:UVyWPhzZdfYFG35ORP3FRDLh8J/raRQ6m8SptDdlgfM=
|
||||||
github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM=
|
github.com/nspcc-dev/neo-go v0.103.0/go.mod h1:x+wmcYqpZYJwLp1l/pHZrqNp3RSWlkMymWGDij3/OPo=
|
||||||
github.com/nspcc-dev/neo-go v0.99.2 h1:Fq79FI6BJkj/XkgWtrURSdXgXIeBHCgbKauBw3LOvZ4=
|
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20231020160724-c3955f87d1b5 h1:09CpI5uwsxb1EeFPIKQRwwWlfCmDD/Dwwh01lPiQScM=
|
||||||
github.com/nspcc-dev/neo-go v0.99.2/go.mod h1:9P0yWqhZX7i/ChJ+zjtiStO1uPTolPFUM+L5oNznU8E=
|
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20231020160724-c3955f87d1b5/go.mod h1:J/Mk6+nKeKSW4wygkZQFLQ6SkLOSGX5Ga0RuuuktEag=
|
||||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220809123759-3094d3e0c14b h1:J7QZNmnO84esVuPbBo88fwAG4XVnDjlSTiO1ewLNCkQ=
|
github.com/nspcc-dev/neofs-api-go/v2 v2.14.0 h1:jhuN8Ldqz7WApvUJRFY0bjRXE1R3iCkboMX5QVZhHVk=
|
||||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220809123759-3094d3e0c14b/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
github.com/nspcc-dev/neofs-crypto v0.4.0 h1:5LlrUAM5O0k1+sH/sktBtrgfWtq1pgpDs09fZo+KYi4=
|
||||||
github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
|
github.com/nspcc-dev/neofs-crypto v0.4.0/go.mod h1:6XJ8kbXgOfevbI2WMruOtI+qUJXNwSGM/E9eClXxPHs=
|
||||||
github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
|
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.11 h1:QOc8ZRN5DXlAeRPh5QG9u8rMLgoeRNiZF5/vL7QupWg=
|
||||||
github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA=
|
|
||||||
github.com/nspcc-dev/neofs-crypto v0.2.3/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw=
|
|
||||||
github.com/nspcc-dev/neofs-crypto v0.3.0/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw=
|
|
||||||
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20211201182451-a5b61c4f6477/go.mod h1:dfMtQWmBHYpl9Dez23TGtIUKiFvCIxUZq/CkSIhEpz4=
|
|
||||||
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659/go.mod h1:/jay1lr3w7NQd/VDBkEhkJmDmyPNsu4W+QV2obsUV40=
|
|
||||||
github.com/nspcc-dev/rfc6979 v0.1.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=
|
|
||||||
github.com/nspcc-dev/rfc6979 v0.2.0 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE=
|
github.com/nspcc-dev/rfc6979 v0.2.0 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE=
|
||||||
github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=
|
github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=
|
||||||
|
github.com/nspcc-dev/tzhash v1.7.0 h1:/+aL33NC7y5OIGnY2kYgjZt8mg7LVGFMdj/KAJLndnk=
|
||||||
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
|
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
|
||||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
|
||||||
github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
|
||||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||||
github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA=
|
github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA=
|
||||||
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||||
github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
|
||||||
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
|
||||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
|
||||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||||
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
|
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
|
||||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||||
|
github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM=
|
||||||
github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
@ -290,7 +228,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||||
github.com/prometheus/client_golang v1.2.1/go.mod h1:XMU6Z2MjaRKVu/dC1qupJI9SiNkDYzz3xecMgSW/F+U=
|
|
||||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||||
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
||||||
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
|
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
|
||||||
|
@ -302,7 +239,6 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
|
||||||
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
||||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||||
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
|
|
||||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||||
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
|
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
|
||||||
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
|
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
|
||||||
|
@ -310,16 +246,14 @@ github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8
|
||||||
github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA=
|
github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA=
|
||||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||||
github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
|
|
||||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||||
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||||
github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=
|
github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=
|
||||||
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
|
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
|
||||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
|
||||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
|
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
|
||||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
||||||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
||||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
||||||
|
@ -327,21 +261,19 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV
|
||||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||||
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/syndtr/goleveldb v0.0.0-20180307113352-169b1b37be73/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||||
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954 h1:xQdMZ1WLrgkkvOZ/LDQxjVxMLdby7osSh4ZEVa5sIjs=
|
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954 h1:xQdMZ1WLrgkkvOZ/LDQxjVxMLdby7osSh4ZEVa5sIjs=
|
||||||
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM=
|
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM=
|
||||||
github.com/twmb/murmur3 v1.1.5 h1:i9OLS9fkuLzBXjt6dptlAEyk58fJsSTXbRg3SgVyqgk=
|
github.com/twmb/murmur3 v1.1.5 h1:i9OLS9fkuLzBXjt6dptlAEyk58fJsSTXbRg3SgVyqgk=
|
||||||
github.com/twmb/murmur3 v1.1.5/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ=
|
github.com/twmb/murmur3 v1.1.5/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ=
|
||||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
|
||||||
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
|
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
|
||||||
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||||
github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74 h1:JwtAtbp7r/7QSyGz8mKUbYJBg2+6Cd7OjM8o/GNOcVo=
|
github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74 h1:JwtAtbp7r/7QSyGz8mKUbYJBg2+6Cd7OjM8o/GNOcVo=
|
||||||
|
@ -349,43 +281,26 @@ github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74/go.mod h1
|
||||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ=
|
||||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
|
||||||
github.com/yuin/gopher-lua v0.0.0-20190514113301-1cd887cd7036/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ=
|
|
||||||
github.com/yuin/gopher-lua v0.0.0-20191128022950-c6266f4fe8d7/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ=
|
|
||||||
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
|
||||||
go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU=
|
|
||||||
go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
|
|
||||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
|
||||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
|
||||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
|
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
|
||||||
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
|
||||||
go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0=
|
|
||||||
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
|
|
||||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
|
||||||
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
|
|
||||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
|
||||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
|
||||||
go.uber.org/zap v1.18.1 h1:CSUJ2mjFszzEWt4CdKISEuChVIXGBn3lAPwkRGyVrc4=
|
|
||||||
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
|
|
||||||
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
|
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||||
|
@ -396,6 +311,7 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
|
||||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||||
|
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ=
|
||||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
@ -407,7 +323,6 @@ golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHl
|
||||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
|
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
|
||||||
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k=
|
|
||||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||||
|
@ -417,9 +332,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
|
||||||
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
|
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
|
||||||
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
@ -451,13 +365,10 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
|
||||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
|
||||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
|
||||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
|
|
||||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
|
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
|
@ -473,18 +384,15 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f h1:Ax0t5p6N38Ga0dThY21weqDEyz2oklo4IvDkpigvkD8=
|
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
|
||||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
@ -493,18 +401,14 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
@ -521,34 +425,31 @@ golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
|
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210429154555-c04ba851c2a4/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
|
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
|
||||||
|
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
|
||||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||||
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/tools v0.0.0-20180318012157-96caea41033d/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
|
@ -564,7 +465,6 @@ golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgw
|
||||||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
@ -590,9 +490,8 @@ golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roY
|
||||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||||
golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 h1:Vve/L0v7CXXuxUmaMGIEK/dEeq7uiqb5qBgQrZzIE7E=
|
||||||
golang.org/x/tools v0.1.8 h1:P1HhGGuLW4aAclzjtmJdf0mJOjVUZUzOTqkAkWL+l6w=
|
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
|
||||||
golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
@ -643,13 +542,13 @@ google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfG
|
||||||
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
|
||||||
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
|
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
|
||||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||||
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
|
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
|
||||||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 h1:eSaPbMR4T7WfH9FvABk36NBMacoTUKdWCvV0dx+KfOg=
|
||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||||
|
@ -662,9 +561,7 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa
|
||||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw=
|
||||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
|
||||||
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
|
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
|
@ -677,30 +574,25 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
|
||||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||||
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
|
||||||
gopkg.in/abiosoft/ishell.v2 v2.0.0/go.mod h1:sFp+cGtH6o4s1FtpVPTMcHq2yue+c4DGOVohJCPUzwY=
|
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
@ -713,3 +605,5 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
|
||||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||||
|
rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU=
|
||||||
|
rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA=
|
||||||
|
|
95
neofs/doc.go
95
neofs/doc.go
|
@ -1,95 +0,0 @@
|
||||||
/*
|
|
||||||
NeoFS contract is a contract deployed in NeoFS mainchain.
|
|
||||||
|
|
||||||
NeoFS contract is an entry point to NeoFS users. This contract stores all NeoFS
|
|
||||||
related GAS, registers new Inner Ring candidates and produces notifications
|
|
||||||
to control the sidechain.
|
|
||||||
|
|
||||||
While mainchain committee controls the list of Alphabet nodes in native
|
|
||||||
RoleManagement contract, NeoFS can't change more than 1\3 keys at a time.
|
|
||||||
NeoFS contract contains the actual list of Alphabet nodes in the sidechain.
|
|
||||||
|
|
||||||
Network configuration is also stored in NeoFS contract. All changes in
|
|
||||||
configuration are mirrored in the sidechain with notifications.
|
|
||||||
|
|
||||||
Contract notifications
|
|
||||||
|
|
||||||
Deposit notification. This notification is produced when user transfers native
|
|
||||||
GAS to the NeoFS contract address. The same amount of NEOFS token will be
|
|
||||||
minted in Balance contract in the sidechain.
|
|
||||||
|
|
||||||
Deposit:
|
|
||||||
- name: from
|
|
||||||
type: Hash160
|
|
||||||
- name: amount
|
|
||||||
type: Integer
|
|
||||||
- name: receiver
|
|
||||||
type: Hash160
|
|
||||||
- name: txHash
|
|
||||||
type: Hash256
|
|
||||||
|
|
||||||
Withdraw notification. This notification is produced when a user wants to
|
|
||||||
withdraw GAS from the internal NeoFS balance and has paid fee for that.
|
|
||||||
|
|
||||||
Withdraw:
|
|
||||||
- name: user
|
|
||||||
type: Hash160
|
|
||||||
- name: amount
|
|
||||||
type: Integer
|
|
||||||
- name: txHash
|
|
||||||
type: Hash256
|
|
||||||
|
|
||||||
|
|
||||||
Cheque notification. This notification is produced when NeoFS contract
|
|
||||||
has successfully transferred assets back to the user after withdraw.
|
|
||||||
|
|
||||||
Cheque:
|
|
||||||
- name: id
|
|
||||||
type: ByteArray
|
|
||||||
- name: user
|
|
||||||
type: Hash160
|
|
||||||
- name: amount
|
|
||||||
type: Integer
|
|
||||||
- name: lockAccount
|
|
||||||
type: ByteArray
|
|
||||||
|
|
||||||
Bind notification. This notification is produced when a user wants to bind
|
|
||||||
public keys with the user account (OwnerID). Keys argument is an array of ByteArray.
|
|
||||||
|
|
||||||
Bind:
|
|
||||||
- name: user
|
|
||||||
type: ByteArray
|
|
||||||
- name: keys
|
|
||||||
type: Array
|
|
||||||
|
|
||||||
Unbind notification. This notification is produced when a user wants to unbind
|
|
||||||
public keys with the user account (OwnerID). Keys argument is an array of ByteArray.
|
|
||||||
|
|
||||||
Unbind:
|
|
||||||
- name: user
|
|
||||||
type: ByteArray
|
|
||||||
- name: keys
|
|
||||||
type: Array
|
|
||||||
|
|
||||||
AlphabetUpdate notification. This notification is produced when Alphabet nodes
|
|
||||||
have updated their lists in the contract. Alphabet argument is an array of ByteArray. It
|
|
||||||
contains public keys of new alphabet nodes.
|
|
||||||
|
|
||||||
AlphabetUpdate:
|
|
||||||
- name: id
|
|
||||||
type: ByteArray
|
|
||||||
- name: alphabet
|
|
||||||
type: Array
|
|
||||||
|
|
||||||
SetConfig notification. This notification is produced when Alphabet nodes update
|
|
||||||
NeoFS network configuration value.
|
|
||||||
|
|
||||||
SetConfig
|
|
||||||
- name: id
|
|
||||||
type: ByteArray
|
|
||||||
- name: key
|
|
||||||
type: ByteArray
|
|
||||||
- name: value
|
|
||||||
type: ByteArray
|
|
||||||
*/
|
|
||||||
package neofs
|
|
|
@ -1,4 +0,0 @@
|
||||||
name: "NeoFS ID"
|
|
||||||
safemethods: ["key", "version"]
|
|
||||||
permissions:
|
|
||||||
- methods: ["update"]
|
|
|
@ -1,20 +0,0 @@
|
||||||
/*
|
|
||||||
NeoFSID contract is a contract deployed in NeoFS sidechain.
|
|
||||||
|
|
||||||
NeoFSID contract is used to store connection between an OwnerID and its public keys.
|
|
||||||
OwnerID is a 25-byte N3 wallet address that can be produced from a public key.
|
|
||||||
It is one-way conversion. In simple cases, NeoFS verifies ownership by checking
|
|
||||||
signature and relation between a public key and an OwnerID.
|
|
||||||
|
|
||||||
In more complex cases, a user can use public keys unrelated to the OwnerID to maintain
|
|
||||||
secure access to the data. NeoFSID contract stores relation between an OwnerID and
|
|
||||||
arbitrary public keys. Data owner can bind a public key with its account or unbind it
|
|
||||||
by invoking Bind or Unbind methods of NeoFS contract in the mainchain. After that,
|
|
||||||
Alphabet nodes produce multisigned AddKey and RemoveKey invocations of NeoFSID
|
|
||||||
contract.
|
|
||||||
|
|
||||||
Contract notifications
|
|
||||||
|
|
||||||
NeoFSID contract does not produce notifications to process.
|
|
||||||
*/
|
|
||||||
package neofsid
|
|
|
@ -1,233 +0,0 @@
|
||||||
package neofsid
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/crypto"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
|
||||||
"github.com/nspcc-dev/neofs-contract/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
|
||||||
UserInfo struct {
|
|
||||||
Keys [][]byte
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
ownerSize = 1 + interop.Hash160Len + 4
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
netmapContractKey = "netmapScriptHash"
|
|
||||||
containerContractKey = "containerScriptHash"
|
|
||||||
notaryDisabledKey = "notary"
|
|
||||||
ownerKeysPrefix = 'o'
|
|
||||||
)
|
|
||||||
|
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
|
|
||||||
if isUpdate {
|
|
||||||
args := data.([]interface{})
|
|
||||||
common.CheckVersion(args[len(args)-1].(int))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
args := data.(struct {
|
|
||||||
notaryDisabled bool
|
|
||||||
addrNetmap interop.Hash160
|
|
||||||
addrContainer interop.Hash160
|
|
||||||
})
|
|
||||||
|
|
||||||
if len(args.addrNetmap) != interop.Hash160Len || len(args.addrContainer) != interop.Hash160Len {
|
|
||||||
panic("incorrect length of contract script hash")
|
|
||||||
}
|
|
||||||
|
|
||||||
storage.Put(ctx, netmapContractKey, args.addrNetmap)
|
|
||||||
storage.Put(ctx, containerContractKey, args.addrContainer)
|
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
|
||||||
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
|
||||||
if args.notaryDisabled {
|
|
||||||
common.InitVote(ctx)
|
|
||||||
runtime.Log("neofsid contract notary disabled")
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.Log("neofsid contract initialized")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. It can be invoked
|
|
||||||
// only by committee.
|
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
|
||||||
if !common.HasUpdateAccess() {
|
|
||||||
panic("only committee can update contract")
|
|
||||||
}
|
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update",
|
|
||||||
contract.All, script, manifest, common.AppendVersion(data))
|
|
||||||
runtime.Log("neofsid contract updated")
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddKey binds a list of the provided public keys to the OwnerID. It can be invoked only by
|
|
||||||
// Alphabet nodes.
|
|
||||||
//
|
|
||||||
// This method panics if the OwnerID is not an ownerSize byte or the public key is not 33 byte long.
|
|
||||||
// If the key is already bound, the method ignores it.
|
|
||||||
func AddKey(owner []byte, keys []interop.PublicKey) {
|
|
||||||
// V2 format
|
|
||||||
if len(owner) != ownerSize {
|
|
||||||
panic("incorrect owner")
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := range keys {
|
|
||||||
if len(keys[i]) != interop.PublicKeyCompressedLen {
|
|
||||||
panic("incorrect public key")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
indirectCall bool
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = common.AlphabetNodes()
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
panic("invocation from non inner ring node")
|
|
||||||
}
|
|
||||||
|
|
||||||
indirectCall = common.FromKnownContract(
|
|
||||||
ctx,
|
|
||||||
runtime.GetCallingScriptHash(),
|
|
||||||
containerContractKey)
|
|
||||||
|
|
||||||
if indirectCall {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := invokeIDKeys(owner, keys, []byte("add"))
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
ownerKey := append([]byte{ownerKeysPrefix}, owner...)
|
|
||||||
for i := range keys {
|
|
||||||
stKey := append(ownerKey, keys[i]...)
|
|
||||||
storage.Put(ctx, stKey, []byte{1})
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.Log("key bound to the owner")
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveKey unbinds the provided public keys from the OwnerID. It can be invoked only by
|
|
||||||
// Alphabet nodes.
|
|
||||||
//
|
|
||||||
// This method panics if the OwnerID is not an ownerSize byte or the public key is not 33 byte long.
|
|
||||||
// If the key is already unbound, the method ignores it.
|
|
||||||
func RemoveKey(owner []byte, keys []interop.PublicKey) {
|
|
||||||
// V2 format
|
|
||||||
if len(owner) != ownerSize {
|
|
||||||
panic("incorrect owner")
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := range keys {
|
|
||||||
if len(keys[i]) != interop.PublicKeyCompressedLen {
|
|
||||||
panic("incorrect public key")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = common.AlphabetNodes()
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
panic("invocation from non inner ring node")
|
|
||||||
}
|
|
||||||
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := invokeIDKeys(owner, keys, []byte("remove"))
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
if !runtime.CheckWitness(multiaddr) {
|
|
||||||
panic("invocation from non inner ring node")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ownerKey := append([]byte{ownerKeysPrefix}, owner...)
|
|
||||||
for i := range keys {
|
|
||||||
stKey := append(ownerKey, keys[i]...)
|
|
||||||
storage.Delete(ctx, stKey)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Key method returns a list of 33-byte public keys bound with the OwnerID.
|
|
||||||
//
|
|
||||||
// This method panics if the owner is not ownerSize byte long.
|
|
||||||
func Key(owner []byte) [][]byte {
|
|
||||||
// V2 format
|
|
||||||
if len(owner) != ownerSize {
|
|
||||||
panic("incorrect owner")
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetReadOnlyContext()
|
|
||||||
|
|
||||||
ownerKey := append([]byte{ownerKeysPrefix}, owner...)
|
|
||||||
info := getUserInfo(ctx, ownerKey)
|
|
||||||
|
|
||||||
return info.Keys
|
|
||||||
}
|
|
||||||
|
|
||||||
// Version returns the version of the contract.
|
|
||||||
func Version() int {
|
|
||||||
return common.Version
|
|
||||||
}
|
|
||||||
|
|
||||||
func getUserInfo(ctx storage.Context, key interface{}) UserInfo {
|
|
||||||
it := storage.Find(ctx, key, storage.KeysOnly|storage.RemovePrefix)
|
|
||||||
pubs := [][]byte{}
|
|
||||||
for iterator.Next(it) {
|
|
||||||
pub := iterator.Value(it).([]byte)
|
|
||||||
pubs = append(pubs, pub)
|
|
||||||
}
|
|
||||||
|
|
||||||
return UserInfo{Keys: pubs}
|
|
||||||
}
|
|
||||||
|
|
||||||
func invokeIDKeys(owner []byte, keys []interop.PublicKey, prefix []byte) []byte {
|
|
||||||
prefix = append(prefix, owner...)
|
|
||||||
for i := range keys {
|
|
||||||
prefix = append(prefix, keys[i]...)
|
|
||||||
}
|
|
||||||
|
|
||||||
return crypto.Sha256(prefix)
|
|
||||||
}
|
|
|
@ -1,5 +1,13 @@
|
||||||
name: "NeoFS Netmap"
|
name: "Netmap"
|
||||||
safemethods: ["innerRingList", "epoch", "netmap", "netmapCandidates", "snapshot", "snapshotByEpoch", "config", "listConfig", "version"]
|
safemethods:
|
||||||
|
- "config"
|
||||||
|
- "epoch"
|
||||||
|
- "listConfig"
|
||||||
|
- "netmap"
|
||||||
|
- "netmapCandidates"
|
||||||
|
- "snapshot"
|
||||||
|
- "snapshotByEpoch"
|
||||||
|
- "version"
|
||||||
permissions:
|
permissions:
|
||||||
- methods: ["update", "newEpoch"]
|
- methods: ["update", "newEpoch"]
|
||||||
events:
|
events:
|
||||||
|
|
|
@ -1,34 +1,45 @@
|
||||||
/*
|
/*
|
||||||
Netmap contract is a contract deployed in NeoFS sidechain.
|
Netmap contract is a contract deployed in FrostFS sidechain.
|
||||||
|
|
||||||
Netmap contract stores and manages NeoFS network map, Storage node candidates
|
Netmap contract stores and manages FrostFS network map, Storage node candidates
|
||||||
and epoch number counter. In notary disabled environment, contract also stores
|
and epoch number counter.
|
||||||
a list of Inner Ring node keys.
|
|
||||||
|
|
||||||
Contract notifications
|
# Contract notifications
|
||||||
|
|
||||||
AddPeer notification. This notification is produced when a Storage node sends
|
AddPeer notification. This notification is produced when a Storage node sends
|
||||||
a bootstrap request by invoking AddPeer method.
|
a bootstrap request by invoking AddPeer method.
|
||||||
|
|
||||||
AddPeer
|
AddPeer
|
||||||
- name: nodeInfo
|
- name: nodeInfo
|
||||||
type: ByteArray
|
type: ByteArray
|
||||||
|
|
||||||
UpdateState notification. This notification is produced when a Storage node wants
|
UpdateState notification. This notification is produced when a Storage node wants
|
||||||
to change its state (go offline) by invoking UpdateState method. Supported
|
to change its state (go offline) by invoking UpdateState method. Supported
|
||||||
states: (2) -- offline.
|
states: (2) -- offline.
|
||||||
|
|
||||||
UpdateState
|
UpdateState
|
||||||
- name: state
|
- name: state
|
||||||
type: Integer
|
type: Integer
|
||||||
- name: publicKey
|
- name: publicKey
|
||||||
type: PublicKey
|
type: PublicKey
|
||||||
|
|
||||||
NewEpoch notification. This notification is produced when a new epoch is applied
|
NewEpoch notification. This notification is produced when a new epoch is applied
|
||||||
in the network by invoking NewEpoch method.
|
in the network by invoking NewEpoch method.
|
||||||
|
|
||||||
NewEpoch
|
NewEpoch
|
||||||
- name: epoch
|
- name: epoch
|
||||||
type: Integer
|
type: Integer
|
||||||
|
|
||||||
|
# Contract storage scheme
|
||||||
|
|
||||||
|
| Key | Value | Description |
|
||||||
|
|-----------------------------|------------|-----------------------------------|
|
||||||
|
| `snapshotCount` | int | snapshot count |
|
||||||
|
| `snapshotEpoch` | int | snapshot epoch |
|
||||||
|
| `snapshotBlock` | int | snapshot block |
|
||||||
|
| `snapshot_` + snapshotNum | ByteArray | serialized '[]Node' array |
|
||||||
|
| `snapshotCurrent` | int | current snapshot |
|
||||||
|
| `balanceScriptHash` | Hash160 | balance contract hash |
|
||||||
|
| `containerScriptHash` | Hash160 | container contract hash |
|
||||||
*/
|
*/
|
||||||
package netmap
|
package netmap
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
package netmap
|
package netmap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/crypto"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/ledger"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/ledger"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neofs-contract/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NodeState is an enumeration for node states.
|
// NodeState is an enumeration for node states.
|
||||||
|
@ -32,10 +31,10 @@ const (
|
||||||
NodeStateMaintenance
|
NodeStateMaintenance
|
||||||
)
|
)
|
||||||
|
|
||||||
// Node groups data related to NeoFS storage nodes registered in the NeoFS
|
// Node groups data related to FrostFS storage nodes registered in the FrostFS
|
||||||
// network. The information is stored in the current contract.
|
// network. The information is stored in the current contract.
|
||||||
type Node struct {
|
type Node struct {
|
||||||
// Information about the node encoded according to the NeoFS binary
|
// Information about the node encoded according to the FrostFS binary
|
||||||
// protocol.
|
// protocol.
|
||||||
BLOB []byte
|
BLOB []byte
|
||||||
|
|
||||||
|
@ -44,8 +43,7 @@ type Node struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
notaryDisabledKey = "notary"
|
innerRingKey = "innerring"
|
||||||
innerRingKey = "innerring"
|
|
||||||
|
|
||||||
// DefaultSnapshotCount contains the number of previous snapshots stored by this contract.
|
// DefaultSnapshotCount contains the number of previous snapshots stored by this contract.
|
||||||
// Must be less than 255.
|
// Must be less than 255.
|
||||||
|
@ -68,16 +66,15 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// _deploy function sets up initial list of inner ring public keys.
|
// _deploy function sets up initial list of inner ring public keys.
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
func _deploy(data any, isUpdate bool) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
var args = data.(struct {
|
args := data.(struct {
|
||||||
notaryDisabled bool
|
addrBalance interop.Hash160
|
||||||
addrBalance interop.Hash160
|
addrContainer interop.Hash160
|
||||||
addrContainer interop.Hash160
|
keys []interop.PublicKey
|
||||||
keys []interop.PublicKey
|
config [][]byte
|
||||||
config [][]byte
|
version int
|
||||||
version int
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ln := len(args.config)
|
ln := len(args.config)
|
||||||
|
@ -94,25 +91,6 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
common.CheckVersion(args.version)
|
common.CheckVersion(args.version)
|
||||||
|
|
||||||
count := getSnapshotCount(ctx)
|
|
||||||
prefix := []byte(snapshotKeyPrefix)
|
|
||||||
for i := 0; i < count; i++ {
|
|
||||||
key := append(prefix, byte(i))
|
|
||||||
data := storage.Get(ctx, key)
|
|
||||||
if data != nil {
|
|
||||||
nodes := std.Deserialize(data.([]byte)).([]Node)
|
|
||||||
for i := range nodes {
|
|
||||||
// Old structure contains only the first field,
|
|
||||||
// second is implicitly assumed to be Online.
|
|
||||||
nodes[i] = Node{
|
|
||||||
BLOB: nodes[i].BLOB,
|
|
||||||
State: NodeStateOnline,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
common.SetSerialized(ctx, key, nodes)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,85 +112,20 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
storage.Put(ctx, balanceContractKey, args.addrBalance)
|
storage.Put(ctx, balanceContractKey, args.addrBalance)
|
||||||
storage.Put(ctx, containerContractKey, args.addrContainer)
|
storage.Put(ctx, containerContractKey, args.addrContainer)
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
|
||||||
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
|
||||||
if args.notaryDisabled {
|
|
||||||
common.SetSerialized(ctx, innerRingKey, args.keys)
|
|
||||||
common.InitVote(ctx)
|
|
||||||
runtime.Log("netmap contract notary disabled")
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.Log("netmap contract initialized")
|
runtime.Log("netmap contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. It can be invoked
|
// Update method updates contract source code and manifest. It can be invoked
|
||||||
// only by committee.
|
// only by committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data any) {
|
||||||
if !common.HasUpdateAccess() {
|
if !common.HasUpdateAccess() {
|
||||||
panic("only committee can update contract")
|
panic("only committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update",
|
management.UpdateWithData(script, manifest, common.AppendVersion(data))
|
||||||
contract.All, script, manifest, common.AppendVersion(data))
|
|
||||||
runtime.Log("netmap contract updated")
|
runtime.Log("netmap contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
// InnerRingList method returns a slice of structures that contains the public key of
|
|
||||||
// an Inner Ring node. It should be used in notary disabled environment only.
|
|
||||||
//
|
|
||||||
// If notary is enabled, look to NeoFSAlphabet role in native RoleManagement
|
|
||||||
// contract of the sidechain.
|
|
||||||
func InnerRingList() []common.IRNode {
|
|
||||||
ctx := storage.GetReadOnlyContext()
|
|
||||||
pubs := getIRNodes(ctx)
|
|
||||||
nodes := []common.IRNode{}
|
|
||||||
for i := range pubs {
|
|
||||||
nodes = append(nodes, common.IRNode{PublicKey: pubs[i]})
|
|
||||||
}
|
|
||||||
return nodes
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateInnerRing method updates a list of Inner Ring node keys. It should be used
|
|
||||||
// only in notary disabled environment. It can be invoked only by Alphabet nodes.
|
|
||||||
//
|
|
||||||
// If notary is enabled, update NeoFSAlphabet role in native RoleManagement
|
|
||||||
// contract of the sidechain. Use notary service to collect multisignature.
|
|
||||||
func UpdateInnerRing(keys []interop.PublicKey) {
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = common.AlphabetNodes()
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
panic("this method must be invoked by alphabet nodes")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := keysID(keys, []byte("updateIR"))
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.Log("inner ring list updated")
|
|
||||||
common.SetSerialized(ctx, innerRingKey, keys)
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddPeerIR accepts Alphabet calls in the notary-enabled contract setting and
|
// AddPeerIR accepts Alphabet calls in the notary-enabled contract setting and
|
||||||
// behaves similar to AddPeer in the notary-disabled one.
|
// behaves similar to AddPeer in the notary-disabled one.
|
||||||
//
|
//
|
||||||
|
@ -220,12 +133,8 @@ func UpdateInnerRing(keys []interop.PublicKey) {
|
||||||
// AddPeerIR MUST be called by the Alphabet member only.
|
// AddPeerIR MUST be called by the Alphabet member only.
|
||||||
func AddPeerIR(nodeInfo []byte) {
|
func AddPeerIR(nodeInfo []byte) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
if notaryDisabled {
|
|
||||||
panic("AddPeerIR should only be called in notary-enabled environment")
|
|
||||||
}
|
|
||||||
|
|
||||||
common.CheckAlphabetWitness(common.AlphabetAddress())
|
common.CheckAlphabetWitness()
|
||||||
|
|
||||||
publicKey := nodeInfo[2:35] // V2 format: offset:2, len:33
|
publicKey := nodeInfo[2:35] // V2 format: offset:2, len:33
|
||||||
|
|
||||||
|
@ -235,78 +144,14 @@ func AddPeerIR(nodeInfo []byte) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddPeer accepts information about the network map candidate in the NeoFS
|
// AddPeer accepts information about the network map candidate in the FrostFS
|
||||||
// binary protocol format, identifies the caller and behaves depending on different
|
// binary protocol format and does nothing. Keep method because storage node
|
||||||
// conditions listed below.
|
// creates a notary transaction with this method, which produces a notary
|
||||||
//
|
// notification (implicit here).
|
||||||
// Contract settings:
|
|
||||||
//
|
|
||||||
// (1) notary-enabled
|
|
||||||
// (2) notary-disabled
|
|
||||||
//
|
|
||||||
// Callers:
|
|
||||||
//
|
|
||||||
// (a) candidate himself, if node's public key corresponds to the signer
|
|
||||||
// (b) Alphabet member
|
|
||||||
// (c) others
|
|
||||||
//
|
|
||||||
// AddPeer case-by-case behavior:
|
|
||||||
//
|
|
||||||
// (1a) does nothing
|
|
||||||
// (1b) panics. Notice that AddPeerIR MUST be used for this purpose.
|
|
||||||
// (2a) throws AddPeer notification with the provided BLOB
|
|
||||||
// (2b) accepts Alphabet vote. If the threshold of votes is reached, adds
|
|
||||||
// new element to the candidate set, and throws AddPeerSuccess notification.
|
|
||||||
// (c) panics
|
|
||||||
//
|
|
||||||
// Candidate MUST call AddPeer with "online" state in its descriptor. Alphabet
|
|
||||||
// members MUST NOT call AddPeer with any other states.
|
|
||||||
func AddPeer(nodeInfo []byte) {
|
func AddPeer(nodeInfo []byte) {
|
||||||
ctx := storage.GetContext()
|
// V2 format - offset:2, len:33
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
common.CheckWitness(nodeInfo[2:35])
|
||||||
|
return
|
||||||
var ( // for invocation collection without notary
|
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = common.AlphabetNodes()
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
}
|
|
||||||
|
|
||||||
// V2 format
|
|
||||||
publicKey := nodeInfo[2:35] // offset:2, len:33
|
|
||||||
|
|
||||||
// If notary is enabled or caller is not an alphabet node,
|
|
||||||
// just emit the notification for alphabet.
|
|
||||||
if !notaryDisabled || len(nodeKey) == 0 {
|
|
||||||
common.CheckWitness(publicKey)
|
|
||||||
if notaryDisabled {
|
|
||||||
runtime.Notify("AddPeer", nodeInfo)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
candidate := Node{
|
|
||||||
BLOB: nodeInfo,
|
|
||||||
State: NodeStateOnline,
|
|
||||||
}
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
rawCandidate := std.Serialize(candidate)
|
|
||||||
id := crypto.Sha256(rawCandidate)
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
addToNetmap(ctx, publicKey, candidate)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// updates state of the network map candidate by its public key in the contract
|
// updates state of the network map candidate by its public key in the contract
|
||||||
|
@ -329,13 +174,8 @@ func updateCandidateState(ctx storage.Context, publicKey interop.PublicKey, stat
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateState accepts new state to be assigned to network map candidate
|
// UpdateState accepts new state to be assigned to network map candidate
|
||||||
// identified by the given public key, identifies the signer and behaves
|
// identified by the given public key, identifies the signer.
|
||||||
// depending on different conditions listed below.
|
// Applicable only for notary-enabled environment.
|
||||||
//
|
|
||||||
// Contract settings:
|
|
||||||
//
|
|
||||||
// (1) notary-enabled
|
|
||||||
// (2) notary-disabled
|
|
||||||
//
|
//
|
||||||
// Signers:
|
// Signers:
|
||||||
//
|
//
|
||||||
|
@ -346,13 +186,10 @@ func updateCandidateState(ctx storage.Context, publicKey interop.PublicKey, stat
|
||||||
//
|
//
|
||||||
// UpdateState case-by-case behavior:
|
// UpdateState case-by-case behavior:
|
||||||
//
|
//
|
||||||
// (1a) panics
|
// (a) panics
|
||||||
// (1b) like (1a)
|
// (b) panics
|
||||||
// (1ab) updates candidate's state in the contract storage (*), and throws
|
// (ab) updates candidate's state in the contract storage (*), and throws
|
||||||
// UpdateStateSuccess with the provided key and new state
|
// UpdateStateSuccess with the provided key and new state
|
||||||
// (2a) throws UpdateState notification with the provided key and new state
|
|
||||||
// (2b) accepts Alphabet vote. If the threshold of votes is reached, behaves
|
|
||||||
// like (1ab).
|
|
||||||
// (c) panics
|
// (c) panics
|
||||||
//
|
//
|
||||||
// (*) Candidate is removed from the candidate set if state is NodeStateOffline.
|
// (*) Candidate is removed from the candidate set if state is NodeStateOffline.
|
||||||
|
@ -368,33 +205,9 @@ func UpdateState(state NodeState, publicKey interop.PublicKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
common.CheckWitness(publicKey)
|
||||||
alphabet := common.AlphabetNodes()
|
common.CheckAlphabetWitness()
|
||||||
nodeKey := common.InnerRingInvoker(alphabet)
|
|
||||||
|
|
||||||
// If caller is not an alphabet node,
|
|
||||||
// just emit the notification for alphabet.
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
common.CheckWitness(publicKey)
|
|
||||||
runtime.Notify("UpdateState", state, publicKey)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := common.InvokeID([]interface{}{state, publicKey}, []byte("update"))
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
} else {
|
|
||||||
common.CheckWitness(publicKey)
|
|
||||||
common.CheckAlphabetWitness(common.AlphabetAddress())
|
|
||||||
}
|
|
||||||
|
|
||||||
updateCandidateState(ctx, publicKey, state)
|
updateCandidateState(ctx, publicKey, state)
|
||||||
}
|
}
|
||||||
|
@ -407,12 +220,8 @@ func UpdateState(state NodeState, publicKey interop.PublicKey) {
|
||||||
// UpdateStateIR MUST be called by the Alphabet member only.
|
// UpdateStateIR MUST be called by the Alphabet member only.
|
||||||
func UpdateStateIR(state NodeState, publicKey interop.PublicKey) {
|
func UpdateStateIR(state NodeState, publicKey interop.PublicKey) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
if notaryDisabled {
|
|
||||||
panic("UpdateStateIR should only be called in notary-enabled environment")
|
|
||||||
}
|
|
||||||
|
|
||||||
common.CheckAlphabetWitness(common.AlphabetAddress())
|
common.CheckAlphabetWitness()
|
||||||
|
|
||||||
updateCandidateState(ctx, publicKey, state)
|
updateCandidateState(ctx, publicKey, state)
|
||||||
}
|
}
|
||||||
|
@ -428,35 +237,8 @@ func UpdateStateIR(state NodeState, publicKey interop.PublicKey) {
|
||||||
// It produces NewEpoch notification.
|
// It produces NewEpoch notification.
|
||||||
func NewEpoch(epochNum int) {
|
func NewEpoch(epochNum int) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
common.CheckAlphabetWitness()
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = common.AlphabetNodes()
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
panic("this method must be invoked by inner ring nodes")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := common.InvokeID([]interface{}{epochNum}, []byte("epoch"))
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
currentEpoch := storage.Get(ctx, snapshotEpoch).(int)
|
currentEpoch := storage.Get(ctx, snapshotEpoch).(int)
|
||||||
if epochNum <= currentEpoch {
|
if epochNum <= currentEpoch {
|
||||||
|
@ -554,7 +336,7 @@ func getSnapshotCount(ctx storage.Context) int {
|
||||||
//
|
//
|
||||||
// Count MUST NOT be negative.
|
// Count MUST NOT be negative.
|
||||||
func UpdateSnapshotCount(count int) {
|
func UpdateSnapshotCount(count int) {
|
||||||
common.CheckAlphabetWitness(common.AlphabetAddress())
|
common.CheckAlphabetWitness()
|
||||||
if count < 0 {
|
if count < 0 {
|
||||||
panic("count must be positive")
|
panic("count must be positive")
|
||||||
}
|
}
|
||||||
|
@ -642,45 +424,19 @@ func SnapshotByEpoch(epoch int) []Node {
|
||||||
return Snapshot(currentEpoch - epoch)
|
return Snapshot(currentEpoch - epoch)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config returns configuration value of NeoFS configuration. If key does
|
// Config returns configuration value of FrostFS configuration. If key does
|
||||||
// not exists, returns nil.
|
// not exists, returns nil.
|
||||||
func Config(key []byte) interface{} {
|
func Config(key []byte) any {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
return getConfig(ctx, key)
|
return getConfig(ctx, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetConfig key-value pair as a NeoFS runtime configuration value. It can be invoked
|
// SetConfig key-value pair as a FrostFS runtime configuration value. It can be invoked
|
||||||
// only by Alphabet nodes.
|
// only by Alphabet nodes.
|
||||||
func SetConfig(id, key, val []byte) {
|
func SetConfig(id, key, val []byte) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
common.CheckAlphabetWitness()
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = common.AlphabetNodes()
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
panic("invoked by non inner ring node")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
setConfig(ctx, key, val)
|
setConfig(ctx, key, val)
|
||||||
|
|
||||||
|
@ -693,7 +449,7 @@ type record struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListConfig returns an array of structures that contain key and value of all
|
// ListConfig returns an array of structures that contain key and value of all
|
||||||
// NeoFS configuration records. Key and value are both byte arrays.
|
// FrostFS configuration records. Key and value are both byte arrays.
|
||||||
func ListConfig() []record {
|
func ListConfig() []record {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
|
@ -782,14 +538,14 @@ func getSnapshot(ctx storage.Context, key string) []Node {
|
||||||
return []Node{}
|
return []Node{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getConfig(ctx storage.Context, key interface{}) interface{} {
|
func getConfig(ctx storage.Context, key any) interface{} {
|
||||||
postfix := key.([]byte)
|
postfix := key.([]byte)
|
||||||
storageKey := append(configPrefix, postfix...)
|
storageKey := append(configPrefix, postfix...)
|
||||||
|
|
||||||
return storage.Get(ctx, storageKey)
|
return storage.Get(ctx, storageKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setConfig(ctx storage.Context, key, val interface{}) {
|
func setConfig(ctx storage.Context, key, val any) {
|
||||||
postfix := key.([]byte)
|
postfix := key.([]byte)
|
||||||
storageKey := append(configPrefix, postfix...)
|
storageKey := append(configPrefix, postfix...)
|
||||||
|
|
||||||
|
@ -803,26 +559,3 @@ func cleanup(ctx storage.Context, epoch int) {
|
||||||
containerContractAddr := storage.Get(ctx, containerContractKey).(interop.Hash160)
|
containerContractAddr := storage.Get(ctx, containerContractKey).(interop.Hash160)
|
||||||
contract.Call(containerContractAddr, cleanupEpochMethod, contract.All, epoch)
|
contract.Call(containerContractAddr, cleanupEpochMethod, contract.All, epoch)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getIRNodes(ctx storage.Context) []interop.PublicKey {
|
|
||||||
data := storage.Get(ctx, innerRingKey)
|
|
||||||
if data != nil {
|
|
||||||
return std.Deserialize(data.([]byte)).([]interop.PublicKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
return []interop.PublicKey{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func keysID(args []interop.PublicKey, prefix []byte) []byte {
|
|
||||||
var (
|
|
||||||
result []byte
|
|
||||||
)
|
|
||||||
|
|
||||||
result = append(result, prefix...)
|
|
||||||
|
|
||||||
for i := range args {
|
|
||||||
result = append(result, args[i]...)
|
|
||||||
}
|
|
||||||
|
|
||||||
return crypto.Sha256(result)
|
|
||||||
}
|
|
||||||
|
|
17
nns/doc.go
Normal file
17
nns/doc.go
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
# Contract storage scheme
|
||||||
|
|
||||||
|
| Key | Value | Description |
|
||||||
|
|--------------------------------------|------------|-----------------------------------|
|
||||||
|
| 0x0 | int | total supply of minted domains |
|
||||||
|
| 0x1 + accountAddr | int | account's balance |
|
||||||
|
| 0x2 + accountAddr + tokenKey | ByteArray | token ID |
|
||||||
|
| 0x10 | int | price for domain registration |
|
||||||
|
| 0x20 | int | set of roots |
|
||||||
|
| 0x21 + tokenKey | ByteArray | serialized NameState struct |
|
||||||
|
| 0x22 + tokenKey + Hash160(tokenName) | Hash160 | container contract hash |
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
package nns
|
18
nns/nns.yml
18
nns/nns.yml
|
@ -1,8 +1,20 @@
|
||||||
name: "NameService"
|
name: "NameService"
|
||||||
supportedstandards: ["NEP-11"]
|
supportedstandards: ["NEP-11"]
|
||||||
safemethods: ["balanceOf", "decimals", "symbol", "totalSupply", "tokensOf", "ownerOf",
|
safemethods:
|
||||||
"tokens", "properties", "roots", "getPrice", "isAvailable", "getRecord",
|
- "balanceOf"
|
||||||
"resolve", "getAllRecords"]
|
- "decimals"
|
||||||
|
- "getAllRecords"
|
||||||
|
- "getPrice"
|
||||||
|
- "getRecord"
|
||||||
|
- "isAvailable"
|
||||||
|
- "ownerOf"
|
||||||
|
- "properties"
|
||||||
|
- "symbol"
|
||||||
|
- "totalSupply"
|
||||||
|
- "tokensOf"
|
||||||
|
- "tokens"
|
||||||
|
- "resolve"
|
||||||
|
- "roots"
|
||||||
events:
|
events:
|
||||||
- name: Transfer
|
- name: Transfer
|
||||||
parameters:
|
parameters:
|
||||||
|
|
|
@ -9,6 +9,7 @@ must be added by committee before a new domain name can be registered.
|
||||||
package nns
|
package nns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
||||||
|
@ -19,7 +20,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
||||||
"github.com/nspcc-dev/neofs-contract/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Prefixes used for contract data storage.
|
// Prefixes used for contract data storage.
|
||||||
|
@ -76,21 +76,20 @@ type RecordState struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update updates NameService contract.
|
// Update updates NameService contract.
|
||||||
func Update(nef []byte, manifest string, data interface{}) {
|
func Update(nef []byte, manifest string, data any) {
|
||||||
checkCommittee()
|
checkCommittee()
|
||||||
// Calculating keys and serializing requires calling
|
// Calculating keys and serializing requires calling
|
||||||
// std and crypto contracts. This can be helpful on update
|
// std and crypto contracts. This can be helpful on update
|
||||||
// thus we provide `AllowCall` to management.Update.
|
// thus we provide `AllowCall` to management.Update.
|
||||||
// management.Update(nef, []byte(manifest))
|
// management.Update(nef, []byte(manifest))
|
||||||
contract.Call(interop.Hash160(management.Hash), "update",
|
management.UpdateWithData(nef, []byte(manifest), common.AppendVersion(data))
|
||||||
contract.All, nef, manifest, common.AppendVersion(data))
|
|
||||||
runtime.Log("nns contract updated")
|
runtime.Log("nns contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
// _deploy initializes defaults (total supply and registration price) on contract deploy.
|
// _deploy initializes defaults (total supply and registration price) on contract deploy.
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
func _deploy(data any, isUpdate bool) {
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
args := data.([]interface{})
|
args := data.([]any)
|
||||||
common.CheckVersion(args[len(args)-1].(int))
|
common.CheckVersion(args[len(args)-1].(int))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -129,10 +128,10 @@ func OwnerOf(tokenID []byte) interop.Hash160 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Properties returns a domain name and an expiration date of the specified domain.
|
// Properties returns a domain name and an expiration date of the specified domain.
|
||||||
func Properties(tokenID []byte) map[string]interface{} {
|
func Properties(tokenID []byte) map[string]any {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
ns := getNameState(ctx, tokenID)
|
ns := getNameState(ctx, tokenID)
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"name": ns.Name,
|
"name": ns.Name,
|
||||||
"expiration": ns.Expiration,
|
"expiration": ns.Expiration,
|
||||||
}
|
}
|
||||||
|
@ -167,7 +166,7 @@ func TokensOf(owner interop.Hash160) iterator.Iterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer transfers the domain with the specified name to a new owner.
|
// Transfer transfers the domain with the specified name to a new owner.
|
||||||
func Transfer(to interop.Hash160, tokenID []byte, data interface{}) bool {
|
func Transfer(to interop.Hash160, tokenID []byte, data any) bool {
|
||||||
if !isValid(to) {
|
if !isValid(to) {
|
||||||
panic(`invalid receiver`)
|
panic(`invalid receiver`)
|
||||||
}
|
}
|
||||||
|
@ -459,13 +458,13 @@ func updateBalance(ctx storage.Context, tokenId []byte, acc interop.Hash160, dif
|
||||||
balanceKey := append([]byte{prefixBalance}, acc...)
|
balanceKey := append([]byte{prefixBalance}, acc...)
|
||||||
var balance int
|
var balance int
|
||||||
if b := storage.Get(ctx, balanceKey); b != nil {
|
if b := storage.Get(ctx, balanceKey); b != nil {
|
||||||
balance = b.(int)
|
balance = common.FromFixedWidth64(b.([]byte))
|
||||||
}
|
}
|
||||||
balance += diff
|
balance += diff
|
||||||
if balance == 0 {
|
if balance == 0 {
|
||||||
storage.Delete(ctx, balanceKey)
|
storage.Delete(ctx, balanceKey)
|
||||||
} else {
|
} else {
|
||||||
storage.Put(ctx, balanceKey, balance)
|
storage.Put(ctx, balanceKey, common.ToFixedWidth64(balance))
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenKey := getTokenKey(tokenId)
|
tokenKey := getTokenKey(tokenId)
|
||||||
|
@ -479,7 +478,7 @@ func updateBalance(ctx storage.Context, tokenId []byte, acc interop.Hash160, dif
|
||||||
|
|
||||||
// postTransfer sends Transfer notification to the network and calls onNEP11Payment
|
// postTransfer sends Transfer notification to the network and calls onNEP11Payment
|
||||||
// method.
|
// method.
|
||||||
func postTransfer(from, to interop.Hash160, tokenID []byte, data interface{}) {
|
func postTransfer(from, to interop.Hash160, tokenID []byte, data any) {
|
||||||
runtime.Notify("Transfer", from, to, 1, tokenID)
|
runtime.Notify("Transfer", from, to, 1, tokenID)
|
||||||
if management.GetContract(to) != nil {
|
if management.GetContract(to) != nil {
|
||||||
contract.Call(to, "onNEP11Payment", contract.All, from, 1, tokenID, data)
|
contract.Call(to, "onNEP11Payment", contract.All, from, 1, tokenID, data)
|
||||||
|
@ -489,14 +488,14 @@ func postTransfer(from, to interop.Hash160, tokenID []byte, data interface{}) {
|
||||||
// getTotalSupply returns total supply from storage.
|
// getTotalSupply returns total supply from storage.
|
||||||
func getTotalSupply(ctx storage.Context) int {
|
func getTotalSupply(ctx storage.Context) int {
|
||||||
val := storage.Get(ctx, []byte{prefixTotalSupply})
|
val := storage.Get(ctx, []byte{prefixTotalSupply})
|
||||||
return val.(int)
|
return common.FromFixedWidth64(val.([]byte))
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateTotalSupply adds the specified diff to the total supply.
|
// updateTotalSupply adds the specified diff to the total supply.
|
||||||
func updateTotalSupply(ctx storage.Context, diff int) {
|
func updateTotalSupply(ctx storage.Context, diff int) {
|
||||||
tsKey := []byte{prefixTotalSupply}
|
tsKey := []byte{prefixTotalSupply}
|
||||||
ts := getTotalSupply(ctx)
|
ts := getTotalSupply(ctx)
|
||||||
storage.Put(ctx, tsKey, ts+diff)
|
storage.Put(ctx, tsKey, common.ToFixedWidth64(ts+diff))
|
||||||
}
|
}
|
||||||
|
|
||||||
// getTokenKey computes hash160 from the given tokenID.
|
// getTokenKey computes hash160 from the given tokenID.
|
||||||
|
|
6
policy/config.yml
Normal file
6
policy/config.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
name: "APE"
|
||||||
|
safemethods:
|
||||||
|
- "getAdmin"
|
||||||
|
- "listChains"
|
||||||
|
- "getChain"
|
||||||
|
- "listChainsByPrefix"
|
12
policy/doc.go
Normal file
12
policy/doc.go
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
# Contract storage scheme
|
||||||
|
|
||||||
|
| Key | Value | Description |
|
||||||
|
|------------------------------------------|--------|-----------------------------------|
|
||||||
|
| 'c' + uint16(len(container)) + container | []byte | Namespace chain |
|
||||||
|
| 'n' + uint16(len(namespace)) + namespace | []byte | Container chain |
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
package policy
|
147
policy/policy_contract.go
Normal file
147
policy/policy_contract.go
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
package policy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Kind represents the object the chain is attached to.
|
||||||
|
// Currently only namespace and container are supported.
|
||||||
|
type Kind byte
|
||||||
|
|
||||||
|
const (
|
||||||
|
Namespace = 'n'
|
||||||
|
Container = 'c'
|
||||||
|
IAM = 'i'
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ownerKeyPrefix = 'o'
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// ErrNotAuthorized is returned when the none of the transaction signers
|
||||||
|
// belongs to the list of autorized keys.
|
||||||
|
ErrNotAuthorized = "none of the signers is authorized to change the contract"
|
||||||
|
)
|
||||||
|
|
||||||
|
// _deploy function sets up initial list of inner ring public keys.
|
||||||
|
func _deploy(data any, isUpdate bool) {
|
||||||
|
if isUpdate {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
args := data.(struct {
|
||||||
|
Admin interop.Hash160
|
||||||
|
})
|
||||||
|
ctx := storage.GetContext()
|
||||||
|
if args.Admin != nil {
|
||||||
|
if len(args.Admin) != 20 {
|
||||||
|
panic("invaliad admin hash length")
|
||||||
|
}
|
||||||
|
storage.Put(ctx, []byte{ownerKeyPrefix}, args.Admin)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkAuthorization(ctx storage.Context) {
|
||||||
|
admin := getAdmin(ctx)
|
||||||
|
if admin != nil && runtime.CheckWitness(admin) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if runtime.CheckWitness(common.AlphabetAddress()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic(ErrNotAuthorized)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetAdmin(addr interop.Hash160) {
|
||||||
|
common.CheckAlphabetWitness()
|
||||||
|
|
||||||
|
ctx := storage.GetContext()
|
||||||
|
storage.Put(ctx, []byte{ownerKeyPrefix}, addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAdmin() interop.Hash160 {
|
||||||
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
return getAdmin(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getAdmin(ctx storage.Context) interop.Hash160 {
|
||||||
|
return storage.Get(ctx, []byte{ownerKeyPrefix}).(interop.Hash160)
|
||||||
|
}
|
||||||
|
|
||||||
|
func storageKey(prefix Kind, entityName string, name []byte) []byte {
|
||||||
|
ln := len(entityName)
|
||||||
|
key := append([]byte{byte(prefix)}, byte(ln&0xFF), byte(ln>>8))
|
||||||
|
key = append(key, entityName...)
|
||||||
|
return append(key, name...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func AddChain(entity Kind, entityName string, name []byte, chain []byte) {
|
||||||
|
ctx := storage.GetContext()
|
||||||
|
checkAuthorization(ctx)
|
||||||
|
|
||||||
|
key := storageKey(entity, entityName, name)
|
||||||
|
storage.Put(ctx, key, chain)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetChain(entity Kind, entityName string, name []byte) []byte {
|
||||||
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
key := storageKey(entity, entityName, name)
|
||||||
|
data := storage.Get(ctx, key).([]byte)
|
||||||
|
if data == nil {
|
||||||
|
panic("not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
func RemoveChain(entity Kind, entityName string, name []byte) {
|
||||||
|
ctx := storage.GetContext()
|
||||||
|
checkAuthorization(ctx)
|
||||||
|
|
||||||
|
key := storageKey(entity, entityName, name)
|
||||||
|
storage.Delete(ctx, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RemoveChainsByPrefix(entity Kind, entityName string, name []byte) {
|
||||||
|
ctx := storage.GetContext()
|
||||||
|
checkAuthorization(ctx)
|
||||||
|
|
||||||
|
key := storageKey(entity, entityName, name)
|
||||||
|
it := storage.Find(ctx, key, storage.KeysOnly)
|
||||||
|
for iterator.Next(it) {
|
||||||
|
storage.Delete(ctx, iterator.Value(it).([]byte))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListChains lists all chains for the namespace by prefix.
|
||||||
|
// container may be empty.
|
||||||
|
func ListChains(namespace, container string, name []byte) [][]byte {
|
||||||
|
result := ListChainsByPrefix(Namespace, namespace, name)
|
||||||
|
|
||||||
|
if container != "" {
|
||||||
|
result = append(result, ListChainsByPrefix(Container, container, name)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListChainsByPrefix list all chains for the provided kind and entity by prefix.
|
||||||
|
func ListChainsByPrefix(entity Kind, entityName string, prefix []byte) [][]byte {
|
||||||
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
|
result := [][]byte{}
|
||||||
|
|
||||||
|
keyPrefix := storageKey(entity, entityName, prefix)
|
||||||
|
it := storage.Find(ctx, keyPrefix, storage.ValuesOnly)
|
||||||
|
for iterator.Next(it) {
|
||||||
|
result = append(result, iterator.Value(it).([]byte))
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
name: "NeoFS Multi Signature Processing"
|
name: "Multi Signature Processing"
|
||||||
safemethods: ["verify", "version"]
|
safemethods: ["verify", "version"]
|
||||||
permissions:
|
permissions:
|
||||||
- methods: ["update"]
|
- methods: ["update"]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Processing contract is a contract deployed in NeoFS mainchain.
|
Processing contract is a contract deployed in FrostFS mainchain.
|
||||||
|
|
||||||
Processing contract pays for all multisignature transaction executions when notary
|
Processing contract pays for all multisignature transaction executions when notary
|
||||||
service is enabled in the mainchain. Notary service prepares multisigned transactions,
|
service is enabled in the mainchain. Notary service prepares multisigned transactions,
|
||||||
|
@ -8,15 +8,21 @@ ask Alphabet nodes to pay for these transactions: nodes can change over time,
|
||||||
some nodes will spend sidechain GAS faster. It leads to economic instability.
|
some nodes will spend sidechain GAS faster. It leads to economic instability.
|
||||||
|
|
||||||
Processing contract exists to solve this issue. At the Withdraw invocation of
|
Processing contract exists to solve this issue. At the Withdraw invocation of
|
||||||
NeoFS contract, a user pays fee directly to this contract. This fee is used to
|
FrostFS contract, a user pays fee directly to this contract. This fee is used to
|
||||||
pay for Cheque invocation of NeoFS contract that returns mainchain GAS back
|
pay for Cheque invocation of FrostFS contract that returns mainchain GAS back
|
||||||
to the user. The address of the Processing contract is used as the first signer in
|
to the user. The address of the Processing contract is used as the first signer in
|
||||||
the multisignature transaction. Therefore, NeoVM executes Verify method of the
|
the multisignature transaction. Therefore, NeoVM executes Verify method of the
|
||||||
contract and if invocation is verified, Processing contract pays for the
|
contract and if invocation is verified, Processing contract pays for the
|
||||||
execution.
|
execution.
|
||||||
|
|
||||||
Contract notifications
|
# Contract notifications
|
||||||
|
|
||||||
Processing contract does not produce notifications to process.
|
Processing contract does not produce notifications to process.
|
||||||
|
|
||||||
|
# Contract storage scheme
|
||||||
|
|
||||||
|
| Key | Value | Description |
|
||||||
|
|-----------------------------|------------|----------------------------------|
|
||||||
|
| `frostfsScriptHash` | Hash160 | frostFS contract hash |
|
||||||
*/
|
*/
|
||||||
package processing
|
package processing
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package processing
|
package processing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/gas"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/gas"
|
||||||
|
@ -9,48 +10,47 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/roles"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/roles"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neofs-contract/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
neofsContractKey = "neofsScriptHash"
|
frostfsContractKey = "frostfsScriptHash"
|
||||||
|
|
||||||
multiaddrMethod = "alphabetAddress"
|
multiaddrMethod = "alphabetAddress"
|
||||||
)
|
)
|
||||||
|
|
||||||
// OnNEP17Payment is a callback for NEP-17 compatible native GAS contract.
|
// OnNEP17Payment is a callback for NEP-17 compatible native GAS contract.
|
||||||
func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
func OnNEP17Payment(from interop.Hash160, amount int, data any) {
|
||||||
caller := runtime.GetCallingScriptHash()
|
caller := runtime.GetCallingScriptHash()
|
||||||
if !common.BytesEqual(caller, []byte(gas.Hash)) {
|
if !common.BytesEqual(caller, []byte(gas.Hash)) {
|
||||||
common.AbortWithMessage("processing contract accepts GAS only")
|
common.AbortWithMessage("processing contract accepts GAS only")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
func _deploy(data any, isUpdate bool) {
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
args := data.([]interface{})
|
args := data.([]any)
|
||||||
common.CheckVersion(args[len(args)-1].(int))
|
common.CheckVersion(args[len(args)-1].(int))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
args := data.(struct {
|
args := data.(struct {
|
||||||
addrNeoFS interop.Hash160
|
addrFrostFS interop.Hash160
|
||||||
})
|
})
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if len(args.addrNeoFS) != interop.Hash160Len {
|
if len(args.addrFrostFS) != interop.Hash160Len {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, neofsContractKey, args.addrNeoFS)
|
storage.Put(ctx, frostfsContractKey, args.addrFrostFS)
|
||||||
|
|
||||||
runtime.Log("processing contract initialized")
|
runtime.Log("processing contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. It can be invoked
|
// Update method updates contract source code and manifest. It can be invoked
|
||||||
// only by the sidechain committee.
|
// only by the sidechain committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data any) {
|
||||||
blockHeight := ledger.CurrentIndex()
|
blockHeight := ledger.CurrentIndex()
|
||||||
alphabetKeys := roles.GetDesignatedByRole(roles.NeoFSAlphabet, uint32(blockHeight+1))
|
alphabetKeys := roles.GetDesignatedByRole(roles.NeoFSAlphabet, uint32(blockHeight+1))
|
||||||
alphabetCommittee := common.Multiaddress(alphabetKeys, true)
|
alphabetCommittee := common.Multiaddress(alphabetKeys, true)
|
||||||
|
@ -59,8 +59,7 @@ func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
panic("only side chain committee can update contract")
|
panic("only side chain committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update",
|
management.UpdateWithData(script, manifest, common.AppendVersion(data))
|
||||||
contract.All, script, manifest, common.AppendVersion(data))
|
|
||||||
runtime.Log("processing contract updated")
|
runtime.Log("processing contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +67,8 @@ func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
// Alphabet nodes of the Inner Ring.
|
// Alphabet nodes of the Inner Ring.
|
||||||
func Verify() bool {
|
func Verify() bool {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
neofsContractAddr := storage.Get(ctx, neofsContractKey).(interop.Hash160)
|
frostfsContractAddr := storage.Get(ctx, frostfsContractKey).(interop.Hash160)
|
||||||
multiaddr := contract.Call(neofsContractAddr, multiaddrMethod, contract.ReadOnly).(interop.Hash160)
|
multiaddr := contract.Call(frostfsContractAddr, multiaddrMethod, contract.ReadOnly).(interop.Hash160)
|
||||||
|
|
||||||
return runtime.CheckWitness(multiaddr)
|
return runtime.CheckWitness(multiaddr)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name: "NeoFS Notary Proxy"
|
name: "Notary Proxy"
|
||||||
safemethods: ["verify", "version"]
|
safemethods: ["verify", "version"]
|
||||||
permissions:
|
permissions:
|
||||||
- methods: ["update"]
|
- methods: ["update"]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Proxy contract is a contract deployed in NeoFS sidechain.
|
Proxy contract is a contract deployed in FrostFS sidechain.
|
||||||
|
|
||||||
Proxy contract pays for all multisignature transaction executions when notary
|
Proxy contract pays for all multisignature transaction executions when notary
|
||||||
service is enabled in the sidechain. Notary service prepares multisigned transactions,
|
service is enabled in the sidechain. Notary service prepares multisigned transactions,
|
||||||
|
@ -14,8 +14,12 @@ Proxy contract is used as the first signer in a multisignature transaction.
|
||||||
Therefore, NeoVM executes Verify method of the contract; and if invocation is
|
Therefore, NeoVM executes Verify method of the contract; and if invocation is
|
||||||
verified, Proxy contract pays for the execution.
|
verified, Proxy contract pays for the execution.
|
||||||
|
|
||||||
Contract notifications
|
# Contract notifications
|
||||||
|
|
||||||
Proxy contract does not produce notifications to process.
|
Proxy contract does not produce notifications to process.
|
||||||
|
|
||||||
|
# Contract storage scheme
|
||||||
|
|
||||||
|
Proxy contract does not use storage
|
||||||
*/
|
*/
|
||||||
package proxy
|
package proxy
|
||||||
|
|
|
@ -1,26 +1,25 @@
|
||||||
package proxy
|
package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/gas"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/gas"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/neo"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/neo"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neofs-contract/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// OnNEP17Payment is a callback for NEP-17 compatible native GAS contract.
|
// OnNEP17Payment is a callback for NEP-17 compatible native GAS contract.
|
||||||
func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
func OnNEP17Payment(from interop.Hash160, amount int, data any) {
|
||||||
caller := runtime.GetCallingScriptHash()
|
caller := runtime.GetCallingScriptHash()
|
||||||
if !common.BytesEqual(caller, []byte(gas.Hash)) {
|
if !common.BytesEqual(caller, []byte(gas.Hash)) {
|
||||||
common.AbortWithMessage("proxy contract accepts GAS only")
|
common.AbortWithMessage("proxy contract accepts GAS only")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
func _deploy(data any, isUpdate bool) {
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
args := data.([]interface{})
|
args := data.([]any)
|
||||||
common.CheckVersion(args[len(args)-1].(int))
|
common.CheckVersion(args[len(args)-1].(int))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -30,13 +29,12 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. It can be invoked
|
// Update method updates contract source code and manifest. It can be invoked
|
||||||
// only by committee.
|
// only by committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data any) {
|
||||||
if !common.HasUpdateAccess() {
|
if !common.HasUpdateAccess() {
|
||||||
panic("only committee can update contract")
|
panic("only committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update",
|
management.UpdateWithData(script, manifest, common.AppendVersion(data))
|
||||||
contract.All, script, manifest, common.AppendVersion(data))
|
|
||||||
runtime.Log("proxy contract updated")
|
runtime.Log("proxy contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
name: "NeoFS Reputation"
|
|
||||||
safemethods: ["get", "getByID", "listByEpoch"]
|
|
||||||
permissions:
|
|
||||||
- methods: ["update"]
|
|
||||||
events:
|
|
||||||
- name: reputationPut
|
|
||||||
parameters:
|
|
||||||
- name: epoch
|
|
||||||
type: Integer
|
|
||||||
- name: peerID
|
|
||||||
type: ByteArray
|
|
||||||
- name: value
|
|
||||||
type: ByteArray
|
|
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
Reputation contract is a contract deployed in NeoFS sidechain.
|
|
||||||
|
|
||||||
Inner Ring nodes produce data audit for each container during each epoch. In the end,
|
|
||||||
nodes produce DataAuditResult structure that contains information about audit
|
|
||||||
progress. Reputation contract provides storage for such structures and simple
|
|
||||||
interface to iterate over available DataAuditResults on specified epoch.
|
|
||||||
|
|
||||||
During settlement process, Alphabet nodes fetch all DataAuditResult structures
|
|
||||||
from the epoch and execute balance transfers from data owners to Storage and
|
|
||||||
Inner Ring nodes if data audit succeeds.
|
|
||||||
|
|
||||||
Contract notifications
|
|
||||||
|
|
||||||
Reputation contract does not produce notifications to process.
|
|
||||||
*/
|
|
||||||
package reputation
|
|
|
@ -1,162 +0,0 @@
|
||||||
package reputation
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/convert"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
|
||||||
"github.com/nspcc-dev/neofs-contract/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
notaryDisabledKey = "notary"
|
|
||||||
reputationValuePrefix = 'r'
|
|
||||||
reputationCountPrefix = 'c'
|
|
||||||
)
|
|
||||||
|
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
|
|
||||||
if isUpdate {
|
|
||||||
args := data.([]interface{})
|
|
||||||
common.CheckVersion(args[len(args)-1].(int))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
args := data.(struct {
|
|
||||||
notaryDisabled bool
|
|
||||||
})
|
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
|
||||||
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
|
||||||
if args.notaryDisabled {
|
|
||||||
common.InitVote(ctx)
|
|
||||||
runtime.Log("reputation contract notary disabled")
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.Log("reputation contract initialized")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. It can be invoked
|
|
||||||
// only by committee.
|
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
|
||||||
if !common.HasUpdateAccess() {
|
|
||||||
panic("only committee can update contract")
|
|
||||||
}
|
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update",
|
|
||||||
contract.All, script, manifest, common.AppendVersion(data))
|
|
||||||
runtime.Log("reputation contract updated")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put method saves DataAuditResult in contract storage. It can be invoked only by
|
|
||||||
// Inner Ring nodes. It does not require multisignature invocations.
|
|
||||||
//
|
|
||||||
// Epoch is the epoch number when DataAuditResult structure was generated.
|
|
||||||
// PeerID contains public keys of the Inner Ring node that has produced DataAuditResult.
|
|
||||||
// Value contains a stable marshaled structure of DataAuditResult.
|
|
||||||
func Put(epoch int, peerID []byte, value []byte) {
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
|
|
||||||
var ( // for invocation collection without notary
|
|
||||||
alphabet []interop.PublicKey
|
|
||||||
nodeKey []byte
|
|
||||||
alphabetCall bool
|
|
||||||
)
|
|
||||||
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet = common.AlphabetNodes()
|
|
||||||
nodeKey = common.InnerRingInvoker(alphabet)
|
|
||||||
alphabetCall = len(nodeKey) != 0
|
|
||||||
} else {
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
alphabetCall = runtime.CheckWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !alphabetCall {
|
|
||||||
runtime.Notify("reputationPut", epoch, peerID, value)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
id := storageID(epoch, peerID)
|
|
||||||
if notaryDisabled {
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
key := getReputationKey(reputationCountPrefix, id)
|
|
||||||
rawCnt := storage.Get(ctx, key)
|
|
||||||
cnt := 0
|
|
||||||
if rawCnt != nil {
|
|
||||||
cnt = rawCnt.(int)
|
|
||||||
}
|
|
||||||
cnt++
|
|
||||||
storage.Put(ctx, key, cnt)
|
|
||||||
|
|
||||||
key[0] = reputationValuePrefix
|
|
||||||
key = append(key, convert.ToBytes(cnt)...)
|
|
||||||
storage.Put(ctx, key, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get method returns a list of all stable marshaled DataAuditResult structures
|
|
||||||
// produced by the specified Inner Ring node during the specified epoch.
|
|
||||||
func Get(epoch int, peerID []byte) [][]byte {
|
|
||||||
id := storageID(epoch, peerID)
|
|
||||||
return GetByID(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetByID method returns a list of all stable marshaled DataAuditResult with
|
|
||||||
// the specified id. Use ListByEpoch method to obtain the id.
|
|
||||||
func GetByID(id []byte) [][]byte {
|
|
||||||
ctx := storage.GetReadOnlyContext()
|
|
||||||
|
|
||||||
var data [][]byte
|
|
||||||
|
|
||||||
it := storage.Find(ctx, getReputationKey(reputationValuePrefix, id), storage.ValuesOnly)
|
|
||||||
for iterator.Next(it) {
|
|
||||||
data = append(data, iterator.Value(it).([]byte))
|
|
||||||
}
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
|
|
||||||
func getReputationKey(prefix byte, id []byte) []byte {
|
|
||||||
return append([]byte{prefix}, id...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListByEpoch returns a list of IDs that may be used to get reputation data
|
|
||||||
// with GetByID method.
|
|
||||||
func ListByEpoch(epoch int) [][]byte {
|
|
||||||
ctx := storage.GetReadOnlyContext()
|
|
||||||
key := getReputationKey(reputationCountPrefix, convert.ToBytes(epoch))
|
|
||||||
it := storage.Find(ctx, key, storage.KeysOnly)
|
|
||||||
|
|
||||||
var result [][]byte
|
|
||||||
|
|
||||||
for iterator.Next(it) {
|
|
||||||
key := iterator.Value(it).([]byte) // iterator MUST BE `storage.KeysOnly`
|
|
||||||
result = append(result, key[1:])
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// Version returns the version of the contract.
|
|
||||||
func Version() int {
|
|
||||||
return common.Version
|
|
||||||
}
|
|
||||||
|
|
||||||
func storageID(epoch int, peerID []byte) []byte {
|
|
||||||
var buf interface{} = epoch
|
|
||||||
|
|
||||||
return append(buf.([]byte), peerID...)
|
|
||||||
}
|
|
138
rpcclient/alphabet/client.go
Normal file
138
rpcclient/alphabet/client.go
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
// Package alphabet contains RPC wrappers for Alphabet contract.
|
||||||
|
//
|
||||||
|
// Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT.
|
||||||
|
package alphabet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"math/big"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Invoker is used by ContractReader to call various safe methods.
|
||||||
|
type Invoker interface {
|
||||||
|
Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actor is used by Contract to call state-changing methods.
|
||||||
|
type Actor interface {
|
||||||
|
Invoker
|
||||||
|
|
||||||
|
MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeRun(script []byte) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
||||||
|
SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error)
|
||||||
|
SendRun(script []byte) (util.Uint256, uint32, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContractReader implements safe contract methods.
|
||||||
|
type ContractReader struct {
|
||||||
|
invoker Invoker
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contract implements all contract methods.
|
||||||
|
type Contract struct {
|
||||||
|
ContractReader
|
||||||
|
actor Actor
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewReader creates an instance of ContractReader using provided contract hash and the given Invoker.
|
||||||
|
func NewReader(invoker Invoker, hash util.Uint160) *ContractReader {
|
||||||
|
return &ContractReader{invoker, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates an instance of Contract using provided contract hash and the given Actor.
|
||||||
|
func New(actor Actor, hash util.Uint160) *Contract {
|
||||||
|
return &Contract{ContractReader{actor, hash}, actor, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gas invokes `gas` method of contract.
|
||||||
|
func (c *ContractReader) Gas() (*big.Int, error) {
|
||||||
|
return unwrap.BigInt(c.invoker.Call(c.hash, "gas"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name invokes `name` method of contract.
|
||||||
|
func (c *ContractReader) Name() (string, error) {
|
||||||
|
return unwrap.UTF8String(c.invoker.Call(c.hash, "name"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Neo invokes `neo` method of contract.
|
||||||
|
func (c *ContractReader) Neo() (*big.Int, error) {
|
||||||
|
return unwrap.BigInt(c.invoker.Call(c.hash, "neo"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version invokes `version` method of contract.
|
||||||
|
func (c *ContractReader) Version() (*big.Int, error) {
|
||||||
|
return unwrap.BigInt(c.invoker.Call(c.hash, "version"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emit creates a transaction invoking `emit` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Emit() (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "emit")
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmitTransaction creates a transaction invoking `emit` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) EmitTransaction() (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "emit")
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmitUnsigned creates a transaction invoking `emit` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) EmitUnsigned() (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "emit", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Update(script []byte, manifest []byte, data any) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "update", script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateTransaction creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) UpdateTransaction(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "update", script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateUnsigned creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) UpdateUnsigned(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "update", nil, script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vote creates a transaction invoking `vote` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Vote(epoch *big.Int, candidates []any) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "vote", epoch, candidates)
|
||||||
|
}
|
||||||
|
|
||||||
|
// VoteTransaction creates a transaction invoking `vote` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) VoteTransaction(epoch *big.Int, candidates []any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "vote", epoch, candidates)
|
||||||
|
}
|
||||||
|
|
||||||
|
// VoteUnsigned creates a transaction invoking `vote` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) VoteUnsigned(epoch *big.Int, candidates []any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "vote", nil, epoch, candidates)
|
||||||
|
}
|
549
rpcclient/balance/client.go
Normal file
549
rpcclient/balance/client.go
Normal file
|
@ -0,0 +1,549 @@
|
||||||
|
// Package balance contains RPC wrappers for Balance contract.
|
||||||
|
//
|
||||||
|
// Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT.
|
||||||
|
package balance
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nep17"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
|
"math/big"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LockEvent represents "Lock" event emitted by the contract.
|
||||||
|
type LockEvent struct {
|
||||||
|
TxID []byte
|
||||||
|
From util.Uint160
|
||||||
|
To util.Uint160
|
||||||
|
Amount *big.Int
|
||||||
|
Until *big.Int
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransferXEvent represents "TransferX" event emitted by the contract.
|
||||||
|
type TransferXEvent struct {
|
||||||
|
From util.Uint160
|
||||||
|
To util.Uint160
|
||||||
|
Amount *big.Int
|
||||||
|
Details []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// MintEvent represents "Mint" event emitted by the contract.
|
||||||
|
type MintEvent struct {
|
||||||
|
To util.Uint160
|
||||||
|
Amount *big.Int
|
||||||
|
}
|
||||||
|
|
||||||
|
// BurnEvent represents "Burn" event emitted by the contract.
|
||||||
|
type BurnEvent struct {
|
||||||
|
From util.Uint160
|
||||||
|
Amount *big.Int
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invoker is used by ContractReader to call various safe methods.
|
||||||
|
type Invoker interface {
|
||||||
|
nep17.Invoker
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actor is used by Contract to call state-changing methods.
|
||||||
|
type Actor interface {
|
||||||
|
Invoker
|
||||||
|
|
||||||
|
nep17.Actor
|
||||||
|
|
||||||
|
MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeRun(script []byte) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
||||||
|
SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error)
|
||||||
|
SendRun(script []byte) (util.Uint256, uint32, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContractReader implements safe contract methods.
|
||||||
|
type ContractReader struct {
|
||||||
|
nep17.TokenReader
|
||||||
|
invoker Invoker
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contract implements all contract methods.
|
||||||
|
type Contract struct {
|
||||||
|
ContractReader
|
||||||
|
nep17.TokenWriter
|
||||||
|
actor Actor
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewReader creates an instance of ContractReader using provided contract hash and the given Invoker.
|
||||||
|
func NewReader(invoker Invoker, hash util.Uint160) *ContractReader {
|
||||||
|
return &ContractReader{*nep17.NewReader(invoker, hash), invoker, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates an instance of Contract using provided contract hash and the given Actor.
|
||||||
|
func New(actor Actor, hash util.Uint160) *Contract {
|
||||||
|
var nep17t = nep17.New(actor, hash)
|
||||||
|
return &Contract{ContractReader{nep17t.TokenReader, actor, hash}, nep17t.TokenWriter, actor, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version invokes `version` method of contract.
|
||||||
|
func (c *ContractReader) Version() (*big.Int, error) {
|
||||||
|
return unwrap.BigInt(c.invoker.Call(c.hash, "version"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Burn creates a transaction invoking `burn` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Burn(from util.Uint160, amount *big.Int, txDetails []byte) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "burn", from, amount, txDetails)
|
||||||
|
}
|
||||||
|
|
||||||
|
// BurnTransaction creates a transaction invoking `burn` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) BurnTransaction(from util.Uint160, amount *big.Int, txDetails []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "burn", from, amount, txDetails)
|
||||||
|
}
|
||||||
|
|
||||||
|
// BurnUnsigned creates a transaction invoking `burn` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) BurnUnsigned(from util.Uint160, amount *big.Int, txDetails []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "burn", nil, from, amount, txDetails)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lock creates a transaction invoking `lock` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Lock(txDetails []byte, from util.Uint160, to util.Uint160, amount *big.Int, until *big.Int) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "lock", txDetails, from, to, amount, until)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LockTransaction creates a transaction invoking `lock` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) LockTransaction(txDetails []byte, from util.Uint160, to util.Uint160, amount *big.Int, until *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "lock", txDetails, from, to, amount, until)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LockUnsigned creates a transaction invoking `lock` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) LockUnsigned(txDetails []byte, from util.Uint160, to util.Uint160, amount *big.Int, until *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "lock", nil, txDetails, from, to, amount, until)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mint creates a transaction invoking `mint` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Mint(to util.Uint160, amount *big.Int, txDetails []byte) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "mint", to, amount, txDetails)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MintTransaction creates a transaction invoking `mint` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) MintTransaction(to util.Uint160, amount *big.Int, txDetails []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "mint", to, amount, txDetails)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MintUnsigned creates a transaction invoking `mint` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) MintUnsigned(to util.Uint160, amount *big.Int, txDetails []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "mint", nil, to, amount, txDetails)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewEpoch creates a transaction invoking `newEpoch` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) NewEpoch(epochNum *big.Int) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "newEpoch", epochNum)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewEpochTransaction creates a transaction invoking `newEpoch` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) NewEpochTransaction(epochNum *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "newEpoch", epochNum)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewEpochUnsigned creates a transaction invoking `newEpoch` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) NewEpochUnsigned(epochNum *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "newEpoch", nil, epochNum)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransferX creates a transaction invoking `transferX` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) TransferX(from util.Uint160, to util.Uint160, amount *big.Int, details []byte) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "transferX", from, to, amount, details)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransferXTransaction creates a transaction invoking `transferX` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) TransferXTransaction(from util.Uint160, to util.Uint160, amount *big.Int, details []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "transferX", from, to, amount, details)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransferXUnsigned creates a transaction invoking `transferX` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) TransferXUnsigned(from util.Uint160, to util.Uint160, amount *big.Int, details []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "transferX", nil, from, to, amount, details)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Update(script []byte, manifest []byte, data any) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "update", script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateTransaction creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) UpdateTransaction(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "update", script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateUnsigned creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) UpdateUnsigned(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "update", nil, script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LockEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "Lock" name from the provided [result.ApplicationLog].
|
||||||
|
func LockEventsFromApplicationLog(log *result.ApplicationLog) ([]*LockEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*LockEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "Lock" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(LockEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize LockEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to LockEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *LockEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 5 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.TxID, err = arr[index].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field TxID: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.From, err = func(item stackitem.Item) (util.Uint160, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
u, err := util.Uint160DecodeBytesBE(b)
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
return u, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field From: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.To, err = func(item stackitem.Item) (util.Uint160, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
u, err := util.Uint160DecodeBytesBE(b)
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
return u, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field To: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.Amount, err = arr[index].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Amount: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.Until, err = arr[index].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Until: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransferXEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "TransferX" name from the provided [result.ApplicationLog].
|
||||||
|
func TransferXEventsFromApplicationLog(log *result.ApplicationLog) ([]*TransferXEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*TransferXEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "TransferX" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(TransferXEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize TransferXEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to TransferXEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *TransferXEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 4 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.From, err = func(item stackitem.Item) (util.Uint160, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
u, err := util.Uint160DecodeBytesBE(b)
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
return u, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field From: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.To, err = func(item stackitem.Item) (util.Uint160, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
u, err := util.Uint160DecodeBytesBE(b)
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
return u, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field To: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.Amount, err = arr[index].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Amount: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.Details, err = arr[index].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Details: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MintEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "Mint" name from the provided [result.ApplicationLog].
|
||||||
|
func MintEventsFromApplicationLog(log *result.ApplicationLog) ([]*MintEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*MintEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "Mint" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(MintEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize MintEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to MintEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *MintEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 2 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.To, err = func(item stackitem.Item) (util.Uint160, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
u, err := util.Uint160DecodeBytesBE(b)
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
return u, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field To: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.Amount, err = arr[index].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Amount: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BurnEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "Burn" name from the provided [result.ApplicationLog].
|
||||||
|
func BurnEventsFromApplicationLog(log *result.ApplicationLog) ([]*BurnEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*BurnEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "Burn" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(BurnEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize BurnEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to BurnEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *BurnEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 2 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.From, err = func(item stackitem.Item) (util.Uint160, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
u, err := util.Uint160DecodeBytesBE(b)
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
return u, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field From: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.Amount, err = arr[index].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Amount: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
661
rpcclient/container/client.go
Normal file
661
rpcclient/container/client.go
Normal file
|
@ -0,0 +1,661 @@
|
||||||
|
// Package container contains RPC wrappers for Container contract.
|
||||||
|
//
|
||||||
|
// Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT.
|
||||||
|
package container
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/elliptic"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
|
"math/big"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PutSuccessEvent represents "PutSuccess" event emitted by the contract.
|
||||||
|
type PutSuccessEvent struct {
|
||||||
|
ContainerID util.Uint256
|
||||||
|
PublicKey *keys.PublicKey
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteSuccessEvent represents "DeleteSuccess" event emitted by the contract.
|
||||||
|
type DeleteSuccessEvent struct {
|
||||||
|
ContainerID []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEACLSuccessEvent represents "SetEACLSuccess" event emitted by the contract.
|
||||||
|
type SetEACLSuccessEvent struct {
|
||||||
|
ContainerID []byte
|
||||||
|
PublicKey *keys.PublicKey
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartEstimationEvent represents "StartEstimation" event emitted by the contract.
|
||||||
|
type StartEstimationEvent struct {
|
||||||
|
Epoch *big.Int
|
||||||
|
}
|
||||||
|
|
||||||
|
// StopEstimationEvent represents "StopEstimation" event emitted by the contract.
|
||||||
|
type StopEstimationEvent struct {
|
||||||
|
Epoch *big.Int
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invoker is used by ContractReader to call various safe methods.
|
||||||
|
type Invoker interface {
|
||||||
|
Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error)
|
||||||
|
CallAndExpandIterator(contract util.Uint160, method string, maxItems int, params ...any) (*result.Invoke, error)
|
||||||
|
TerminateSession(sessionID uuid.UUID) error
|
||||||
|
TraverseIterator(sessionID uuid.UUID, iterator *result.Iterator, num int) ([]stackitem.Item, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actor is used by Contract to call state-changing methods.
|
||||||
|
type Actor interface {
|
||||||
|
Invoker
|
||||||
|
|
||||||
|
MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeRun(script []byte) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
||||||
|
SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error)
|
||||||
|
SendRun(script []byte) (util.Uint256, uint32, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContractReader implements safe contract methods.
|
||||||
|
type ContractReader struct {
|
||||||
|
invoker Invoker
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contract implements all contract methods.
|
||||||
|
type Contract struct {
|
||||||
|
ContractReader
|
||||||
|
actor Actor
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewReader creates an instance of ContractReader using provided contract hash and the given Invoker.
|
||||||
|
func NewReader(invoker Invoker, hash util.Uint160) *ContractReader {
|
||||||
|
return &ContractReader{invoker, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates an instance of Contract using provided contract hash and the given Actor.
|
||||||
|
func New(actor Actor, hash util.Uint160) *Contract {
|
||||||
|
return &Contract{ContractReader{actor, hash}, actor, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContainersOf invokes `containersOf` method of contract.
|
||||||
|
func (c *ContractReader) ContainersOf(owner []byte) (uuid.UUID, result.Iterator, error) {
|
||||||
|
return unwrap.SessionIterator(c.invoker.Call(c.hash, "containersOf", owner))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContainersOfExpanded is similar to ContainersOf (uses the same contract
|
||||||
|
// method), but can be useful if the server used doesn't support sessions and
|
||||||
|
// doesn't expand iterators. It creates a script that will get the specified
|
||||||
|
// number of result items from the iterator right in the VM and return them to
|
||||||
|
// you. It's only limited by VM stack and GAS available for RPC invocations.
|
||||||
|
func (c *ContractReader) ContainersOfExpanded(owner []byte, _numOfIteratorItems int) ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.CallAndExpandIterator(c.hash, "containersOf", _numOfIteratorItems, owner))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count invokes `count` method of contract.
|
||||||
|
func (c *ContractReader) Count() (*big.Int, error) {
|
||||||
|
return unwrap.BigInt(c.invoker.Call(c.hash, "count"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletionInfo invokes `deletionInfo` method of contract.
|
||||||
|
func (c *ContractReader) DeletionInfo(containerID []byte) ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "deletionInfo", containerID))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EACL invokes `eACL` method of contract.
|
||||||
|
func (c *ContractReader) EACL(containerID []byte) ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "eACL", containerID))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get invokes `get` method of contract.
|
||||||
|
func (c *ContractReader) Get(containerID []byte) ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "get", containerID))
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetContainerSize invokes `getContainerSize` method of contract.
|
||||||
|
func (c *ContractReader) GetContainerSize(id []byte) ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "getContainerSize", id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IterateContainerSizes invokes `iterateContainerSizes` method of contract.
|
||||||
|
func (c *ContractReader) IterateContainerSizes(epoch *big.Int) (uuid.UUID, result.Iterator, error) {
|
||||||
|
return unwrap.SessionIterator(c.invoker.Call(c.hash, "iterateContainerSizes", epoch))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IterateContainerSizesExpanded is similar to IterateContainerSizes (uses the same contract
|
||||||
|
// method), but can be useful if the server used doesn't support sessions and
|
||||||
|
// doesn't expand iterators. It creates a script that will get the specified
|
||||||
|
// number of result items from the iterator right in the VM and return them to
|
||||||
|
// you. It's only limited by VM stack and GAS available for RPC invocations.
|
||||||
|
func (c *ContractReader) IterateContainerSizesExpanded(epoch *big.Int, _numOfIteratorItems int) ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.CallAndExpandIterator(c.hash, "iterateContainerSizes", _numOfIteratorItems, epoch))
|
||||||
|
}
|
||||||
|
|
||||||
|
// List invokes `list` method of contract.
|
||||||
|
func (c *ContractReader) List(owner []byte) ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "list", owner))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListContainerSizes invokes `listContainerSizes` method of contract.
|
||||||
|
func (c *ContractReader) ListContainerSizes(epoch *big.Int) ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "listContainerSizes", epoch))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Owner invokes `owner` method of contract.
|
||||||
|
func (c *ContractReader) Owner(containerID []byte) ([]byte, error) {
|
||||||
|
return unwrap.Bytes(c.invoker.Call(c.hash, "owner", containerID))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version invokes `version` method of contract.
|
||||||
|
func (c *ContractReader) Version() (*big.Int, error) {
|
||||||
|
return unwrap.BigInt(c.invoker.Call(c.hash, "version"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete creates a transaction invoking `delete` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Delete(containerID []byte, signature []byte, publicKey *keys.PublicKey, token []byte) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "delete", containerID, signature, publicKey, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteTransaction creates a transaction invoking `delete` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) DeleteTransaction(containerID []byte, signature []byte, publicKey *keys.PublicKey, token []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "delete", containerID, signature, publicKey, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteUnsigned creates a transaction invoking `delete` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) DeleteUnsigned(containerID []byte, signature []byte, publicKey *keys.PublicKey, token []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "delete", nil, containerID, signature, publicKey, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewEpoch creates a transaction invoking `newEpoch` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) NewEpoch(epochNum *big.Int) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "newEpoch", epochNum)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewEpochTransaction creates a transaction invoking `newEpoch` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) NewEpochTransaction(epochNum *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "newEpoch", epochNum)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewEpochUnsigned creates a transaction invoking `newEpoch` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) NewEpochUnsigned(epochNum *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "newEpoch", nil, epochNum)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Put creates a transaction invoking `put` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Put(container []byte, signature []byte, publicKey *keys.PublicKey, token []byte) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "put", container, signature, publicKey, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PutTransaction creates a transaction invoking `put` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) PutTransaction(container []byte, signature []byte, publicKey *keys.PublicKey, token []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "put", container, signature, publicKey, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PutUnsigned creates a transaction invoking `put` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) PutUnsigned(container []byte, signature []byte, publicKey *keys.PublicKey, token []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "put", nil, container, signature, publicKey, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PutContainerSize creates a transaction invoking `putContainerSize` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) PutContainerSize(epoch *big.Int, cid []byte, usedSize *big.Int, pubKey *keys.PublicKey) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "putContainerSize", epoch, cid, usedSize, pubKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PutContainerSizeTransaction creates a transaction invoking `putContainerSize` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) PutContainerSizeTransaction(epoch *big.Int, cid []byte, usedSize *big.Int, pubKey *keys.PublicKey) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "putContainerSize", epoch, cid, usedSize, pubKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PutContainerSizeUnsigned creates a transaction invoking `putContainerSize` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) PutContainerSizeUnsigned(epoch *big.Int, cid []byte, usedSize *big.Int, pubKey *keys.PublicKey) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "putContainerSize", nil, epoch, cid, usedSize, pubKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PutNamed creates a transaction invoking `putNamed` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) PutNamed(container []byte, signature []byte, publicKey *keys.PublicKey, token []byte, name string, zone string) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "putNamed", container, signature, publicKey, token, name, zone)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PutNamedTransaction creates a transaction invoking `putNamed` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) PutNamedTransaction(container []byte, signature []byte, publicKey *keys.PublicKey, token []byte, name string, zone string) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "putNamed", container, signature, publicKey, token, name, zone)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PutNamedUnsigned creates a transaction invoking `putNamed` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) PutNamedUnsigned(container []byte, signature []byte, publicKey *keys.PublicKey, token []byte, name string, zone string) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "putNamed", nil, container, signature, publicKey, token, name, zone)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEACL creates a transaction invoking `setEACL` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) SetEACL(eACL []byte, signature []byte, publicKey *keys.PublicKey, token []byte) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "setEACL", eACL, signature, publicKey, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEACLTransaction creates a transaction invoking `setEACL` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) SetEACLTransaction(eACL []byte, signature []byte, publicKey *keys.PublicKey, token []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "setEACL", eACL, signature, publicKey, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEACLUnsigned creates a transaction invoking `setEACL` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) SetEACLUnsigned(eACL []byte, signature []byte, publicKey *keys.PublicKey, token []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "setEACL", nil, eACL, signature, publicKey, token)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartContainerEstimation creates a transaction invoking `startContainerEstimation` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) StartContainerEstimation(epoch *big.Int) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "startContainerEstimation", epoch)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartContainerEstimationTransaction creates a transaction invoking `startContainerEstimation` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) StartContainerEstimationTransaction(epoch *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "startContainerEstimation", epoch)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartContainerEstimationUnsigned creates a transaction invoking `startContainerEstimation` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) StartContainerEstimationUnsigned(epoch *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "startContainerEstimation", nil, epoch)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StopContainerEstimation creates a transaction invoking `stopContainerEstimation` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) StopContainerEstimation(epoch *big.Int) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "stopContainerEstimation", epoch)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StopContainerEstimationTransaction creates a transaction invoking `stopContainerEstimation` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) StopContainerEstimationTransaction(epoch *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "stopContainerEstimation", epoch)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StopContainerEstimationUnsigned creates a transaction invoking `stopContainerEstimation` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) StopContainerEstimationUnsigned(epoch *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "stopContainerEstimation", nil, epoch)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Update(script []byte, manifest []byte, data any) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "update", script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateTransaction creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) UpdateTransaction(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "update", script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateUnsigned creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) UpdateUnsigned(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "update", nil, script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PutSuccessEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "PutSuccess" name from the provided [result.ApplicationLog].
|
||||||
|
func PutSuccessEventsFromApplicationLog(log *result.ApplicationLog) ([]*PutSuccessEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*PutSuccessEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "PutSuccess" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(PutSuccessEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize PutSuccessEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to PutSuccessEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *PutSuccessEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 2 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.ContainerID, err = func(item stackitem.Item) (util.Uint256, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint256{}, err
|
||||||
|
}
|
||||||
|
u, err := util.Uint256DecodeBytesBE(b)
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint256{}, err
|
||||||
|
}
|
||||||
|
return u, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field ContainerID: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.PublicKey, err = func(item stackitem.Item) (*keys.PublicKey, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
k, err := keys.NewPublicKeyFromBytes(b, elliptic.P256())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return k, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field PublicKey: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteSuccessEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "DeleteSuccess" name from the provided [result.ApplicationLog].
|
||||||
|
func DeleteSuccessEventsFromApplicationLog(log *result.ApplicationLog) ([]*DeleteSuccessEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*DeleteSuccessEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "DeleteSuccess" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(DeleteSuccessEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize DeleteSuccessEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to DeleteSuccessEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *DeleteSuccessEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 1 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.ContainerID, err = arr[index].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field ContainerID: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEACLSuccessEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "SetEACLSuccess" name from the provided [result.ApplicationLog].
|
||||||
|
func SetEACLSuccessEventsFromApplicationLog(log *result.ApplicationLog) ([]*SetEACLSuccessEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*SetEACLSuccessEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "SetEACLSuccess" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(SetEACLSuccessEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize SetEACLSuccessEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to SetEACLSuccessEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *SetEACLSuccessEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 2 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.ContainerID, err = arr[index].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field ContainerID: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.PublicKey, err = func(item stackitem.Item) (*keys.PublicKey, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
k, err := keys.NewPublicKeyFromBytes(b, elliptic.P256())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return k, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field PublicKey: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartEstimationEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "StartEstimation" name from the provided [result.ApplicationLog].
|
||||||
|
func StartEstimationEventsFromApplicationLog(log *result.ApplicationLog) ([]*StartEstimationEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*StartEstimationEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "StartEstimation" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(StartEstimationEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize StartEstimationEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to StartEstimationEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *StartEstimationEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 1 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.Epoch, err = arr[index].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Epoch: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// StopEstimationEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "StopEstimation" name from the provided [result.ApplicationLog].
|
||||||
|
func StopEstimationEventsFromApplicationLog(log *result.ApplicationLog) ([]*StopEstimationEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*StopEstimationEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "StopEstimation" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(StopEstimationEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize StopEstimationEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to StopEstimationEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *StopEstimationEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 1 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.Epoch, err = arr[index].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Epoch: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
851
rpcclient/frostfs/client.go
Normal file
851
rpcclient/frostfs/client.go
Normal file
|
@ -0,0 +1,851 @@
|
||||||
|
// Package frostfs contains RPC wrappers for FrostFS contract.
|
||||||
|
//
|
||||||
|
// Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT.
|
||||||
|
package frostfs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
|
"math/big"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DepositEvent represents "Deposit" event emitted by the contract.
|
||||||
|
type DepositEvent struct {
|
||||||
|
From util.Uint160
|
||||||
|
Amount *big.Int
|
||||||
|
Receiver util.Uint160
|
||||||
|
TxHash util.Uint256
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithdrawEvent represents "Withdraw" event emitted by the contract.
|
||||||
|
type WithdrawEvent struct {
|
||||||
|
User util.Uint160
|
||||||
|
Amount *big.Int
|
||||||
|
TxHash util.Uint256
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChequeEvent represents "Cheque" event emitted by the contract.
|
||||||
|
type ChequeEvent struct {
|
||||||
|
Id []byte
|
||||||
|
User util.Uint160
|
||||||
|
Amount *big.Int
|
||||||
|
LockAccount []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// BindEvent represents "Bind" event emitted by the contract.
|
||||||
|
type BindEvent struct {
|
||||||
|
User []byte
|
||||||
|
Keys []any
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnbindEvent represents "Unbind" event emitted by the contract.
|
||||||
|
type UnbindEvent struct {
|
||||||
|
User []byte
|
||||||
|
Keys []any
|
||||||
|
}
|
||||||
|
|
||||||
|
// AlphabetUpdateEvent represents "AlphabetUpdate" event emitted by the contract.
|
||||||
|
type AlphabetUpdateEvent struct {
|
||||||
|
Id []byte
|
||||||
|
Alphabet []any
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetConfigEvent represents "SetConfig" event emitted by the contract.
|
||||||
|
type SetConfigEvent struct {
|
||||||
|
Id []byte
|
||||||
|
Key []byte
|
||||||
|
Value []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invoker is used by ContractReader to call various safe methods.
|
||||||
|
type Invoker interface {
|
||||||
|
Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actor is used by Contract to call state-changing methods.
|
||||||
|
type Actor interface {
|
||||||
|
Invoker
|
||||||
|
|
||||||
|
MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeRun(script []byte) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
||||||
|
SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error)
|
||||||
|
SendRun(script []byte) (util.Uint256, uint32, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContractReader implements safe contract methods.
|
||||||
|
type ContractReader struct {
|
||||||
|
invoker Invoker
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contract implements all contract methods.
|
||||||
|
type Contract struct {
|
||||||
|
ContractReader
|
||||||
|
actor Actor
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewReader creates an instance of ContractReader using provided contract hash and the given Invoker.
|
||||||
|
func NewReader(invoker Invoker, hash util.Uint160) *ContractReader {
|
||||||
|
return &ContractReader{invoker, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates an instance of Contract using provided contract hash and the given Actor.
|
||||||
|
func New(actor Actor, hash util.Uint160) *Contract {
|
||||||
|
return &Contract{ContractReader{actor, hash}, actor, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AlphabetAddress invokes `alphabetAddress` method of contract.
|
||||||
|
func (c *ContractReader) AlphabetAddress() (util.Uint160, error) {
|
||||||
|
return unwrap.Uint160(c.invoker.Call(c.hash, "alphabetAddress"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Config invokes `config` method of contract.
|
||||||
|
func (c *ContractReader) Config(key []byte) (any, error) {
|
||||||
|
return func(item stackitem.Item, err error) (any, error) {
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return item.Value(), error(nil)
|
||||||
|
}(unwrap.Item(c.invoker.Call(c.hash, "config", key)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// InnerRingCandidates invokes `innerRingCandidates` method of contract.
|
||||||
|
func (c *ContractReader) InnerRingCandidates() ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "innerRingCandidates"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListConfig invokes `listConfig` method of contract.
|
||||||
|
func (c *ContractReader) ListConfig() ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "listConfig"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version invokes `version` method of contract.
|
||||||
|
func (c *ContractReader) Version() (*big.Int, error) {
|
||||||
|
return unwrap.BigInt(c.invoker.Call(c.hash, "version"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bind creates a transaction invoking `bind` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Bind(user []byte, keys []any) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "bind", user, keys)
|
||||||
|
}
|
||||||
|
|
||||||
|
// BindTransaction creates a transaction invoking `bind` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) BindTransaction(user []byte, keys []any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "bind", user, keys)
|
||||||
|
}
|
||||||
|
|
||||||
|
// BindUnsigned creates a transaction invoking `bind` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) BindUnsigned(user []byte, keys []any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "bind", nil, user, keys)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cheque creates a transaction invoking `cheque` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Cheque(id []byte, user util.Uint160, amount *big.Int, lockAcc []byte) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "cheque", id, user, amount, lockAcc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChequeTransaction creates a transaction invoking `cheque` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) ChequeTransaction(id []byte, user util.Uint160, amount *big.Int, lockAcc []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "cheque", id, user, amount, lockAcc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChequeUnsigned creates a transaction invoking `cheque` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) ChequeUnsigned(id []byte, user util.Uint160, amount *big.Int, lockAcc []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "cheque", nil, id, user, amount, lockAcc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InnerRingCandidateAdd creates a transaction invoking `innerRingCandidateAdd` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) InnerRingCandidateAdd(key *keys.PublicKey) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "innerRingCandidateAdd", key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InnerRingCandidateAddTransaction creates a transaction invoking `innerRingCandidateAdd` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) InnerRingCandidateAddTransaction(key *keys.PublicKey) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "innerRingCandidateAdd", key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InnerRingCandidateAddUnsigned creates a transaction invoking `innerRingCandidateAdd` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) InnerRingCandidateAddUnsigned(key *keys.PublicKey) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "innerRingCandidateAdd", nil, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InnerRingCandidateRemove creates a transaction invoking `innerRingCandidateRemove` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) InnerRingCandidateRemove(key *keys.PublicKey) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "innerRingCandidateRemove", key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InnerRingCandidateRemoveTransaction creates a transaction invoking `innerRingCandidateRemove` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) InnerRingCandidateRemoveTransaction(key *keys.PublicKey) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "innerRingCandidateRemove", key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InnerRingCandidateRemoveUnsigned creates a transaction invoking `innerRingCandidateRemove` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) InnerRingCandidateRemoveUnsigned(key *keys.PublicKey) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "innerRingCandidateRemove", nil, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetConfig creates a transaction invoking `setConfig` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) SetConfig(id []byte, key []byte, val []byte) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "setConfig", id, key, val)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetConfigTransaction creates a transaction invoking `setConfig` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) SetConfigTransaction(id []byte, key []byte, val []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "setConfig", id, key, val)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetConfigUnsigned creates a transaction invoking `setConfig` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) SetConfigUnsigned(id []byte, key []byte, val []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "setConfig", nil, id, key, val)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unbind creates a transaction invoking `unbind` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Unbind(user []byte, keys []any) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "unbind", user, keys)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnbindTransaction creates a transaction invoking `unbind` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) UnbindTransaction(user []byte, keys []any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "unbind", user, keys)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnbindUnsigned creates a transaction invoking `unbind` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) UnbindUnsigned(user []byte, keys []any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "unbind", nil, user, keys)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Update(script []byte, manifest []byte, data any) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "update", script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateTransaction creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) UpdateTransaction(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "update", script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateUnsigned creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) UpdateUnsigned(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "update", nil, script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Withdraw creates a transaction invoking `withdraw` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Withdraw(user util.Uint160, amount *big.Int) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "withdraw", user, amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithdrawTransaction creates a transaction invoking `withdraw` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) WithdrawTransaction(user util.Uint160, amount *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "withdraw", user, amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithdrawUnsigned creates a transaction invoking `withdraw` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) WithdrawUnsigned(user util.Uint160, amount *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "withdraw", nil, user, amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DepositEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "Deposit" name from the provided [result.ApplicationLog].
|
||||||
|
func DepositEventsFromApplicationLog(log *result.ApplicationLog) ([]*DepositEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*DepositEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "Deposit" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(DepositEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize DepositEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to DepositEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *DepositEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 4 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.From, err = func(item stackitem.Item) (util.Uint160, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
u, err := util.Uint160DecodeBytesBE(b)
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
return u, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field From: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.Amount, err = arr[index].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Amount: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.Receiver, err = func(item stackitem.Item) (util.Uint160, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
u, err := util.Uint160DecodeBytesBE(b)
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
return u, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Receiver: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.TxHash, err = func(item stackitem.Item) (util.Uint256, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint256{}, err
|
||||||
|
}
|
||||||
|
u, err := util.Uint256DecodeBytesBE(b)
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint256{}, err
|
||||||
|
}
|
||||||
|
return u, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field TxHash: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithdrawEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "Withdraw" name from the provided [result.ApplicationLog].
|
||||||
|
func WithdrawEventsFromApplicationLog(log *result.ApplicationLog) ([]*WithdrawEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*WithdrawEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "Withdraw" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(WithdrawEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize WithdrawEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to WithdrawEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *WithdrawEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 3 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.User, err = func(item stackitem.Item) (util.Uint160, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
u, err := util.Uint160DecodeBytesBE(b)
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
return u, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field User: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.Amount, err = arr[index].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Amount: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.TxHash, err = func(item stackitem.Item) (util.Uint256, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint256{}, err
|
||||||
|
}
|
||||||
|
u, err := util.Uint256DecodeBytesBE(b)
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint256{}, err
|
||||||
|
}
|
||||||
|
return u, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field TxHash: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChequeEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "Cheque" name from the provided [result.ApplicationLog].
|
||||||
|
func ChequeEventsFromApplicationLog(log *result.ApplicationLog) ([]*ChequeEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*ChequeEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "Cheque" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(ChequeEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize ChequeEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to ChequeEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *ChequeEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 4 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.Id, err = arr[index].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Id: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.User, err = func(item stackitem.Item) (util.Uint160, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
u, err := util.Uint160DecodeBytesBE(b)
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint160{}, err
|
||||||
|
}
|
||||||
|
return u, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field User: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.Amount, err = arr[index].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Amount: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.LockAccount, err = arr[index].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field LockAccount: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BindEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "Bind" name from the provided [result.ApplicationLog].
|
||||||
|
func BindEventsFromApplicationLog(log *result.ApplicationLog) ([]*BindEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*BindEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "Bind" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(BindEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize BindEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to BindEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *BindEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 2 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.User, err = arr[index].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field User: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.Keys, err = func(item stackitem.Item) ([]any, error) {
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("not an array")
|
||||||
|
}
|
||||||
|
res := make([]any, len(arr))
|
||||||
|
for i := range res {
|
||||||
|
res[i], err = arr[i].Value(), error(nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("item %d: %w", i, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Keys: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnbindEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "Unbind" name from the provided [result.ApplicationLog].
|
||||||
|
func UnbindEventsFromApplicationLog(log *result.ApplicationLog) ([]*UnbindEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*UnbindEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "Unbind" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(UnbindEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize UnbindEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to UnbindEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *UnbindEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 2 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.User, err = arr[index].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field User: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.Keys, err = func(item stackitem.Item) ([]any, error) {
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("not an array")
|
||||||
|
}
|
||||||
|
res := make([]any, len(arr))
|
||||||
|
for i := range res {
|
||||||
|
res[i], err = arr[i].Value(), error(nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("item %d: %w", i, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Keys: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AlphabetUpdateEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "AlphabetUpdate" name from the provided [result.ApplicationLog].
|
||||||
|
func AlphabetUpdateEventsFromApplicationLog(log *result.ApplicationLog) ([]*AlphabetUpdateEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*AlphabetUpdateEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "AlphabetUpdate" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(AlphabetUpdateEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize AlphabetUpdateEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to AlphabetUpdateEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *AlphabetUpdateEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 2 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.Id, err = arr[index].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Id: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.Alphabet, err = func(item stackitem.Item) ([]any, error) {
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("not an array")
|
||||||
|
}
|
||||||
|
res := make([]any, len(arr))
|
||||||
|
for i := range res {
|
||||||
|
res[i], err = arr[i].Value(), error(nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("item %d: %w", i, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Alphabet: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetConfigEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "SetConfig" name from the provided [result.ApplicationLog].
|
||||||
|
func SetConfigEventsFromApplicationLog(log *result.ApplicationLog) ([]*SetConfigEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*SetConfigEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "SetConfig" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(SetConfigEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize SetConfigEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to SetConfigEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *SetConfigEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 3 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.Id, err = arr[index].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Id: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.Key, err = arr[index].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Key: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.Value, err = arr[index].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Value: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
2044
rpcclient/frostfsid/client.go
Normal file
2044
rpcclient/frostfsid/client.go
Normal file
File diff suppressed because it is too large
Load diff
629
rpcclient/netmap/client.go
Normal file
629
rpcclient/netmap/client.go
Normal file
|
@ -0,0 +1,629 @@
|
||||||
|
// Package netmap contains RPC wrappers for Netmap contract.
|
||||||
|
//
|
||||||
|
// Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT.
|
||||||
|
package netmap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/elliptic"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
|
"math/big"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddPeerEvent represents "AddPeer" event emitted by the contract.
|
||||||
|
type AddPeerEvent struct {
|
||||||
|
NodeInfo []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPeerSuccessEvent represents "AddPeerSuccess" event emitted by the contract.
|
||||||
|
type AddPeerSuccessEvent struct {
|
||||||
|
PublicKey *keys.PublicKey
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStateEvent represents "UpdateState" event emitted by the contract.
|
||||||
|
type UpdateStateEvent struct {
|
||||||
|
State *big.Int
|
||||||
|
PublicKey *keys.PublicKey
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStateSuccessEvent represents "UpdateStateSuccess" event emitted by the contract.
|
||||||
|
type UpdateStateSuccessEvent struct {
|
||||||
|
PublicKey *keys.PublicKey
|
||||||
|
State *big.Int
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewEpochEvent represents "NewEpoch" event emitted by the contract.
|
||||||
|
type NewEpochEvent struct {
|
||||||
|
Epoch *big.Int
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invoker is used by ContractReader to call various safe methods.
|
||||||
|
type Invoker interface {
|
||||||
|
Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actor is used by Contract to call state-changing methods.
|
||||||
|
type Actor interface {
|
||||||
|
Invoker
|
||||||
|
|
||||||
|
MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeRun(script []byte) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
||||||
|
SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error)
|
||||||
|
SendRun(script []byte) (util.Uint256, uint32, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContractReader implements safe contract methods.
|
||||||
|
type ContractReader struct {
|
||||||
|
invoker Invoker
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contract implements all contract methods.
|
||||||
|
type Contract struct {
|
||||||
|
ContractReader
|
||||||
|
actor Actor
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewReader creates an instance of ContractReader using provided contract hash and the given Invoker.
|
||||||
|
func NewReader(invoker Invoker, hash util.Uint160) *ContractReader {
|
||||||
|
return &ContractReader{invoker, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates an instance of Contract using provided contract hash and the given Actor.
|
||||||
|
func New(actor Actor, hash util.Uint160) *Contract {
|
||||||
|
return &Contract{ContractReader{actor, hash}, actor, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Config invokes `config` method of contract.
|
||||||
|
func (c *ContractReader) Config(key []byte) (any, error) {
|
||||||
|
return func(item stackitem.Item, err error) (any, error) {
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return item.Value(), error(nil)
|
||||||
|
}(unwrap.Item(c.invoker.Call(c.hash, "config", key)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Epoch invokes `epoch` method of contract.
|
||||||
|
func (c *ContractReader) Epoch() (*big.Int, error) {
|
||||||
|
return unwrap.BigInt(c.invoker.Call(c.hash, "epoch"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListConfig invokes `listConfig` method of contract.
|
||||||
|
func (c *ContractReader) ListConfig() ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "listConfig"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Netmap invokes `netmap` method of contract.
|
||||||
|
func (c *ContractReader) Netmap() ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "netmap"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NetmapCandidates invokes `netmapCandidates` method of contract.
|
||||||
|
func (c *ContractReader) NetmapCandidates() ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "netmapCandidates"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Snapshot invokes `snapshot` method of contract.
|
||||||
|
func (c *ContractReader) Snapshot(diff *big.Int) ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "snapshot", diff))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SnapshotByEpoch invokes `snapshotByEpoch` method of contract.
|
||||||
|
func (c *ContractReader) SnapshotByEpoch(epoch *big.Int) ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "snapshotByEpoch", epoch))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version invokes `version` method of contract.
|
||||||
|
func (c *ContractReader) Version() (*big.Int, error) {
|
||||||
|
return unwrap.BigInt(c.invoker.Call(c.hash, "version"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPeer creates a transaction invoking `addPeer` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) AddPeer(nodeInfo []byte) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "addPeer", nodeInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPeerTransaction creates a transaction invoking `addPeer` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) AddPeerTransaction(nodeInfo []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "addPeer", nodeInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPeerUnsigned creates a transaction invoking `addPeer` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) AddPeerUnsigned(nodeInfo []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "addPeer", nil, nodeInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPeerIR creates a transaction invoking `addPeerIR` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) AddPeerIR(nodeInfo []byte) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "addPeerIR", nodeInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPeerIRTransaction creates a transaction invoking `addPeerIR` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) AddPeerIRTransaction(nodeInfo []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "addPeerIR", nodeInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPeerIRUnsigned creates a transaction invoking `addPeerIR` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) AddPeerIRUnsigned(nodeInfo []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "addPeerIR", nil, nodeInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastEpochBlock creates a transaction invoking `lastEpochBlock` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) LastEpochBlock() (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "lastEpochBlock")
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastEpochBlockTransaction creates a transaction invoking `lastEpochBlock` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) LastEpochBlockTransaction() (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "lastEpochBlock")
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastEpochBlockUnsigned creates a transaction invoking `lastEpochBlock` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) LastEpochBlockUnsigned() (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "lastEpochBlock", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewEpoch creates a transaction invoking `newEpoch` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) NewEpoch(epochNum *big.Int) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "newEpoch", epochNum)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewEpochTransaction creates a transaction invoking `newEpoch` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) NewEpochTransaction(epochNum *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "newEpoch", epochNum)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewEpochUnsigned creates a transaction invoking `newEpoch` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) NewEpochUnsigned(epochNum *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "newEpoch", nil, epochNum)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetConfig creates a transaction invoking `setConfig` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) SetConfig(id []byte, key []byte, val []byte) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "setConfig", id, key, val)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetConfigTransaction creates a transaction invoking `setConfig` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) SetConfigTransaction(id []byte, key []byte, val []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "setConfig", id, key, val)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetConfigUnsigned creates a transaction invoking `setConfig` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) SetConfigUnsigned(id []byte, key []byte, val []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "setConfig", nil, id, key, val)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Update(script []byte, manifest []byte, data any) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "update", script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateTransaction creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) UpdateTransaction(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "update", script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateUnsigned creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) UpdateUnsigned(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "update", nil, script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateSnapshotCount creates a transaction invoking `updateSnapshotCount` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) UpdateSnapshotCount(count *big.Int) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "updateSnapshotCount", count)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateSnapshotCountTransaction creates a transaction invoking `updateSnapshotCount` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) UpdateSnapshotCountTransaction(count *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "updateSnapshotCount", count)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateSnapshotCountUnsigned creates a transaction invoking `updateSnapshotCount` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) UpdateSnapshotCountUnsigned(count *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "updateSnapshotCount", nil, count)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateState creates a transaction invoking `updateState` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) UpdateState(state *big.Int, publicKey *keys.PublicKey) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "updateState", state, publicKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStateTransaction creates a transaction invoking `updateState` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) UpdateStateTransaction(state *big.Int, publicKey *keys.PublicKey) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "updateState", state, publicKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStateUnsigned creates a transaction invoking `updateState` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) UpdateStateUnsigned(state *big.Int, publicKey *keys.PublicKey) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "updateState", nil, state, publicKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStateIR creates a transaction invoking `updateStateIR` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) UpdateStateIR(state *big.Int, publicKey *keys.PublicKey) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "updateStateIR", state, publicKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStateIRTransaction creates a transaction invoking `updateStateIR` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) UpdateStateIRTransaction(state *big.Int, publicKey *keys.PublicKey) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "updateStateIR", state, publicKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStateIRUnsigned creates a transaction invoking `updateStateIR` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) UpdateStateIRUnsigned(state *big.Int, publicKey *keys.PublicKey) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "updateStateIR", nil, state, publicKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPeerEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "AddPeer" name from the provided [result.ApplicationLog].
|
||||||
|
func AddPeerEventsFromApplicationLog(log *result.ApplicationLog) ([]*AddPeerEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*AddPeerEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "AddPeer" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(AddPeerEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize AddPeerEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to AddPeerEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *AddPeerEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 1 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.NodeInfo, err = arr[index].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field NodeInfo: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPeerSuccessEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "AddPeerSuccess" name from the provided [result.ApplicationLog].
|
||||||
|
func AddPeerSuccessEventsFromApplicationLog(log *result.ApplicationLog) ([]*AddPeerSuccessEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*AddPeerSuccessEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "AddPeerSuccess" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(AddPeerSuccessEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize AddPeerSuccessEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to AddPeerSuccessEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *AddPeerSuccessEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 1 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.PublicKey, err = func(item stackitem.Item) (*keys.PublicKey, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
k, err := keys.NewPublicKeyFromBytes(b, elliptic.P256())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return k, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field PublicKey: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStateEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "UpdateState" name from the provided [result.ApplicationLog].
|
||||||
|
func UpdateStateEventsFromApplicationLog(log *result.ApplicationLog) ([]*UpdateStateEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*UpdateStateEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "UpdateState" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(UpdateStateEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize UpdateStateEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to UpdateStateEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *UpdateStateEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 2 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.State, err = arr[index].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field State: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.PublicKey, err = func(item stackitem.Item) (*keys.PublicKey, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
k, err := keys.NewPublicKeyFromBytes(b, elliptic.P256())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return k, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field PublicKey: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStateSuccessEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "UpdateStateSuccess" name from the provided [result.ApplicationLog].
|
||||||
|
func UpdateStateSuccessEventsFromApplicationLog(log *result.ApplicationLog) ([]*UpdateStateSuccessEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*UpdateStateSuccessEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "UpdateStateSuccess" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(UpdateStateSuccessEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize UpdateStateSuccessEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to UpdateStateSuccessEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *UpdateStateSuccessEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 2 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.PublicKey, err = func(item stackitem.Item) (*keys.PublicKey, error) {
|
||||||
|
b, err := item.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
k, err := keys.NewPublicKeyFromBytes(b, elliptic.P256())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return k, nil
|
||||||
|
}(arr[index])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field PublicKey: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
index++
|
||||||
|
e.State, err = arr[index].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field State: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewEpochEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
|
// with "NewEpoch" name from the provided [result.ApplicationLog].
|
||||||
|
func NewEpochEventsFromApplicationLog(log *result.ApplicationLog) ([]*NewEpochEvent, error) {
|
||||||
|
if log == nil {
|
||||||
|
return nil, errors.New("nil application log")
|
||||||
|
}
|
||||||
|
|
||||||
|
var res []*NewEpochEvent
|
||||||
|
for i, ex := range log.Executions {
|
||||||
|
for j, e := range ex.Events {
|
||||||
|
if e.Name != "NewEpoch" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
event := new(NewEpochEvent)
|
||||||
|
err := event.FromStackItem(e.Item)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to deserialize NewEpochEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
||||||
|
}
|
||||||
|
res = append(res, event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromStackItem converts provided [stackitem.Array] to NewEpochEvent or
|
||||||
|
// returns an error if it's not possible to do to so.
|
||||||
|
func (e *NewEpochEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
|
if item == nil {
|
||||||
|
return errors.New("nil item")
|
||||||
|
}
|
||||||
|
arr, ok := item.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("not an array")
|
||||||
|
}
|
||||||
|
if len(arr) != 1 {
|
||||||
|
return errors.New("wrong number of structure elements")
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
index = -1
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
index++
|
||||||
|
e.Epoch, err = arr[index].TryInteger()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("field Epoch: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
336
rpcclient/nns/client.go
Normal file
336
rpcclient/nns/client.go
Normal file
|
@ -0,0 +1,336 @@
|
||||||
|
// Package nameservice contains RPC wrappers for NameService contract.
|
||||||
|
//
|
||||||
|
// Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT.
|
||||||
|
package nameservice
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nep11"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
|
"math/big"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Invoker is used by ContractReader to call various safe methods.
|
||||||
|
type Invoker interface {
|
||||||
|
nep11.Invoker
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actor is used by Contract to call state-changing methods.
|
||||||
|
type Actor interface {
|
||||||
|
Invoker
|
||||||
|
|
||||||
|
nep11.Actor
|
||||||
|
|
||||||
|
MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeRun(script []byte) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
||||||
|
SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error)
|
||||||
|
SendRun(script []byte) (util.Uint256, uint32, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContractReader implements safe contract methods.
|
||||||
|
type ContractReader struct {
|
||||||
|
nep11.NonDivisibleReader
|
||||||
|
invoker Invoker
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contract implements all contract methods.
|
||||||
|
type Contract struct {
|
||||||
|
ContractReader
|
||||||
|
nep11.BaseWriter
|
||||||
|
actor Actor
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewReader creates an instance of ContractReader using provided contract hash and the given Invoker.
|
||||||
|
func NewReader(invoker Invoker, hash util.Uint160) *ContractReader {
|
||||||
|
return &ContractReader{*nep11.NewNonDivisibleReader(invoker, hash), invoker, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates an instance of Contract using provided contract hash and the given Actor.
|
||||||
|
func New(actor Actor, hash util.Uint160) *Contract {
|
||||||
|
var nep11ndt = nep11.NewNonDivisible(actor, hash)
|
||||||
|
return &Contract{ContractReader{nep11ndt.NonDivisibleReader, actor, hash}, nep11ndt.BaseWriter, actor, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPrice invokes `getPrice` method of contract.
|
||||||
|
func (c *ContractReader) GetPrice() (*big.Int, error) {
|
||||||
|
return unwrap.BigInt(c.invoker.Call(c.hash, "getPrice"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRecords invokes `getRecords` method of contract.
|
||||||
|
func (c *ContractReader) GetRecords(name string, typ *big.Int) ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "getRecords", name, typ))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsAvailable invokes `isAvailable` method of contract.
|
||||||
|
func (c *ContractReader) IsAvailable(name string) (bool, error) {
|
||||||
|
return unwrap.Bool(c.invoker.Call(c.hash, "isAvailable", name))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolve invokes `resolve` method of contract.
|
||||||
|
func (c *ContractReader) Resolve(name string, typ *big.Int) ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "resolve", name, typ))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Roots invokes `roots` method of contract.
|
||||||
|
func (c *ContractReader) Roots() (uuid.UUID, result.Iterator, error) {
|
||||||
|
return unwrap.SessionIterator(c.invoker.Call(c.hash, "roots"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RootsExpanded is similar to Roots (uses the same contract
|
||||||
|
// method), but can be useful if the server used doesn't support sessions and
|
||||||
|
// doesn't expand iterators. It creates a script that will get the specified
|
||||||
|
// number of result items from the iterator right in the VM and return them to
|
||||||
|
// you. It's only limited by VM stack and GAS available for RPC invocations.
|
||||||
|
func (c *ContractReader) RootsExpanded(_numOfIteratorItems int) ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.CallAndExpandIterator(c.hash, "roots", _numOfIteratorItems))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version invokes `version` method of contract.
|
||||||
|
func (c *ContractReader) Version() (*big.Int, error) {
|
||||||
|
return unwrap.BigInt(c.invoker.Call(c.hash, "version"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRecord creates a transaction invoking `addRecord` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) AddRecord(name string, typ *big.Int, data string) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "addRecord", name, typ, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRecordTransaction creates a transaction invoking `addRecord` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) AddRecordTransaction(name string, typ *big.Int, data string) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "addRecord", name, typ, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRecordUnsigned creates a transaction invoking `addRecord` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) AddRecordUnsigned(name string, typ *big.Int, data string) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "addRecord", nil, name, typ, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteRecords creates a transaction invoking `deleteRecords` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) DeleteRecords(name string, typ *big.Int) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "deleteRecords", name, typ)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteRecordsTransaction creates a transaction invoking `deleteRecords` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) DeleteRecordsTransaction(name string, typ *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "deleteRecords", name, typ)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteRecordsUnsigned creates a transaction invoking `deleteRecords` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) DeleteRecordsUnsigned(name string, typ *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "deleteRecords", nil, name, typ)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAllRecords creates a transaction invoking `getAllRecords` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) GetAllRecords(name string) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "getAllRecords", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAllRecordsTransaction creates a transaction invoking `getAllRecords` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) GetAllRecordsTransaction(name string) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "getAllRecords", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAllRecordsUnsigned creates a transaction invoking `getAllRecords` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) GetAllRecordsUnsigned(name string) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "getAllRecords", nil, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Contract) scriptForRegister(name string, owner util.Uint160, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) ([]byte, error) {
|
||||||
|
return smartcontract.CreateCallWithAssertScript(c.hash, "register", name, owner, email, refresh, retry, expire, ttl)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register creates a transaction invoking `register` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Register(name string, owner util.Uint160, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) (util.Uint256, uint32, error) {
|
||||||
|
script, err := c.scriptForRegister(name, owner, email, refresh, retry, expire, ttl)
|
||||||
|
if err != nil {
|
||||||
|
return util.Uint256{}, 0, err
|
||||||
|
}
|
||||||
|
return c.actor.SendRun(script)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterTransaction creates a transaction invoking `register` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) RegisterTransaction(name string, owner util.Uint160, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) (*transaction.Transaction, error) {
|
||||||
|
script, err := c.scriptForRegister(name, owner, email, refresh, retry, expire, ttl)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return c.actor.MakeRun(script)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterUnsigned creates a transaction invoking `register` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) RegisterUnsigned(name string, owner util.Uint160, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) (*transaction.Transaction, error) {
|
||||||
|
script, err := c.scriptForRegister(name, owner, email, refresh, retry, expire, ttl)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return c.actor.MakeUnsignedRun(script, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Renew creates a transaction invoking `renew` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Renew(name string) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "renew", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RenewTransaction creates a transaction invoking `renew` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) RenewTransaction(name string) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "renew", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RenewUnsigned creates a transaction invoking `renew` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) RenewUnsigned(name string) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "renew", nil, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdmin creates a transaction invoking `setAdmin` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) SetAdmin(name string, admin util.Uint160) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "setAdmin", name, admin)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdminTransaction creates a transaction invoking `setAdmin` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) SetAdminTransaction(name string, admin util.Uint160) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "setAdmin", name, admin)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdminUnsigned creates a transaction invoking `setAdmin` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) SetAdminUnsigned(name string, admin util.Uint160) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "setAdmin", nil, name, admin)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPrice creates a transaction invoking `setPrice` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) SetPrice(price *big.Int) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "setPrice", price)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPriceTransaction creates a transaction invoking `setPrice` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) SetPriceTransaction(price *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "setPrice", price)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPriceUnsigned creates a transaction invoking `setPrice` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) SetPriceUnsigned(price *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "setPrice", nil, price)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRecord creates a transaction invoking `setRecord` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) SetRecord(name string, typ *big.Int, id *big.Int, data string) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "setRecord", name, typ, id, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRecordTransaction creates a transaction invoking `setRecord` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) SetRecordTransaction(name string, typ *big.Int, id *big.Int, data string) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "setRecord", name, typ, id, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRecordUnsigned creates a transaction invoking `setRecord` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) SetRecordUnsigned(name string, typ *big.Int, id *big.Int, data string) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "setRecord", nil, name, typ, id, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Update(nef []byte, manifest string, data any) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "update", nef, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateTransaction creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) UpdateTransaction(nef []byte, manifest string, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "update", nef, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateUnsigned creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) UpdateUnsigned(nef []byte, manifest string, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "update", nil, nef, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateSOA creates a transaction invoking `updateSOA` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) UpdateSOA(name string, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "updateSOA", name, email, refresh, retry, expire, ttl)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateSOATransaction creates a transaction invoking `updateSOA` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) UpdateSOATransaction(name string, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "updateSOA", name, email, refresh, retry, expire, ttl)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateSOAUnsigned creates a transaction invoking `updateSOA` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) UpdateSOAUnsigned(name string, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "updateSOA", nil, name, email, refresh, retry, expire, ttl)
|
||||||
|
}
|
161
rpcclient/policy/client.go
Normal file
161
rpcclient/policy/client.go
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
// Package ape contains RPC wrappers for APE contract.
|
||||||
|
//
|
||||||
|
// Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT.
|
||||||
|
package ape
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
|
"math/big"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Invoker is used by ContractReader to call various safe methods.
|
||||||
|
type Invoker interface {
|
||||||
|
Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actor is used by Contract to call state-changing methods.
|
||||||
|
type Actor interface {
|
||||||
|
Invoker
|
||||||
|
|
||||||
|
MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeRun(script []byte) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
||||||
|
SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error)
|
||||||
|
SendRun(script []byte) (util.Uint256, uint32, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContractReader implements safe contract methods.
|
||||||
|
type ContractReader struct {
|
||||||
|
invoker Invoker
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contract implements all contract methods.
|
||||||
|
type Contract struct {
|
||||||
|
ContractReader
|
||||||
|
actor Actor
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewReader creates an instance of ContractReader using provided contract hash and the given Invoker.
|
||||||
|
func NewReader(invoker Invoker, hash util.Uint160) *ContractReader {
|
||||||
|
return &ContractReader{invoker, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates an instance of Contract using provided contract hash and the given Actor.
|
||||||
|
func New(actor Actor, hash util.Uint160) *Contract {
|
||||||
|
return &Contract{ContractReader{actor, hash}, actor, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAdmin invokes `getAdmin` method of contract.
|
||||||
|
func (c *ContractReader) GetAdmin() (util.Uint160, error) {
|
||||||
|
return unwrap.Uint160(c.invoker.Call(c.hash, "getAdmin"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetChain invokes `getChain` method of contract.
|
||||||
|
func (c *ContractReader) GetChain(entity *big.Int, entityName string, name []byte) ([]byte, error) {
|
||||||
|
return unwrap.Bytes(c.invoker.Call(c.hash, "getChain", entity, entityName, name))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListChains invokes `listChains` method of contract.
|
||||||
|
func (c *ContractReader) ListChains(namespace string, container string, name []byte) ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "listChains", namespace, container, name))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListChainsByPrefix invokes `listChainsByPrefix` method of contract.
|
||||||
|
func (c *ContractReader) ListChainsByPrefix(entity *big.Int, entityName string, prefix []byte) ([]stackitem.Item, error) {
|
||||||
|
return unwrap.Array(c.invoker.Call(c.hash, "listChainsByPrefix", entity, entityName, prefix))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddChain creates a transaction invoking `addChain` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) AddChain(entity *big.Int, entityName string, name []byte, chain []byte) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "addChain", entity, entityName, name, chain)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddChainTransaction creates a transaction invoking `addChain` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) AddChainTransaction(entity *big.Int, entityName string, name []byte, chain []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "addChain", entity, entityName, name, chain)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddChainUnsigned creates a transaction invoking `addChain` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) AddChainUnsigned(entity *big.Int, entityName string, name []byte, chain []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "addChain", nil, entity, entityName, name, chain)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveChain creates a transaction invoking `removeChain` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) RemoveChain(entity *big.Int, entityName string, name []byte) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "removeChain", entity, entityName, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveChainTransaction creates a transaction invoking `removeChain` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) RemoveChainTransaction(entity *big.Int, entityName string, name []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "removeChain", entity, entityName, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveChainUnsigned creates a transaction invoking `removeChain` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) RemoveChainUnsigned(entity *big.Int, entityName string, name []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "removeChain", nil, entity, entityName, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveChainsByPrefix creates a transaction invoking `removeChainsByPrefix` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) RemoveChainsByPrefix(entity *big.Int, entityName string, name []byte) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "removeChainsByPrefix", entity, entityName, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveChainsByPrefixTransaction creates a transaction invoking `removeChainsByPrefix` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) RemoveChainsByPrefixTransaction(entity *big.Int, entityName string, name []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "removeChainsByPrefix", entity, entityName, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveChainsByPrefixUnsigned creates a transaction invoking `removeChainsByPrefix` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) RemoveChainsByPrefixUnsigned(entity *big.Int, entityName string, name []byte) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "removeChainsByPrefix", nil, entity, entityName, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdmin creates a transaction invoking `setAdmin` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) SetAdmin(addr util.Uint160) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "setAdmin", addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdminTransaction creates a transaction invoking `setAdmin` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) SetAdminTransaction(addr util.Uint160) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "setAdmin", addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdminUnsigned creates a transaction invoking `setAdmin` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) SetAdminUnsigned(addr util.Uint160) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "setAdmin", nil, addr)
|
||||||
|
}
|
84
rpcclient/processing/client.go
Normal file
84
rpcclient/processing/client.go
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
// Package multisignatureprocessing contains RPC wrappers for Multi Signature Processing contract.
|
||||||
|
//
|
||||||
|
// Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT.
|
||||||
|
package multisignatureprocessing
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"math/big"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Invoker is used by ContractReader to call various safe methods.
|
||||||
|
type Invoker interface {
|
||||||
|
Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actor is used by Contract to call state-changing methods.
|
||||||
|
type Actor interface {
|
||||||
|
Invoker
|
||||||
|
|
||||||
|
MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeRun(script []byte) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
||||||
|
SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error)
|
||||||
|
SendRun(script []byte) (util.Uint256, uint32, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContractReader implements safe contract methods.
|
||||||
|
type ContractReader struct {
|
||||||
|
invoker Invoker
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contract implements all contract methods.
|
||||||
|
type Contract struct {
|
||||||
|
ContractReader
|
||||||
|
actor Actor
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewReader creates an instance of ContractReader using provided contract hash and the given Invoker.
|
||||||
|
func NewReader(invoker Invoker, hash util.Uint160) *ContractReader {
|
||||||
|
return &ContractReader{invoker, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates an instance of Contract using provided contract hash and the given Actor.
|
||||||
|
func New(actor Actor, hash util.Uint160) *Contract {
|
||||||
|
return &Contract{ContractReader{actor, hash}, actor, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify invokes `verify` method of contract.
|
||||||
|
func (c *ContractReader) Verify() (bool, error) {
|
||||||
|
return unwrap.Bool(c.invoker.Call(c.hash, "verify"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version invokes `version` method of contract.
|
||||||
|
func (c *ContractReader) Version() (*big.Int, error) {
|
||||||
|
return unwrap.BigInt(c.invoker.Call(c.hash, "version"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Update(script []byte, manifest []byte, data any) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "update", script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateTransaction creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) UpdateTransaction(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "update", script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateUnsigned creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) UpdateUnsigned(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "update", nil, script, manifest, data)
|
||||||
|
}
|
84
rpcclient/proxy/client.go
Normal file
84
rpcclient/proxy/client.go
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
// Package notaryproxy contains RPC wrappers for Notary Proxy contract.
|
||||||
|
//
|
||||||
|
// Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT.
|
||||||
|
package notaryproxy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"math/big"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Invoker is used by ContractReader to call various safe methods.
|
||||||
|
type Invoker interface {
|
||||||
|
Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actor is used by Contract to call state-changing methods.
|
||||||
|
type Actor interface {
|
||||||
|
Invoker
|
||||||
|
|
||||||
|
MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeRun(script []byte) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error)
|
||||||
|
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
||||||
|
SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error)
|
||||||
|
SendRun(script []byte) (util.Uint256, uint32, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContractReader implements safe contract methods.
|
||||||
|
type ContractReader struct {
|
||||||
|
invoker Invoker
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contract implements all contract methods.
|
||||||
|
type Contract struct {
|
||||||
|
ContractReader
|
||||||
|
actor Actor
|
||||||
|
hash util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewReader creates an instance of ContractReader using provided contract hash and the given Invoker.
|
||||||
|
func NewReader(invoker Invoker, hash util.Uint160) *ContractReader {
|
||||||
|
return &ContractReader{invoker, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates an instance of Contract using provided contract hash and the given Actor.
|
||||||
|
func New(actor Actor, hash util.Uint160) *Contract {
|
||||||
|
return &Contract{ContractReader{actor, hash}, actor, hash}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify invokes `verify` method of contract.
|
||||||
|
func (c *ContractReader) Verify() (bool, error) {
|
||||||
|
return unwrap.Bool(c.invoker.Call(c.hash, "verify"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version invokes `version` method of contract.
|
||||||
|
func (c *ContractReader) Version() (*big.Int, error) {
|
||||||
|
return unwrap.BigInt(c.invoker.Call(c.hash, "version"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed and immediately sent to the network.
|
||||||
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
|
func (c *Contract) Update(script []byte, manifest []byte, data any) (util.Uint256, uint32, error) {
|
||||||
|
return c.actor.SendCall(c.hash, "update", script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateTransaction creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
|
// returned to the caller.
|
||||||
|
func (c *Contract) UpdateTransaction(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeCall(c.hash, "update", script, manifest, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateUnsigned creates a transaction invoking `update` method of the contract.
|
||||||
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
|
func (c *Contract) UpdateUnsigned(script []byte, manifest []byte, data any) (*transaction.Transaction, error) {
|
||||||
|
return c.actor.MakeUnsignedCall(c.hash, "update", nil, script, manifest, data)
|
||||||
|
}
|
|
@ -1,23 +0,0 @@
|
||||||
name: "NeoFS Subnet"
|
|
||||||
safemethods: ["version"]
|
|
||||||
permissions:
|
|
||||||
- methods: ["update"]
|
|
||||||
events:
|
|
||||||
- name: Put
|
|
||||||
parameters:
|
|
||||||
- name: id
|
|
||||||
type: ByteArray
|
|
||||||
- name: ownerKey
|
|
||||||
type: PublicKey
|
|
||||||
- name: info
|
|
||||||
type: ByteArray
|
|
||||||
- name: Delete
|
|
||||||
parameters:
|
|
||||||
- name: id
|
|
||||||
type: ByteArray
|
|
||||||
- name: RemoveNode
|
|
||||||
parameters:
|
|
||||||
- name: subnetID
|
|
||||||
type: ByteArray
|
|
||||||
- name: node
|
|
||||||
type: PublicKey
|
|
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
Subnet contract is a contract deployed in NeoFS sidechain.
|
|
||||||
|
|
||||||
Subnet contract stores and manages NeoFS subnetwork states. It allows registering
|
|
||||||
and deleting subnetworks, limiting access to them, and defining a list of the Storage
|
|
||||||
Nodes that can be included in them.
|
|
||||||
|
|
||||||
Contract notifications
|
|
||||||
|
|
||||||
Put notification. This notification is produced when a new subnetwork is
|
|
||||||
registered by invoking Put method.
|
|
||||||
|
|
||||||
Put
|
|
||||||
- name: id
|
|
||||||
type: ByteArray
|
|
||||||
- name: ownerKey
|
|
||||||
type: PublicKey
|
|
||||||
- name: info
|
|
||||||
type: ByteArray
|
|
||||||
|
|
||||||
Delete notification. This notification is produced when some subnetwork is
|
|
||||||
deleted by invoking Delete method.
|
|
||||||
|
|
||||||
Delete
|
|
||||||
- name: id
|
|
||||||
type: ByteArray
|
|
||||||
|
|
||||||
RemoveNode notification. This notification is produced when some node is deleted
|
|
||||||
by invoking RemoveNode method.
|
|
||||||
|
|
||||||
RemoveNode
|
|
||||||
- name: subnetID
|
|
||||||
type: ByteArray
|
|
||||||
- name: node
|
|
||||||
type: PublicKey
|
|
||||||
*/
|
|
||||||
package subnet
|
|
|
@ -1,593 +0,0 @@
|
||||||
package subnet
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
|
||||||
"github.com/nspcc-dev/neofs-contract/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// ErrInvalidSubnetID is thrown when subnet id is not a slice of 5 bytes.
|
|
||||||
ErrInvalidSubnetID = "invalid subnet ID"
|
|
||||||
// ErrInvalidGroupID is thrown when group id is not a slice of 5 bytes.
|
|
||||||
ErrInvalidGroupID = "invalid group ID"
|
|
||||||
// ErrInvalidOwner is thrown when owner has invalid format.
|
|
||||||
ErrInvalidOwner = "invalid owner"
|
|
||||||
// ErrInvalidAdmin is thrown when admin has invalid format.
|
|
||||||
ErrInvalidAdmin = "invalid administrator"
|
|
||||||
// ErrAlreadyExists is thrown when id already exists.
|
|
||||||
ErrAlreadyExists = "subnet id already exists"
|
|
||||||
// ErrNotExist is thrown when id doesn't exist.
|
|
||||||
ErrNotExist = "subnet id doesn't exist"
|
|
||||||
// ErrInvalidUser is thrown when user has invalid format.
|
|
||||||
ErrInvalidUser = "invalid user"
|
|
||||||
// ErrInvalidNode is thrown when node has invalid format.
|
|
||||||
ErrInvalidNode = "invalid node key"
|
|
||||||
// ErrNodeAdmNotExist is thrown when node admin is not found.
|
|
||||||
ErrNodeAdmNotExist = "node admin not found"
|
|
||||||
// ErrClientAdmNotExist is thrown when client admin is not found.
|
|
||||||
ErrClientAdmNotExist = "client admin not found"
|
|
||||||
// ErrNodeNotExist is thrown when node is not found.
|
|
||||||
ErrNodeNotExist = "node not found"
|
|
||||||
// ErrUserNotExist is thrown when user is not found.
|
|
||||||
ErrUserNotExist = "user not found"
|
|
||||||
// ErrAccessDenied is thrown when operation is denied for caller.
|
|
||||||
ErrAccessDenied = "access denied"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
nodeAdminPrefix = 'a'
|
|
||||||
infoPrefix = 'i'
|
|
||||||
clientAdminPrefix = 'm'
|
|
||||||
nodePrefix = 'n'
|
|
||||||
ownerPrefix = 'o'
|
|
||||||
userPrefix = 'u'
|
|
||||||
notaryDisabledKey = 'z'
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
userIDSize = 27
|
|
||||||
subnetIDSize = 5
|
|
||||||
groupIDSize = 5
|
|
||||||
)
|
|
||||||
|
|
||||||
// _deploy function sets up initial list of inner ring public keys.
|
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
|
||||||
if isUpdate {
|
|
||||||
args := data.([]interface{})
|
|
||||||
common.CheckVersion(args[len(args)-1].(int))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
args := data.(struct {
|
|
||||||
notaryDisabled bool
|
|
||||||
})
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
storage.Put(ctx, []byte{notaryDisabledKey}, args.notaryDisabled)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. It can be invoked
|
|
||||||
// only by committee.
|
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
|
||||||
if !common.HasUpdateAccess() {
|
|
||||||
panic("only committee can update contract")
|
|
||||||
}
|
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All,
|
|
||||||
script, manifest, common.AppendVersion(data))
|
|
||||||
runtime.Log("subnet contract updated")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put creates a new subnet with the specified owner and info.
|
|
||||||
func Put(id []byte, ownerKey interop.PublicKey, info []byte) {
|
|
||||||
// V2 format
|
|
||||||
if len(id) != subnetIDSize {
|
|
||||||
panic(ErrInvalidSubnetID)
|
|
||||||
}
|
|
||||||
if len(ownerKey) != interop.PublicKeyCompressedLen {
|
|
||||||
panic(ErrInvalidOwner)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
stKey := append([]byte{ownerPrefix}, id...)
|
|
||||||
if storage.Get(ctx, stKey) != nil {
|
|
||||||
panic(ErrAlreadyExists)
|
|
||||||
}
|
|
||||||
|
|
||||||
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
|
|
||||||
if notaryDisabled {
|
|
||||||
alphabet := common.AlphabetNodes()
|
|
||||||
nodeKey := common.InnerRingInvoker(alphabet)
|
|
||||||
if len(nodeKey) == 0 {
|
|
||||||
common.CheckWitness(ownerKey)
|
|
||||||
runtime.Notify("Put", id, ownerKey, info)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
threshold := len(alphabet)*2/3 + 1
|
|
||||||
id := common.InvokeID([]interface{}{ownerKey, info}, []byte("put"))
|
|
||||||
n := common.Vote(ctx, id, nodeKey)
|
|
||||||
if n < threshold {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
common.RemoveVotes(ctx, id)
|
|
||||||
} else {
|
|
||||||
common.CheckOwnerWitness(ownerKey)
|
|
||||||
|
|
||||||
multiaddr := common.AlphabetAddress()
|
|
||||||
common.CheckAlphabetWitness(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
storage.Put(ctx, stKey, ownerKey)
|
|
||||||
stKey[0] = infoPrefix
|
|
||||||
storage.Put(ctx, stKey, info)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get returns info about the subnet with the specified id.
|
|
||||||
func Get(id []byte) []byte {
|
|
||||||
// V2 format
|
|
||||||
if len(id) != subnetIDSize {
|
|
||||||
panic(ErrInvalidSubnetID)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetReadOnlyContext()
|
|
||||||
key := append([]byte{infoPrefix}, id...)
|
|
||||||
raw := storage.Get(ctx, key)
|
|
||||||
if raw == nil {
|
|
||||||
panic(ErrNotExist)
|
|
||||||
}
|
|
||||||
return raw.([]byte)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete deletes the subnet with the specified id.
|
|
||||||
func Delete(id []byte) {
|
|
||||||
// V2 format
|
|
||||||
if len(id) != subnetIDSize {
|
|
||||||
panic(ErrInvalidSubnetID)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
key := append([]byte{ownerPrefix}, id...)
|
|
||||||
raw := storage.Get(ctx, key)
|
|
||||||
if raw == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
owner := raw.([]byte)
|
|
||||||
common.CheckOwnerWitness(owner)
|
|
||||||
|
|
||||||
storage.Delete(ctx, key)
|
|
||||||
|
|
||||||
key[0] = infoPrefix
|
|
||||||
storage.Delete(ctx, key)
|
|
||||||
|
|
||||||
key[0] = nodeAdminPrefix
|
|
||||||
deleteByPrefix(ctx, key)
|
|
||||||
|
|
||||||
key[0] = nodePrefix
|
|
||||||
deleteByPrefix(ctx, key)
|
|
||||||
|
|
||||||
key[0] = clientAdminPrefix
|
|
||||||
deleteByPrefix(ctx, key)
|
|
||||||
|
|
||||||
key[0] = userPrefix
|
|
||||||
deleteByPrefix(ctx, key)
|
|
||||||
|
|
||||||
runtime.Notify("Delete", id)
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddNodeAdmin adds a new node administrator to the specified subnetwork.
|
|
||||||
func AddNodeAdmin(subnetID []byte, adminKey interop.PublicKey) {
|
|
||||||
// V2 format
|
|
||||||
if len(subnetID) != subnetIDSize {
|
|
||||||
panic(ErrInvalidSubnetID)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(adminKey) != interop.PublicKeyCompressedLen {
|
|
||||||
panic(ErrInvalidAdmin)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
|
|
||||||
stKey := append([]byte{ownerPrefix}, subnetID...)
|
|
||||||
|
|
||||||
rawOwner := storage.Get(ctx, stKey)
|
|
||||||
if rawOwner == nil {
|
|
||||||
panic(ErrNotExist)
|
|
||||||
}
|
|
||||||
|
|
||||||
owner := rawOwner.([]byte)
|
|
||||||
common.CheckOwnerWitness(owner)
|
|
||||||
|
|
||||||
stKey[0] = nodeAdminPrefix
|
|
||||||
|
|
||||||
if keyInList(ctx, adminKey, stKey) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
putKeyInList(ctx, adminKey, stKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveNodeAdmin removes node administrator from the specified subnetwork.
|
|
||||||
// Must be called by the subnet owner only.
|
|
||||||
func RemoveNodeAdmin(subnetID []byte, adminKey interop.PublicKey) {
|
|
||||||
// V2 format
|
|
||||||
if len(subnetID) != subnetIDSize {
|
|
||||||
panic(ErrInvalidSubnetID)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(adminKey) != interop.PublicKeyCompressedLen {
|
|
||||||
panic(ErrInvalidAdmin)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
|
|
||||||
stKey := append([]byte{ownerPrefix}, subnetID...)
|
|
||||||
|
|
||||||
rawOwner := storage.Get(ctx, stKey)
|
|
||||||
if rawOwner == nil {
|
|
||||||
panic(ErrNotExist)
|
|
||||||
}
|
|
||||||
|
|
||||||
owner := rawOwner.([]byte)
|
|
||||||
common.CheckOwnerWitness(owner)
|
|
||||||
|
|
||||||
stKey[0] = nodeAdminPrefix
|
|
||||||
|
|
||||||
if !keyInList(ctx, adminKey, stKey) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteKeyFromList(ctx, adminKey, stKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddNode adds a node to the specified subnetwork.
|
|
||||||
// Must be called by the subnet's owner or the node administrator
|
|
||||||
// only.
|
|
||||||
func AddNode(subnetID []byte, node interop.PublicKey) {
|
|
||||||
// V2 format
|
|
||||||
if len(subnetID) != subnetIDSize {
|
|
||||||
panic(ErrInvalidSubnetID)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(node) != interop.PublicKeyCompressedLen {
|
|
||||||
panic(ErrInvalidNode)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
|
|
||||||
stKey := append([]byte{ownerPrefix}, subnetID...)
|
|
||||||
|
|
||||||
rawOwner := storage.Get(ctx, stKey)
|
|
||||||
if rawOwner == nil {
|
|
||||||
panic(ErrNotExist)
|
|
||||||
}
|
|
||||||
|
|
||||||
stKey[0] = nodeAdminPrefix
|
|
||||||
|
|
||||||
owner := rawOwner.([]byte)
|
|
||||||
|
|
||||||
if !calledByOwnerOrAdmin(ctx, owner, stKey) {
|
|
||||||
panic(ErrAccessDenied)
|
|
||||||
}
|
|
||||||
|
|
||||||
stKey[0] = nodePrefix
|
|
||||||
|
|
||||||
if keyInList(ctx, node, stKey) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
putKeyInList(ctx, node, stKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveNode removes a node from the specified subnetwork.
|
|
||||||
// Must be called by the subnet's owner or the node administrator
|
|
||||||
// only.
|
|
||||||
func RemoveNode(subnetID []byte, node interop.PublicKey) {
|
|
||||||
// V2 format
|
|
||||||
if len(subnetID) != subnetIDSize {
|
|
||||||
panic(ErrInvalidSubnetID)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(node) != interop.PublicKeyCompressedLen {
|
|
||||||
panic(ErrInvalidNode)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
|
|
||||||
stKey := append([]byte{ownerPrefix}, subnetID...)
|
|
||||||
|
|
||||||
rawOwner := storage.Get(ctx, stKey)
|
|
||||||
if rawOwner == nil {
|
|
||||||
panic(ErrNotExist)
|
|
||||||
}
|
|
||||||
|
|
||||||
stKey[0] = nodeAdminPrefix
|
|
||||||
|
|
||||||
owner := rawOwner.([]byte)
|
|
||||||
|
|
||||||
if !calledByOwnerOrAdmin(ctx, owner, stKey) {
|
|
||||||
panic(ErrAccessDenied)
|
|
||||||
}
|
|
||||||
|
|
||||||
stKey[0] = nodePrefix
|
|
||||||
|
|
||||||
if !keyInList(ctx, node, stKey) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
storage.Delete(ctx, append(stKey, node...))
|
|
||||||
|
|
||||||
runtime.Notify("RemoveNode", subnetID, node)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NodeAllowed checks if a node is included in the
|
|
||||||
// specified subnet.
|
|
||||||
func NodeAllowed(subnetID []byte, node interop.PublicKey) bool {
|
|
||||||
// V2 format
|
|
||||||
if len(subnetID) != subnetIDSize {
|
|
||||||
panic(ErrInvalidSubnetID)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(node) != interop.PublicKeyCompressedLen {
|
|
||||||
panic(ErrInvalidNode)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetReadOnlyContext()
|
|
||||||
|
|
||||||
stKey := append([]byte{ownerPrefix}, subnetID...)
|
|
||||||
|
|
||||||
rawOwner := storage.Get(ctx, stKey)
|
|
||||||
if rawOwner == nil {
|
|
||||||
panic(ErrNotExist)
|
|
||||||
}
|
|
||||||
|
|
||||||
stKey[0] = nodePrefix
|
|
||||||
|
|
||||||
return storage.Get(ctx, append(stKey, node...)) != nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddClientAdmin adds a new client administrator of the specified group in the specified subnetwork.
|
|
||||||
// Must be called by the owner only.
|
|
||||||
func AddClientAdmin(subnetID []byte, groupID []byte, adminPublicKey interop.PublicKey) {
|
|
||||||
// V2 format
|
|
||||||
if len(subnetID) != subnetIDSize {
|
|
||||||
panic(ErrInvalidSubnetID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// V2 format
|
|
||||||
if len(groupID) != groupIDSize {
|
|
||||||
panic(ErrInvalidGroupID)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(adminPublicKey) != interop.PublicKeyCompressedLen {
|
|
||||||
panic(ErrInvalidAdmin)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
|
|
||||||
stKey := append([]byte{ownerPrefix}, subnetID...)
|
|
||||||
|
|
||||||
rawOwner := storage.Get(ctx, stKey)
|
|
||||||
if rawOwner == nil {
|
|
||||||
panic(ErrNotExist)
|
|
||||||
}
|
|
||||||
|
|
||||||
owner := rawOwner.([]byte)
|
|
||||||
common.CheckOwnerWitness(owner)
|
|
||||||
|
|
||||||
stKey[0] = clientAdminPrefix
|
|
||||||
stKey = append(stKey, groupID...)
|
|
||||||
|
|
||||||
if keyInList(ctx, adminPublicKey, stKey) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
putKeyInList(ctx, adminPublicKey, stKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveClientAdmin removes client administrator from the
|
|
||||||
// specified group in the specified subnetwork.
|
|
||||||
// Must be called by the owner only.
|
|
||||||
func RemoveClientAdmin(subnetID []byte, groupID []byte, adminPublicKey interop.PublicKey) {
|
|
||||||
// V2 format
|
|
||||||
if len(subnetID) != subnetIDSize {
|
|
||||||
panic(ErrInvalidSubnetID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// V2 format
|
|
||||||
if len(groupID) != groupIDSize {
|
|
||||||
panic(ErrInvalidGroupID)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(adminPublicKey) != interop.PublicKeyCompressedLen {
|
|
||||||
panic(ErrInvalidAdmin)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
|
|
||||||
stKey := append([]byte{ownerPrefix}, subnetID...)
|
|
||||||
|
|
||||||
rawOwner := storage.Get(ctx, stKey)
|
|
||||||
if rawOwner == nil {
|
|
||||||
panic(ErrNotExist)
|
|
||||||
}
|
|
||||||
|
|
||||||
owner := rawOwner.([]byte)
|
|
||||||
common.CheckOwnerWitness(owner)
|
|
||||||
|
|
||||||
stKey[0] = clientAdminPrefix
|
|
||||||
stKey = append(stKey, groupID...)
|
|
||||||
|
|
||||||
if !keyInList(ctx, adminPublicKey, stKey) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteKeyFromList(ctx, adminPublicKey, stKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddUser adds user to the specified subnetwork and group.
|
|
||||||
// Must be called by the owner or the group's admin only.
|
|
||||||
func AddUser(subnetID []byte, groupID []byte, userID []byte) {
|
|
||||||
// V2 format
|
|
||||||
if len(subnetID) != subnetIDSize {
|
|
||||||
panic(ErrInvalidSubnetID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// V2 format
|
|
||||||
if len(userID) != userIDSize {
|
|
||||||
panic(ErrInvalidUser)
|
|
||||||
}
|
|
||||||
|
|
||||||
// V2 format
|
|
||||||
if len(groupID) != groupIDSize {
|
|
||||||
panic(ErrInvalidGroupID)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
|
|
||||||
stKey := append([]byte{ownerPrefix}, subnetID...)
|
|
||||||
|
|
||||||
rawOwner := storage.Get(ctx, stKey)
|
|
||||||
if rawOwner == nil {
|
|
||||||
panic(ErrNotExist)
|
|
||||||
}
|
|
||||||
|
|
||||||
stKey[0] = clientAdminPrefix
|
|
||||||
stKey = append(stKey, groupID...)
|
|
||||||
|
|
||||||
owner := rawOwner.([]byte)
|
|
||||||
|
|
||||||
if !calledByOwnerOrAdmin(ctx, owner, stKey) {
|
|
||||||
panic(ErrAccessDenied)
|
|
||||||
}
|
|
||||||
|
|
||||||
stKey[0] = userPrefix
|
|
||||||
|
|
||||||
if keyInList(ctx, userID, stKey) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
putKeyInList(ctx, userID, stKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveUser removes a user from the specified subnetwork and group.
|
|
||||||
// Must be called by the owner or the group's admin only.
|
|
||||||
func RemoveUser(subnetID []byte, groupID []byte, userID []byte) {
|
|
||||||
// V2 format
|
|
||||||
if len(subnetID) != subnetIDSize {
|
|
||||||
panic(ErrInvalidSubnetID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// V2 format
|
|
||||||
if len(groupID) != groupIDSize {
|
|
||||||
panic(ErrInvalidGroupID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// V2 format
|
|
||||||
if len(userID) != userIDSize {
|
|
||||||
panic(ErrInvalidUser)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
|
|
||||||
stKey := append([]byte{ownerPrefix}, subnetID...)
|
|
||||||
|
|
||||||
rawOwner := storage.Get(ctx, stKey)
|
|
||||||
if rawOwner == nil {
|
|
||||||
panic(ErrNotExist)
|
|
||||||
}
|
|
||||||
|
|
||||||
stKey[0] = clientAdminPrefix
|
|
||||||
stKey = append(stKey, groupID...)
|
|
||||||
|
|
||||||
owner := rawOwner.([]byte)
|
|
||||||
|
|
||||||
if !calledByOwnerOrAdmin(ctx, owner, stKey) {
|
|
||||||
panic(ErrAccessDenied)
|
|
||||||
}
|
|
||||||
|
|
||||||
stKey[0] = userPrefix
|
|
||||||
|
|
||||||
if !keyInList(ctx, userID, stKey) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteKeyFromList(ctx, userID, stKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UserAllowed returns bool that indicates if a node is included in the
|
|
||||||
// specified subnet.
|
|
||||||
func UserAllowed(subnetID []byte, user []byte) bool {
|
|
||||||
// V2 format
|
|
||||||
if len(subnetID) != subnetIDSize {
|
|
||||||
panic(ErrInvalidSubnetID)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
|
||||||
|
|
||||||
stKey := append([]byte{ownerPrefix}, subnetID...)
|
|
||||||
if storage.Get(ctx, stKey) == nil {
|
|
||||||
panic(ErrNotExist)
|
|
||||||
}
|
|
||||||
|
|
||||||
stKey[0] = userPrefix
|
|
||||||
prefixLen := len(stKey) + groupIDSize
|
|
||||||
|
|
||||||
iter := storage.Find(ctx, stKey, storage.KeysOnly)
|
|
||||||
for iterator.Next(iter) {
|
|
||||||
key := iterator.Value(iter).([]byte)
|
|
||||||
if common.BytesEqual(user, key[prefixLen:]) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Version returns the version of the contract.
|
|
||||||
func Version() int {
|
|
||||||
return common.Version
|
|
||||||
}
|
|
||||||
|
|
||||||
func keyInList(ctx storage.Context, searchedKey interop.PublicKey, prefix []byte) bool {
|
|
||||||
return storage.Get(ctx, append(prefix, searchedKey...)) != nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func putKeyInList(ctx storage.Context, keyToPut interop.PublicKey, prefix []byte) {
|
|
||||||
storage.Put(ctx, append(prefix, keyToPut...), []byte{1})
|
|
||||||
}
|
|
||||||
|
|
||||||
func deleteKeyFromList(ctx storage.Context, keyToDelete interop.PublicKey, prefix []byte) {
|
|
||||||
storage.Delete(ctx, append(prefix, keyToDelete...))
|
|
||||||
}
|
|
||||||
|
|
||||||
func deleteByPrefix(ctx storage.Context, prefix []byte) {
|
|
||||||
iter := storage.Find(ctx, prefix, storage.KeysOnly)
|
|
||||||
for iterator.Next(iter) {
|
|
||||||
k := iterator.Value(iter).([]byte)
|
|
||||||
storage.Delete(ctx, k)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func calledByOwnerOrAdmin(ctx storage.Context, owner []byte, adminPrefix []byte) bool {
|
|
||||||
if runtime.CheckWitness(owner) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
iter := storage.Find(ctx, adminPrefix, storage.KeysOnly|storage.RemovePrefix)
|
|
||||||
for iterator.Next(iter) {
|
|
||||||
key := iterator.Value(iter).([]byte)
|
|
||||||
if runtime.CheckWitness(key) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
|
@ -4,6 +4,8 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/container"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
|
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
||||||
|
@ -11,8 +13,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
"github.com/nspcc-dev/neofs-contract/common"
|
|
||||||
"github.com/nspcc-dev/neofs-contract/container"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,13 +21,12 @@ const alphabetPath = "../alphabet"
|
||||||
func deployAlphabetContract(t *testing.T, e *neotest.Executor, addrNetmap, addrProxy util.Uint160, name string, index, total int64) util.Uint160 {
|
func deployAlphabetContract(t *testing.T, e *neotest.Executor, addrNetmap, addrProxy util.Uint160, name string, index, total int64) util.Uint160 {
|
||||||
c := neotest.CompileFile(t, e.CommitteeHash, alphabetPath, path.Join(alphabetPath, "config.yml"))
|
c := neotest.CompileFile(t, e.CommitteeHash, alphabetPath, path.Join(alphabetPath, "config.yml"))
|
||||||
|
|
||||||
args := make([]interface{}, 6)
|
args := make([]any, 5)
|
||||||
args[0] = false
|
args[0] = addrNetmap
|
||||||
args[1] = addrNetmap
|
args[1] = addrProxy
|
||||||
args[2] = addrProxy
|
args[2] = name
|
||||||
args[3] = name
|
args[3] = index
|
||||||
args[4] = index
|
args[4] = total
|
||||||
args[5] = total
|
|
||||||
|
|
||||||
e.DeployContract(t, c, args)
|
e.DeployContract(t, c, args)
|
||||||
return c.Hash
|
return c.Hash
|
||||||
|
@ -88,8 +87,8 @@ func TestVote(t *testing.T) {
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
cNewAlphabet := c.WithSigners(newAlphabet)
|
cNewAlphabet := c.WithSigners(newAlphabet)
|
||||||
|
|
||||||
cNewAlphabet.InvokeFail(t, common.ErrAlphabetWitnessFailed, method, int64(0), []interface{}{newAlphabetPub})
|
cNewAlphabet.InvokeFail(t, common.ErrAlphabetWitnessFailed, method, int64(0), []any{newAlphabetPub})
|
||||||
c.InvokeFail(t, "invalid epoch", method, int64(1), []interface{}{newAlphabetPub})
|
c.InvokeFail(t, "invalid epoch", method, int64(1), []any{newAlphabetPub})
|
||||||
|
|
||||||
setAlphabetRole(t, e, newAlphabetPub)
|
setAlphabetRole(t, e, newAlphabetPub)
|
||||||
transferNeoToContract(t, c)
|
transferNeoToContract(t, c)
|
||||||
|
@ -109,7 +108,7 @@ func TestVote(t *testing.T) {
|
||||||
newInvoker := neoInvoker.WithSigners(newAlphabet)
|
newInvoker := neoInvoker.WithSigners(newAlphabet)
|
||||||
|
|
||||||
newInvoker.Invoke(t, stackitem.NewBool(true), "registerCandidate", newAlphabetPub)
|
newInvoker.Invoke(t, stackitem.NewBool(true), "registerCandidate", newAlphabetPub)
|
||||||
c.Invoke(t, stackitem.Null{}, method, int64(0), []interface{}{newAlphabetPub})
|
c.Invoke(t, stackitem.Null{}, method, int64(0), []any{newAlphabetPub})
|
||||||
|
|
||||||
// wait one block util
|
// wait one block util
|
||||||
// a new committee is accepted
|
// a new committee is accepted
|
||||||
|
@ -139,7 +138,7 @@ func setAlphabetRole(t *testing.T, e *neotest.Executor, new []byte) {
|
||||||
designInvoker := e.CommitteeInvoker(designSH)
|
designInvoker := e.CommitteeInvoker(designSH)
|
||||||
|
|
||||||
// set committee as NeoFSAlphabet
|
// set committee as NeoFSAlphabet
|
||||||
designInvoker.Invoke(t, stackitem.Null{}, "designateAsRole", int64(noderoles.NeoFSAlphabet), []interface{}{new})
|
designInvoker.Invoke(t, stackitem.Null{}, "designateAsRole", int64(noderoles.NeoFSAlphabet), []any{new})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAlphabetAcc(t *testing.T, e *neotest.Executor) *wallet.Account {
|
func getAlphabetAcc(t *testing.T, e *neotest.Executor) *wallet.Account {
|
||||||
|
|
|
@ -14,10 +14,9 @@ const balancePath = "../balance"
|
||||||
func deployBalanceContract(t *testing.T, e *neotest.Executor, addrNetmap, addrContainer util.Uint160) util.Uint160 {
|
func deployBalanceContract(t *testing.T, e *neotest.Executor, addrNetmap, addrContainer util.Uint160) util.Uint160 {
|
||||||
c := neotest.CompileFile(t, e.CommitteeHash, balancePath, path.Join(balancePath, "config.yml"))
|
c := neotest.CompileFile(t, e.CommitteeHash, balancePath, path.Join(balancePath, "config.yml"))
|
||||||
|
|
||||||
args := make([]interface{}, 3)
|
args := make([]any, 3)
|
||||||
args[0] = false
|
args[0] = addrNetmap
|
||||||
args[1] = addrNetmap
|
args[1] = addrContainer
|
||||||
args[2] = addrContainer
|
|
||||||
|
|
||||||
e.DeployContract(t, c, args)
|
e.DeployContract(t, c, args)
|
||||||
return c.Hash
|
return c.Hash
|
||||||
|
|
61
tests/common_test.go
Normal file
61
tests/common_test.go
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
package tests
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math"
|
||||||
|
"math/big"
|
||||||
|
"path"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
const testdataPath = "./testdata"
|
||||||
|
|
||||||
|
func newTestdataInvoker(t *testing.T) *neotest.ContractInvoker {
|
||||||
|
e := newExecutor(t)
|
||||||
|
ctr := neotest.CompileFile(t, e.CommitteeHash, testdataPath, path.Join(testdataPath, "config.yml"))
|
||||||
|
e.DeployContract(t, ctr, nil)
|
||||||
|
return e.CommitteeInvoker(ctr.Hash)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestEncodeU64(t *testing.T) {
|
||||||
|
// Let's check boundary values for all bit sizes:
|
||||||
|
var nums []uint64
|
||||||
|
for i := 0; i < 64; i++ {
|
||||||
|
if i != 0 {
|
||||||
|
nums = append(nums, (1<<i)-1)
|
||||||
|
}
|
||||||
|
nums = append(nums, 1<<i)
|
||||||
|
if i != 63 {
|
||||||
|
nums = append(nums, (1<<i)+1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c := newTestdataInvoker(t)
|
||||||
|
for _, n := range nums {
|
||||||
|
v, err := c.TestInvoke(t, "encode", n)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, 1, v.Len())
|
||||||
|
|
||||||
|
r := v.Pop().Bytes()
|
||||||
|
require.Equal(t, 9, len(r), "got: %x", r)
|
||||||
|
|
||||||
|
v, err = c.TestInvoke(t, "encodeDecode", n)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, 1, v.Len())
|
||||||
|
require.Equal(t, n, v.Pop().BigInt().Uint64())
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run("bad cases should be handled", func(t *testing.T) {
|
||||||
|
x := new(big.Int).SetUint64(math.MaxUint64)
|
||||||
|
x.Add(x, big.NewInt(1))
|
||||||
|
|
||||||
|
nums := []*big.Int{x, big.NewInt(-1), big.NewInt(-128)}
|
||||||
|
for _, n := range nums {
|
||||||
|
v, err := c.TestInvoke(t, "encodeDecode", n)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, 0, v.Pop().BigInt().Cmp(n))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
|
@ -3,35 +3,38 @@ package tests
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
|
"fmt"
|
||||||
|
"math/big"
|
||||||
"path"
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/container"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
||||||
"github.com/mr-tron/base58"
|
"github.com/mr-tron/base58"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/interop/storage"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
"github.com/nspcc-dev/neofs-contract/common"
|
|
||||||
"github.com/nspcc-dev/neofs-contract/container"
|
|
||||||
"github.com/nspcc-dev/neofs-contract/nns"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
const containerPath = "../container"
|
const containerPath = "../container"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
containerFee = 0_0100_0000
|
containerFee = 0o_0100_0000
|
||||||
containerAliasFee = 0_0050_0000
|
containerAliasFee = 0o_0050_0000
|
||||||
)
|
)
|
||||||
|
|
||||||
func deployContainerContract(t *testing.T, e *neotest.Executor, addrNetmap, addrBalance, addrNNS util.Uint160) util.Uint160 {
|
func deployContainerContract(t *testing.T, e *neotest.Executor, addrNetmap, addrBalance, addrNNS util.Uint160) util.Uint160 {
|
||||||
args := make([]interface{}, 6)
|
args := make([]any, 5)
|
||||||
args[0] = int64(0)
|
args[0] = addrNetmap
|
||||||
args[1] = addrNetmap
|
args[1] = addrBalance
|
||||||
args[2] = addrBalance
|
args[2] = util.Uint160{} // not needed for now
|
||||||
args[3] = util.Uint160{} // not needed for now
|
args[3] = addrNNS
|
||||||
args[4] = addrNNS
|
args[4] = "frostfs"
|
||||||
args[5] = "neofs"
|
|
||||||
|
|
||||||
c := neotest.CompileFile(t, e.CommitteeHash, containerPath, path.Join(containerPath, "config.yml"))
|
c := neotest.CompileFile(t, e.CommitteeHash, containerPath, path.Join(containerPath, "config.yml"))
|
||||||
e.DeployContract(t, c, args)
|
e.DeployContract(t, c, args)
|
||||||
|
@ -56,8 +59,12 @@ func newContainerInvoker(t *testing.T) (*neotest.ContractInvoker, *neotest.Contr
|
||||||
}
|
}
|
||||||
|
|
||||||
func setContainerOwner(c []byte, acc neotest.Signer) {
|
func setContainerOwner(c []byte, acc neotest.Signer) {
|
||||||
|
copy(c[6:], signerToOwner(acc))
|
||||||
|
}
|
||||||
|
|
||||||
|
func signerToOwner(acc neotest.Signer) []byte {
|
||||||
owner, _ := base58.Decode(address.Uint160ToString(acc.ScriptHash()))
|
owner, _ := base58.Decode(address.Uint160ToString(acc.ScriptHash()))
|
||||||
copy(c[6:], owner)
|
return owner
|
||||||
}
|
}
|
||||||
|
|
||||||
type testContainer struct {
|
type testContainer struct {
|
||||||
|
@ -101,15 +108,61 @@ func TestContainerCount(t *testing.T) {
|
||||||
cnt3 := dummyContainer(acc1)
|
cnt3 := dummyContainer(acc1)
|
||||||
balanceMint(t, cBal, acc1, containerFee*1, []byte{})
|
balanceMint(t, cBal, acc1, containerFee*1, []byte{})
|
||||||
c.Invoke(t, stackitem.Null{}, "put", cnt3.value, cnt3.sig, cnt3.pub, cnt3.token)
|
c.Invoke(t, stackitem.Null{}, "put", cnt3.value, cnt3.sig, cnt3.pub, cnt3.token)
|
||||||
|
checkContainerList(t, c, [][]byte{cnt1.id[:], cnt2.id[:], cnt3.id[:]})
|
||||||
|
|
||||||
c.Invoke(t, stackitem.Null{}, "delete", cnt1.id[:], cnt1.sig, cnt1.token)
|
c.Invoke(t, stackitem.Null{}, "delete", cnt1.id[:], cnt1.sig, cnt1.pub, cnt1.token)
|
||||||
checkCount(t, 2)
|
checkCount(t, 2)
|
||||||
|
checkContainerList(t, c, [][]byte{cnt2.id[:], cnt3.id[:]})
|
||||||
|
|
||||||
c.Invoke(t, stackitem.Null{}, "delete", cnt2.id[:], cnt2.sig, cnt2.token)
|
c.Invoke(t, stackitem.Null{}, "delete", cnt2.id[:], cnt2.sig, cnt2.pub, cnt2.token)
|
||||||
checkCount(t, 1)
|
checkCount(t, 1)
|
||||||
|
checkContainerList(t, c, [][]byte{cnt3.id[:]})
|
||||||
|
|
||||||
c.Invoke(t, stackitem.Null{}, "delete", cnt3.id[:], cnt3.sig, cnt3.token)
|
c.Invoke(t, stackitem.Null{}, "delete", cnt3.id[:], cnt3.sig, cnt3.pub, cnt3.token)
|
||||||
checkCount(t, 0)
|
checkCount(t, 0)
|
||||||
|
checkContainerList(t, c, [][]byte{})
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkContainerList(t *testing.T, c *neotest.ContractInvoker, expected [][]byte) {
|
||||||
|
t.Run("check with `list`", func(t *testing.T) {
|
||||||
|
s, err := c.TestInvoke(t, "list", nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, 1, s.Len())
|
||||||
|
|
||||||
|
if len(expected) == 0 {
|
||||||
|
_, ok := s.Top().Item().(stackitem.Null)
|
||||||
|
require.True(t, ok)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
arr, ok := s.Top().Value().([]stackitem.Item)
|
||||||
|
require.True(t, ok)
|
||||||
|
require.Equal(t, len(expected), len(arr))
|
||||||
|
|
||||||
|
actual := make([][]byte, 0, len(expected))
|
||||||
|
for i := range arr {
|
||||||
|
id, ok := arr[i].Value().([]byte)
|
||||||
|
require.True(t, ok)
|
||||||
|
actual = append(actual, id)
|
||||||
|
}
|
||||||
|
require.ElementsMatch(t, expected, actual)
|
||||||
|
})
|
||||||
|
t.Run("check with `containersOf`", func(t *testing.T) {
|
||||||
|
s, err := c.TestInvoke(t, "containersOf", nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, 1, s.Len())
|
||||||
|
|
||||||
|
iter, ok := s.Top().Value().(*storage.Iterator)
|
||||||
|
require.True(t, ok)
|
||||||
|
|
||||||
|
actual := make([][]byte, 0, len(expected))
|
||||||
|
for iter.Next() {
|
||||||
|
id, ok := iter.Value().Value().([]byte)
|
||||||
|
require.True(t, ok)
|
||||||
|
actual = append(actual, id)
|
||||||
|
}
|
||||||
|
require.ElementsMatch(t, expected, actual)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestContainerPut(t *testing.T) {
|
func TestContainerPut(t *testing.T) {
|
||||||
|
@ -118,7 +171,7 @@ func TestContainerPut(t *testing.T) {
|
||||||
acc := c.NewAccount(t)
|
acc := c.NewAccount(t)
|
||||||
cnt := dummyContainer(acc)
|
cnt := dummyContainer(acc)
|
||||||
|
|
||||||
putArgs := []interface{}{cnt.value, cnt.sig, cnt.pub, cnt.token}
|
putArgs := []any{cnt.value, cnt.sig, cnt.pub, cnt.token}
|
||||||
c.InvokeFail(t, "insufficient balance to create container", "put", putArgs...)
|
c.InvokeFail(t, "insufficient balance to create container", "put", putArgs...)
|
||||||
|
|
||||||
balanceMint(t, cBal, acc, containerFee*1, []byte{})
|
balanceMint(t, cBal, acc, containerFee*1, []byte{})
|
||||||
|
@ -134,7 +187,7 @@ func TestContainerPut(t *testing.T) {
|
||||||
|
|
||||||
balanceMint(t, cBal, acc, containerFee*1, []byte{})
|
balanceMint(t, cBal, acc, containerFee*1, []byte{})
|
||||||
|
|
||||||
putArgs := []interface{}{cnt.value, cnt.sig, cnt.pub, cnt.token, "mycnt", ""}
|
putArgs := []any{cnt.value, cnt.sig, cnt.pub, cnt.token, "mycnt", ""}
|
||||||
t.Run("no fee for alias", func(t *testing.T) {
|
t.Run("no fee for alias", func(t *testing.T) {
|
||||||
c.InvokeFail(t, "insufficient balance to create container", "putNamed", putArgs...)
|
c.InvokeFail(t, "insufficient balance to create container", "putNamed", putArgs...)
|
||||||
})
|
})
|
||||||
|
@ -146,14 +199,14 @@ func TestContainerPut(t *testing.T) {
|
||||||
stackitem.NewByteArray([]byte(base58.Encode(cnt.id[:]))),
|
stackitem.NewByteArray([]byte(base58.Encode(cnt.id[:]))),
|
||||||
})
|
})
|
||||||
cNNS := c.CommitteeInvoker(nnsHash)
|
cNNS := c.CommitteeInvoker(nnsHash)
|
||||||
cNNS.Invoke(t, expected, "resolve", "mycnt.neofs", int64(nns.TXT))
|
cNNS.Invoke(t, expected, "resolve", "mycnt.frostfs", int64(nns.TXT))
|
||||||
|
|
||||||
t.Run("name is already taken", func(t *testing.T) {
|
t.Run("name is already taken", func(t *testing.T) {
|
||||||
c.InvokeFail(t, "name is already taken", "putNamed", putArgs...)
|
c.InvokeFail(t, "name is already taken", "putNamed", putArgs...)
|
||||||
})
|
})
|
||||||
|
|
||||||
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.token)
|
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.pub, cnt.token)
|
||||||
cNNS.Invoke(t, stackitem.Null{}, "resolve", "mycnt.neofs", int64(nns.TXT))
|
cNNS.Invoke(t, stackitem.Null{}, "resolve", "mycnt.frostfs", int64(nns.TXT))
|
||||||
|
|
||||||
t.Run("register in advance", func(t *testing.T) {
|
t.Run("register in advance", func(t *testing.T) {
|
||||||
cnt.value[len(cnt.value)-1] = 10
|
cnt.value[len(cnt.value)-1] = 10
|
||||||
|
@ -169,15 +222,44 @@ func TestContainerPut(t *testing.T) {
|
||||||
|
|
||||||
balanceMint(t, cBal, acc, (containerFee+containerAliasFee)*1, []byte{})
|
balanceMint(t, cBal, acc, (containerFee+containerAliasFee)*1, []byte{})
|
||||||
|
|
||||||
putArgs := []interface{}{cnt.value, cnt.sig, cnt.pub, cnt.token, "domain", "cdn"}
|
putArgs := []any{cnt.value, cnt.sig, cnt.pub, cnt.token, "domain", "cdn"}
|
||||||
c2 := c.WithSigners(c.Committee, acc)
|
c2 := c.WithSigners(c.Committee, acc)
|
||||||
c2.Invoke(t, stackitem.Null{}, "putNamed", putArgs...)
|
c2.Invoke(t, stackitem.Null{}, "putNamed", putArgs...)
|
||||||
|
|
||||||
expected = stackitem.NewArray([]stackitem.Item{
|
expected = stackitem.NewArray([]stackitem.Item{
|
||||||
stackitem.NewByteArray([]byte(base58.Encode(cnt.id[:])))})
|
stackitem.NewByteArray([]byte(base58.Encode(cnt.id[:]))),
|
||||||
|
})
|
||||||
cNNS.Invoke(t, expected, "resolve", "domain.cdn", int64(nns.TXT))
|
cNNS.Invoke(t, expected, "resolve", "domain.cdn", int64(nns.TXT))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("gas costs are the same for all containers in block", func(t *testing.T) {
|
||||||
|
const (
|
||||||
|
containerPerBlock = 512
|
||||||
|
totalContainers = containerPerBlock + 1
|
||||||
|
totalPrice = containerFee + containerAliasFee
|
||||||
|
)
|
||||||
|
|
||||||
|
acc := c.NewAccount(t)
|
||||||
|
balanceMint(t, cBal, acc, totalPrice*totalContainers, []byte{})
|
||||||
|
cnt := dummyContainer(acc)
|
||||||
|
putArgs := []any{cnt.value, cnt.sig, cnt.pub, cnt.token, "precreated", ""}
|
||||||
|
c.Invoke(t, stackitem.Null{}, "putNamed", putArgs...)
|
||||||
|
|
||||||
|
txs := make([]*transaction.Transaction, 0, containerPerBlock)
|
||||||
|
for i := 0; i < containerPerBlock; i++ {
|
||||||
|
cnt := dummyContainer(acc)
|
||||||
|
name := fmt.Sprintf("name-%.5d", i)
|
||||||
|
tx := c.PrepareInvoke(t, "putNamed", cnt.value, cnt.sig, cnt.pub, cnt.token, name, "")
|
||||||
|
txs = append(txs, tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.AddNewBlock(t, txs...)
|
||||||
|
|
||||||
|
for i := 0; i < containerPerBlock; i++ {
|
||||||
|
c.CheckHalt(t, txs[i].Hash(), stackitem.Make(stackitem.Null{}))
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func addContainer(t *testing.T, c, cBal *neotest.ContractInvoker) (neotest.Signer, testContainer) {
|
func addContainer(t *testing.T, c, cBal *neotest.ContractInvoker) (neotest.Signer, testContainer) {
|
||||||
|
@ -190,19 +272,67 @@ func addContainer(t *testing.T, c, cBal *neotest.ContractInvoker) (neotest.Signe
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestContainerDelete(t *testing.T) {
|
func TestContainerDelete(t *testing.T) {
|
||||||
c, cBal, _ := newContainerInvoker(t)
|
c, cBal, cNm := newContainerInvoker(t)
|
||||||
|
|
||||||
acc, cnt := addContainer(t, c, cBal)
|
acc, cnt := addContainer(t, c, cBal)
|
||||||
cAcc := c.WithSigners(acc)
|
cAcc := c.WithSigners(acc)
|
||||||
cAcc.InvokeFail(t, common.ErrAlphabetWitnessFailed, "delete",
|
cAcc.InvokeFail(t, common.ErrAlphabetWitnessFailed, "delete",
|
||||||
cnt.id[:], cnt.sig, cnt.token)
|
cnt.id[:], cnt.sig, cnt.pub, cnt.token)
|
||||||
|
|
||||||
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.token)
|
newDelInfo := func(acc neotest.Signer, epoch int64) *stackitem.Struct {
|
||||||
|
return stackitem.NewStruct([]stackitem.Item{
|
||||||
|
stackitem.NewBuffer([]byte(signerToOwner(acc))),
|
||||||
|
stackitem.NewBigInteger(big.NewInt(epoch)),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
c.InvokeFail(t, container.NotFoundError, "deletionInfo", cnt.id[:])
|
||||||
|
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.pub, cnt.token)
|
||||||
|
c.Invoke(t, newDelInfo(acc, 0), "deletionInfo", cnt.id[:])
|
||||||
|
|
||||||
|
t.Run("multi-epoch", func(t *testing.T) {
|
||||||
|
cNm.Invoke(t, stackitem.Null{}, "newEpoch", 1)
|
||||||
|
|
||||||
|
t.Run("epoch tick does not change deletion info", func(t *testing.T) {
|
||||||
|
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.pub, cnt.token)
|
||||||
|
c.Invoke(t, newDelInfo(acc, 0), "deletionInfo", cnt.id[:])
|
||||||
|
})
|
||||||
|
|
||||||
|
acc1, cnt1 := addContainer(t, c, cBal)
|
||||||
|
c.Invoke(t, stackitem.Null{}, "delete", cnt1.id[:], cnt1.sig, cnt1.pub, cnt1.token)
|
||||||
|
c.Invoke(t, newDelInfo(acc, 0), "deletionInfo", cnt.id[:])
|
||||||
|
c.Invoke(t, newDelInfo(acc1, 1), "deletionInfo", cnt1.id[:])
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("missing container", func(t *testing.T) {
|
t.Run("missing container", func(t *testing.T) {
|
||||||
id := cnt.id
|
id := cnt.id
|
||||||
id[0] ^= 0xFF
|
id[0] ^= 0xFF
|
||||||
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.token)
|
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.pub, cnt.token)
|
||||||
|
c.InvokeFail(t, container.NotFoundError, "deletionInfo", id[:])
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("gas costs are the same for different epochs", func(t *testing.T) {
|
||||||
|
_, cnt2 := addContainer(t, c, cBal)
|
||||||
|
args := []any{cnt2.id[:], cnt2.sig, cnt2.pub, cnt2.token}
|
||||||
|
|
||||||
|
tx := c.PrepareInvoke(t, "delete", args...)
|
||||||
|
for _, e := range []int{126, 127, 128, 129, 65536} {
|
||||||
|
cNm.Invoke(t, stackitem.Null{}, "newEpoch", e)
|
||||||
|
|
||||||
|
// Sanity check.
|
||||||
|
s, err := cNm.TestInvoke(t, "epoch")
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, big.NewInt(int64(e)), s.Top().BigInt())
|
||||||
|
|
||||||
|
tx2 := c.PrepareInvoke(t, "delete", args...)
|
||||||
|
require.Equal(t, tx.Size(), tx2.Size())
|
||||||
|
require.Equal(t, tx.SystemFee, tx2.SystemFee)
|
||||||
|
require.Equal(t, tx.NetworkFee, tx2.NetworkFee)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Another sanity check: we want to test successful invocations,
|
||||||
|
// bad ones can trivially be equal.
|
||||||
|
c.Invoke(t, stackitem.Null{}, "delete", args...)
|
||||||
})
|
})
|
||||||
|
|
||||||
c.InvokeFail(t, container.NotFoundError, "get", cnt.id[:])
|
c.InvokeFail(t, container.NotFoundError, "get", cnt.id[:])
|
||||||
|
@ -219,7 +349,7 @@ func TestContainerOwner(t *testing.T) {
|
||||||
c.InvokeFail(t, container.NotFoundError, "owner", id[:])
|
c.InvokeFail(t, container.NotFoundError, "owner", id[:])
|
||||||
})
|
})
|
||||||
|
|
||||||
owner, _ := base58.Decode(address.Uint160ToString(acc.ScriptHash()))
|
owner := signerToOwner(acc)
|
||||||
c.Invoke(t, stackitem.NewBuffer(owner), "owner", cnt.id[:])
|
c.Invoke(t, stackitem.NewBuffer(owner), "owner", cnt.id[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +404,7 @@ func TestContainerSetEACL(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
e := dummyEACL(cnt.id)
|
e := dummyEACL(cnt.id)
|
||||||
setArgs := []interface{}{e.value, e.sig, e.pub, e.token}
|
setArgs := []any{e.value, e.sig, e.pub, e.token}
|
||||||
cAcc := c.WithSigners(acc)
|
cAcc := c.WithSigners(acc)
|
||||||
cAcc.InvokeFail(t, common.ErrAlphabetWitnessFailed, "setEACL", setArgs...)
|
cAcc.InvokeFail(t, common.ErrAlphabetWitnessFailed, "setEACL", setArgs...)
|
||||||
|
|
||||||
|
@ -366,6 +496,16 @@ type estimation struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkEstimations(t *testing.T, c *neotest.ContractInvoker, epoch int64, cnt testContainer, estimations ...estimation) {
|
func checkEstimations(t *testing.T, c *neotest.ContractInvoker, epoch int64, cnt testContainer, estimations ...estimation) {
|
||||||
|
// Check that listed estimations match expected
|
||||||
|
listEstimations := getListEstimations(t, c, epoch, cnt)
|
||||||
|
requireEstimationsMatch(t, estimations, listEstimations)
|
||||||
|
|
||||||
|
// Check that iterated estimations match expected
|
||||||
|
iterEstimations := getIterEstimations(t, c, epoch)
|
||||||
|
requireEstimationsMatch(t, estimations, iterEstimations)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getListEstimations(t *testing.T, c *neotest.ContractInvoker, epoch int64, cnt testContainer) []estimation {
|
||||||
s, err := c.TestInvoke(t, "listContainerSizes", epoch)
|
s, err := c.TestInvoke(t, "listContainerSizes", epoch)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
@ -375,9 +515,8 @@ func checkEstimations(t *testing.T, c *neotest.ContractInvoker, epoch int64, cnt
|
||||||
item := s.Top().Item()
|
item := s.Top().Item()
|
||||||
switch it := item.(type) {
|
switch it := item.(type) {
|
||||||
case stackitem.Null:
|
case stackitem.Null:
|
||||||
require.Equal(t, 0, len(estimations))
|
|
||||||
require.Equal(t, stackitem.Null{}, it)
|
require.Equal(t, stackitem.Null{}, it)
|
||||||
return
|
return make([]estimation, 0)
|
||||||
case *stackitem.Array:
|
case *stackitem.Array:
|
||||||
id, err = it.Value().([]stackitem.Item)[0].TryBytes()
|
id, err = it.Value().([]stackitem.Item)[0].TryBytes()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -388,25 +527,52 @@ func checkEstimations(t *testing.T, c *neotest.ContractInvoker, epoch int64, cnt
|
||||||
s, err = c.TestInvoke(t, "getContainerSize", id)
|
s, err = c.TestInvoke(t, "getContainerSize", id)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// Here and below we assume that all estimations in the contract are related to our container
|
||||||
sizes := s.Top().Array()
|
sizes := s.Top().Array()
|
||||||
require.Equal(t, cnt.id[:], sizes[0].Value())
|
require.Equal(t, cnt.id[:], sizes[0].Value())
|
||||||
|
|
||||||
actual := sizes[1].Value().([]stackitem.Item)
|
return convertStackToEstimations(sizes[1].Value().([]stackitem.Item))
|
||||||
require.Equal(t, len(estimations), len(actual))
|
}
|
||||||
for i := range actual {
|
|
||||||
// type estimation struct {
|
func getIterEstimations(t *testing.T, c *neotest.ContractInvoker, epoch int64) []estimation {
|
||||||
// from interop.PublicKey
|
iterStack, err := c.TestInvoke(t, "iterateContainerSizes", epoch)
|
||||||
// size int
|
require.NoError(t, err)
|
||||||
// }
|
iter := iterStack.Pop().Value().(*storage.Iterator)
|
||||||
est := actual[i].Value().([]stackitem.Item)
|
|
||||||
pub := est[0].Value().([]byte)
|
// Iterator contains pairs: key + estimation (as stack item), we extract estimations only
|
||||||
|
pairs := iteratorToArray(iter)
|
||||||
|
estimationItems := make([]stackitem.Item, len(pairs))
|
||||||
|
for i, pair := range pairs {
|
||||||
|
pairItems := pair.Value().([]stackitem.Item)
|
||||||
|
estimationItems[i] = pairItems[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
return convertStackToEstimations(estimationItems)
|
||||||
|
}
|
||||||
|
|
||||||
|
func convertStackToEstimations(stackItems []stackitem.Item) []estimation {
|
||||||
|
estimations := make([]estimation, 0, len(stackItems))
|
||||||
|
for _, item := range stackItems {
|
||||||
|
value := item.Value().([]stackitem.Item)
|
||||||
|
from := value[0].Value().([]byte)
|
||||||
|
size := value[1].Value().(*big.Int)
|
||||||
|
|
||||||
|
estimation := estimation{from: from, size: size.Int64()}
|
||||||
|
estimations = append(estimations, estimation)
|
||||||
|
}
|
||||||
|
return estimations
|
||||||
|
}
|
||||||
|
|
||||||
|
func requireEstimationsMatch(t *testing.T, expected []estimation, actual []estimation) {
|
||||||
|
require.Equal(t, len(expected), len(actual))
|
||||||
|
for _, e := range expected {
|
||||||
found := false
|
found := false
|
||||||
for i := range estimations {
|
for _, a := range actual {
|
||||||
if found = bytes.Equal(estimations[i].from, pub); found {
|
if found = bytes.Equal(e.from, a.from); found {
|
||||||
require.Equal(t, stackitem.Make(estimations[i].size), est[1])
|
require.Equal(t, e.size, a.size)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
require.True(t, found, "expected estimation from %x to be present", pub)
|
require.True(t, found, "expected estimation from %x to be present", e.from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/frostfs"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
||||||
|
@ -14,31 +15,30 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
"github.com/nspcc-dev/neofs-contract/neofs"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
const neofsPath = "../neofs"
|
const frostfsPath = "../frostfs"
|
||||||
|
|
||||||
func deployNeoFSContract(t *testing.T, e *neotest.Executor, addrProc util.Uint160,
|
func deployFrostFSContract(t *testing.T, e *neotest.Executor, addrProc util.Uint160,
|
||||||
pubs keys.PublicKeys, config ...interface{}) util.Uint160 {
|
pubs keys.PublicKeys, config ...any,
|
||||||
args := make([]interface{}, 5)
|
) util.Uint160 {
|
||||||
args[0] = false
|
args := make([]any, 3)
|
||||||
args[1] = addrProc
|
args[0] = addrProc
|
||||||
|
|
||||||
arr := make([]interface{}, len(pubs))
|
arr := make([]any, len(pubs))
|
||||||
for i := range pubs {
|
for i := range pubs {
|
||||||
arr[i] = pubs[i].Bytes()
|
arr[i] = pubs[i].Bytes()
|
||||||
}
|
}
|
||||||
args[2] = arr
|
args[1] = arr
|
||||||
args[3] = append([]interface{}{}, config...)
|
args[2] = append([]any{}, config...)
|
||||||
|
|
||||||
c := neotest.CompileFile(t, e.CommitteeHash, neofsPath, path.Join(neofsPath, "config.yml"))
|
c := neotest.CompileFile(t, e.CommitteeHash, frostfsPath, path.Join(frostfsPath, "config.yml"))
|
||||||
e.DeployContract(t, c, args)
|
e.DeployContract(t, c, args)
|
||||||
return c.Hash
|
return c.Hash
|
||||||
}
|
}
|
||||||
|
|
||||||
func newNeoFSInvoker(t *testing.T, n int, config ...interface{}) (*neotest.ContractInvoker, neotest.Signer, keys.PublicKeys) {
|
func newFrostFSInvoker(t *testing.T, n int, config ...any) (*neotest.ContractInvoker, neotest.Signer, keys.PublicKeys) {
|
||||||
e := newExecutor(t)
|
e := newExecutor(t)
|
||||||
|
|
||||||
accounts := make([]*wallet.Account, n)
|
accounts := make([]*wallet.Account, n)
|
||||||
|
@ -66,7 +66,7 @@ func newNeoFSInvoker(t *testing.T, n int, config ...interface{}) (*neotest.Contr
|
||||||
}
|
}
|
||||||
|
|
||||||
alphabet := neotest.NewMultiSigner(accounts...)
|
alphabet := neotest.NewMultiSigner(accounts...)
|
||||||
h := deployNeoFSContract(t, e, util.Uint160{}, pubs, config...)
|
h := deployFrostFSContract(t, e, util.Uint160{}, pubs, config...)
|
||||||
|
|
||||||
gasHash, err := e.Chain.GetNativeContractScriptHash(nativenames.Gas)
|
gasHash, err := e.Chain.GetNativeContractScriptHash(nativenames.Gas)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -79,22 +79,8 @@ func newNeoFSInvoker(t *testing.T, n int, config ...interface{}) (*neotest.Contr
|
||||||
return e.CommitteeInvoker(h).WithSigners(alphabet), alphabet, pubs
|
return e.CommitteeInvoker(h).WithSigners(alphabet), alphabet, pubs
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNeoFS_AlphabetList(t *testing.T) {
|
func TestFrostFS_InnerRingCandidate(t *testing.T) {
|
||||||
const alphabetSize = 4
|
e, _, _ := newFrostFSInvoker(t, 4, frostfs.CandidateFeeConfigKey, int64(10))
|
||||||
|
|
||||||
e, _, pubs := newNeoFSInvoker(t, alphabetSize)
|
|
||||||
arr := make([]stackitem.Item, len(pubs))
|
|
||||||
for i := range arr {
|
|
||||||
arr[i] = stackitem.NewStruct([]stackitem.Item{
|
|
||||||
stackitem.NewByteArray(pubs[i].Bytes()),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
e.Invoke(t, stackitem.NewArray(arr), "alphabetList")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNeoFS_InnerRingCandidate(t *testing.T) {
|
|
||||||
e, _, _ := newNeoFSInvoker(t, 4, neofs.CandidateFeeConfigKey, int64(10))
|
|
||||||
|
|
||||||
const candidateCount = 3
|
const candidateCount = 3
|
||||||
|
|
537
tests/frostfsid_client_test.go
Normal file
537
tests/frostfsid_client_test.go
Normal file
|
@ -0,0 +1,537 @@
|
||||||
|
package tests
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/frostfsid/client"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
type testFrostFSIDClientInvoker struct {
|
||||||
|
base *testFrostFSIDInvoker
|
||||||
|
cli *client.Client
|
||||||
|
a awaiter
|
||||||
|
}
|
||||||
|
|
||||||
|
func initFrostfsIFClientTest(t *testing.T) (clientInvoker *testFrostFSIDClientInvoker, cancelFn func()) {
|
||||||
|
f := newFrostFSIDInvoker(t)
|
||||||
|
|
||||||
|
wlt := initTmpWallet(t)
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
address := runRPC(ctx, t, f.e.Chain, wlt)
|
||||||
|
|
||||||
|
cli, rpc := frostfsidRPCClient(t, address, f.contractHash, f.owner)
|
||||||
|
|
||||||
|
clientInvoker = &testFrostFSIDClientInvoker{
|
||||||
|
base: f,
|
||||||
|
cli: cli,
|
||||||
|
a: awaiter{
|
||||||
|
ctx: ctx,
|
||||||
|
t: t,
|
||||||
|
rpc: rpc,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return clientInvoker, func() {
|
||||||
|
cancel()
|
||||||
|
err := os.Remove(wlt)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func frostfsidRPCClient(t *testing.T, address string, contractHash util.Uint160, accs ...*wallet.Account) (*client.Client, *rpcclient.Client) {
|
||||||
|
rpcCli, err := rpcclient.New(context.Background(), "http://"+address, rpcclient.Options{})
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
var acc *wallet.Account
|
||||||
|
if len(accs) == 0 {
|
||||||
|
acc, err = wallet.NewAccount()
|
||||||
|
require.NoError(t, err)
|
||||||
|
} else {
|
||||||
|
require.Len(t, accs, 1)
|
||||||
|
acc = accs[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
cli, err := client.New(rpcCli, acc, contractHash, nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
return cli, rpcCli
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFrostFSID_Client_ContractOwnersManagement(t *testing.T) {
|
||||||
|
ffsid, cancel := initFrostfsIFClientTest(t)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
committeeInvoker := ffsid.base.CommitteeInvoker()
|
||||||
|
defaultOwnerAddress := ffsid.base.owner.ScriptHash()
|
||||||
|
_, newOwnerAddress := newKey(t)
|
||||||
|
|
||||||
|
checkAdminClient(t, ffsid.cli, defaultOwnerAddress)
|
||||||
|
|
||||||
|
_, _, err := ffsid.cli.SetAdmin(newOwnerAddress)
|
||||||
|
require.ErrorContains(t, err, "not witnessed")
|
||||||
|
committeeInvoker.Invoke(t, stackitem.Null{}, setAdminMethod, newOwnerAddress)
|
||||||
|
|
||||||
|
checkAdminClient(t, ffsid.cli, newOwnerAddress)
|
||||||
|
|
||||||
|
_, _, err = ffsid.cli.ClearAdmin()
|
||||||
|
require.ErrorContains(t, err, "not witnessed")
|
||||||
|
committeeInvoker.Invoke(t, stackitem.Null{}, clearAdminMethod)
|
||||||
|
|
||||||
|
checkAdminClient(t, ffsid.cli)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newKey(t *testing.T) (*keys.PrivateKey, util.Uint160) {
|
||||||
|
key, err := keys.NewPrivateKey()
|
||||||
|
require.NoError(t, err)
|
||||||
|
return key, key.PublicKey().GetScriptHash()
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkAdminClient(t *testing.T, cli *client.Client, owners ...util.Uint160) {
|
||||||
|
address, isSet, err := cli.GetAdmin()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, len(owners) > 0, isSet)
|
||||||
|
if isSet {
|
||||||
|
require.Equal(t, owners[0], address)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFrostFSID_Client_SubjectManagement(t *testing.T) {
|
||||||
|
ffsid, cancel := initFrostfsIFClientTest(t)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
subjKey, subjAddr := newKey(t)
|
||||||
|
extraKey, _ := newKey(t)
|
||||||
|
subjLogin := "subj-login"
|
||||||
|
iamPathKV := "iam/path"
|
||||||
|
|
||||||
|
ffsid.a.await(ffsid.cli.CreateSubject(subjKey.PublicKey()))
|
||||||
|
ffsid.a.await(ffsid.cli.SetSubjectName(subjAddr, subjLogin))
|
||||||
|
ffsid.a.await(ffsid.cli.SetSubjectKV(subjAddr, client.IAMPathKey, iamPathKV))
|
||||||
|
ffsid.a.await(ffsid.cli.AddSubjectKey(subjAddr, extraKey.PublicKey()))
|
||||||
|
|
||||||
|
subj, err := ffsid.cli.GetSubject(subjAddr)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, subjKey.PublicKey().Equal(subj.PrimaryKey))
|
||||||
|
require.Equal(t, subj.Name, subjLogin)
|
||||||
|
require.Equal(t, map[string]string{client.IAMPathKey: iamPathKV}, subj.KV)
|
||||||
|
require.ElementsMatch(t, []*keys.PublicKey{extraKey.PublicKey()}, subj.AdditionalKeys)
|
||||||
|
|
||||||
|
ffsid.a.await(ffsid.cli.DeleteSubjectKV(subjAddr, client.IAMPathKey))
|
||||||
|
subj, err = ffsid.cli.GetSubject(subjAddr)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Empty(t, subj.KV)
|
||||||
|
|
||||||
|
subjects, err := ffsid.cli.ListSubjects()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.ElementsMatch(t, subjects, []util.Uint160{subjAddr})
|
||||||
|
|
||||||
|
subj, err = ffsid.cli.GetSubjectByKey(extraKey.PublicKey())
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, subjKey.PublicKey().Equal(subj.PrimaryKey))
|
||||||
|
|
||||||
|
ffsid.a.await(ffsid.cli.RemoveSubjectKey(subjAddr, extraKey.PublicKey()))
|
||||||
|
_, err = ffsid.cli.GetSubjectByKey(extraKey.PublicKey())
|
||||||
|
require.ErrorContains(t, err, "not found")
|
||||||
|
|
||||||
|
ffsid.a.await(ffsid.cli.DeleteSubject(subjAddr))
|
||||||
|
|
||||||
|
_, err = ffsid.cli.GetSubject(subjAddr)
|
||||||
|
require.ErrorContains(t, err, "not found")
|
||||||
|
subjects, err = ffsid.cli.ListSubjects()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Empty(t, subjects)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFrostFSID_Client_NamespaceManagement(t *testing.T) {
|
||||||
|
ffsid, cancel := initFrostfsIFClientTest(t)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
subjKey, subjAddr := newKey(t)
|
||||||
|
ffsid.a.await(ffsid.cli.CreateSubject(subjKey.PublicKey()))
|
||||||
|
|
||||||
|
namespace := "namespace"
|
||||||
|
ffsid.a.await(ffsid.cli.CreateNamespace(namespace))
|
||||||
|
_, _, err := ffsid.cli.CreateNamespace(namespace)
|
||||||
|
require.ErrorContains(t, err, "already exists")
|
||||||
|
|
||||||
|
ns, err := ffsid.cli.GetNamespace(namespace)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, namespace, ns.Name)
|
||||||
|
|
||||||
|
namespaces, err := ffsid.cli.ListNamespaces()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.ElementsMatch(t, []*client.Namespace{ns}, namespaces)
|
||||||
|
|
||||||
|
ffsid.a.await(ffsid.cli.AddSubjectToNamespace(subjAddr, namespace))
|
||||||
|
_, _, err = ffsid.cli.AddSubjectToNamespace(subjAddr, namespace)
|
||||||
|
require.ErrorContains(t, err, "already added")
|
||||||
|
|
||||||
|
subj, err := ffsid.cli.GetSubject(subjAddr)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, namespace, subj.Namespace)
|
||||||
|
|
||||||
|
subjects, err := ffsid.cli.ListNamespaceSubjects(namespace)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.ElementsMatch(t, []util.Uint160{subjAddr}, subjects)
|
||||||
|
|
||||||
|
ffsid.a.await(ffsid.cli.RemoveSubjectFromNamespace(subjAddr))
|
||||||
|
|
||||||
|
subj, err = ffsid.cli.GetSubject(subjAddr)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Empty(t, subj.Namespace)
|
||||||
|
|
||||||
|
subjects, err = ffsid.cli.ListNamespaceSubjects(namespace)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Empty(t, subjects)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFrostFSID_Client_GroupManagement(t *testing.T) {
|
||||||
|
ffsid, cancel := initFrostfsIFClientTest(t)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
subjKey, subjAddr := newKey(t)
|
||||||
|
ffsid.a.await(ffsid.cli.CreateSubject(subjKey.PublicKey()))
|
||||||
|
|
||||||
|
namespace := "namespace"
|
||||||
|
ffsid.a.await(ffsid.cli.CreateNamespace(namespace))
|
||||||
|
|
||||||
|
groupName := "group"
|
||||||
|
groupID := int64(1)
|
||||||
|
actGroupID, err := ffsid.cli.ParseGroupID(ffsid.cli.Wait(ffsid.cli.CreateGroup(namespace, groupName)))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, groupID, actGroupID)
|
||||||
|
|
||||||
|
_, _, err = ffsid.cli.CreateGroup(namespace, groupName)
|
||||||
|
require.ErrorContains(t, err, "is not available")
|
||||||
|
|
||||||
|
iamARN := "arn"
|
||||||
|
ffsid.a.await(ffsid.cli.SetGroupKV(namespace, groupID, client.IAMARNKey, iamARN))
|
||||||
|
|
||||||
|
group, err := ffsid.cli.GetGroup(namespace, groupID)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, groupName, group.Name)
|
||||||
|
require.Equal(t, map[string]string{client.IAMARNKey: iamARN}, group.KV)
|
||||||
|
|
||||||
|
ffsid.a.await(ffsid.cli.DeleteGroupKV(namespace, groupID, client.IAMARNKey))
|
||||||
|
|
||||||
|
groupExt, err := ffsid.cli.GetGroupExtended(namespace, groupID)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Zero(t, groupExt.SubjectsCount)
|
||||||
|
|
||||||
|
ffsid.a.await(ffsid.cli.AddSubjectToNamespace(subjAddr, namespace))
|
||||||
|
ffsid.a.await(ffsid.cli.AddSubjectToGroup(subjAddr, groupID))
|
||||||
|
|
||||||
|
subjExt, err := ffsid.cli.GetSubjectExtended(subjAddr)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.ElementsMatch(t, []*client.Group{{ID: groupID, Name: groupName, Namespace: namespace, KV: map[string]string{}}}, subjExt.Groups)
|
||||||
|
|
||||||
|
groupExt, err = ffsid.cli.GetGroupExtended(namespace, groupID)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.EqualValues(t, 1, groupExt.SubjectsCount)
|
||||||
|
|
||||||
|
subjects, err := ffsid.cli.ListGroupSubjects(namespace, groupID)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.ElementsMatch(t, []util.Uint160{subjAddr}, subjects)
|
||||||
|
|
||||||
|
ffsid.a.await(ffsid.cli.RemoveSubjectFromGroup(subjAddr, groupID))
|
||||||
|
|
||||||
|
subjects, err = ffsid.cli.ListGroupSubjects(namespace, groupID)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Empty(t, subjects)
|
||||||
|
|
||||||
|
subjects, err = ffsid.cli.ListNamespaceSubjects(namespace)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.ElementsMatch(t, []util.Uint160{subjAddr}, subjects)
|
||||||
|
|
||||||
|
groups, err := ffsid.cli.ListGroups(namespace)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.ElementsMatch(t, []*client.Group{{ID: groupID, Name: groupName, Namespace: namespace, KV: map[string]string{}}}, groups)
|
||||||
|
|
||||||
|
ffsid.a.await(ffsid.cli.DeleteGroup(namespace, groupID))
|
||||||
|
_, err = ffsid.cli.GetGroup(namespace, groupID)
|
||||||
|
require.ErrorContains(t, err, "not found")
|
||||||
|
|
||||||
|
groups, err = ffsid.cli.ListGroups(namespace)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Empty(t, groups)
|
||||||
|
}
|
||||||
|
|
||||||
|
type testSubject struct {
|
||||||
|
key *keys.PrivateKey
|
||||||
|
addr util.Uint160
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFrostFSID_Client_Lists(t *testing.T) {
|
||||||
|
ffsid, cancel := initFrostfsIFClientTest(t)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
namespaces := []string{"empty-ns0", "ns1", "ns2", "ns3"}
|
||||||
|
|
||||||
|
tx := ffsid.cli.StartTx()
|
||||||
|
for _, namespace := range namespaces {
|
||||||
|
err := tx.WrapCall(ffsid.cli.CreateNamespaceCall(namespace))
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
ffsid.a.await(ffsid.cli.SendTx(tx))
|
||||||
|
|
||||||
|
subjects := make([]testSubject, 10)
|
||||||
|
tx = ffsid.cli.StartTx()
|
||||||
|
for i := range subjects {
|
||||||
|
subjects[i].key, subjects[i].addr = newKey(t)
|
||||||
|
err := tx.WrapCall(ffsid.cli.CreateSubjectCall(subjects[i].key.PublicKey()))
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
ffsid.a.await(ffsid.cli.SendTx(tx))
|
||||||
|
|
||||||
|
groups := []client.Group{
|
||||||
|
{
|
||||||
|
ID: 1,
|
||||||
|
Name: "empty-group0",
|
||||||
|
Namespace: namespaces[0],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: 2,
|
||||||
|
Name: "empty-group1",
|
||||||
|
Namespace: namespaces[1],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: 3,
|
||||||
|
Name: "group2",
|
||||||
|
Namespace: namespaces[1],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: 4,
|
||||||
|
Name: "group3",
|
||||||
|
Namespace: namespaces[2],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: 5,
|
||||||
|
Name: "group4",
|
||||||
|
Namespace: namespaces[3],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: 6,
|
||||||
|
Name: "group5",
|
||||||
|
Namespace: namespaces[3],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
tx = ffsid.cli.StartTx()
|
||||||
|
for _, group := range groups[:3] {
|
||||||
|
err := tx.WrapCall(ffsid.cli.CreateGroupCall(group.Namespace, group.Name))
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
ffsid.a.await(ffsid.cli.SendTx(tx))
|
||||||
|
|
||||||
|
// we split into two tx because of gas limit exceeded error
|
||||||
|
tx = ffsid.cli.StartTx()
|
||||||
|
for _, group := range groups[3:] {
|
||||||
|
err := tx.WrapCall(ffsid.cli.CreateGroupCall(group.Namespace, group.Name))
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
ffsid.a.await(ffsid.cli.SendTx(tx))
|
||||||
|
|
||||||
|
addSubjectsToNamespaces(t, ffsid, namespaces, subjects)
|
||||||
|
addSubjectsToGroups(t, ffsid, groups, subjects)
|
||||||
|
|
||||||
|
nsList, err := ffsid.cli.ListNamespaces()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.ElementsMatch(t, []*client.Namespace{{Name: namespaces[0]}, {Name: namespaces[1]}, {Name: namespaces[2]}, {Name: namespaces[3]}}, nsList)
|
||||||
|
|
||||||
|
nonEmptyNs, err := ffsid.cli.ListNonEmptyNamespaces()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.ElementsMatch(t, namespaces[1:], nonEmptyNs)
|
||||||
|
|
||||||
|
checkNamespaceSubjects(t, ffsid.cli, namespaces[0], subjects, 0, 0)
|
||||||
|
checkNamespaceSubjects(t, ffsid.cli, namespaces[1], subjects, 0, 3)
|
||||||
|
checkNamespaceSubjects(t, ffsid.cli, namespaces[2], subjects, 3, 5)
|
||||||
|
checkNamespaceSubjects(t, ffsid.cli, namespaces[3], subjects, 5, 10)
|
||||||
|
|
||||||
|
nonEmptyGroups, err := ffsid.cli.ListNonEmptyGroups(namespaces[1])
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.ElementsMatch(t, []string{groups[2].Name}, nonEmptyGroups)
|
||||||
|
|
||||||
|
checkGroupSubjects(t, ffsid.cli, groups[0], subjects, 0, 0)
|
||||||
|
checkGroupSubjects(t, ffsid.cli, groups[1], subjects, 0, 0)
|
||||||
|
checkGroupSubjects(t, ffsid.cli, groups[2], subjects, 2, 3)
|
||||||
|
checkGroupSubjects(t, ffsid.cli, groups[3], subjects, 3, 5)
|
||||||
|
checkGroupSubjects(t, ffsid.cli, groups[4], subjects, 6, 8)
|
||||||
|
checkGroupSubjects(t, ffsid.cli, groups[5], subjects, 8, 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
func addSubjectsToNamespaces(t *testing.T, ffsid *testFrostFSIDClientInvoker, namespaces []string, subjects []testSubject) {
|
||||||
|
cli := ffsid.cli
|
||||||
|
|
||||||
|
tx := cli.StartTx()
|
||||||
|
for _, subject := range subjects[:3] {
|
||||||
|
err := tx.WrapCall(cli.AddSubjectToNamespaceCall(subject.addr, namespaces[1]))
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
ffsid.a.await(cli.SendTx(tx))
|
||||||
|
|
||||||
|
tx = cli.StartTx()
|
||||||
|
for _, subject := range subjects[3:5] {
|
||||||
|
err := tx.WrapCall(cli.AddSubjectToNamespaceCall(subject.addr, namespaces[2]))
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
ffsid.a.await(cli.SendTx(tx))
|
||||||
|
|
||||||
|
tx = cli.StartTx()
|
||||||
|
for _, subject := range subjects[5:] {
|
||||||
|
err := tx.WrapCall(cli.AddSubjectToNamespaceCall(subject.addr, namespaces[3]))
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
ffsid.a.await(cli.SendTx(tx))
|
||||||
|
}
|
||||||
|
|
||||||
|
func addSubjectsToGroups(t *testing.T, ffsid *testFrostFSIDClientInvoker, groups []client.Group, subjects []testSubject) {
|
||||||
|
cli := ffsid.cli
|
||||||
|
tx := cli.StartTx()
|
||||||
|
|
||||||
|
err := tx.WrapCall(cli.AddSubjectToGroupCall(subjects[2].addr, groups[2].ID))
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
err = tx.WrapCall(cli.AddSubjectToGroupCall(subjects[3].addr, groups[3].ID))
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = tx.WrapCall(cli.AddSubjectToGroupCall(subjects[4].addr, groups[3].ID))
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
ffsid.a.await(cli.SendTx(tx))
|
||||||
|
|
||||||
|
// we have to start new tx because of insufficient gas / gas limit exceeded error
|
||||||
|
tx = cli.StartTx()
|
||||||
|
|
||||||
|
err = tx.WrapCall(cli.AddSubjectToGroupCall(subjects[6].addr, groups[4].ID))
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = tx.WrapCall(cli.AddSubjectToGroupCall(subjects[7].addr, groups[4].ID))
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = tx.WrapCall(cli.AddSubjectToGroupCall(subjects[8].addr, groups[5].ID))
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = tx.WrapCall(cli.AddSubjectToGroupCall(subjects[9].addr, groups[5].ID))
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
ffsid.a.await(cli.SendTx(tx))
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkNamespaceSubjects(t *testing.T, cli *client.Client, ns string, subjects []testSubject, start, end int) {
|
||||||
|
nsSubjects, err := cli.ListNamespaceSubjects(ns)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.ElementsMatch(t, subjSlice(subjects, start, end), nsSubjects)
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkGroupSubjects(t *testing.T, cli *client.Client, group client.Group, subjects []testSubject, start, end int) {
|
||||||
|
groupSubjects, err := cli.ListGroupSubjects(group.Namespace, group.ID)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.ElementsMatch(t, subjSlice(subjects, start, end), groupSubjects)
|
||||||
|
}
|
||||||
|
|
||||||
|
func subjSlice(subjects []testSubject, start, end int) []util.Uint160 {
|
||||||
|
res := make([]util.Uint160, 0, end-start)
|
||||||
|
for i := start; i < end; i++ {
|
||||||
|
res = append(res, subjects[i].addr)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFrostFSID_Client_UseCaseWithS3GW(t *testing.T) {
|
||||||
|
ffsid, cancel := initFrostfsIFClientTest(t)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
namespace := "namespace"
|
||||||
|
login := "login"
|
||||||
|
dataUserKey, dataUserAddr := newKey(t)
|
||||||
|
extraDataUserKey, _ := newKey(t)
|
||||||
|
|
||||||
|
// admin
|
||||||
|
tx := ffsid.cli.StartTx()
|
||||||
|
err := tx.WrapCall(ffsid.cli.CreateNamespaceCall(namespace))
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = tx.WrapCall(ffsid.cli.CreateSubjectCall(dataUserKey.PublicKey()))
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = tx.WrapCall(ffsid.cli.SetSubjectNameCall(dataUserAddr, login))
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = tx.WrapCall(ffsid.cli.AddSubjectKeyCall(dataUserAddr, extraDataUserKey.PublicKey()))
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = tx.WrapCall(ffsid.cli.AddSubjectToNamespaceCall(dataUserAddr, namespace))
|
||||||
|
require.NoError(t, err)
|
||||||
|
ffsid.a.await(ffsid.cli.SendTx(tx))
|
||||||
|
|
||||||
|
// s3-gw
|
||||||
|
subj, err := ffsid.cli.GetSubjectByKey(extraDataUserKey.PublicKey())
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, login, subj.Name)
|
||||||
|
require.True(t, dataUserKey.PublicKey().Equal(subj.PrimaryKey))
|
||||||
|
require.Equal(t, namespace, subj.Namespace)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFrostFSID_Client_UseCaseListNSSubjects(t *testing.T) {
|
||||||
|
ffsid, cancel := initFrostfsIFClientTest(t)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
namespace := "namespace"
|
||||||
|
group := "group"
|
||||||
|
groupID := int64(1)
|
||||||
|
|
||||||
|
tx := ffsid.cli.StartTx()
|
||||||
|
err := tx.WrapCall(ffsid.cli.CreateNamespaceCall(namespace))
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = tx.WrapCall(ffsid.cli.CreateGroupCall(namespace, group))
|
||||||
|
require.NoError(t, err)
|
||||||
|
ffsid.a.await(ffsid.cli.SendTx(tx))
|
||||||
|
|
||||||
|
// admin
|
||||||
|
|
||||||
|
subjects := make([]testSubject, 5)
|
||||||
|
|
||||||
|
for i := range subjects {
|
||||||
|
tx = ffsid.cli.StartTx()
|
||||||
|
subjects[i].key, subjects[i].addr = newKey(t)
|
||||||
|
err = tx.WrapCall(ffsid.cli.CreateSubjectCall(subjects[i].key.PublicKey()))
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = tx.WrapCall(ffsid.cli.SetSubjectNameCall(subjects[i].addr, "login"+strconv.Itoa(i)))
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = tx.WrapCall(ffsid.cli.AddSubjectToNamespaceCall(subjects[i].addr, namespace))
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
if i > len(subjects)/2 {
|
||||||
|
err = tx.WrapCall(ffsid.cli.AddSubjectToGroupCall(subjects[i].addr, groupID))
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
ffsid.a.await(ffsid.cli.SendTx(tx))
|
||||||
|
}
|
||||||
|
|
||||||
|
nsSubjects, err := ffsid.cli.ListNamespaceSubjects(namespace)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
res := make([]*client.SubjectExtended, len(nsSubjects))
|
||||||
|
for i, subj := range nsSubjects {
|
||||||
|
res[i], err = ffsid.cli.GetSubjectExtended(subj)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
prettyPrintExtendedSubjects(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
func prettyPrintExtendedSubjects(subjects []*client.SubjectExtended) {
|
||||||
|
for _, subj := range subjects {
|
||||||
|
var sb strings.Builder
|
||||||
|
sb.WriteString(fmt.Sprintf("login: %s, namespace: %v, groups: [ ", subj.Name, subj.Namespace))
|
||||||
|
|
||||||
|
for _, group := range subj.Groups {
|
||||||
|
sb.WriteString(group.Namespace + ":" + group.Name + " ")
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.WriteByte(']')
|
||||||
|
fmt.Println(sb.String())
|
||||||
|
}
|
||||||
|
}
|
854
tests/frostfsid_test.go
Normal file
854
tests/frostfsid_test.go
Normal file
|
@ -0,0 +1,854 @@
|
||||||
|
package tests
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"path"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/frostfsid/client"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/interop/storage"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/vmstate"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
const frostfsidPath = "../frostfsid"
|
||||||
|
|
||||||
|
const (
|
||||||
|
setAdminMethod = "setAdmin"
|
||||||
|
getAdminMethod = "getAdmin"
|
||||||
|
clearAdminMethod = "clearAdmin"
|
||||||
|
|
||||||
|
createSubjectMethod = "createSubject"
|
||||||
|
getSubjectMethod = "getSubject"
|
||||||
|
listSubjectsMethod = "listSubjects"
|
||||||
|
addSubjectKeyMethod = "addSubjectKey"
|
||||||
|
removeSubjectKeyMethod = "removeSubjectKey"
|
||||||
|
getSubjectByKeyMethod = "getSubjectByKey"
|
||||||
|
getSubjectKeyByNameMethod = "getSubjectKeyByName"
|
||||||
|
setSubjectNameMethod = "setSubjectName"
|
||||||
|
setSubjectKVMethod = "setSubjectKV"
|
||||||
|
deleteSubjectKVMethod = "deleteSubjectKV"
|
||||||
|
deleteSubjectMethod = "deleteSubject"
|
||||||
|
|
||||||
|
createNamespaceMethod = "createNamespace"
|
||||||
|
getNamespaceMethod = "getNamespace"
|
||||||
|
getNamespaceExtendedMethod = "getNamespaceExtended"
|
||||||
|
listNamespacesMethod = "listNamespaces"
|
||||||
|
addSubjectToNamespaceMethod = "addSubjectToNamespace"
|
||||||
|
removeSubjectFromNamespaceMethod = "removeSubjectFromNamespace"
|
||||||
|
listNamespaceSubjectsMethod = "listNamespaceSubjects"
|
||||||
|
|
||||||
|
createGroupMethod = "createGroup"
|
||||||
|
getGroupMethod = "getGroup"
|
||||||
|
getGroupExtendedMethod = "getGroupExtended"
|
||||||
|
getGroupIDByNameMethod = "getGroupIDByName"
|
||||||
|
setGroupNameMethod = "setGroupName"
|
||||||
|
setGroupKVMethod = "setGroupKV"
|
||||||
|
deleteGroupKVMethod = "deleteGroupKV"
|
||||||
|
listGroupsMethod = "listGroups"
|
||||||
|
addSubjectToGroupMethod = "addSubjectToGroup"
|
||||||
|
removeSubjectFromGroupMethod = "removeSubjectFromGroup"
|
||||||
|
listGroupSubjectsMethod = "listGroupSubjects"
|
||||||
|
deleteGroupMethod = "deleteGroup"
|
||||||
|
)
|
||||||
|
|
||||||
|
const notWitnessedError = "not witnessed"
|
||||||
|
|
||||||
|
type testFrostFSIDInvoker struct {
|
||||||
|
e *neotest.Executor
|
||||||
|
contractHash util.Uint160
|
||||||
|
owner *wallet.Account
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *testFrostFSIDInvoker) OwnerInvoker() *neotest.ContractInvoker {
|
||||||
|
return f.e.NewInvoker(f.contractHash, neotest.NewSingleSigner(f.owner))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *testFrostFSIDInvoker) CommitteeInvoker() *neotest.ContractInvoker {
|
||||||
|
return f.e.CommitteeInvoker(f.contractHash)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *testFrostFSIDInvoker) AnonInvoker(t *testing.T) *neotest.ContractInvoker {
|
||||||
|
acc, err := wallet.NewAccount()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
return f.e.NewInvoker(f.contractHash, newSigner(t, f.CommitteeInvoker(), acc))
|
||||||
|
}
|
||||||
|
|
||||||
|
func newSigner(t *testing.T, c *neotest.ContractInvoker, acc *wallet.Account) neotest.Signer {
|
||||||
|
amount := int64(100_0000_0000)
|
||||||
|
|
||||||
|
tx := c.NewTx(t, []neotest.Signer{c.Validator},
|
||||||
|
c.NativeHash(t, nativenames.Gas), "transfer",
|
||||||
|
c.Validator.ScriptHash(), acc.Contract.ScriptHash(), amount, nil)
|
||||||
|
c.AddNewBlock(t, tx)
|
||||||
|
c.CheckHalt(t, tx.Hash())
|
||||||
|
return neotest.NewSingleSigner(acc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func deployFrostFSIDContract(t *testing.T, e *neotest.Executor, contractOwner util.Uint160) util.Uint160 {
|
||||||
|
args := make([]any, 5)
|
||||||
|
args[0] = contractOwner
|
||||||
|
|
||||||
|
c := neotest.CompileFile(t, e.CommitteeHash, frostfsidPath, path.Join(frostfsidPath, "config.yml"))
|
||||||
|
e.DeployContract(t, c, args)
|
||||||
|
return c.Hash
|
||||||
|
}
|
||||||
|
|
||||||
|
func newFrostFSIDInvoker(t *testing.T) *testFrostFSIDInvoker {
|
||||||
|
e := newExecutor(t)
|
||||||
|
|
||||||
|
acc, err := wallet.NewAccount()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
h := deployFrostFSIDContract(t, e, acc.ScriptHash())
|
||||||
|
|
||||||
|
newSigner(t, e.CommitteeInvoker(h), acc)
|
||||||
|
|
||||||
|
return &testFrostFSIDInvoker{
|
||||||
|
e: e,
|
||||||
|
contractHash: h,
|
||||||
|
owner: acc,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFrostFSID_ContractOwnersManagement(t *testing.T) {
|
||||||
|
f := newFrostFSIDInvoker(t)
|
||||||
|
|
||||||
|
anonInvoker := f.AnonInvoker(t)
|
||||||
|
anonInvokerHash := anonInvoker.Signers[0].ScriptHash()
|
||||||
|
invoker := f.OwnerInvoker()
|
||||||
|
invokerHash := invoker.Signers[0].ScriptHash()
|
||||||
|
committeeInvoker := f.CommitteeInvoker()
|
||||||
|
|
||||||
|
checkOwner(t, anonInvoker, invokerHash)
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, createNamespaceMethod, "namespace")
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, createNamespaceMethod, "namespace")
|
||||||
|
|
||||||
|
t.Run("setAdmin is only allowed for committee", func(t *testing.T) {
|
||||||
|
invoker.InvokeFail(t, notWitnessedError, setAdminMethod, anonInvokerHash)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("replace owner", func(t *testing.T) {
|
||||||
|
committeeInvoker.Invoke(t, stackitem.Null{}, setAdminMethod, anonInvokerHash)
|
||||||
|
checkOwner(t, anonInvoker, anonInvokerHash)
|
||||||
|
|
||||||
|
invoker.InvokeFail(t, notWitnessedError, createNamespaceMethod, "namespace2")
|
||||||
|
anonInvoker.Invoke(t, stackitem.Null{}, createNamespaceMethod, "namespace2")
|
||||||
|
})
|
||||||
|
t.Run("remove owner", func(t *testing.T) {
|
||||||
|
committeeInvoker.Invoke(t, stackitem.Null{}, clearAdminMethod)
|
||||||
|
checkOwner(t, anonInvoker)
|
||||||
|
|
||||||
|
invoker.InvokeFail(t, notWitnessedError, createNamespaceMethod, "namespace3")
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, createNamespaceMethod, "namespace3")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkOwner(t *testing.T, invoker *neotest.ContractInvoker, owner ...util.Uint160) {
|
||||||
|
if len(owner) > 1 {
|
||||||
|
require.Fail(t, "invalid testcase")
|
||||||
|
}
|
||||||
|
|
||||||
|
s, err := invoker.TestInvoke(t, getAdminMethod)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, 1, s.Len(), "unexpected number items on stack")
|
||||||
|
if len(owner) == 0 {
|
||||||
|
_, isMissing := s.Pop().Item().(stackitem.Null)
|
||||||
|
require.True(t, isMissing)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
bs, err := s.Pop().Item().TryBytes()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, bs, owner[0].BytesBE())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFrostFSID_SubjectManagement(t *testing.T) {
|
||||||
|
f := newFrostFSIDInvoker(t)
|
||||||
|
|
||||||
|
subjKey, err := keys.NewPrivateKey()
|
||||||
|
require.NoError(t, err)
|
||||||
|
subjKeyAddr := subjKey.PublicKey().GetScriptHash()
|
||||||
|
|
||||||
|
anonInvoker := f.AnonInvoker(t)
|
||||||
|
invoker := f.OwnerInvoker()
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, createSubjectMethod, subjKey.PublicKey().Bytes())
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, createSubjectMethod, subjKey.PublicKey().Bytes())
|
||||||
|
invoker.InvokeFail(t, "already exists", createSubjectMethod, subjKey.PublicKey().Bytes())
|
||||||
|
|
||||||
|
s, err := anonInvoker.TestInvoke(t, getSubjectMethod, subjKeyAddr)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
subj := parseSubject(t, s)
|
||||||
|
require.True(t, subjKey.PublicKey().Equal(&subj.PrimaryKey))
|
||||||
|
|
||||||
|
t.Run("add subject key", func(t *testing.T) {
|
||||||
|
subjNewKey, err := keys.NewPrivateKey()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, addSubjectKeyMethod, subjKeyAddr, subjNewKey.PublicKey().Bytes())
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, addSubjectKeyMethod, subjKeyAddr, subjNewKey.PublicKey().Bytes())
|
||||||
|
|
||||||
|
s, err = anonInvoker.TestInvoke(t, getSubjectMethod, subjKeyAddr)
|
||||||
|
require.NoError(t, err)
|
||||||
|
subj := parseSubject(t, s)
|
||||||
|
require.Len(t, subj.AdditionalKeys, 1)
|
||||||
|
require.True(t, subjNewKey.PublicKey().Equal(subj.AdditionalKeys[0]))
|
||||||
|
|
||||||
|
t.Run("get subject by additional key", func(t *testing.T) {
|
||||||
|
s, err = anonInvoker.TestInvoke(t, getSubjectByKeyMethod, subjNewKey.PublicKey().Bytes())
|
||||||
|
require.NoError(t, err)
|
||||||
|
subj := parseSubject(t, s)
|
||||||
|
require.True(t, subjKey.PublicKey().Equal(&subj.PrimaryKey), "keys must be the same")
|
||||||
|
|
||||||
|
s, err = anonInvoker.TestInvoke(t, getSubjectByKeyMethod, subjKey.PublicKey().Bytes())
|
||||||
|
require.NoError(t, err)
|
||||||
|
subj = parseSubject(t, s)
|
||||||
|
require.True(t, subjKey.PublicKey().Equal(&subj.PrimaryKey), "keys must be the same")
|
||||||
|
|
||||||
|
t.Run("remove subject key", func(t *testing.T) {
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, removeSubjectKeyMethod, subjKeyAddr, subjNewKey.PublicKey().Bytes())
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, removeSubjectKeyMethod, subjKeyAddr, subjNewKey.PublicKey().Bytes())
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, "not found", getSubjectByKeyMethod, subjNewKey.PublicKey().Bytes())
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("set subject name", func(t *testing.T) {
|
||||||
|
login := "some-login"
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, setSubjectNameMethod, subjKeyAddr, login)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, setSubjectNameMethod, subjKeyAddr, login)
|
||||||
|
|
||||||
|
s, err = anonInvoker.TestInvoke(t, getSubjectMethod, subjKeyAddr)
|
||||||
|
require.NoError(t, err)
|
||||||
|
subj = parseSubject(t, s)
|
||||||
|
require.Equal(t, login, subj.Name)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("set subject KVs", func(t *testing.T) {
|
||||||
|
iamPath := "iam/path"
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, setSubjectKVMethod, subjKeyAddr, client.IAMPathKey, iamPath)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, setSubjectKVMethod, subjKeyAddr, client.IAMPathKey, iamPath)
|
||||||
|
|
||||||
|
s, err = anonInvoker.TestInvoke(t, getSubjectMethod, subjKeyAddr)
|
||||||
|
require.NoError(t, err)
|
||||||
|
subj = parseSubject(t, s)
|
||||||
|
require.Equal(t, iamPath, subj.KV[client.IAMPathKey])
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, deleteSubjectKVMethod, subjKeyAddr, client.IAMPathKey)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, deleteSubjectKVMethod, subjKeyAddr, client.IAMPathKey)
|
||||||
|
|
||||||
|
s, err = anonInvoker.TestInvoke(t, getSubjectMethod, subjKeyAddr)
|
||||||
|
require.NoError(t, err)
|
||||||
|
subj = parseSubject(t, s)
|
||||||
|
require.Empty(t, subj.KV)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("list subjects", func(t *testing.T) {
|
||||||
|
newSubjKey, err := keys.NewPrivateKey()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, createSubjectMethod, newSubjKey.PublicKey().Bytes())
|
||||||
|
|
||||||
|
s, err = anonInvoker.TestInvoke(t, listSubjectsMethod)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
addresses, err := unwrap.ArrayOfUint160(makeValidRes(stackitem.NewArray(readIteratorAll(s))), nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, addresses, 2)
|
||||||
|
require.ElementsMatch(t, addresses, []util.Uint160{subjKeyAddr, newSubjKey.PublicKey().GetScriptHash()})
|
||||||
|
})
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, deleteSubjectMethod, subjKeyAddr)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, deleteSubjectMethod, subjKeyAddr)
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, "subject not found", getSubjectMethod, subjKeyAddr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFrostFSIS_SubjectNameRelatedInvariants(t *testing.T) {
|
||||||
|
f := newFrostFSIDInvoker(t)
|
||||||
|
|
||||||
|
subjName1 := "subj1"
|
||||||
|
subjKey1, err := keys.NewPrivateKey()
|
||||||
|
require.NoError(t, err)
|
||||||
|
subjKeyAddr1 := subjKey1.PublicKey().GetScriptHash()
|
||||||
|
|
||||||
|
subjName2 := "subj2"
|
||||||
|
subjKey2, err := keys.NewPrivateKey()
|
||||||
|
require.NoError(t, err)
|
||||||
|
subjKeyAddr2 := subjKey2.PublicKey().GetScriptHash()
|
||||||
|
|
||||||
|
invoker := f.OwnerInvoker()
|
||||||
|
|
||||||
|
ns1, ns2 := "ns1", "ns2"
|
||||||
|
|
||||||
|
// Create two subject (one of them with name)
|
||||||
|
// Create two namespace.
|
||||||
|
// Add these subjects to ns1
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, createSubjectMethod, subjKey1.PublicKey().Bytes())
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, setSubjectNameMethod, subjKeyAddr1, subjName1)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, createSubjectMethod, subjKey2.PublicKey().Bytes())
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, createNamespaceMethod, ns1)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, createNamespaceMethod, ns2)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, addSubjectToNamespaceMethod, subjKeyAddr1, ns1)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, addSubjectToNamespaceMethod, subjKeyAddr2, ns1)
|
||||||
|
|
||||||
|
// Check that we can find public key by name for subj1 (with name)
|
||||||
|
// and cannot find key for subj2 (without name)
|
||||||
|
s, err := invoker.TestInvoke(t, getSubjectKeyByNameMethod, ns1, subjName1)
|
||||||
|
checkPublicKeyResult(t, s, err, subjKey1)
|
||||||
|
s, err = invoker.TestInvoke(t, getSubjectKeyByNameMethod, ns1, subjName2)
|
||||||
|
checkPublicKeyResult(t, s, err, nil)
|
||||||
|
|
||||||
|
// Check that we can find public key for by name for subj2 when we set its name
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, setSubjectNameMethod, subjKeyAddr2, subjName2)
|
||||||
|
s, err = invoker.TestInvoke(t, getSubjectKeyByNameMethod, ns1, subjName2)
|
||||||
|
checkPublicKeyResult(t, s, err, subjKey2)
|
||||||
|
|
||||||
|
// Check that we cannot set for second subject name that the first subject has already taken
|
||||||
|
invoker.InvokeFail(t, "not available", setSubjectNameMethod, subjKeyAddr2, subjName1)
|
||||||
|
|
||||||
|
// Check that we cannot move subject from one namespace to another
|
||||||
|
invoker.InvokeFail(t, "cannot be moved", addSubjectToNamespaceMethod, subjKeyAddr2, ns2)
|
||||||
|
|
||||||
|
// Check that we cannot find public key by name for subject that was removed from namespace
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, removeSubjectFromNamespaceMethod, subjKeyAddr2)
|
||||||
|
s, err = invoker.TestInvoke(t, getSubjectKeyByNameMethod, ns1, subjName2)
|
||||||
|
checkPublicKeyResult(t, s, err, nil)
|
||||||
|
|
||||||
|
// Check that we can find public key by name for subject in new namespace
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, addSubjectToNamespaceMethod, subjKeyAddr2, ns2)
|
||||||
|
s, err = invoker.TestInvoke(t, getSubjectKeyByNameMethod, ns2, subjName2)
|
||||||
|
checkPublicKeyResult(t, s, err, subjKey2)
|
||||||
|
|
||||||
|
// Check that subj2 can have the same name as subj1 if they belong to different namespaces
|
||||||
|
// Also check that after subject renaming its key cannot be found by old name
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, setSubjectNameMethod, subjKeyAddr2, subjName1)
|
||||||
|
s, err = invoker.TestInvoke(t, getSubjectKeyByNameMethod, ns2, subjName1)
|
||||||
|
checkPublicKeyResult(t, s, err, subjKey2)
|
||||||
|
s, err = invoker.TestInvoke(t, getSubjectKeyByNameMethod, ns2, subjName2)
|
||||||
|
checkPublicKeyResult(t, s, err, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFrostFSIS_GroupNameRelatedInvariants(t *testing.T) {
|
||||||
|
f := newFrostFSIDInvoker(t)
|
||||||
|
|
||||||
|
groupName1, groupName2 := "group1", "group2"
|
||||||
|
groupID1, groupID2 := int64(1), int64(2)
|
||||||
|
|
||||||
|
invoker := f.OwnerInvoker()
|
||||||
|
|
||||||
|
ns1, ns2 := "ns1", "ns2"
|
||||||
|
|
||||||
|
// Create two group
|
||||||
|
// Create two namespace.
|
||||||
|
// Add these groups to ns1
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, createNamespaceMethod, ns1)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, createNamespaceMethod, ns2)
|
||||||
|
invoker.Invoke(t, stackitem.Make(groupID1), createGroupMethod, ns1, groupName1)
|
||||||
|
invoker.Invoke(t, stackitem.Make(groupID2), createGroupMethod, ns1, groupName2)
|
||||||
|
|
||||||
|
// Check that we can find group id by name for group1 in ns1 and not in ns2
|
||||||
|
s, err := invoker.TestInvoke(t, getGroupIDByNameMethod, ns1, groupName1)
|
||||||
|
checkGroupIDResult(t, s, err, groupID1)
|
||||||
|
s, err = invoker.TestInvoke(t, getGroupIDByNameMethod, ns2, groupName1)
|
||||||
|
checkGroupIDResult(t, s, err, -1)
|
||||||
|
|
||||||
|
// Check that we cannot set for second group name that the first subject has already taken
|
||||||
|
invoker.InvokeFail(t, "not available", setGroupNameMethod, ns1, groupID1, groupName2)
|
||||||
|
|
||||||
|
// Check that we cannot create group with the same name in namespace, but can in another
|
||||||
|
invoker.InvokeFail(t, "not available", createGroupMethod, ns1, groupName2)
|
||||||
|
invoker.Invoke(t, stackitem.Make(3), createGroupMethod, ns2, groupName2)
|
||||||
|
|
||||||
|
// Check that we cannot find group id by name for group that was removed
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, deleteGroupMethod, ns1, groupID2)
|
||||||
|
s, err = invoker.TestInvoke(t, getGroupIDByNameMethod, ns1, groupName2)
|
||||||
|
checkGroupIDResult(t, s, err, -1)
|
||||||
|
|
||||||
|
// Check that we can create group with the name that was freed after deleting
|
||||||
|
invoker.Invoke(t, stackitem.Make(4), createGroupMethod, ns1, groupName2)
|
||||||
|
|
||||||
|
// Check that after group renaming its id cannot be found by old name
|
||||||
|
newGroupName := "new"
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, setGroupNameMethod, ns1, groupID1, newGroupName)
|
||||||
|
s, err = invoker.TestInvoke(t, getGroupIDByNameMethod, ns1, groupName1)
|
||||||
|
checkGroupIDResult(t, s, err, -1)
|
||||||
|
s, err = invoker.TestInvoke(t, getGroupIDByNameMethod, ns1, newGroupName)
|
||||||
|
checkGroupIDResult(t, s, err, groupID1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFrostFSID_NamespaceManagement(t *testing.T) {
|
||||||
|
f := newFrostFSIDInvoker(t)
|
||||||
|
|
||||||
|
anonInvoker := f.AnonInvoker(t)
|
||||||
|
invoker := f.OwnerInvoker()
|
||||||
|
|
||||||
|
namespace := "some-namespace"
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, createNamespaceMethod, namespace)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, createNamespaceMethod, namespace)
|
||||||
|
invoker.InvokeFail(t, "already exists", createNamespaceMethod, namespace)
|
||||||
|
|
||||||
|
s, err := anonInvoker.TestInvoke(t, getNamespaceMethod, namespace)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
ns := parseNamespace(t, s.Pop().Item())
|
||||||
|
require.Equal(t, namespace, ns.Name)
|
||||||
|
|
||||||
|
t.Run("add user to namespace", func(t *testing.T) {
|
||||||
|
subjKey, err := keys.NewPrivateKey()
|
||||||
|
require.NoError(t, err)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, createSubjectMethod, subjKey.PublicKey().Bytes())
|
||||||
|
|
||||||
|
subjName := "name"
|
||||||
|
subjAddress := subjKey.PublicKey().GetScriptHash()
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, setSubjectNameMethod, subjAddress, subjName)
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, addSubjectToNamespaceMethod, subjAddress, namespace)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, addSubjectToNamespaceMethod, subjAddress, namespace)
|
||||||
|
invoker.InvokeFail(t, "already added", addSubjectToNamespaceMethod, subjAddress, namespace)
|
||||||
|
|
||||||
|
s, err := anonInvoker.TestInvoke(t, getSubjectMethod, subjAddress)
|
||||||
|
require.NoError(t, err)
|
||||||
|
subj := parseSubject(t, s)
|
||||||
|
require.Equal(t, namespace, subj.Namespace)
|
||||||
|
|
||||||
|
t.Run("list namespace subjects", func(t *testing.T) {
|
||||||
|
s, err := anonInvoker.TestInvoke(t, listNamespaceSubjectsMethod, namespace)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
addresses, err := unwrap.ArrayOfUint160(makeValidRes(stackitem.NewArray(readIteratorAll(s))), nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.ElementsMatch(t, addresses, []util.Uint160{subjAddress})
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("get subject key by name", func(t *testing.T) {
|
||||||
|
s, err := anonInvoker.TestInvoke(t, getSubjectKeyByNameMethod, namespace, subjName)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
foundKey, err := unwrap.PublicKey(makeValidRes(s.Pop().Item()), nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, subjKey.PublicKey(), foundKey)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("list namespaces", func(t *testing.T) {
|
||||||
|
namespace2 := "some-namespace2"
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, createNamespaceMethod, namespace2)
|
||||||
|
|
||||||
|
s, err := anonInvoker.TestInvoke(t, listNamespacesMethod)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
namespaces := parseNamespaces(t, readIteratorAll(s))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.ElementsMatch(t, namespaces, []Namespace{{Name: namespace}, {Name: namespace2}})
|
||||||
|
|
||||||
|
t.Run("find namespaces with some subjects", func(t *testing.T) {
|
||||||
|
for _, ns := range namespaces {
|
||||||
|
s, err := anonInvoker.TestInvoke(t, getNamespaceExtendedMethod, ns.Name)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
nsExt := parseNamespaceExtended(t, s.Pop().Item())
|
||||||
|
if nsExt.SubjectsCount > 0 {
|
||||||
|
require.Equal(t, namespace, nsExt.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run("remove subject from namespace", func(t *testing.T) {
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, removeSubjectFromNamespaceMethod, subjAddress)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, removeSubjectFromNamespaceMethod, subjAddress)
|
||||||
|
|
||||||
|
s, err := anonInvoker.TestInvoke(t, getSubjectMethod, subjAddress)
|
||||||
|
require.NoError(t, err)
|
||||||
|
subj := parseSubject(t, s)
|
||||||
|
require.Empty(t, subj.Namespace)
|
||||||
|
|
||||||
|
s, err = anonInvoker.TestInvoke(t, getNamespaceExtendedMethod, namespace)
|
||||||
|
require.NoError(t, err)
|
||||||
|
nsExt := parseNamespaceExtended(t, s.Pop().Item())
|
||||||
|
require.Zero(t, nsExt.SubjectsCount)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFrostFSID_GroupManagement(t *testing.T) {
|
||||||
|
f := newFrostFSIDInvoker(t)
|
||||||
|
|
||||||
|
anonInvoker := f.AnonInvoker(t)
|
||||||
|
invoker := f.OwnerInvoker()
|
||||||
|
|
||||||
|
nsName := "namespace"
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, createNamespaceMethod, nsName)
|
||||||
|
|
||||||
|
groupID := int64(1)
|
||||||
|
groupName := "group"
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, createGroupMethod, nsName, groupName)
|
||||||
|
invoker.Invoke(t, stackitem.Make(groupID), createGroupMethod, nsName, groupName)
|
||||||
|
|
||||||
|
s, err := anonInvoker.TestInvoke(t, getGroupMethod, nsName, groupID)
|
||||||
|
require.NoError(t, err)
|
||||||
|
group := parseGroup(t, s.Pop().Item())
|
||||||
|
require.Equal(t, groupID, group.ID)
|
||||||
|
require.Equal(t, groupName, group.Name)
|
||||||
|
|
||||||
|
s, err = anonInvoker.TestInvoke(t, listGroupsMethod, nsName)
|
||||||
|
require.NoError(t, err)
|
||||||
|
groups := parseGroups(t, readIteratorAll(s))
|
||||||
|
require.ElementsMatch(t, groups, []Group{{ID: groupID, Name: groupName, Namespace: nsName}})
|
||||||
|
|
||||||
|
t.Run("add subjects to group", func(t *testing.T) {
|
||||||
|
subjKey, err := keys.NewPrivateKey()
|
||||||
|
require.NoError(t, err)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, createSubjectMethod, subjKey.PublicKey().Bytes())
|
||||||
|
|
||||||
|
subjAddress := subjKey.PublicKey().GetScriptHash()
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, addSubjectToNamespaceMethod, subjAddress, nsName)
|
||||||
|
anonInvoker.InvokeFail(t, "not witnessed", addSubjectToGroupMethod, subjAddress, groupID)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, addSubjectToGroupMethod, subjAddress, groupID)
|
||||||
|
|
||||||
|
t.Run("list group subjects", func(t *testing.T) {
|
||||||
|
s, err = anonInvoker.TestInvoke(t, listGroupSubjectsMethod, nsName, groupID)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
addresses, err := unwrap.ArrayOfUint160(makeValidRes(stackitem.NewArray(readIteratorAll(s))), nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.ElementsMatch(t, addresses, []util.Uint160{subjAddress})
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, "not witnessed", removeSubjectFromGroupMethod, subjAddress, groupID)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, removeSubjectFromGroupMethod, subjAddress, groupID)
|
||||||
|
|
||||||
|
s, err = anonInvoker.TestInvoke(t, listGroupSubjectsMethod, nsName, groupID)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
addresses, err = unwrap.ArrayOfUint160(makeValidRes(stackitem.NewArray(readIteratorAll(s))), nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Empty(t, addresses)
|
||||||
|
|
||||||
|
t.Run("get group extended", func(t *testing.T) {
|
||||||
|
subjectsCount := 10
|
||||||
|
for i := 0; i < subjectsCount; i++ {
|
||||||
|
subjKey, err := keys.NewPrivateKey()
|
||||||
|
require.NoError(t, err)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, createSubjectMethod, subjKey.PublicKey().Bytes())
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, addSubjectToNamespaceMethod, subjKey.PublicKey().GetScriptHash(), nsName)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, addSubjectToGroupMethod, subjKey.PublicKey().GetScriptHash(), groupID)
|
||||||
|
}
|
||||||
|
|
||||||
|
s, err = anonInvoker.TestInvoke(t, getGroupExtendedMethod, nsName, groupID)
|
||||||
|
require.NoError(t, err)
|
||||||
|
groupExt := parseGroupExtended(t, s.Pop().Item())
|
||||||
|
require.Equal(t, groupID, groupExt.ID)
|
||||||
|
require.Equal(t, groupName, groupExt.Name)
|
||||||
|
require.Empty(t, groupExt.KV)
|
||||||
|
require.EqualValues(t, subjectsCount, groupExt.SubjectsCount)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("set group name", func(t *testing.T) {
|
||||||
|
newGroupName := "new-name"
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, setGroupNameMethod, nsName, groupID, newGroupName)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, setGroupNameMethod, nsName, groupID, newGroupName)
|
||||||
|
|
||||||
|
s, err = anonInvoker.TestInvoke(t, getGroupIDByNameMethod, nsName, newGroupName)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, groupID, s.Pop().BigInt().Int64())
|
||||||
|
|
||||||
|
s, err = anonInvoker.TestInvoke(t, getGroupMethod, nsName, groupID)
|
||||||
|
require.NoError(t, err)
|
||||||
|
group = parseGroup(t, s.Pop().Item())
|
||||||
|
require.Equal(t, newGroupName, group.Name)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("set group KVs", func(t *testing.T) {
|
||||||
|
iamARN := "arn"
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, setGroupKVMethod, nsName, groupID, client.IAMARNKey, iamARN)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, setGroupKVMethod, nsName, groupID, client.IAMARNKey, iamARN)
|
||||||
|
|
||||||
|
s, err = anonInvoker.TestInvoke(t, getGroupMethod, nsName, groupID)
|
||||||
|
require.NoError(t, err)
|
||||||
|
group = parseGroup(t, s.Pop().Item())
|
||||||
|
require.Equal(t, iamARN, group.KV[client.IAMARNKey])
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, deleteGroupKVMethod, nsName, groupID, client.IAMARNKey)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, deleteGroupKVMethod, nsName, groupID, client.IAMARNKey)
|
||||||
|
|
||||||
|
s, err = anonInvoker.TestInvoke(t, getGroupMethod, nsName, groupID)
|
||||||
|
require.NoError(t, err)
|
||||||
|
group = parseGroup(t, s.Pop().Item())
|
||||||
|
require.Empty(t, group.KV)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("delete group", func(t *testing.T) {
|
||||||
|
anonInvoker.InvokeFail(t, notWitnessedError, deleteGroupMethod, nsName, groupID)
|
||||||
|
invoker.Invoke(t, stackitem.Null{}, deleteGroupMethod, nsName, groupID)
|
||||||
|
|
||||||
|
anonInvoker.InvokeFail(t, "group not found", getGroupMethod, nsName, groupID)
|
||||||
|
|
||||||
|
s, err = anonInvoker.TestInvoke(t, listGroupsMethod, nsName)
|
||||||
|
require.NoError(t, err)
|
||||||
|
groups := parseGroups(t, readIteratorAll(s))
|
||||||
|
require.Empty(t, groups)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkPublicKeyResult(t *testing.T, s *vm.Stack, err error, key *keys.PrivateKey) {
|
||||||
|
if key == nil {
|
||||||
|
require.ErrorContains(t, err, "not found")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(t, err)
|
||||||
|
foundKey, err := unwrap.PublicKey(makeValidRes(s.Pop().Item()), nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, key.PublicKey(), foundKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkGroupIDResult(t *testing.T, s *vm.Stack, err error, groupID int64) {
|
||||||
|
if groupID == -1 {
|
||||||
|
require.ErrorContains(t, err, "not found")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(t, err)
|
||||||
|
foundGroupID, err := unwrap.Int64(makeValidRes(s.Pop().Item()), nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, groupID, foundGroupID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func readIteratorAll(s *vm.Stack) []stackitem.Item {
|
||||||
|
iter := s.Pop().Value().(*storage.Iterator)
|
||||||
|
|
||||||
|
stackItems := make([]stackitem.Item, 0)
|
||||||
|
for iter.Next() {
|
||||||
|
stackItems = append(stackItems, iter.Value())
|
||||||
|
}
|
||||||
|
|
||||||
|
return stackItems
|
||||||
|
}
|
||||||
|
|
||||||
|
type Subject struct {
|
||||||
|
PrimaryKey keys.PublicKey
|
||||||
|
AdditionalKeys keys.PublicKeys
|
||||||
|
Namespace string
|
||||||
|
Name string
|
||||||
|
KV map[string]string
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseSubject(t *testing.T, s *vm.Stack) Subject {
|
||||||
|
var subj Subject
|
||||||
|
|
||||||
|
subjStruct := s.Pop().Array()
|
||||||
|
require.Len(t, subjStruct, 5)
|
||||||
|
|
||||||
|
pkBytes, err := subjStruct[0].TryBytes()
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = subj.PrimaryKey.DecodeBytes(pkBytes)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
if !subjStruct[1].Equals(stackitem.Null{}) {
|
||||||
|
subj.AdditionalKeys, err = unwrap.ArrayOfPublicKeys(makeValidRes(subjStruct[1]), nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
nsBytes, err := subjStruct[2].TryBytes()
|
||||||
|
require.NoError(t, err)
|
||||||
|
subj.Namespace = string(nsBytes)
|
||||||
|
|
||||||
|
nameBytes, err := subjStruct[3].TryBytes()
|
||||||
|
require.NoError(t, err)
|
||||||
|
subj.Name = string(nameBytes)
|
||||||
|
|
||||||
|
subj.KV, err = parseMap(subjStruct[4])
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
return subj
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseMap(item stackitem.Item) (map[string]string, error) {
|
||||||
|
if item.Equals(stackitem.Null{}) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
metaMap, err := unwrap.Map(makeValidRes(item), nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
meta, ok := metaMap.Value().([]stackitem.MapElement)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("invalid map type")
|
||||||
|
}
|
||||||
|
|
||||||
|
res := make(map[string]string, len(meta))
|
||||||
|
for _, element := range meta {
|
||||||
|
key, err := element.Key.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
val, err := element.Value.TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
res[string(key)] = string(val)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type Namespace struct {
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
type NamespaceExtended struct {
|
||||||
|
Name string
|
||||||
|
SubjectsCount int64
|
||||||
|
GroupsCount int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseNamespace(t *testing.T, item stackitem.Item) Namespace {
|
||||||
|
var ns Namespace
|
||||||
|
|
||||||
|
subjStruct := item.Value().([]stackitem.Item)
|
||||||
|
require.Len(t, subjStruct, 1)
|
||||||
|
|
||||||
|
nameBytes, err := subjStruct[0].TryBytes()
|
||||||
|
require.NoError(t, err)
|
||||||
|
ns.Name = string(nameBytes)
|
||||||
|
|
||||||
|
return ns
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseNamespaceExtended(t *testing.T, item stackitem.Item) NamespaceExtended {
|
||||||
|
var ns NamespaceExtended
|
||||||
|
|
||||||
|
subjStruct := item.Value().([]stackitem.Item)
|
||||||
|
require.Len(t, subjStruct, 3)
|
||||||
|
|
||||||
|
nameBytes, err := subjStruct[0].TryBytes()
|
||||||
|
require.NoError(t, err)
|
||||||
|
ns.Name = string(nameBytes)
|
||||||
|
|
||||||
|
groupCountInt, err := subjStruct[1].TryInteger()
|
||||||
|
require.NoError(t, err)
|
||||||
|
ns.GroupsCount = groupCountInt.Int64()
|
||||||
|
|
||||||
|
subjectsCountInt, err := subjStruct[2].TryInteger()
|
||||||
|
require.NoError(t, err)
|
||||||
|
ns.SubjectsCount = subjectsCountInt.Int64()
|
||||||
|
|
||||||
|
return ns
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseNamespaces(t *testing.T, items []stackitem.Item) []Namespace {
|
||||||
|
res := make([]Namespace, len(items))
|
||||||
|
|
||||||
|
for i := 0; i < len(items); i++ {
|
||||||
|
res[i] = parseNamespace(t, items[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
type Group struct {
|
||||||
|
ID int64
|
||||||
|
Name string
|
||||||
|
Namespace string
|
||||||
|
KV map[string]string
|
||||||
|
}
|
||||||
|
|
||||||
|
type GroupExtended struct {
|
||||||
|
ID int64
|
||||||
|
Name string
|
||||||
|
Namespace string
|
||||||
|
KV map[string]string
|
||||||
|
SubjectsCount int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseGroup(t *testing.T, item stackitem.Item) Group {
|
||||||
|
var group Group
|
||||||
|
|
||||||
|
subjStruct := item.Value().([]stackitem.Item)
|
||||||
|
require.Len(t, subjStruct, 4)
|
||||||
|
|
||||||
|
groupID, err := subjStruct[0].TryInteger()
|
||||||
|
require.NoError(t, err)
|
||||||
|
group.ID = groupID.Int64()
|
||||||
|
|
||||||
|
nameBytes, err := subjStruct[1].TryBytes()
|
||||||
|
require.NoError(t, err)
|
||||||
|
group.Name = string(nameBytes)
|
||||||
|
|
||||||
|
namespaceBytes, err := subjStruct[2].TryBytes()
|
||||||
|
require.NoError(t, err)
|
||||||
|
group.Namespace = string(namespaceBytes)
|
||||||
|
|
||||||
|
group.KV, err = parseMap(subjStruct[3])
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
return group
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseGroupExtended(t *testing.T, item stackitem.Item) GroupExtended {
|
||||||
|
var gr GroupExtended
|
||||||
|
|
||||||
|
subjStruct := item.Value().([]stackitem.Item)
|
||||||
|
require.Len(t, subjStruct, 5)
|
||||||
|
|
||||||
|
groupID, err := subjStruct[0].TryInteger()
|
||||||
|
require.NoError(t, err)
|
||||||
|
gr.ID = groupID.Int64()
|
||||||
|
|
||||||
|
nameBytes, err := subjStruct[1].TryBytes()
|
||||||
|
require.NoError(t, err)
|
||||||
|
gr.Name = string(nameBytes)
|
||||||
|
|
||||||
|
namespaceBytes, err := subjStruct[2].TryBytes()
|
||||||
|
require.NoError(t, err)
|
||||||
|
gr.Namespace = string(namespaceBytes)
|
||||||
|
|
||||||
|
gr.KV, err = parseMap(subjStruct[3])
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
subjectsCountInt, err := subjStruct[4].TryInteger()
|
||||||
|
require.NoError(t, err)
|
||||||
|
gr.SubjectsCount = subjectsCountInt.Int64()
|
||||||
|
|
||||||
|
return gr
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseGroups(t *testing.T, items []stackitem.Item) []Group {
|
||||||
|
res := make([]Group, len(items))
|
||||||
|
|
||||||
|
for i := 0; i < len(items); i++ {
|
||||||
|
res[i] = parseGroup(t, items[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeValidRes(item stackitem.Item) *result.Invoke {
|
||||||
|
return &result.Invoke{
|
||||||
|
Stack: []stackitem.Item{item},
|
||||||
|
State: vmstate.Halt.String(),
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,113 +0,0 @@
|
||||||
package tests
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"path"
|
|
||||||
"sort"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/mr-tron/base58"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
|
||||||
"github.com/nspcc-dev/neofs-contract/container"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
|
||||||
|
|
||||||
const neofsidPath = "../neofsid"
|
|
||||||
|
|
||||||
func deployNeoFSIDContract(t *testing.T, e *neotest.Executor, addrNetmap, addrContainer util.Uint160) util.Uint160 {
|
|
||||||
args := make([]interface{}, 5)
|
|
||||||
args[0] = false
|
|
||||||
args[1] = addrNetmap
|
|
||||||
args[2] = addrContainer
|
|
||||||
|
|
||||||
c := neotest.CompileFile(t, e.CommitteeHash, neofsidPath, path.Join(neofsidPath, "config.yml"))
|
|
||||||
e.DeployContract(t, c, args)
|
|
||||||
return c.Hash
|
|
||||||
}
|
|
||||||
|
|
||||||
func newNeoFSIDInvoker(t *testing.T) *neotest.ContractInvoker {
|
|
||||||
e := newExecutor(t)
|
|
||||||
|
|
||||||
ctrNNS := neotest.CompileFile(t, e.CommitteeHash, nnsPath, path.Join(nnsPath, "config.yml"))
|
|
||||||
ctrNetmap := neotest.CompileFile(t, e.CommitteeHash, netmapPath, path.Join(netmapPath, "config.yml"))
|
|
||||||
ctrBalance := neotest.CompileFile(t, e.CommitteeHash, balancePath, path.Join(balancePath, "config.yml"))
|
|
||||||
ctrContainer := neotest.CompileFile(t, e.CommitteeHash, containerPath, path.Join(containerPath, "config.yml"))
|
|
||||||
|
|
||||||
e.DeployContract(t, ctrNNS, nil)
|
|
||||||
deployNetmapContract(t, e, ctrBalance.Hash, ctrContainer.Hash,
|
|
||||||
container.RegistrationFeeKey, int64(containerFee),
|
|
||||||
container.AliasFeeKey, int64(containerAliasFee))
|
|
||||||
deployBalanceContract(t, e, ctrNetmap.Hash, ctrContainer.Hash)
|
|
||||||
deployContainerContract(t, e, ctrNetmap.Hash, ctrBalance.Hash, ctrNNS.Hash)
|
|
||||||
h := deployNeoFSIDContract(t, e, ctrNetmap.Hash, ctrContainer.Hash)
|
|
||||||
return e.CommitteeInvoker(h)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNeoFSID_AddKey(t *testing.T) {
|
|
||||||
e := newNeoFSIDInvoker(t)
|
|
||||||
|
|
||||||
pubs := make([][]byte, 6)
|
|
||||||
for i := range pubs {
|
|
||||||
p, err := keys.NewPrivateKey()
|
|
||||||
require.NoError(t, err)
|
|
||||||
pubs[i] = p.PublicKey().Bytes()
|
|
||||||
}
|
|
||||||
acc := e.NewAccount(t)
|
|
||||||
owner, _ := base58.Decode(address.Uint160ToString(acc.ScriptHash()))
|
|
||||||
e.Invoke(t, stackitem.Null{}, "addKey", owner,
|
|
||||||
[]interface{}{pubs[0], pubs[1]})
|
|
||||||
|
|
||||||
sort.Slice(pubs[:2], func(i, j int) bool {
|
|
||||||
return bytes.Compare(pubs[i], pubs[j]) == -1
|
|
||||||
})
|
|
||||||
arr := []stackitem.Item{
|
|
||||||
stackitem.NewBuffer(pubs[0]),
|
|
||||||
stackitem.NewBuffer(pubs[1]),
|
|
||||||
}
|
|
||||||
e.Invoke(t, stackitem.NewArray(arr), "key", owner)
|
|
||||||
|
|
||||||
t.Run("multiple addKey per block", func(t *testing.T) {
|
|
||||||
tx1 := e.PrepareInvoke(t, "addKey", owner, []interface{}{pubs[2]})
|
|
||||||
tx2 := e.PrepareInvoke(t, "addKey", owner, []interface{}{pubs[3], pubs[4]})
|
|
||||||
e.AddNewBlock(t, tx1, tx2)
|
|
||||||
e.CheckHalt(t, tx1.Hash(), stackitem.Null{})
|
|
||||||
e.CheckHalt(t, tx2.Hash(), stackitem.Null{})
|
|
||||||
|
|
||||||
sort.Slice(pubs[:5], func(i, j int) bool {
|
|
||||||
return bytes.Compare(pubs[i], pubs[j]) == -1
|
|
||||||
})
|
|
||||||
arr = []stackitem.Item{
|
|
||||||
stackitem.NewBuffer(pubs[0]),
|
|
||||||
stackitem.NewBuffer(pubs[1]),
|
|
||||||
stackitem.NewBuffer(pubs[2]),
|
|
||||||
stackitem.NewBuffer(pubs[3]),
|
|
||||||
stackitem.NewBuffer(pubs[4]),
|
|
||||||
}
|
|
||||||
e.Invoke(t, stackitem.NewArray(arr), "key", owner)
|
|
||||||
})
|
|
||||||
|
|
||||||
e.Invoke(t, stackitem.Null{}, "removeKey", owner,
|
|
||||||
[]interface{}{pubs[1], pubs[5]})
|
|
||||||
arr = []stackitem.Item{
|
|
||||||
stackitem.NewBuffer(pubs[0]),
|
|
||||||
stackitem.NewBuffer(pubs[2]),
|
|
||||||
stackitem.NewBuffer(pubs[3]),
|
|
||||||
stackitem.NewBuffer(pubs[4]),
|
|
||||||
}
|
|
||||||
e.Invoke(t, stackitem.NewArray(arr), "key", owner)
|
|
||||||
|
|
||||||
t.Run("multiple removeKey per block", func(t *testing.T) {
|
|
||||||
tx1 := e.PrepareInvoke(t, "removeKey", owner, []interface{}{pubs[2]})
|
|
||||||
tx2 := e.PrepareInvoke(t, "removeKey", owner, []interface{}{pubs[0], pubs[4]})
|
|
||||||
e.AddNewBlock(t, tx1, tx2)
|
|
||||||
e.CheckHalt(t, tx1.Hash(), stackitem.Null{})
|
|
||||||
e.CheckHalt(t, tx2.Hash(), stackitem.Null{})
|
|
||||||
|
|
||||||
arr = []stackitem.Item{stackitem.NewBuffer(pubs[3])}
|
|
||||||
e.Invoke(t, stackitem.NewArray(arr), "key", owner)
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -7,36 +7,35 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/container"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/netmap"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/bigint"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/bigint"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
"github.com/nspcc-dev/neofs-contract/common"
|
|
||||||
"github.com/nspcc-dev/neofs-contract/container"
|
|
||||||
"github.com/nspcc-dev/neofs-contract/netmap"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
const netmapPath = "../netmap"
|
const netmapPath = "../netmap"
|
||||||
|
|
||||||
func deployNetmapContract(t *testing.T, e *neotest.Executor, addrBalance, addrContainer util.Uint160, config ...interface{}) util.Uint160 {
|
func deployNetmapContract(t *testing.T, e *neotest.Executor, addrBalance, addrContainer util.Uint160, config ...any) util.Uint160 {
|
||||||
_, pubs, ok := vm.ParseMultiSigContract(e.Committee.Script())
|
_, pubs, ok := vm.ParseMultiSigContract(e.Committee.Script())
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
args := make([]interface{}, 5)
|
args := make([]any, 4)
|
||||||
args[0] = false
|
args[0] = addrBalance
|
||||||
args[1] = addrBalance
|
args[1] = addrContainer
|
||||||
args[2] = addrContainer
|
args[2] = []any{pubs[0]}
|
||||||
args[3] = []interface{}{pubs[0]}
|
args[3] = append([]any{}, config...)
|
||||||
args[4] = append([]interface{}{}, config...)
|
|
||||||
|
|
||||||
c := neotest.CompileFile(t, e.CommitteeHash, netmapPath, path.Join(netmapPath, "config.yml"))
|
c := neotest.CompileFile(t, e.CommitteeHash, netmapPath, path.Join(netmapPath, "config.yml"))
|
||||||
e.DeployContract(t, c, args)
|
e.DeployContract(t, c, args)
|
||||||
return c.Hash
|
return c.Hash
|
||||||
}
|
}
|
||||||
|
|
||||||
func newNetmapInvoker(t *testing.T, config ...interface{}) *neotest.ContractInvoker {
|
func newNetmapInvoker(t *testing.T, config ...any) *neotest.ContractInvoker {
|
||||||
e := newExecutor(t)
|
e := newExecutor(t)
|
||||||
|
|
||||||
ctrNNS := neotest.CompileFile(t, e.CommitteeHash, nnsPath, path.Join(nnsPath, "config.yml"))
|
ctrNNS := neotest.CompileFile(t, e.CommitteeHash, nnsPath, path.Join(nnsPath, "config.yml"))
|
||||||
|
|
|
@ -8,10 +8,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/core/interop/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
"github.com/nspcc-dev/neofs-contract/nns"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ func newNNSInvoker(t *testing.T, addRoot bool) *neotest.ContractInvoker {
|
||||||
refresh, retry, expire, ttl := int64(101), int64(102), int64(msPerYear/1000*100), int64(104)
|
refresh, retry, expire, ttl := int64(101), int64(102), int64(msPerYear/1000*100), int64(104)
|
||||||
c.Invoke(t, true, "register",
|
c.Invoke(t, true, "register",
|
||||||
"com", c.CommitteeHash,
|
"com", c.CommitteeHash,
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
@ -50,21 +50,21 @@ func TestNNSRegisterTLD(t *testing.T) {
|
||||||
|
|
||||||
c.InvokeFail(t, "invalid domain name format", "register",
|
c.InvokeFail(t, "invalid domain name format", "register",
|
||||||
"0com", c.CommitteeHash,
|
"0com", c.CommitteeHash,
|
||||||
"email@nspcc.ru", refresh, retry, expire, ttl)
|
"email@frostfs.info", refresh, retry, expire, ttl)
|
||||||
|
|
||||||
acc := c.NewAccount(t)
|
acc := c.NewAccount(t)
|
||||||
cAcc := c.WithSigners(acc)
|
cAcc := c.WithSigners(acc)
|
||||||
cAcc.InvokeFail(t, "not witnessed by committee", "register",
|
cAcc.InvokeFail(t, "not witnessed by committee", "register",
|
||||||
"com", acc.ScriptHash(),
|
"com", acc.ScriptHash(),
|
||||||
"email@nspcc.ru", refresh, retry, expire, ttl)
|
"email@frostfs.info", refresh, retry, expire, ttl)
|
||||||
|
|
||||||
c.Invoke(t, true, "register",
|
c.Invoke(t, true, "register",
|
||||||
"com", c.CommitteeHash,
|
"com", c.CommitteeHash,
|
||||||
"email@nspcc.ru", refresh, retry, expire, ttl)
|
"email@frostfs.info", refresh, retry, expire, ttl)
|
||||||
|
|
||||||
c.InvokeFail(t, "TLD already exists", "register",
|
c.InvokeFail(t, "TLD already exists", "register",
|
||||||
"com", c.CommitteeHash,
|
"com", c.CommitteeHash,
|
||||||
"email@nspcc.ru", refresh, retry, expire, ttl)
|
"email@frostfs.info", refresh, retry, expire, ttl)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNNSRegister(t *testing.T) {
|
func TestNNSRegister(t *testing.T) {
|
||||||
|
@ -75,33 +75,33 @@ func TestNNSRegister(t *testing.T) {
|
||||||
c1 := c.WithSigners(c.Committee, accTop)
|
c1 := c.WithSigners(c.Committee, accTop)
|
||||||
c1.Invoke(t, true, "register",
|
c1.Invoke(t, true, "register",
|
||||||
"com", accTop.ScriptHash(),
|
"com", accTop.ScriptHash(),
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
|
|
||||||
acc := c.NewAccount(t)
|
acc := c.NewAccount(t)
|
||||||
c2 := c.WithSigners(c.Committee, acc)
|
c2 := c.WithSigners(c.Committee, acc)
|
||||||
c2.InvokeFail(t, "not witnessed by admin", "register",
|
c2.InvokeFail(t, "not witnessed by admin", "register",
|
||||||
"testdomain.com", acc.ScriptHash(),
|
"testdomain.com", acc.ScriptHash(),
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
|
|
||||||
c3 := c.WithSigners(accTop, acc)
|
c3 := c.WithSigners(accTop, acc)
|
||||||
t.Run("domain names with hyphen", func(t *testing.T) {
|
t.Run("domain names with hyphen", func(t *testing.T) {
|
||||||
c3.InvokeFail(t, "invalid domain name format", "register",
|
c3.InvokeFail(t, "invalid domain name format", "register",
|
||||||
"-testdomain.com", acc.ScriptHash(),
|
"-testdomain.com", acc.ScriptHash(),
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
c3.InvokeFail(t, "invalid domain name format", "register",
|
c3.InvokeFail(t, "invalid domain name format", "register",
|
||||||
"testdomain-.com", acc.ScriptHash(),
|
"testdomain-.com", acc.ScriptHash(),
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
c3.Invoke(t, true, "register",
|
c3.Invoke(t, true, "register",
|
||||||
"test-domain.com", acc.ScriptHash(),
|
"test-domain.com", acc.ScriptHash(),
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
})
|
})
|
||||||
c3.Invoke(t, true, "register",
|
c3.Invoke(t, true, "register",
|
||||||
"testdomain.com", acc.ScriptHash(),
|
"testdomain.com", acc.ScriptHash(),
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
|
|
||||||
b := c.TopBlock(t)
|
b := c.TopBlock(t)
|
||||||
expected := stackitem.NewArray([]stackitem.Item{stackitem.NewBuffer(
|
expected := stackitem.NewArray([]stackitem.Item{stackitem.NewBuffer(
|
||||||
[]byte(fmt.Sprintf("testdomain.com myemail@nspcc.ru %d %d %d %d %d",
|
[]byte(fmt.Sprintf("testdomain.com myemail@frostfs.info %d %d %d %d %d",
|
||||||
b.Timestamp, refresh, retry, expire, ttl)))})
|
b.Timestamp, refresh, retry, expire, ttl)))})
|
||||||
c.Invoke(t, expected, "getRecords", "testdomain.com", int64(nns.SOA))
|
c.Invoke(t, expected, "getRecords", "testdomain.com", int64(nns.SOA))
|
||||||
|
|
||||||
|
@ -115,7 +115,8 @@ func TestNNSRegister(t *testing.T) {
|
||||||
|
|
||||||
expected = stackitem.NewArray([]stackitem.Item{
|
expected = stackitem.NewArray([]stackitem.Item{
|
||||||
stackitem.NewByteArray([]byte("first TXT record")),
|
stackitem.NewByteArray([]byte("first TXT record")),
|
||||||
stackitem.NewByteArray([]byte("second TXT record"))})
|
stackitem.NewByteArray([]byte("second TXT record")),
|
||||||
|
})
|
||||||
c.Invoke(t, expected, "getRecords", "testdomain.com", int64(nns.TXT))
|
c.Invoke(t, expected, "getRecords", "testdomain.com", int64(nns.TXT))
|
||||||
|
|
||||||
cAcc.Invoke(t, stackitem.Null{}, "setRecord",
|
cAcc.Invoke(t, stackitem.Null{}, "setRecord",
|
||||||
|
@ -123,7 +124,8 @@ func TestNNSRegister(t *testing.T) {
|
||||||
|
|
||||||
expected = stackitem.NewArray([]stackitem.Item{
|
expected = stackitem.NewArray([]stackitem.Item{
|
||||||
stackitem.NewByteArray([]byte("replaced first")),
|
stackitem.NewByteArray([]byte("replaced first")),
|
||||||
stackitem.NewByteArray([]byte("second TXT record"))})
|
stackitem.NewByteArray([]byte("second TXT record")),
|
||||||
|
})
|
||||||
c.Invoke(t, expected, "getRecords", "testdomain.com", int64(nns.TXT))
|
c.Invoke(t, expected, "getRecords", "testdomain.com", int64(nns.TXT))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,8 +141,8 @@ func TestTLDRecord(t *testing.T) {
|
||||||
func TestNNSRegisterMulti(t *testing.T) {
|
func TestNNSRegisterMulti(t *testing.T) {
|
||||||
c := newNNSInvoker(t, true)
|
c := newNNSInvoker(t, true)
|
||||||
|
|
||||||
newArgs := func(domain string, account neotest.Signer) []interface{} {
|
newArgs := func(domain string, account neotest.Signer) []any {
|
||||||
return []interface{}{
|
return []any{
|
||||||
domain, account.ScriptHash(), "doesnt@matter.com",
|
domain, account.ScriptHash(), "doesnt@matter.com",
|
||||||
int64(101), int64(102), int64(103), int64(104),
|
int64(101), int64(102), int64(103), int64(104),
|
||||||
}
|
}
|
||||||
|
@ -185,7 +187,8 @@ func TestNNSRegisterMulti(t *testing.T) {
|
||||||
c2.Invoke(t, stackitem.Null{}, "addRecord",
|
c2.Invoke(t, stackitem.Null{}, "addRecord",
|
||||||
"cdn.mainnet.fs.neo.com", int64(nns.A), "166.15.14.13")
|
"cdn.mainnet.fs.neo.com", int64(nns.A), "166.15.14.13")
|
||||||
result := stackitem.NewArray([]stackitem.Item{
|
result := stackitem.NewArray([]stackitem.Item{
|
||||||
stackitem.NewByteArray([]byte("166.15.14.13"))})
|
stackitem.NewByteArray([]byte("166.15.14.13")),
|
||||||
|
})
|
||||||
c2.Invoke(t, result, "resolve", "cdn.mainnet.fs.neo.com", int64(nns.A))
|
c2.Invoke(t, result, "resolve", "cdn.mainnet.fs.neo.com", int64(nns.A))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,18 +198,18 @@ func TestNNSUpdateSOA(t *testing.T) {
|
||||||
refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104)
|
refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104)
|
||||||
c.Invoke(t, true, "register",
|
c.Invoke(t, true, "register",
|
||||||
"testdomain.com", c.CommitteeHash,
|
"testdomain.com", c.CommitteeHash,
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
|
|
||||||
refresh *= 2
|
refresh *= 2
|
||||||
retry *= 2
|
retry *= 2
|
||||||
expire *= 2
|
expire *= 2
|
||||||
ttl *= 2
|
ttl *= 2
|
||||||
c.Invoke(t, stackitem.Null{}, "updateSOA",
|
c.Invoke(t, stackitem.Null{}, "updateSOA",
|
||||||
"testdomain.com", "newemail@nspcc.ru", refresh, retry, expire, ttl)
|
"testdomain.com", "newemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
|
|
||||||
b := c.TopBlock(t)
|
b := c.TopBlock(t)
|
||||||
expected := stackitem.NewArray([]stackitem.Item{stackitem.NewBuffer(
|
expected := stackitem.NewArray([]stackitem.Item{stackitem.NewBuffer(
|
||||||
[]byte(fmt.Sprintf("testdomain.com newemail@nspcc.ru %d %d %d %d %d",
|
[]byte(fmt.Sprintf("testdomain.com newemail@frostfs.info %d %d %d %d %d",
|
||||||
b.Timestamp, refresh, retry, expire, ttl)))})
|
b.Timestamp, refresh, retry, expire, ttl)))})
|
||||||
c.Invoke(t, expected, "getRecords", "testdomain.com", int64(nns.SOA))
|
c.Invoke(t, expected, "getRecords", "testdomain.com", int64(nns.SOA))
|
||||||
}
|
}
|
||||||
|
@ -217,13 +220,13 @@ func TestNNSGetAllRecords(t *testing.T) {
|
||||||
refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104)
|
refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104)
|
||||||
c.Invoke(t, true, "register",
|
c.Invoke(t, true, "register",
|
||||||
"testdomain.com", c.CommitteeHash,
|
"testdomain.com", c.CommitteeHash,
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
|
|
||||||
c.Invoke(t, stackitem.Null{}, "addRecord", "testdomain.com", int64(nns.TXT), "first TXT record")
|
c.Invoke(t, stackitem.Null{}, "addRecord", "testdomain.com", int64(nns.TXT), "first TXT record")
|
||||||
c.Invoke(t, stackitem.Null{}, "addRecord", "testdomain.com", int64(nns.A), "1.2.3.4")
|
c.Invoke(t, stackitem.Null{}, "addRecord", "testdomain.com", int64(nns.A), "1.2.3.4")
|
||||||
|
|
||||||
b := c.TopBlock(t)
|
b := c.TopBlock(t)
|
||||||
expSOA := fmt.Sprintf("testdomain.com myemail@nspcc.ru %d %d %d %d %d",
|
expSOA := fmt.Sprintf("testdomain.com myemail@frostfs.info %d %d %d %d %d",
|
||||||
b.Timestamp, refresh, retry, expire, ttl)
|
b.Timestamp, refresh, retry, expire, ttl)
|
||||||
|
|
||||||
s, err := c.TestInvoke(t, "getAllRecords", "testdomain.com")
|
s, err := c.TestInvoke(t, "getAllRecords", "testdomain.com")
|
||||||
|
@ -257,12 +260,13 @@ func TestExpiration(t *testing.T) {
|
||||||
refresh, retry, expire, ttl := int64(101), int64(102), int64(msPerYear/1000*10), int64(104)
|
refresh, retry, expire, ttl := int64(101), int64(102), int64(msPerYear/1000*10), int64(104)
|
||||||
c.Invoke(t, true, "register",
|
c.Invoke(t, true, "register",
|
||||||
"testdomain.com", c.CommitteeHash,
|
"testdomain.com", c.CommitteeHash,
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
|
|
||||||
checkProperties := func(t *testing.T, expiration uint64) {
|
checkProperties := func(t *testing.T, expiration uint64) {
|
||||||
expected := stackitem.NewMapWithValue([]stackitem.MapElement{
|
expected := stackitem.NewMapWithValue([]stackitem.MapElement{
|
||||||
{Key: stackitem.Make("name"), Value: stackitem.Make("testdomain.com")},
|
{Key: stackitem.Make("name"), Value: stackitem.Make("testdomain.com")},
|
||||||
{Key: stackitem.Make("expiration"), Value: stackitem.Make(expiration)}})
|
{Key: stackitem.Make("expiration"), Value: stackitem.Make(expiration)},
|
||||||
|
})
|
||||||
s, err := c.TestInvoke(t, "properties", "testdomain.com")
|
s, err := c.TestInvoke(t, "properties", "testdomain.com")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, expected.Value(), s.Top().Item().Value())
|
require.Equal(t, expected.Value(), s.Top().Item().Value())
|
||||||
|
@ -295,7 +299,7 @@ func TestNNSSetAdmin(t *testing.T) {
|
||||||
refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104)
|
refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104)
|
||||||
c.Invoke(t, true, "register",
|
c.Invoke(t, true, "register",
|
||||||
"testdomain.com", c.CommitteeHash,
|
"testdomain.com", c.CommitteeHash,
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
|
|
||||||
acc := c.NewAccount(t)
|
acc := c.NewAccount(t)
|
||||||
cAcc := c.WithSigners(acc)
|
cAcc := c.WithSigners(acc)
|
||||||
|
@ -318,7 +322,7 @@ func TestNNSIsAvailable(t *testing.T) {
|
||||||
refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104)
|
refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104)
|
||||||
c.Invoke(t, true, "register",
|
c.Invoke(t, true, "register",
|
||||||
"com", c.CommitteeHash,
|
"com", c.CommitteeHash,
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
|
|
||||||
c.Invoke(t, false, "isAvailable", "com")
|
c.Invoke(t, false, "isAvailable", "com")
|
||||||
c.Invoke(t, true, "isAvailable", "domain.com")
|
c.Invoke(t, true, "isAvailable", "domain.com")
|
||||||
|
@ -327,7 +331,7 @@ func TestNNSIsAvailable(t *testing.T) {
|
||||||
c1 := c.WithSigners(c.Committee, acc)
|
c1 := c.WithSigners(c.Committee, acc)
|
||||||
c1.Invoke(t, true, "register",
|
c1.Invoke(t, true, "register",
|
||||||
"domain.com", acc.ScriptHash(),
|
"domain.com", acc.ScriptHash(),
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
|
|
||||||
c.Invoke(t, false, "isAvailable", "domain.com")
|
c.Invoke(t, false, "isAvailable", "domain.com")
|
||||||
}
|
}
|
||||||
|
@ -340,7 +344,7 @@ func TestNNSRenew(t *testing.T) {
|
||||||
refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104)
|
refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104)
|
||||||
c1.Invoke(t, true, "register",
|
c1.Invoke(t, true, "register",
|
||||||
"testdomain.com", c.CommitteeHash,
|
"testdomain.com", c.CommitteeHash,
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
|
|
||||||
const msPerYear = 365 * 24 * time.Hour / time.Millisecond
|
const msPerYear = 365 * 24 * time.Hour / time.Millisecond
|
||||||
b := c.TopBlock(t)
|
b := c.TopBlock(t)
|
||||||
|
@ -351,7 +355,8 @@ func TestNNSRenew(t *testing.T) {
|
||||||
c1.Invoke(t, ts, "renew", "testdomain.com")
|
c1.Invoke(t, ts, "renew", "testdomain.com")
|
||||||
expected := stackitem.NewMapWithValue([]stackitem.MapElement{
|
expected := stackitem.NewMapWithValue([]stackitem.MapElement{
|
||||||
{Key: stackitem.Make("name"), Value: stackitem.Make("testdomain.com")},
|
{Key: stackitem.Make("name"), Value: stackitem.Make("testdomain.com")},
|
||||||
{Key: stackitem.Make("expiration"), Value: stackitem.Make(ts)}})
|
{Key: stackitem.Make("expiration"), Value: stackitem.Make(ts)},
|
||||||
|
})
|
||||||
cAcc.Invoke(t, expected, "properties", "testdomain.com")
|
cAcc.Invoke(t, expected, "properties", "testdomain.com")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +366,7 @@ func TestNNSResolve(t *testing.T) {
|
||||||
refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104)
|
refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104)
|
||||||
c.Invoke(t, true, "register",
|
c.Invoke(t, true, "register",
|
||||||
"test.com", c.CommitteeHash,
|
"test.com", c.CommitteeHash,
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@frostfs.info", refresh, retry, expire, ttl)
|
||||||
|
|
||||||
c.Invoke(t, stackitem.Null{}, "addRecord",
|
c.Invoke(t, stackitem.Null{}, "addRecord",
|
||||||
"test.com", int64(nns.TXT), "expected result")
|
"test.com", int64(nns.TXT), "expected result")
|
||||||
|
|
127
tests/policy_test.go
Normal file
127
tests/policy_test.go
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
package tests
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"path"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/policy"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
const policyPath = "../policy"
|
||||||
|
|
||||||
|
func deployPolicyContract(t *testing.T, e *neotest.Executor) util.Uint160 {
|
||||||
|
cfgPath := path.Join(policyPath, "config.yml")
|
||||||
|
c := neotest.CompileFile(t, e.CommitteeHash, policyPath, cfgPath)
|
||||||
|
e.DeployContract(t, c, []any{nil})
|
||||||
|
return c.Hash
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPolicyInvoker(t *testing.T) *neotest.ContractInvoker {
|
||||||
|
e := newExecutor(t)
|
||||||
|
h := deployPolicyContract(t, e)
|
||||||
|
return e.CommitteeInvoker(h)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPolicy(t *testing.T) {
|
||||||
|
e := newPolicyInvoker(t)
|
||||||
|
|
||||||
|
// Policies are opaque to the contract and are just raw bytes to store.
|
||||||
|
p1 := []byte("chain1")
|
||||||
|
p2 := []byte("chain2")
|
||||||
|
p3 := []byte("chain3")
|
||||||
|
p33 := []byte("chain33")
|
||||||
|
|
||||||
|
e.Invoke(t, stackitem.Null{}, "addChain", policy.Namespace, "mynamespace", "ingress:123", p1)
|
||||||
|
checkChains(t, e, "mynamespace", "", "ingress", [][]byte{p1})
|
||||||
|
checkChains(t, e, "mynamespace", "", "all", nil)
|
||||||
|
|
||||||
|
e.Invoke(t, stackitem.Null{}, "addChain", policy.Container, "cnr1", "ingress:myrule2", p2)
|
||||||
|
checkChains(t, e, "mynamespace", "", "ingress", [][]byte{p1}) // Only namespace chains.
|
||||||
|
checkChains(t, e, "mynamespace", "cnr1", "ingress", [][]byte{p1, p2})
|
||||||
|
checkChains(t, e, "mynamespace", "cnr1", "all", nil) // No chains attached to 'all'.
|
||||||
|
checkChains(t, e, "mynamespace", "cnr2", "ingress", [][]byte{p1}) // Only namespace, no chains for the container.
|
||||||
|
|
||||||
|
e.Invoke(t, stackitem.Null{}, "addChain", policy.Container, "cnr1", "ingress:myrule3", p3)
|
||||||
|
checkChains(t, e, "mynamespace", "cnr1", "ingress", [][]byte{p1, p2, p3})
|
||||||
|
|
||||||
|
e.Invoke(t, stackitem.Null{}, "addChain", policy.Container, "cnr1", "ingress:myrule3", p33)
|
||||||
|
checkChain(t, e, policy.Container, "cnr1", "ingress:myrule3", p33)
|
||||||
|
checkChains(t, e, "mynamespace", "cnr1", "ingress", [][]byte{p1, p2, p33}) // Override chain.
|
||||||
|
checkChainsByPrefix(t, e, policy.Container, "cnr1", "", [][]byte{p2, p33})
|
||||||
|
checkChainsByPrefix(t, e, policy.IAM, "", "", nil)
|
||||||
|
|
||||||
|
t.Run("removal", func(t *testing.T) {
|
||||||
|
t.Run("wrong name", func(t *testing.T) {
|
||||||
|
e.Invoke(t, stackitem.Null{}, "removeChain", policy.Namespace, "mynamespace", "ingress")
|
||||||
|
checkChains(t, e, "mynamespace", "", "ingress", [][]byte{p1})
|
||||||
|
})
|
||||||
|
|
||||||
|
e.Invoke(t, stackitem.Null{}, "removeChain", policy.Namespace, "mynamespace", "ingress:123")
|
||||||
|
checkChains(t, e, "mynamespace", "", "ingress", nil)
|
||||||
|
checkChains(t, e, "mynamespace", "cnr1", "ingress", [][]byte{p2, p33}) // Container chains still exist.
|
||||||
|
|
||||||
|
// Remove by prefix.
|
||||||
|
e.Invoke(t, stackitem.Null{}, "removeChainsByPrefix", policy.Container, "cnr1", "ingress")
|
||||||
|
checkChains(t, e, "mynamespace", "cnr1", "ingress", nil)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAutorization(t *testing.T) {
|
||||||
|
e := newPolicyInvoker(t)
|
||||||
|
|
||||||
|
e.Invoke(t, stackitem.Null{}, "getAdmin")
|
||||||
|
|
||||||
|
s := e.NewAccount(t, 1_0000_0000)
|
||||||
|
c := e.WithSigners(s)
|
||||||
|
|
||||||
|
args := []any{policy.Container, "cnr1", "ingress:myrule3", []byte("opaque")}
|
||||||
|
c.InvokeFail(t, policy.ErrNotAuthorized, "addChain", args...)
|
||||||
|
|
||||||
|
e.Invoke(t, stackitem.Null{}, "setAdmin", s.ScriptHash())
|
||||||
|
e.Invoke(t, stackitem.NewBuffer(s.ScriptHash().BytesBE()), "getAdmin")
|
||||||
|
|
||||||
|
c.Invoke(t, stackitem.Null{}, "addChain", args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkChains(t *testing.T, e *neotest.ContractInvoker, namespace, container, name string, expected [][]byte) {
|
||||||
|
s, err := e.TestInvoke(t, "listChains", namespace, container, name)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
checksChainsOnStack(t, s, expected)
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkChainsByPrefix(t *testing.T, e *neotest.ContractInvoker, kind byte, entityName, prefix string, expected [][]byte) {
|
||||||
|
s, err := e.TestInvoke(t, "listChainsByPrefix", kind, entityName, prefix)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
checksChainsOnStack(t, s, expected)
|
||||||
|
}
|
||||||
|
|
||||||
|
func checksChainsOnStack(t *testing.T, s *vm.Stack, expected [][]byte) {
|
||||||
|
require.Equal(t, 1, s.Len())
|
||||||
|
|
||||||
|
var actual [][]byte
|
||||||
|
arr := s.Pop().Array()
|
||||||
|
for i := range arr {
|
||||||
|
bs, err := arr[i].TryBytes()
|
||||||
|
|
||||||
|
require.NoError(t, err)
|
||||||
|
actual = append(actual, bs)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.ElementsMatch(t, expected, actual)
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkChain(t *testing.T, e *neotest.ContractInvoker, kind byte, entityName, name string, expected []byte) {
|
||||||
|
s, err := e.TestInvoke(t, "getChain", kind, entityName, name)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, 1, s.Len())
|
||||||
|
|
||||||
|
require.True(t, bytes.Equal(expected, s.Pop().Bytes()))
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue