Skip to content

Commit

Permalink
Remove compiled Ethereum contracts from version control and switch to…
Browse files Browse the repository at this point in the history
… using artifact files (#564)
  • Loading branch information
abacabadabacaba authored Apr 19, 2021
1 parent 949a7af commit 0630756
Show file tree
Hide file tree
Showing 57 changed files with 1,939 additions and 8,634 deletions.
12 changes: 0 additions & 12 deletions .buildkite/contracts-eth.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
steps:
- label: "build all solidity contracts"
command: |
docker-compose up compile-solidity
git status
changed_files=$$(git status --porcelain --untracked-files=no | wc -l)
if [ $$changed_files -gt 0 ]; then
echo 'contract changed, please rebuild contract'
exit 1
fi
agents:
- "queue=medium"

- label: "nearbridge test"
command: |
source ~/.nvm/nvm.sh
Expand Down
4 changes: 2 additions & 2 deletions cli/commands/danger-submit-invalid-near-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class DangerSubmitInvalidNearBlock {
nearNetworkId,
ethNodeUrl,
ethMasterSk,
ethClientAbiPath,
ethClientArtifactPath,
ethClientAddress,
ethGasMultiplier,
near2ethRelayMinDelay,
Expand All @@ -19,7 +19,7 @@ class DangerSubmitInvalidNearBlock {
nearNetworkId,
ethNodeUrl,
ethMasterSk,
ethClientAbiPath,
ethClientArtifactPath,
ethClientAddress,
ethGasMultiplier
})
Expand Down
6 changes: 3 additions & 3 deletions cli/commands/start/near2eth-relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class StartNear2EthRelayCommand {
nearNetworkId,
ethNodeUrl,
ethMasterSk,
ethClientAbiPath,
ethClientArtifactPath,
ethClientAddress,
ethGasMultiplier,
near2ethRelayMinDelay,
Expand Down Expand Up @@ -38,7 +38,7 @@ class StartNear2EthRelayCommand {
'--near-network-id', nearNetworkId,
'--eth-node-url', ethNodeUrl,
'--eth-master-sk', ethMasterSk,
'--eth-client-abi-path', ethClientAbiPath,
'--eth-client-artifact-path', ethClientArtifactPath,
'--eth-client-address', ethClientAddress,
'--eth-gas-multiplier', ethGasMultiplier,
'--near2eth-relay-min-delay', near2ethRelayMinDelay,
Expand All @@ -59,7 +59,7 @@ class StartNear2EthRelayCommand {
nearNetworkId,
ethNodeUrl,
ethMasterSk,
ethClientAbiPath,
ethClientArtifactPath,
ethClientAddress,
ethGasMultiplier,
metricsPort
Expand Down
6 changes: 3 additions & 3 deletions cli/commands/start/watchdog.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class StartWatchdogCommand {
daemon,
ethNodeUrl,
ethMasterSk,
ethClientAbiPath,
ethClientArtifactPath,
ethClientAddress,
watchdogDelay,
watchdogErrorDelay,
Expand All @@ -33,7 +33,7 @@ class StartWatchdogCommand {
'bridge-watchdog',
'--eth-node-url', ethNodeUrl,
'--eth-master-sk', ethMasterSk,
'--eth-client-abi-path', ethClientAbiPath,
'--eth-client-artifact-path', ethClientArtifactPath,
'--eth-client-address', ethClientAddress,
'--watchdog-delay', watchdogDelay,
'--watchdog-error-delay', watchdogErrorDelay,
Expand All @@ -48,7 +48,7 @@ class StartWatchdogCommand {
await watchdog.initialize({
ethNodeUrl,
ethMasterSk,
ethClientAbiPath,
ethClientArtifactPath,
ethClientAddress,
metricsPort
})
Expand Down
54 changes: 18 additions & 36 deletions cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,9 @@ RainbowConfig.declareOption(
'ETH address of the ED25519 contract.'
)
RainbowConfig.declareOption(
'eth-ed25519-abi-path',
'Path to the .abi file defining Ethereum ED25519 contract.',
path.join(LIBS_SOL_SRC_DIR, 'nearbridge/dist/Ed25519.full.abi')
)
RainbowConfig.declareOption(
'eth-ed25519-bin-path',
'Path to the .bin file defining Ethereum ED25519 contract.',
path.join(LIBS_SOL_SRC_DIR, 'nearbridge/dist/Ed25519.full.bin')
'eth-ed25519-artifact-path',
'Path to the artifact file defining Ethereum ED25519 contract.',
path.join(LIBS_SOL_SRC_DIR, 'nearbridge/artifacts/contracts/Ed25519.sol/Ed25519.json')
)
RainbowConfig.declareOption(
'eth-client-lock-eth-amount',
Expand All @@ -244,14 +239,9 @@ RainbowConfig.declareOption(
'ETH address of the EthClient contract.'
)
RainbowConfig.declareOption(
'eth-client-abi-path',
'Path to the .abi file defining Ethereum Client contract.',
path.join(LIBS_SOL_SRC_DIR, 'nearbridge/dist/NearBridge.full.abi')
)
RainbowConfig.declareOption(
'eth-client-bin-path',
'Path to the .bin file defining Ethereum Client contract.',
path.join(LIBS_SOL_SRC_DIR, 'nearbridge/dist/NearBridge.full.bin')
'eth-client-artifact-path',
'Path to the artifact file defining Ethereum Client contract.',
path.join(LIBS_SOL_SRC_DIR, 'nearbridge/artifacts/contracts/NearBridge.sol/NearBridge.json')
)
RainbowConfig.declareOption(
'eth-admin-address',
Expand All @@ -268,14 +258,9 @@ RainbowConfig.declareOption(
'ETH address of the EthProver contract.'
)
RainbowConfig.declareOption(
'eth-prover-abi-path',
'Path to the .abi file defining Ethereum Prover contract.',
path.join(LIBS_SOL_SRC_DIR, 'nearprover/dist/NearProver.full.abi')
)
RainbowConfig.declareOption(
'eth-prover-bin-path',
'Path to the .bin file defining Ethereum Prover contract.',
path.join(LIBS_SOL_SRC_DIR, 'nearprover/dist/NearProver.full.bin')
'eth-prover-artifact-path',
'Path to the artifact file defining Ethereum Prover contract.',
path.join(LIBS_SOL_SRC_DIR, 'nearprover/artifacts/contracts/NearProver.sol/NearProver.json')
)
RainbowConfig.declareOption(
'near2eth-relay-min-delay',
Expand Down Expand Up @@ -375,7 +360,7 @@ RainbowConfig.addOptions(
'eth-master-sk',
'near-node-url',
'near-network-id',
'eth-client-abi-path',
'eth-client-artifact-path',
'eth-client-address',
'near2eth-relay-min-delay',
'near2eth-relay-max-delay',
Expand All @@ -392,7 +377,7 @@ RainbowConfig.addOptions(
[
'eth-node-url',
'eth-master-sk',
'eth-client-abi-path',
'eth-client-artifact-path',
'eth-client-address',
'watchdog-delay',
'watchdog-error-delay',
Expand Down Expand Up @@ -494,8 +479,7 @@ RainbowConfig.addOptions(
[
'eth-node-url',
'eth-master-sk',
'eth-ed25519-abi-path',
'eth-ed25519-bin-path',
'eth-ed25519-artifact-path',
'eth-gas-multiplier'
]
)
Expand All @@ -508,8 +492,7 @@ RainbowConfig.addOptions(
[
'eth-node-url',
'eth-master-sk',
'eth-client-abi-path',
'eth-client-bin-path',
'eth-client-artifact-path',
'eth-admin-address',
'eth-ed25519-address',
'eth-client-lock-eth-amount',
Expand All @@ -527,8 +510,7 @@ RainbowConfig.addOptions(
[
'eth-node-url',
'eth-master-sk',
'eth-prover-abi-path',
'eth-prover-bin-path',
'eth-prover-artifact-path',
'eth-admin-address',
'eth-client-address',
'eth-gas-multiplier'
Expand Down Expand Up @@ -720,9 +702,9 @@ RainbowConfig.addOptions(
'eth-erc20-abi-path',
'eth-locker-address',
'eth-locker-abi-path',
'eth-client-abi-path',
'eth-client-artifact-path',
'eth-client-address',
'eth-prover-abi-path',
'eth-prover-artifact-path',
'eth-prover-address',
'eth-gas-multiplier'
]
Expand Down Expand Up @@ -802,7 +784,7 @@ RainbowConfig.addOptions(
[
'eth-node-url',
'eth-master-sk',
'eth-client-abi-path',
'eth-client-artifact-path',
'eth-client-address'
]
)
Expand Down Expand Up @@ -878,7 +860,7 @@ RainbowConfig.addOptions(
'eth-master-sk',
'near-node-url',
'near-network-id',
'eth-client-abi-path',
'eth-client-artifact-path',
'eth-client-address',
'near2eth-relay-min-delay',
'near2eth-relay-max-delay',
Expand Down
40 changes: 20 additions & 20 deletions cli/init/eth-contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ class EthContractInitializer {
ethMasterSk,
ethContractAbiPath,
ethContractBinPath,
ethContractArtifactPath,
ethGasMultiplier
}) {
let ethContractAddress
if (!ethContractAbiPath || !ethContractBinPath) {
if ((!ethContractAbiPath || !ethContractBinPath) && !ethContractArtifactPath) {
return null
}

Expand All @@ -27,12 +28,17 @@ class EthContractInitializer {
ethMasterAccount = ethMasterAccount.address

console.log('Deploying ETH contract')
const tokenContract = new web3.eth.Contract(
JSON.parse(fs.readFileSync(ethContractAbiPath))
)
let abi, bytecode
if (ethContractArtifactPath) {
({ abi, bytecode } = JSON.parse(fs.readFileSync(ethContractArtifactPath)))
} else {
abi = JSON.parse(fs.readFileSync(ethContractAbiPath))
bytecode = '0x' + fs.readFileSync(ethContractBinPath)
}
const tokenContract = new web3.eth.Contract(abi)
const txContract = await tokenContract
.deploy({
data: '0x' + fs.readFileSync(ethContractBinPath),
data: bytecode,
arguments: args
})
.send({
Expand All @@ -58,24 +64,22 @@ class InitEthEd25519 {
static async execute ({
ethNodeUrl,
ethMasterSk,
ethEd25519AbiPath,
ethEd25519BinPath,
ethEd25519ArtifactPath,
ethGasMultiplier
}) {
const ethContractInitializer = new EthContractInitializer()
const success = await ethContractInitializer.execute(
{
args: [],
gas: 5000000,
ethContractAbiPath: ethEd25519AbiPath,
ethContractBinPath: ethEd25519BinPath,
ethContractArtifactPath: ethEd25519ArtifactPath,
ethNodeUrl,
ethMasterSk,
ethGasMultiplier
}
)
if (!success) {
console.log("Can't deploy", ethEd25519AbiPath)
console.log("Can't deploy", ethEd25519ArtifactPath)
process.exit(1)
}
return {
Expand Down Expand Up @@ -171,8 +175,7 @@ class InitEthClient {
ethClientLockDuration,
ethClientReplaceDuration,
ethEd25519Address,
ethClientAbiPath,
ethClientBinPath,
ethClientArtifactPath,
ethAdminAddress,
ethGasMultiplier
}) {
Expand Down Expand Up @@ -223,15 +226,14 @@ class InitEthClient {
0
],
gas: 5000000,
ethContractAbiPath: ethClientAbiPath,
ethContractBinPath: ethClientBinPath,
ethContractArtifactPath: ethClientArtifactPath,
ethNodeUrl,
ethMasterSk,
ethGasMultiplier
}
)
if (!success) {
console.log("Can't deploy", ethClientAbiPath)
console.log("Can't deploy", ethClientArtifactPath)
process.exit(1)
}
return {
Expand All @@ -245,8 +247,7 @@ class InitEthProver {
ethNodeUrl,
ethMasterSk,
ethClientAddress,
ethProverAbiPath,
ethProverBinPath,
ethProverArtifactPath,
ethAdminAddress,
ethGasMultiplier
}) {
Expand All @@ -261,15 +262,14 @@ class InitEthProver {
{
args: [ethClientAddress, ethAdminAddress, 0],
gas: 3000000,
ethContractAbiPath: ethProverAbiPath,
ethContractBinPath: ethProverBinPath,
ethContractArtifactPath: ethProverArtifactPath,
ethNodeUrl,
ethMasterSk,
ethGasMultiplier
}
)
if (!success) {
console.log("Can't deploy", ethProverAbiPath)
console.log("Can't deploy", ethProverArtifactPath)
process.exit(1)
}
return {
Expand Down
12 changes: 0 additions & 12 deletions contracts/eth/build_all.sh

This file was deleted.

30 changes: 0 additions & 30 deletions contracts/eth/dist.sh

This file was deleted.

Loading

0 comments on commit 0630756

Please sign in to comment.