Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
c4b37bf5
Unverified
Commit
c4b37bf5
authored
May 15, 2024
by
Roberto Bayardo
Committed by
GitHub
May 16, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ability to decode ecotone scalar values into components (#10547)
parent
27d2f163
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
5 deletions
+38
-5
main.go
op-chain-ops/cmd/ecotone-scalar/main.go
+37
-4
types.go
op-service/eth/types.go
+1
-1
No files found.
op-chain-ops/cmd/ecotone-scalar/main.go
View file @
c4b37bf5
...
@@ -12,6 +12,8 @@ import (
...
@@ -12,6 +12,8 @@ import (
func
main
()
{
func
main
()
{
var
scalar
,
blobScalar
uint
var
scalar
,
blobScalar
uint
var
decode
string
flag
.
StringVar
(
&
decode
,
"decode"
,
""
,
"uint256 post-ecotone scalar value to decode into its components"
)
flag
.
UintVar
(
&
scalar
,
"scalar"
,
0
,
"base fee scalar value for the gas config (uint32)"
)
flag
.
UintVar
(
&
scalar
,
"scalar"
,
0
,
"base fee scalar value for the gas config (uint32)"
)
flag
.
UintVar
(
&
blobScalar
,
"blob-scalar"
,
0
,
"blob base fee scalar value for the gas config (uint32)"
)
flag
.
UintVar
(
&
blobScalar
,
"blob-scalar"
,
0
,
"blob base fee scalar value for the gas config (uint32)"
)
flag
.
Parse
()
flag
.
Parse
()
...
@@ -27,10 +29,41 @@ func main() {
...
@@ -27,10 +29,41 @@ func main() {
os
.
Exit
(
2
)
os
.
Exit
(
2
)
}
}
encoded
:=
eth
.
EncodeScalar
(
eth
.
EcostoneScalars
{
var
encoded
[
32
]
byte
BlobBaseFeeScalar
:
uint32
(
blobScalar
),
if
len
(
decode
)
>
0
{
BaseFeeScalar
:
uint32
(
scalar
),
if
scalar
!=
0
||
blobScalar
!=
0
{
})
fmt
.
Fprintln
(
flag
.
CommandLine
.
Output
(),
"decode parameter should not be used with scalar and blob-scalar"
)
flag
.
Usage
()
os
.
Exit
(
2
)
}
uint256
:=
new
(
big
.
Int
)
_
,
ok
:=
uint256
.
SetString
(
decode
,
10
)
if
!
ok
{
fmt
.
Fprintln
(
flag
.
CommandLine
.
Output
(),
"failed to parse int from post-ecotone scalar"
)
flag
.
Usage
()
os
.
Exit
(
2
)
}
encodedSlice
:=
uint256
.
Bytes
()
if
len
(
encodedSlice
)
>
32
{
fmt
.
Fprintln
(
flag
.
CommandLine
.
Output
(),
"post-ecotone scalar out of uint256 range"
)
flag
.
Usage
()
os
.
Exit
(
2
)
}
copy
(
encoded
[
:
],
encodedSlice
)
decoded
,
err
:=
eth
.
DecodeScalar
(
encoded
)
if
err
!=
nil
{
fmt
.
Fprintln
(
flag
.
CommandLine
.
Output
(),
"post-ecotone scalar could not be decoded:"
,
err
)
flag
.
Usage
()
os
.
Exit
(
2
)
}
scalar
=
uint
(
decoded
.
BaseFeeScalar
)
blobScalar
=
uint
(
decoded
.
BlobBaseFeeScalar
)
}
else
{
encoded
=
eth
.
EncodeScalar
(
eth
.
EcostoneScalars
{
BlobBaseFeeScalar
:
uint32
(
blobScalar
),
BaseFeeScalar
:
uint32
(
scalar
),
})
}
i
:=
new
(
big
.
Int
)
.
SetBytes
(
encoded
[
:
])
i
:=
new
(
big
.
Int
)
.
SetBytes
(
encoded
[
:
])
fmt
.
Println
(
"# base fee scalar :"
,
scalar
)
fmt
.
Println
(
"# base fee scalar :"
,
scalar
)
...
...
op-service/eth/types.go
View file @
c4b37bf5
...
@@ -425,7 +425,7 @@ func DecodeScalar(scalar [32]byte) (EcostoneScalars, error) {
...
@@ -425,7 +425,7 @@ func DecodeScalar(scalar [32]byte) (EcostoneScalars, error) {
BaseFeeScalar
:
binary
.
BigEndian
.
Uint32
(
scalar
[
28
:
32
]),
BaseFeeScalar
:
binary
.
BigEndian
.
Uint32
(
scalar
[
28
:
32
]),
},
nil
},
nil
default
:
default
:
return
EcostoneScalars
{},
fmt
.
Errorf
(
"unexpected system config scalar: %
s
"
,
scalar
)
return
EcostoneScalars
{},
fmt
.
Errorf
(
"unexpected system config scalar: %
x
"
,
scalar
)
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment