Skip to content

Commit

Permalink
update smc and config files (0xPolygonHermez#1122)
Browse files Browse the repository at this point in the history
* update smc and config files

* test config
  • Loading branch information
ARR552 authored Sep 5, 2022
1 parent 605fa45 commit 35f5710
Show file tree
Hide file tree
Showing 18 changed files with 578 additions and 306 deletions.
6 changes: 6 additions & 0 deletions config/config.debug.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ URL = "http://localhost:8545"
PrivateKeyPath = "../test/test.keystore"
PrivateKeyPassword = "testonly"

[EthTxManager]
MaxSendBatchTxRetries = 10
MaxVerifyBatchTxRetries = 10
FrequencyForResendingFailedSendBatches = "1s"
FrequencyForResendingFailedVerifyBatch = "1s"

[RPC]
Host = "0.0.0.0"
Port = 8123
Expand Down
6 changes: 6 additions & 0 deletions config/config.local.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ URL = "http://zkevm-mock-l1-network:8545"
PrivateKeyPath = "./test/test.keystore"
PrivateKeyPassword = "testonly"

[EthTxManager]
MaxSendBatchTxRetries = 10
MaxVerifyBatchTxRetries = 10
FrequencyForResendingFailedSendBatches = "1s"
FrequencyForResendingFailedVerifyBatch = "1s"

[RPC]
Host = "0.0.0.0"
Port = 8123
Expand Down
4 changes: 4 additions & 0 deletions etherman/etherman.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
sequencedBatchesEventSignatureHash = crypto.Keccak256Hash([]byte("SequenceBatches(uint64)"))
forceSequencedBatchesSignatureHash = crypto.Keccak256Hash([]byte("SequenceForceBatches(uint64)"))
verifiedBatchSignatureHash = crypto.Keccak256Hash([]byte("VerifyBatch(uint64,address)"))
initializedSignatureHash = crypto.Keccak256Hash([]byte("Initialized(uint8)"))

// ErrNotFound is used when the object is not found
ErrNotFound = errors.New("Not found")
Expand Down Expand Up @@ -152,6 +153,9 @@ func (etherMan *Client) processEvent(ctx context.Context, vLog types.Log, blocks
return etherMan.verifyBatchEvent(ctx, vLog, blocks, blocksOrder)
case forceSequencedBatchesSignatureHash:
return etherMan.forceSequencedBatchesEvent(ctx, vLog, blocks, blocksOrder)
case initializedSignatureHash:
log.Debug("Initialized event detected")
return nil
}
log.Warn("Event not registered: ", vLog)
return nil
Expand Down
6 changes: 3 additions & 3 deletions etherman/etherman_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestGEREvent(t *testing.T) {
amount := big.NewInt(1000000000000000)
a := etherman.auth
a.Value = amount
_, err = br.Bridge(a, common.Address{}, 1, etherman.auth.From, amount)
_, err = br.Bridge(a, common.Address{}, 1, etherman.auth.From, amount, []byte{})
require.NoError(t, err)

// Mine the tx in a block
Expand Down Expand Up @@ -123,7 +123,7 @@ func TestSequencedBatchesEvent(t *testing.T) {
// Make a bridge tx
a := etherman.auth
a.Value = big.NewInt(1000000000000000)
_, err = br.Bridge(a, common.Address{}, 1, a.From, a.Value)
_, err = br.Bridge(a, common.Address{}, 1, a.From, a.Value, []byte{})
require.NoError(t, err)
ethBackend.Commit()
a.Value = big.NewInt(0)
Expand Down Expand Up @@ -280,7 +280,7 @@ func TestSendSequences(t *testing.T) {
// Make a bridge tx
a := etherman.auth
a.Value = big.NewInt(1000000000000000)
_, err = br.Bridge(a, common.Address{}, 1, a.From, a.Value)
_, err = br.Bridge(a, common.Address{}, 1, a.From, a.Value, []byte{})
require.NoError(t, err)
ethBackend.Commit()
a.Value = big.NewInt(0)
Expand Down
25 changes: 19 additions & 6 deletions etherman/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,32 @@ func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts) (etherman *Client
if err != nil {
return nil, nil, common.Address{}, nil, err
}
calculatedBridgeAddr := crypto.CreateAddress(auth.From, nonce+1)
const pos = 2
calculatedPoEAddr := crypto.CreateAddress(auth.From, nonce+pos)
const posBridge = 2
calculatedBridgeAddr := crypto.CreateAddress(auth.From, nonce+posBridge)
const posPoE = 4
calculatedPoEAddr := crypto.CreateAddress(auth.From, nonce+posPoE)
var genesis [32]byte
exitManagerAddr, _, globalExitRoot, err := globalexitrootmanager.DeployGlobalexitrootmanager(auth, client, calculatedPoEAddr, calculatedBridgeAddr)
exitManagerAddr, _, globalExitRoot, err := globalexitrootmanager.DeployGlobalexitrootmanager(auth, client)
if err != nil {
return nil, nil, common.Address{}, nil, err
}
bridgeAddr, _, br, err := bridge.DeployBridge(auth, client, 0, exitManagerAddr)
_, err = globalExitRoot.Initialize(auth, calculatedPoEAddr, calculatedBridgeAddr)
if err != nil {
return nil, nil, common.Address{}, nil, err
}
poeAddr, _, poe, err := proofofefficiency.DeployProofofefficiency(auth, client, exitManagerAddr, maticAddr, rollupVerifierAddr, genesis, auth.From, true, "http://localhost")
bridgeAddr, _, br, err := bridge.DeployBridge(auth, client)
if err != nil {
return nil, nil, common.Address{}, nil, err
}
_, err = br.Initialize(auth, 0, exitManagerAddr)
if err != nil {
return nil, nil, common.Address{}, nil, err
}
poeAddr, _, poe, err := proofofefficiency.DeployProofofefficiency(auth, client)
if err != nil {
return nil, nil, common.Address{}, nil, err
}
_, err = poe.Initialize(auth, exitManagerAddr, maticAddr, rollupVerifierAddr, genesis, auth.From, true, "http://localhost")
if err != nil {
return nil, nil, common.Address{}, nil, err
}
Expand Down
94 changes: 31 additions & 63 deletions etherman/smartcontracts/abi/bridge.abi
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
[
{
"inputs": [
{
"internalType": "uint32",
"name": "_networkID",
"type": "uint32"
},
{
"internalType": "contract IGlobalExitRootManager",
"name": "_globalExitRootManager",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
Expand Down Expand Up @@ -101,6 +85,19 @@
"name": "ClaimEvent",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand All @@ -126,25 +123,6 @@
"name": "NewWrappedToken",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"inputs": [],
"name": "MAINNET_NETWORK_ID",
Expand Down Expand Up @@ -179,6 +157,11 @@
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "permitData",
"type": "bytes"
}
],
"name": "bridge",
Expand Down Expand Up @@ -371,26 +354,31 @@
"type": "function"
},
{
"inputs": [],
"name": "networkID",
"outputs": [
"inputs": [
{
"internalType": "uint32",
"name": "",
"name": "_networkID",
"type": "uint32"
},
{
"internalType": "contract IGlobalExitRootManager",
"name": "_globalExitRootManager",
"type": "address"
}
],
"stateMutability": "view",
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"name": "networkID",
"outputs": [
{
"internalType": "address",
"internalType": "uint32",
"name": "",
"type": "address"
"type": "uint32"
}
],
"stateMutability": "view",
Expand Down Expand Up @@ -420,13 +408,6 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "tokenImplementation",
Expand Down Expand Up @@ -459,19 +440,6 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
35 changes: 25 additions & 10 deletions etherman/smartcontracts/abi/globalexitrootmanager.abi
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
[
{
"anonymous": false,
"inputs": [
{
"internalType": "address",
"name": "_rollupAddress",
"type": "address"
},
{
"internalType": "address",
"name": "_bridgeAddress",
"type": "address"
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
"name": "Initialized",
"type": "event"
},
{
"anonymous": false,
Expand Down Expand Up @@ -85,6 +82,24 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_rollupAddress",
"type": "address"
},
{
"internalType": "address",
"name": "_bridgeAddress",
"type": "address"
}
],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "lastGlobalExitRootNum",
Expand Down
4 changes: 2 additions & 2 deletions etherman/smartcontracts/abi/mockverifier.abi
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"type": "uint256[2]"
},
{
"internalType": "uint256[2]",
"internalType": "uint256[1]",
"name": "input",
"type": "uint256[2]"
"type": "uint256[1]"
}
],
"name": "verifyProof",
Expand Down
Loading

0 comments on commit 35f5710

Please sign in to comment.