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
535bcb42
Unverified
Commit
535bcb42
authored
Oct 04, 2023
by
Mark Tyneway
Committed by
GitHub
Oct 04, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7535 from ethereum-optimism/feat/batch-no-calldata
op-chain-ops: option for skipping calldata encoding
parents
1335d991
db56aaa9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
11 deletions
+30
-11
batch.go
op-chain-ops/safe/batch.go
+14
-2
batch_test.go
op-chain-ops/safe/batch_test.go
+2
-2
l1.go
op-chain-ops/upgrades/l1.go
+14
-7
No files found.
op-chain-ops/safe/batch.go
View file @
535bcb42
...
...
@@ -6,6 +6,7 @@ package safe
import
(
"bytes"
"encoding/json"
"errors"
"fmt"
"math/big"
"strings"
...
...
@@ -19,7 +20,12 @@ import (
)
// Batch represents a Safe tx-builder transaction.
// SkipCalldata will skip adding the calldata to the BatchTransaction.
// This is useful for when using the Safe UI because it prefers using
// the raw calldata when both the calldata and ABIs with arguments are
// present.
type
Batch
struct
{
SkipCalldata
bool
Version
string
`json:"version"`
ChainID
*
big
.
Int
`json:"chainId"`
CreatedAt
uint64
`json:"createdAt"`
...
...
@@ -29,7 +35,10 @@ type Batch struct {
// AddCall will add a call to the batch. After a series of calls are
// added to the batch, it can be serialized to JSON.
func
(
b
*
Batch
)
AddCall
(
to
common
.
Address
,
value
*
big
.
Int
,
sig
string
,
args
[]
any
,
iface
abi
.
ABI
)
error
{
func
(
b
*
Batch
)
AddCall
(
to
common
.
Address
,
value
*
big
.
Int
,
sig
string
,
args
[]
any
,
iface
*
abi
.
ABI
)
error
{
if
iface
==
nil
{
return
errors
.
New
(
"abi cannot be nil"
)
}
// Attempt to pull out the signature from the top level methods.
// The abi package uses normalization that we do not want to be
// coupled to, so attempt to search for the raw name if the top
...
...
@@ -87,10 +96,13 @@ func (b *Batch) AddCall(to common.Address, value *big.Int, sig string, args []an
To
:
to
,
Value
:
value
,
Method
:
contractMethod
,
Data
:
data
,
InputValues
:
inputValues
,
}
if
!
b
.
SkipCalldata
{
batchTransaction
.
Data
=
data
}
b
.
Transactions
=
append
(
b
.
Transactions
,
batchTransaction
)
return
nil
...
...
op-chain-ops/safe/batch_test.go
View file @
535bcb42
...
...
@@ -58,7 +58,7 @@ func TestBatchAddCallFinalizeWithdrawalTransaction(t *testing.T) {
to
:=
common
.
Address
{
19
:
0x01
}
value
:=
big
.
NewInt
(
222
)
require
.
NoError
(
t
,
batch
.
AddCall
(
to
,
value
,
sig
,
argument
,
portalABI
))
require
.
NoError
(
t
,
batch
.
AddCall
(
to
,
value
,
sig
,
argument
,
&
portalABI
))
require
.
NoError
(
t
,
batch
.
Check
())
require
.
Equal
(
t
,
batch
.
Transactions
[
0
]
.
Signature
(),
"finalizeWithdrawalTransaction((uint256,address,address,uint256,uint256,bytes))"
)
...
...
@@ -89,7 +89,7 @@ func TestBatchAddCallDespositTransaction(t *testing.T) {
[]
byte
{},
}
require
.
NoError
(
t
,
batch
.
AddCall
(
to
,
value
,
sig
,
argument
,
portalABI
))
require
.
NoError
(
t
,
batch
.
AddCall
(
to
,
value
,
sig
,
argument
,
&
portalABI
))
require
.
NoError
(
t
,
batch
.
Check
())
require
.
Equal
(
t
,
batch
.
Transactions
[
0
]
.
Signature
(),
"depositTransaction(address,uint256,uint64,bool,bytes)"
)
...
...
op-chain-ops/upgrades/l1.go
View file @
535bcb42
...
...
@@ -63,6 +63,7 @@ func L1CrossDomainMessenger(batch *safe.Batch, implementations superchain.Implem
if
err
!=
nil
{
return
err
}
calldata
=
append
(
initialize
.
ID
,
calldata
...
)
args
:=
[]
any
{
common
.
HexToAddress
(
list
.
L1CrossDomainMessengerProxy
.
String
()),
...
...
@@ -72,7 +73,7 @@ func L1CrossDomainMessenger(batch *safe.Batch, implementations superchain.Implem
proxyAdmin
:=
common
.
HexToAddress
(
list
.
ProxyAdmin
.
String
())
sig
:=
"upgradeAndCall(address,address,bytes)"
if
err
:=
batch
.
AddCall
(
proxyAdmin
,
common
.
Big0
,
sig
,
args
,
*
proxyAdminABI
);
err
!=
nil
{
if
err
:=
batch
.
AddCall
(
proxyAdmin
,
common
.
Big0
,
sig
,
args
,
proxyAdminABI
);
err
!=
nil
{
return
err
}
...
...
@@ -102,6 +103,7 @@ func L1ERC721Bridge(batch *safe.Batch, implementations superchain.Implementation
if
err
!=
nil
{
return
err
}
calldata
=
append
(
initialize
.
ID
,
calldata
...
)
args
:=
[]
any
{
common
.
HexToAddress
(
list
.
L1ERC721BridgeProxy
.
String
()),
...
...
@@ -111,7 +113,7 @@ func L1ERC721Bridge(batch *safe.Batch, implementations superchain.Implementation
proxyAdmin
:=
common
.
HexToAddress
(
list
.
ProxyAdmin
.
String
())
sig
:=
"upgradeAndCall(address,address,bytes)"
if
err
:=
batch
.
AddCall
(
proxyAdmin
,
common
.
Big0
,
sig
,
args
,
*
proxyAdminABI
);
err
!=
nil
{
if
err
:=
batch
.
AddCall
(
proxyAdmin
,
common
.
Big0
,
sig
,
args
,
proxyAdminABI
);
err
!=
nil
{
return
err
}
...
...
@@ -141,6 +143,7 @@ func L1StandardBridge(batch *safe.Batch, implementations superchain.Implementati
if
err
!=
nil
{
return
err
}
calldata
=
append
(
initialize
.
ID
,
calldata
...
)
args
:=
[]
any
{
common
.
HexToAddress
(
list
.
L1StandardBridgeProxy
.
String
()),
...
...
@@ -150,7 +153,7 @@ func L1StandardBridge(batch *safe.Batch, implementations superchain.Implementati
proxyAdmin
:=
common
.
HexToAddress
(
list
.
ProxyAdmin
.
String
())
sig
:=
"upgradeAndCall(address,address,bytes)"
if
err
:=
batch
.
AddCall
(
proxyAdmin
,
common
.
Big0
,
sig
,
args
,
*
proxyAdminABI
);
err
!=
nil
{
if
err
:=
batch
.
AddCall
(
proxyAdmin
,
common
.
Big0
,
sig
,
args
,
proxyAdminABI
);
err
!=
nil
{
return
err
}
...
...
@@ -219,6 +222,7 @@ func L2OutputOracle(batch *safe.Batch, implementations superchain.Implementation
if
err
!=
nil
{
return
err
}
calldata
=
append
(
initialize
.
ID
,
calldata
...
)
args
:=
[]
any
{
common
.
HexToAddress
(
list
.
L2OutputOracleProxy
.
String
()),
...
...
@@ -228,7 +232,7 @@ func L2OutputOracle(batch *safe.Batch, implementations superchain.Implementation
proxyAdmin
:=
common
.
HexToAddress
(
list
.
ProxyAdmin
.
String
())
sig
:=
"upgradeAndCall(address,address,bytes)"
if
err
:=
batch
.
AddCall
(
proxyAdmin
,
common
.
Big0
,
sig
,
args
,
*
proxyAdminABI
);
err
!=
nil
{
if
err
:=
batch
.
AddCall
(
proxyAdmin
,
common
.
Big0
,
sig
,
args
,
proxyAdminABI
);
err
!=
nil
{
return
err
}
...
...
@@ -258,6 +262,7 @@ func OptimismMintableERC20Factory(batch *safe.Batch, implementations superchain.
if
err
!=
nil
{
return
err
}
calldata
=
append
(
initialize
.
ID
,
calldata
...
)
args
:=
[]
any
{
common
.
HexToAddress
(
list
.
OptimismMintableERC20FactoryProxy
.
String
()),
...
...
@@ -267,7 +272,7 @@ func OptimismMintableERC20Factory(batch *safe.Batch, implementations superchain.
proxyAdmin
:=
common
.
HexToAddress
(
list
.
ProxyAdmin
.
String
())
sig
:=
"upgradeAndCall(address,address,bytes)"
if
err
:=
batch
.
AddCall
(
proxyAdmin
,
common
.
Big0
,
sig
,
args
,
*
proxyAdminABI
);
err
!=
nil
{
if
err
:=
batch
.
AddCall
(
proxyAdmin
,
common
.
Big0
,
sig
,
args
,
proxyAdminABI
);
err
!=
nil
{
return
err
}
...
...
@@ -315,6 +320,7 @@ func OptimismPortal(batch *safe.Batch, implementations superchain.Implementation
if
err
!=
nil
{
return
err
}
calldata
=
append
(
initialize
.
ID
,
calldata
...
)
args
:=
[]
any
{
common
.
HexToAddress
(
list
.
OptimismPortalProxy
.
String
()),
...
...
@@ -324,7 +330,7 @@ func OptimismPortal(batch *safe.Batch, implementations superchain.Implementation
proxyAdmin
:=
common
.
HexToAddress
(
list
.
ProxyAdmin
.
String
())
sig
:=
"upgradeAndCall(address,address,bytes)"
if
err
:=
batch
.
AddCall
(
proxyAdmin
,
common
.
Big0
,
sig
,
args
,
*
proxyAdminABI
);
err
!=
nil
{
if
err
:=
batch
.
AddCall
(
proxyAdmin
,
common
.
Big0
,
sig
,
args
,
proxyAdminABI
);
err
!=
nil
{
return
err
}
...
...
@@ -434,6 +440,7 @@ func SystemConfig(batch *safe.Batch, implementations superchain.ImplementationLi
if
err
!=
nil
{
return
err
}
calldata
=
append
(
initialize
.
ID
,
calldata
...
)
args
:=
[]
any
{
common
.
HexToAddress
(
chainConfig
.
SystemConfigAddr
.
String
()),
...
...
@@ -443,7 +450,7 @@ func SystemConfig(batch *safe.Batch, implementations superchain.ImplementationLi
proxyAdmin
:=
common
.
HexToAddress
(
list
.
ProxyAdmin
.
String
())
sig
:=
"upgradeAndCall(address,address,bytes)"
if
err
:=
batch
.
AddCall
(
proxyAdmin
,
common
.
Big0
,
sig
,
args
,
*
proxyAdminABI
);
err
!=
nil
{
if
err
:=
batch
.
AddCall
(
proxyAdmin
,
common
.
Big0
,
sig
,
args
,
proxyAdminABI
);
err
!=
nil
{
return
err
}
...
...
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